:root {
  color-scheme: light;
  --ink: #1d2925;
  --muted: #58655f;
  --paper: #f2f4ef;
  --card: #ffffff;
  --line: #dce3dc;
  --accent: #2e735e;
  --accent-dark: #205542;
  --soft: #e6eee8;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
}

a {
  color: inherit;
}

.page-shell {
  width: min(1060px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-decoration: none;
}

.page-kind,
.eyebrow {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero {
  max-width: 720px;
  padding: clamp(58px, 11vw, 112px) 0 clamp(62px, 9vw, 92px);
}

.hero .eyebrow {
  margin: 0 0 15px;
}

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

h1 {
  max-width: 14ch;
  margin-bottom: 20px;
  font-size: clamp(2.5rem, 7vw, 4.8rem);
  font-weight: 650;
  letter-spacing: -0.055em;
  line-height: 1.04;
}

.lede {
  max-width: 58ch;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.18rem);
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 140ms ease, transform 140ms ease;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.button:focus-visible,
.direction-button:focus-visible,
.wordmark:focus-visible {
  outline: 3px solid #88b9a2;
  outline-offset: 3px;
}

.game-section {
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 14px 40px rgb(31 51 41 / 5%);
  scroll-margin-top: 24px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.section-heading .eyebrow {
  margin-bottom: 7px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: -0.04em;
  line-height: 1.2;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(245px, 0.75fr);
  gap: 30px;
  align-items: start;
}

.board-frame {
  overflow: hidden;
  border: 1px solid #d5e1d8;
  border-radius: 18px;
  background: #edf4ef;
}

#game-board {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  touch-action: none;
}

.game-panel {
  display: grid;
  gap: 18px;
}

.score-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfa;
}

.score-label {
  color: var(--muted);
  font-size: 0.9rem;
}

#score {
  font-size: 1.55rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.game-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.game-actions .button:first-child {
  grid-column: 1 / -1;
}

.button.secondary {
  border: 1px solid var(--line);
  background: #f7f9f6;
  color: var(--ink);
}

.button.secondary:hover {
  background: var(--soft);
}

.button:disabled {
  opacity: 0.48;
  transform: none;
  cursor: not-allowed;
}

.game-message {
  min-height: 3.2em;
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.help-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.direction-pad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(2, 48px);
  justify-content: center;
  gap: 7px;
  margin: 2px 0;
}

.direction-button {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f7f9f6;
  color: var(--ink);
  font: inherit;
  font-size: 1.25rem;
  cursor: pointer;
  touch-action: manipulation;
}

.direction-button:hover {
  background: var(--soft);
}

.direction-button.up {
  grid-column: 2;
}

.direction-button.left {
  grid-column: 1;
  grid-row: 2;
}

.direction-button.down {
  grid-column: 2;
  grid-row: 2;
}

.direction-button.right {
  grid-column: 3;
  grid-row: 2;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 0 42px;
  color: var(--muted);
  font-size: 0.82rem;
}

.footer p {
  margin: 0;
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 28px, 560px);
  }

  .topbar {
    min-height: 64px;
  }

  .hero {
    padding-top: 62px;
    padding-bottom: 58px;
  }

  .game-section {
    padding: 20px;
    border-radius: 19px;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 7px;
  }

  .game-layout {
    grid-template-columns: 1fr;
    gap: 21px;
  }

  .game-panel {
    gap: 13px;
  }

  .footer {
    flex-direction: column;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
