:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #07100d;
  --panel: rgba(13, 28, 23, 0.88);
  --line: rgba(109, 255, 183, 0.16);
  --muted: #86a398;
  --text: #effff8;
  --green: #53fca1;
  --green-strong: #17dc78;
  --orange: #ff9d44;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(44, 236, 136, 0.1), transparent 34rem),
    radial-gradient(circle at 90% 90%, rgba(24, 127, 85, 0.11), transparent 30rem),
    var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

button, select { font: inherit; }
button { touch-action: manipulation; }

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.game-card {
  width: min(100%, 660px);
  padding: clamp(18px, 4vw, 32px);
  background: linear-gradient(145deg, rgba(16, 34, 28, 0.95), rgba(8, 19, 15, 0.95));
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.44), inset 0 1px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(18px);
}

.hero, .scoreboard, .actions, footer {
  display: flex;
  align-items: center;
}

.hero { justify-content: space-between; margin-bottom: 22px; }
.eyebrow { margin: 0 0 7px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .2em; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }
h1 { margin: 0; font-size: clamp(28px, 6vw, 42px); line-height: 1; letter-spacing: -.05em; }

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  color: var(--green);
  background: rgba(83, 252, 161, 0.06);
  cursor: pointer;
}
.icon-button[aria-pressed="false"] { color: var(--muted); }

.scoreboard {
  gap: 14px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.14);
}
.score-item, .level-select { display: grid; gap: 3px; }
.score-item { min-width: 105px; }
.score-item span, .level-select span { color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.score-item strong { color: var(--green); font-variant-numeric: tabular-nums; font-size: 22px; letter-spacing: .06em; }
.level-select { margin-left: auto; }
select {
  color: var(--text);
  border: 0;
  border-radius: 8px;
  outline: 0;
  background: #173328;
  padding: 5px 28px 5px 8px;
  cursor: pointer;
}

.board-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(83, 252, 161, 0.22);
  border-radius: 20px;
  background: #07120e;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.45), 0 0 32px rgba(28, 232, 124, 0.05);
  touch-action: none;
}

canvas { display: block; width: 100%; aspect-ratio: 1; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(4, 12, 9, 0.76);
  backdrop-filter: blur(6px);
  transition: opacity .2s ease, visibility .2s ease;
}
.overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.overlay h2 { margin: 20px 0 8px; font-size: clamp(23px, 5vw, 32px); }
.overlay p { max-width: 340px; margin: 0 0 24px; color: var(--muted); line-height: 1.55; }

.snake-mark { position: relative; display: flex; align-items: center; gap: 5px; filter: drop-shadow(0 0 12px rgba(83, 252, 161, .45)); }
.snake-mark span { width: 22px; height: 22px; border-radius: 7px; background: var(--green-strong); }
.snake-mark span:first-child { opacity: .5; }
.snake-mark span:nth-child(2) { opacity: .72; }
.snake-mark i { width: 27px; height: 27px; border-radius: 8px; background: var(--green); }
.snake-mark i::before, .snake-mark i::after { content: ""; position: absolute; top: 8px; width: 4px; height: 4px; border-radius: 50%; background: #06311d; }
.snake-mark i::before { right: 17px; }
.snake-mark i::after { right: 7px; }

.primary-button, .secondary-button {
  border: 0;
  border-radius: 13px;
  font-weight: 750;
  cursor: pointer;
  transition: transform .15s ease, filter .15s ease;
}
.primary-button { min-width: 150px; padding: 13px 24px; color: #032315; background: var(--green); box-shadow: 0 10px 28px rgba(36, 231, 126, .22); }
.secondary-button { flex: 1; padding: 12px; color: var(--text); background: rgba(83, 252, 161, .07); border: 1px solid var(--line); }
.primary-button:hover, .secondary-button:hover { filter: brightness(1.12); }
.primary-button:active, .secondary-button:active { transform: translateY(1px) scale(.99); }
.secondary-button:disabled { opacity: .45; cursor: not-allowed; }

.actions { gap: 12px; margin-top: 14px; }

.mobile-controls {
  display: none;
  grid-template-columns: repeat(3, 52px);
  grid-template-areas: ". up ." "left down right";
  justify-content: center;
  gap: 7px;
  margin-top: 16px;
}
.mobile-controls button { height: 45px; border: 1px solid var(--line); border-radius: 12px; color: var(--green); background: rgba(83, 252, 161, .07); }
.mobile-controls [data-direction="up"] { grid-area: up; }
.mobile-controls [data-direction="left"] { grid-area: left; }
.mobile-controls [data-direction="down"] { grid-area: down; }
.mobile-controls [data-direction="right"] { grid-area: right; }

footer { justify-content: space-between; gap: 10px; margin-top: 18px; color: #607a70; font-size: 11px; }

@media (max-width: 560px) {
  .app-shell { place-items: start center; padding: 10px; }
  .game-card { border-radius: 22px; }
  .scoreboard { gap: 8px; padding: 11px; }
  .score-item { min-width: 0; flex: 1; }
  .score-item strong { font-size: 18px; }
  .mobile-controls { display: grid; }
  footer { display: none; }
}

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