:root {
  --bg-top: #0b1330;
  --bg-bottom: #050914;
  --panel: rgba(10, 19, 46, 0.78);
  --panel-strong: rgba(18, 30, 71, 0.94);
  --text-main: #eef3ff;
  --text-soft: #b6c4f3;
  --line: rgba(154, 177, 255, 0.16);
  --shadow: 0 24px 50px rgba(0, 0, 0, 0.34);
  --accent: #ffb43d;
  --accent-strong: #ff8f1f;
  --accent-soft: rgba(255, 180, 61, 0.2);
  --success: #53d3a2;
  --danger: #ff5b6d;
  --danger-soft: rgba(255, 91, 109, 0.28);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100svh;
  font-family: "Avenir Next Condensed", "Trebuchet MS", "Arial Narrow", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(83, 211, 162, 0.16), transparent 34%),
    radial-gradient(circle at top right, rgba(255, 180, 61, 0.16), transparent 30%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.75), transparent 92%);
  pointer-events: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

.page-shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 2rem;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.hero {
  position: relative;
  padding: 0.75rem 0 1.2rem;
}

.hero__topbar {
  position: absolute;
  top: 0.1rem;
  right: 0;
  margin: 0;
}

.hero__cluster-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  color: var(--text-main);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition:
    transform 140ms ease,
    background-color 140ms ease,
    box-shadow 140ms ease;
}

.hero__cluster-link:hover {
  transform: translateY(-1px);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.hero__title {
  display: flex;
  align-items: center;
  margin-bottom: 0.6rem;
}

.hero__logo-button {
  appearance: none;
  display: inline-block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition:
    transform 140ms ease,
    opacity 140ms ease;
}

.hero__wordmark {
  display: block;
  font-size: clamp(2.6rem, 5vw, 4.6rem);
  line-height: 0.92;
  letter-spacing: 0.02em;
  font-weight: 900;
  color: var(--text-main);
  text-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  transition:
    transform 140ms ease,
    opacity 140ms ease;
}

.hero__logo-button:hover {
  opacity: 0.92;
}

.hero__logo-button:hover .hero__wordmark {
  transform: translateY(-1px);
}

.hero__logo-button:focus-visible {
  outline: 3px solid rgba(83, 211, 162, 0.85);
  outline-offset: 4px;
  border-radius: 1rem;
}

.hero__eyebrow,
.result-kicker {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.5rem;
  font-size: clamp(2.6rem, 5vw, 4.6rem);
  line-height: 0.92;
  letter-spacing: 0.02em;
}

h2 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.hero__copy,
.panel__copy,
.info-card__meta {
  color: var(--text-soft);
}

.hero__copy,
.panel__copy {
  max-width: 38rem;
  font-size: 1.05rem;
  line-height: 1.55;
}

.app-shell {
  display: grid;
  min-height: 0;
}

.screen {
  animation: rise-in 260ms ease;
}

.screen--play {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
}

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 1.75rem;
  background: linear-gradient(180deg, rgba(15, 25, 58, 0.9), rgba(8, 16, 39, 0.95));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(255, 180, 61, 0.12), transparent 28%),
    radial-gradient(circle at bottom left, rgba(83, 211, 162, 0.12), transparent 30%);
  pointer-events: none;
}

.panel > * {
  position: relative;
  z-index: 1;
}

.mode-picker,
.action-row,
.hud,
.start-grid {
  display: grid;
  gap: 0.8rem;
}

