:root {
  color-scheme: dark;
  --background: #060807;
  --surface: #0d1210;
  --surface-strong: #121a16;
  --line: rgba(196, 255, 216, 0.12);
  --text: #edf7f0;
  --muted: #9bac9f;
  --green: #73e899;
  --green-soft: #c9ffda;
  --amethyst: #b88cff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--text);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 10% 0%, rgba(115, 232, 153, 0.12), transparent 34rem),
    radial-gradient(circle at 92% 8%, rgba(184, 140, 255, 0.13), transparent 30rem),
    var(--background);
}

button { font: inherit; }
button:focus-visible { outline: 3px solid var(--amethyst); outline-offset: 3px; }

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 max(28px, env(safe-area-inset-bottom));
}

.masthead,
.game-layout,
.score-strip,
footer {
  display: flex;
  gap: 20px;
}

.masthead {
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2.2rem, 6vw, 4.8rem); line-height: 0.94; letter-spacing: -0.055em; }
h2 { margin-bottom: 10px; font-size: 1.45rem; }
.subtitle, .control-panel p, footer { color: var(--muted); }
.subtitle { max-width: 650px; margin-bottom: 0; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(13, 18, 16, 0.76);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 16px var(--green); }

.game-layout { align-items: flex-start; }
.game-column { min-width: 0; flex: 1 1 720px; }
.control-panel { flex: 0 0 280px; }
.score-strip { margin-bottom: 12px; }
.score-strip article {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(13, 18, 16, 0.86);
}
.score-strip span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.score-strip strong { font-size: 1.55rem; }

.board-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(196, 255, 216, 0.18);
  border-radius: 24px;
  background: #090c0b;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(255, 255, 255, 0.025);
  touch-action: none;
}
canvas { display: block; width: 100%; height: 100%; }

.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 28px;
  text-align: center;
  background: rgba(5, 8, 6, 0.78);
  backdrop-filter: blur(10px);
}
.game-overlay[hidden] { display: none; }
.game-overlay p:not(.eyebrow) { max-width: 360px; color: var(--muted); }

.primary-button,
.secondary-button,
.direction-pad button {
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}
.primary-button { padding: 12px 22px; background: var(--green); color: #071109; }
.secondary-button { width: 100%; padding: 12px 16px; border-color: var(--line); background: var(--surface-strong); color: var(--text); }
button:not(:disabled):active { transform: translateY(1px) scale(0.99); }
button:disabled { cursor: not-allowed; opacity: 0.42; }

.control-panel {
  display: grid;
  gap: 20px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(13, 18, 16, 0.88);
}
.direction-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.direction-pad button {
  min-height: 58px;
  border-color: var(--line);
  background: var(--surface-strong);
  color: var(--green-soft);
  font-size: 1.35rem;
  touch-action: manipulation;
}
.direction-pad button[data-direction="UP"] { grid-column: 2; }
.direction-pad button[data-direction="LEFT"] { grid-column: 1; grid-row: 2; }
.direction-pad button[data-direction="DOWN"] { grid-column: 2; grid-row: 2; }
.direction-pad button[data-direction="RIGHT"] { grid-column: 3; grid-row: 2; }

.boundary-note { padding: 14px; border-left: 3px solid var(--amethyst); background: rgba(184, 140, 255, 0.07); }
.boundary-note strong { display: block; margin-bottom: 6px; }
.boundary-note p { margin-bottom: 0; font-size: 0.9rem; }
footer { justify-content: space-between; margin-top: 18px; padding: 0 4px; font-size: 0.8rem; }

.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;
}

@media (max-width: 840px) {
  .game-layout { flex-direction: column; }
  .game-column, .control-panel { width: 100%; flex-basis: auto; }
  .control-panel { grid-template-columns: 1fr 1fr; align-items: start; }
  .direction-pad { grid-row: span 2; }
}

@media (max-width: 600px) {
  .shell { width: min(100% - 20px, 720px); padding-top: 22px; }
  .masthead { gap: 14px; }
  .status-badge { padding: 8px 10px; }
  .subtitle { font-size: 0.9rem; }
  .score-strip { gap: 8px; }
  .score-strip article { padding: 10px; border-radius: 12px; }
  .score-strip span { font-size: 0.62rem; }
  .score-strip strong { font-size: 1.2rem; }
  .board-shell { border-radius: 18px; }
  .control-panel { grid-template-columns: 1fr; padding: 18px; border-radius: 18px; }
  footer { flex-direction: column; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
