/*
 * Flash Sums — deep-space flash-anzan styling. The number appears alone in
 * the dark; everything else stays quiet so the digit is the only star.
 */

:root {
  --bg0: #0a0d18;
  --bg1: #10142a;
  --ink: #f4f2ec;
  --dim: rgba(244, 242, 236, 0.62);
  --faint: rgba(244, 242, 236, 0.4);
  --card: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.1);
  --line-hi: rgba(255, 255, 255, 0.2);
  --orange: #ff5e00;
  --gold: #ffc432;
  --cyan: #5ad7ff;
  --green: #34d399;
  --red: #ff4757;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 600px at 80% -10%, rgba(90, 215, 255, 0.1), transparent 60%),
    radial-gradient(800px 600px at -10% 40%, rgba(255, 94, 0, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 60%, var(--bg0));
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100svh;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--orange);
  color: #fff;
  padding: 10px 16px;
  z-index: 50;
}
.skip-link:focus {
  left: 0;
}

.noscript-card {
  max-width: 420px;
  margin: 18vh auto 0;
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--line-hi);
  border-radius: 16px;
  line-height: 1.55;
}
.noscript-card a {
  color: var(--gold);
}
.noscript-title {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

.mini-header {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 4px 10px;
  padding: 14px 16px 6px;
}
.brand-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  padding: 12px 0;
}
.brand-link .accent {
  color: var(--orange);
}
.mini-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.more-games {
  color: var(--dim);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  padding: 14px 0;
}
.more-games:hover {
  color: var(--gold);
}

.chip-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 13px;
  border: 1px solid var(--line-hi);
  border-radius: 99px;
  background: var(--card);
  color: var(--dim);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.screen {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100svh - 60px);
}

.screen-inner {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4vh 16px 0;
}

.game-title {
  margin: 0 0 6px;
  font-size: clamp(2.2rem, 9vw, 3.2rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  text-align: center;
}
.game-title .accent {
  color: var(--orange);
  text-shadow: 0 0 30px rgba(255, 94, 0, 0.4);
}
.hook-line {
  margin: 0 0 22px;
  color: var(--dim);
  font-weight: 600;
  text-align: center;
}

.cfg {
  width: 100%;
  margin: 0 0 12px;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}
.cfg legend {
  padding: 0 6px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}
.cfg-hint {
  margin: 8px 2px 0;
  font-size: 0.8rem;
  color: var(--dim);
}

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.seg button {
  flex: 1 1 0;
  min-height: 44px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  opacity: 0.6;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}
.seg button[aria-checked='true'] {
  background: linear-gradient(135deg, var(--orange), #ff8a00);
  color: #3a2200;
  opacity: 1;
  box-shadow: 0 3px 14px rgba(255, 94, 0, 0.4);
}

.best-line {
  min-height: 1.2em;
  margin: 6px 0 0;
  color: var(--gold);
  font-weight: 700;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.btn-primary {
  margin-top: 18px;
  min-height: 58px;
  padding: 0 60px;
  border: none;
  border-radius: 16px;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(135deg, var(--orange), #ff8a00);
  box-shadow: 0 10px 30px rgba(255, 94, 0, 0.4);
  cursor: pointer;
  touch-action: manipulation;
}
.btn-primary:active {
  transform: scale(0.97);
}

.hint-line {
  color: var(--faint);
  font-size: 0.8rem;
  text-align: center;
  padding: 0 16px;
}

/* ---------- game screen ---------- */

.game-top {
  width: 100%;
  max-width: 540px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 0 6px;
}
.hud {
  display: flex;
  gap: 8px;
}
.hud-item {
  min-width: 74px;
  text-align: center;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line-hi);
}
.hud-item span {
  display: block;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}
.hud-item b {
  font-size: 1rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.stage {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 20px);
}

.flash-area {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.flash-num {
  font-size: clamp(4rem, 22vw, 7rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--cyan);
  text-shadow: 0 0 60px rgba(90, 215, 255, 0.5);
  min-height: 1.1em;
  display: grid;
  place-items: center;
}
.flash-count {
  color: var(--faint);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-height: 1.2em;
}

.answer-ui {
  width: min(100%, 340px);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.answer-well {
  width: 100%;
  min-height: 64px;
  margin-bottom: 12px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  border-radius: 16px;
  border: 1.5px dashed var(--line-hi);
  background: rgba(255, 255, 255, 0.03);
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}
.key {
  min-height: 56px;
  border-radius: 14px;
  border: 1px solid var(--line-hi);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.08s ease-out,
    background 0.12s ease-out;
}
.key:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.11);
}
.key-minus {
  color: var(--cyan);
}
.key-ok {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.55);
  color: var(--green);
}

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  background: rgba(7, 8, 15, 0.72);
  backdrop-filter: blur(6px);
}
.overlay-card {
  width: min(88vw, 320px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 24px;
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--line-hi);
  border-radius: 22px;
}
.overlay-title {
  margin: 0 0 18px;
  font-size: 1.6rem;
  font-weight: 900;
}
.overlay-card .btn-primary {
  width: 100%;
  margin-top: 0;
  padding: 0;
}
.btn-ghost {
  margin-top: 12px;
  min-height: 48px;
  width: 100%;
  border: 1px solid var(--line-hi);
  border-radius: 13px;
  background: transparent;
  color: var(--dim);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  transform: translateX(-50%);
  z-index: 45;
  padding: 11px 20px;
  border-radius: 99px;
  background: rgba(20, 22, 38, 0.92);
  border: 1px solid var(--line-hi);
  font-size: 0.95rem;
  font-weight: 700;
  pointer-events: none;
  max-width: 86vw;
  text-align: center;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

@media (max-height: 640px) {
  .flash-area {
    min-height: 200px;
  }
  .flash-num {
    font-size: clamp(3rem, 16vw, 5rem);
  }
  .key {
    min-height: 46px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}
