@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;600;700&display=swap');

:root {
  color-scheme: dark;
  font-family: 'Manrope', system-ui, sans-serif;
  --theme-bg: #07111f;
  --theme-surface: #0d2134;
  --theme-wall: #79d7c6;
  --theme-path: #0a1828;
  --theme-glow: #b9fff1;
  --theme-accent: #f5d96b;
  --theme-muted: #83a1ad;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  min-width: 320px;
  background: radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--theme-wall) 18%, transparent), transparent 35%), var(--theme-bg);
  color: #f7fbff;
  transition: background-color 700ms ease;
  overflow-x: hidden;
}
button { font: inherit; }
.game-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 36px);
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto;
  gap: 18px;
}
.hud, .controls-bar { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.eyebrow, .screen-kicker, .stat span { font-family: 'DM Mono', monospace; text-transform: uppercase; letter-spacing: .12em; }
.eyebrow { color: var(--theme-wall); font-size: 11px; font-weight: 500; }
h1 { margin: 2px 0 0; font-size: clamp(22px, 3vw, 36px); line-height: 1; letter-spacing: -.045em; }
.stats { display: flex; gap: clamp(14px, 3vw, 38px); }
.stat { display: grid; gap: 3px; }
.stat span { color: var(--theme-muted); font-size: 9px; }
.stat strong { font-size: 14px; white-space: nowrap; }
.timer strong { min-width: 92px; color: var(--theme-accent); font-family: 'DM Mono', monospace; }
.board-wrap {
  position: relative;
  min-height: min(70vh, 760px);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--theme-wall) 25%, transparent);
  border-radius: 24px;
  background: var(--theme-path);
  box-shadow: 0 28px 90px rgb(0 0 0 / 34%), inset 0 0 80px rgb(0 0 0 / 16%);
  transition: background-color 700ms ease, border-color 700ms ease;
}
canvas { display: block; width: 100%; height: 100%; min-height: inherit; touch-action: none; }
.screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgb(3 8 16 / 66%);
  backdrop-filter: blur(8px);
  transition: opacity 240ms ease, visibility 240ms ease;
}
.screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.screen-card {
  width: min(520px, 100%);
  padding: clamp(25px, 5vw, 48px);
  border: 1px solid color-mix(in srgb, var(--theme-wall) 35%, transparent);
  border-radius: 20px;
  background: color-mix(in srgb, var(--theme-bg) 88%, transparent);
  text-align: center;
  box-shadow: 0 24px 70px rgb(0 0 0 / 35%);
}
.screen-card.compact { padding-block: 32px; }
.screen-kicker { color: var(--theme-wall); font-size: 10px; }
.screen h2 { margin: 10px 0 12px; font-size: clamp(34px, 7vw, 64px); line-height: .98; letter-spacing: -.06em; }
.screen-card.compact h2 { font-size: clamp(28px, 5vw, 48px); }
.screen p { margin: 0 auto; max-width: 430px; color: #b8c4cc; line-height: 1.6; }
.legend { display: flex; justify-content: center; gap: 24px; margin: 24px 0; color: #d9e2e8; font-size: 13px; }
.legend span { display: flex; align-items: center; gap: 8px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; }
.player-dot { background: #fff; box-shadow: 0 0 12px #fff; }
.exit-dot { background: var(--theme-accent); box-shadow: 0 0 12px var(--theme-accent); }
.primary-button {
  min-width: 180px;
  padding: 13px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--theme-accent);
  color: #101217;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 28px color-mix(in srgb, var(--theme-accent) 28%, transparent);
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 0 38px color-mix(in srgb, var(--theme-accent) 45%, transparent); }
.screen small { display: block; margin-top: 16px; color: #7e919d; }
.final-time { color: var(--theme-accent) !important; font-family: 'DM Mono', monospace; font-size: clamp(28px, 7vw, 52px); font-weight: 500; line-height: 1.1 !important; margin-bottom: 12px !important; }
.controls-bar p { margin: 0; color: var(--theme-muted); font-size: 12px; }
.controls-bar strong { color: #eaf0f4; }
.dpad { display: grid; grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(2, 36px); gap: 5px; }
.dpad button { border: 1px solid color-mix(in srgb, var(--theme-wall) 28%, transparent); border-radius: 9px; background: color-mix(in srgb, var(--theme-surface) 80%, transparent); color: #f6fbff; cursor: pointer; user-select: none; -webkit-user-select: none; }
.dpad button:active { background: var(--theme-wall); color: var(--theme-bg); }
.dpad [data-direction="up"] { grid-column: 2; }
.dpad [data-direction="left"] { grid-column: 1; grid-row: 2; }
.dpad [data-direction="down"] { grid-column: 2; grid-row: 2; }
.dpad [data-direction="right"] { grid-column: 3; grid-row: 2; }
@media (max-width: 700px) {
  .game-shell { padding: 12px; gap: 12px; }
  .hud { align-items: flex-start; }
  .brand .eyebrow { display: none; }
  h1 { font-size: 20px; }
  .stats { gap: 14px; }
  .stat:nth-child(2) { display: none; }
  .board-wrap { min-height: 62vh; border-radius: 16px; }
  .controls-bar { align-items: end; }
  .controls-bar p { max-width: 170px; }
  .dpad { grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(2, 42px); }
}
@media (max-height: 620px) and (orientation: landscape) {
  .game-shell { grid-template-rows: auto minmax(250px, 1fr); }
  .controls-bar { display: none; }
  .board-wrap { min-height: 72vh; }
  .screen-card { padding: 20px; }
  .screen h2 { font-size: 36px; }
}
