:root {
  --bg: #f3f6f3;
  --card: #ffffff;
  --ink: #213127;
  --muted: #66756b;
  --accent: #3f7d4a;
  --line: #d7e0d8;
  --shadow: 0 10px 28px rgba(33, 49, 39, 0.08);
  --board-ratio: 0.642857;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
}

html {
  height: 100%;
}

.shell {
  width: min(100%, 760px);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 14px;
}

.intro {
  text-align: center;
  color: var(--ink);
  margin-bottom: 10px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
  color: var(--muted);
}

.intro h1 {
  margin: 0;
  font-size: clamp(1.9rem, 5vw, 3.6rem);
  line-height: 0.98;
}

.lede {
  width: min(100%, 640px);
  margin: 8px auto 0;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--muted);
}

.game-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 12px;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.stat {
  min-width: 86px;
  padding: 10px 14px;
  background: #f7faf7;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stat span {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.5rem;
}

.secondary-button,
.primary-button,
.control-button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.secondary-button,
.primary-button {
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

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

.primary-button {
  background: var(--accent);
  color: #f8fff8;
}

.secondary-button:hover,
.primary-button:hover,
.control-button:hover {
  transform: translateY(-1px);
}

.secondary-button:active,
.primary-button:active,
.control-button:active {
  transform: translateY(1px);
}

.canvas-frame {
  position: relative;
  overflow: hidden;
  width: min(100%, calc((100dvh - 246px) * var(--board-ratio)));
  max-width: 432px;
  aspect-ratio: 432 / 672;
  margin: 0 auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #edf5ee;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(243, 246, 243, 0.74);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(100%, 360px);
  text-align: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.overlay-kicker {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.overlay-card h2 {
  margin: 10px 0 12px;
  font-size: 2rem;
}

.overlay-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

.touch-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.control-button {
  border-radius: 12px;
  padding: 14px 10px;
  font-weight: 700;
  background: #f4f7f4;
  border: 1px solid var(--line);
  color: var(--ink);
}

.control-button--primary {
  background: var(--accent);
  color: #f8fff8;
}

.help {
  margin: 10px 4px 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

kbd {
  display: inline-block;
  margin-left: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.86rem;
}

@media (min-width: 821px) {
  .touch-controls {
    width: min(100%, 340px);
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 8px 8px 10px;
  }

  .game-card {
    padding: 10px;
    border-radius: 16px;
  }

  .hud {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 8px;
  }

  .stat {
    min-width: 0;
    padding: 8px 10px;
  }

  .stat strong {
    font-size: 1.25rem;
  }

  .secondary-button {
    grid-column: 1 / -1;
    padding: 10px 14px;
  }

  .overlay-card {
    padding: 18px;
  }

  .touch-controls {
    gap: 8px;
    margin-top: 8px;
  }

  .control-button {
    padding: 11px 8px;
    font-size: 0.92rem;
  }

  .canvas-frame {
    width: min(100%, calc((100dvh - 400px) * var(--board-ratio)));
  }
}

@media (max-height: 860px) {
  .lede {
    font-size: 0.88rem;
    line-height: 1.35;
  }

  .canvas-frame {
    width: min(100%, calc((100dvh - 214px) * var(--board-ratio)));
  }

  .help {
    display: none;
  }
}

@media (max-height: 760px) {
  .eyebrow,
  .lede {
    display: none;
  }

  .intro {
    margin-bottom: 6px;
  }

  .intro h1 {
    font-size: clamp(1.55rem, 5vw, 2.4rem);
  }

  .canvas-frame {
    width: min(100%, calc((100dvh - 166px) * var(--board-ratio)));
  }
}