.mode-picker {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mode-picker--types {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mode-pill,
.button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease,
    color 140ms ease,
    opacity 140ms ease;
}

.mode-pill {
  min-height: 3.25rem;
  padding: 0.85rem 1rem;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mode-pill.is-selected {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #1d1202;
  box-shadow: 0 12px 24px rgba(255, 143, 31, 0.28);
}

.mode-pill:active {
  transform: scale(0.99);
}

.mode-pill:hover,
.button:hover {
  transform: translateY(-1px);
}

.mode-pill:focus-visible,
.button:focus-visible,
.number-chip:focus-visible {
  outline: 3px solid rgba(83, 211, 162, 0.85);
  outline-offset: 3px;
}

.start-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.info-card,
.stat-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
}

.info-card--highlight {
  background:
    linear-gradient(135deg, rgba(255, 180, 61, 0.14), rgba(83, 211, 162, 0.08)),
    rgba(255, 255, 255, 0.05);
}

.info-card__label,
.stat-card__label {
  margin-bottom: 0.45rem;
  color: var(--text-soft);
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.info-card__value,
.stat-card__value {
  margin-bottom: 0.2rem;
  font-size: clamp(1.5rem, 3.5vw, 2.15rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.info-card__value--hero {
  font-size: clamp(2.6rem, 6vw, 4rem);
  line-height: 0.95;
}

.info-card__meta--accent {
  color: var(--accent);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.info-card__meta--target {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.hud {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card--accent {
  background: linear-gradient(135deg, rgba(255, 180, 61, 0.18), rgba(255, 143, 31, 0.08));
}

.board-frame {
  position: relative;
  min-height: min(68svh, 760px);
  padding: 0.75rem;
  border-radius: 1.5rem;
  background: linear-gradient(180deg, rgba(12, 22, 54, 0.94), rgba(8, 13, 31, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.screen--play .board-frame {
  min-height: 0;
  height: 100%;
}

.board {
  position: relative;
  height: 100%;
  min-height: min(62svh, 700px);
  overflow: hidden;
  border-radius: 1.1rem;
  background:
    radial-gradient(circle at center, rgba(83, 211, 162, 0.06), transparent 48%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
}

.screen--play .board {
  min-height: 0;
}

.board::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

.board.is-ending {
  pointer-events: none;
}

.board.is-failed {
  animation: board-flash 260ms ease;
}

.number-chip {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: #08101c;
  background: linear-gradient(180deg, #ffffff, #dbe7ff);
  box-shadow:
    0 12px 20px rgba(0, 0, 0, 0.25),
    inset 0 -5px 10px rgba(79, 105, 160, 0.18);
  font-size: clamp(1rem, 1.55rem, 1.6rem);
  font-weight: 800;
  line-height: 1;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transform: translateZ(0);
}

.number-chip--math {
  padding: 0.35rem 0.45rem;
  border-radius: 1rem;
  color: var(--text-main);
  background: linear-gradient(180deg, rgba(244, 248, 255, 0.14), rgba(180, 203, 255, 0.08));
  box-shadow:
    0 12px 20px rgba(0, 0, 0, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  font-size: clamp(0.92rem, 1.4rem, 1.25rem);
  line-height: 1.1;
}

.number-chip:hover {
  box-shadow:
    0 14px 24px rgba(0, 0, 0, 0.28),
    inset 0 -5px 10px rgba(79, 105, 160, 0.18);
}

.number-chip:active {
  transform: scale(0.97);
}

.number-chip.is-found {
  background: linear-gradient(180deg, rgba(83, 211, 162, 0.9), rgba(52, 163, 124, 0.92));
  color: rgba(6, 19, 18, 0.75);
  box-shadow: inset 0 -4px 10px rgba(0, 0, 0, 0.16);
  opacity: 0.4;
  cursor: default;
}

.number-chip--math.is-found {
  color: rgba(6, 19, 18, 0.82);
}

.number-chip.is-wrong {
  background: linear-gradient(180deg, #ff9ea7, var(--danger));
  color: #2b0410;
  animation: wrong-pulse 220ms ease;
}

.button {
  min-height: 3.35rem;
  padding: 0.9rem 1.45rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.button--primary {
  color: #191007;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 16px 28px rgba(255, 143, 31, 0.28);
}

.button--secondary {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.button--ghost {
  color: var(--text-main);
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.button.is-copied {
  color: #0f1707;
  background: linear-gradient(135deg, rgba(83, 211, 162, 0.92), rgba(48, 165, 123, 0.92));
}

.action-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.action-row .button--primary:only-child {
  grid-column: 1 / -1;
}

.action-row--play {
  margin-top: 0.2rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-self: end;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

.site-footer {
  padding: 1rem 0 0.35rem;
}

.site-footer__inner {
  display: grid;
  gap: 0.25rem;
  justify-items: start;
  color: rgba(182, 196, 243, 0.76);
  font-size: 0.9rem;
}

.site-footer__inner p {
  margin: 0;
}

.site-footer__inner a {
  color: rgba(238, 243, 255, 0.94);
  text-decoration: none;
}

.site-footer__inner a:hover {
  color: #ffffff;
}

.site-footer__sub {
  color: rgba(182, 196, 243, 0.62);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes wrong-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes board-flash {
  0% {
    box-shadow: inset 0 0 0 0 rgba(255, 91, 109, 0);
  }
  50% {
    box-shadow: inset 0 0 0 999px var(--danger-soft);
  }
  100% {
    box-shadow: inset 0 0 0 0 rgba(255, 91, 109, 0);
  }
}

@media (max-width: 840px) {
  .page-shell {
    width: min(100% - 1rem, 1120px);
    padding-top: 0.7rem;
  }

  .start-grid,
  .hud,
  .action-row {
    grid-template-columns: 1fr;
  }

  .board-frame {
    min-height: 56svh;
  }

  .board {
    min-height: 52svh;
  }

  .screen--play .board-frame,
  .screen--play .board {
    min-height: 0;
  }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 0.75rem, 1120px);
    padding-bottom: 1rem;
  }

  .hero {
    padding-bottom: 0.8rem;
  }

  .hero__topbar {
    top: 0;
    right: 0;
  }

  .hero__cluster-link {
    justify-content: center;
    min-height: 2.1rem;
    padding-inline: 0.8rem;
  }

  .site-footer {
    padding-top: 0.8rem;
  }

  .panel {
    padding: 0.95rem;
    border-radius: 1.35rem;
  }

  .mode-picker {
    grid-template-columns: 1fr;
  }

  .mode-picker--types {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-pill,
  .button {
    min-height: 3.15rem;
  }

  .info-card,
  .stat-card {
    padding: 0.9rem;
  }

  .board-frame {
    padding: 0.5rem;
  }
}

@media (max-height: 720px) {
  .hero {
    padding-top: 0.2rem;
    padding-bottom: 0.6rem;
  }

  .hero__copy,
  .panel__copy {
    font-size: 1rem;
  }

  .board-frame {
    min-height: 50svh;
  }

  .board {
    min-height: 46svh;
  }

  .screen--play {
    gap: 0.9rem;
  }

  .screen--play .stat-card {
    padding: 0.8rem;
  }

  .screen--play .board-frame,
  .screen--play .board {
    min-height: 0;
  }
}
