:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #081221;
  color: #e9f3ff;
}

* { box-sizing: border-box; }

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

body {
  background: radial-gradient(circle at 16% 3%, #174060 0, transparent 35%), #081221;
}

button { font: inherit; }

a { color: #85e6ff; }

.game-shell {
  width: min(100%, 980px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 42px) clamp(16px, 4vw, 36px) 28px;
}

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

.eyebrow {
  margin: 0 0 7px;
  color: #63dadd;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: clamp(32px, 6vw, 54px); line-height: 1; letter-spacing: -.045em; }

.subtitle { margin: 8px 0 0; color: #91a8bc; font-size: 14px; }

.scores { display: flex; gap: 10px; }

.scorebox {
  display: grid;
  align-content: center;
  gap: 2px;
  min-width: 84px;
  min-height: 72px;
  padding: 10px 14px;
  border: 1px solid #31536c;
  border-radius: 14px;
  background: #102538;
  text-align: center;
}

.scorebox span { color: #91a8bc; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.scorebox strong { font-size: 24px; line-height: 1; }

.playfield {
  padding: clamp(14px, 3vw, 28px);
  border: 1px solid #284d62;
  border-radius: 22px;
  background: #0b1d2d;
  box-shadow: 0 20px 70px #0005;
}

.board-frame { padding: clamp(6px, 1.4vw, 12px); border: 1px solid #2b5266; border-radius: 12px; background: #07131f; }

.board {
  display: grid;
  grid-template-columns: repeat(40, minmax(0, 1fr));
  gap: clamp(1px, .2vw, 3px);
  width: 100%;
}

.cell {
  display: block;
  aspect-ratio: 1;
  border-radius: max(1px, .16vw);
  background: #183044;
  transition: background-color 70ms linear;
}

.cell.snake { background: #51e8a7; box-shadow: inset 0 -2px 0 #27a878; }
.cell.head { background: #b3ffca; box-shadow: inset 0 -2px 0 #51e8a7; }
.cell.food { background: #ffac5e; box-shadow: 0 0 10px #ff843899; }

.legend { display: flex; gap: 20px; margin: 14px 0 0; color: #9eb7c7; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; }
.key-snake { background: #51e8a7; }
.key-food { background: #ffac5e; }

.status { min-height: 26px; margin: 20px 0 16px; color: #e0eef8; font-size: 15px; font-weight: 650; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.actions button,
.direction-pad button {
  min-height: 48px;
  border: 1px solid #41647a;
  border-radius: 11px;
  background: #173247;
  color: #e9f3ff;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.actions button { min-width: 108px; padding: 10px 17px; }
.actions .action-primary { border-color: #54dac7; background: #35cdb3; color: #05282b; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:not(:disabled):hover { filter: brightness(1.12); }
button:focus-visible, a:focus-visible { outline: 3px solid #ffb462; outline-offset: 3px; }

.directions { display: flex; align-items: center; gap: clamp(20px, 5vw, 54px); margin: 24px auto 0; }
.directions p { max-width: 360px; color: #a8bdce; line-height: 1.6; font-size: 14px; }

.direction-pad {
  flex: none;
  display: grid;
  grid-template: repeat(2, 56px) / repeat(3, 56px);
  gap: 6px;
  user-select: none;
}

.direction-pad button { font-size: 19px; }
.direction-pad .up { grid-area: 1 / 2; }
.direction-pad .left { grid-area: 2 / 1; }
.direction-pad .down { grid-area: 2 / 2; }
.direction-pad .right { grid-area: 2 / 3; }

footer { margin-top: 28px; color: #819daf; font-size: 12px; line-height: 1.5; }

.cozcade-credit { background: #0b1d2d !important; color: #91a8bc !important; }
.cozcade-credit a { color: #85e6ff !important; }

@media (max-width: 600px) {
  .topline { align-items: flex-start; flex-direction: column; gap: 18px; }
  .scores { width: 100%; }
  .scorebox { flex: 1; min-height: 62px; }
  .playfield { border-radius: 16px; }
  .directions { flex-direction: column; gap: 8px; }
  .directions p { text-align: center; margin: 6px auto 0; }
  .actions button { flex: 1; min-width: 0; }
}
