/* ==========================================================================
   SNAKE ARENA — design tokens
   Palette grounded in a late-night arcade cabinet: near-black void, three
   hot signal colors borrowed from the snakes themselves, LCD-style mono
   for anything that counts (score, timers), a pixel display face reserved
   for the marquee moments (brand, round result) so it doesn't wear out.
   ========================================================================== */
:root {
  --void: #0B0E14;
  --panel: #121722;
  --panel-raised: #171D2B;
  --line: #1F2739;
  --text: #E7ECF3;
  --text-dim: #7C8699;
  --lime: #B6FF3C;
  --cyan: #3CE7FF;
  --pink: #FF3CAC;
  --gold: #FFD23C;

  --font-display: 'Press Start 2P', monospace;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--void);
  color: var(--text);
  font-family: var(--font-body);
  overscroll-behavior: none;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------------------- Top bar ---------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0D1119, #0B0E14);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--lime); font-size: 18px; text-shadow: 0 0 12px rgba(182,255,60,.55); }
.brand-name { font-size: 15px; letter-spacing: .04em; font-weight: 600; color: var(--text-dim); }
.brand-name b { color: var(--text); font-weight: 800; }

.hud { display: flex; gap: 22px; }
.hud-item { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.hud-label { font-size: 11px; color: var(--text-dim); }
.hud-value { font-family: var(--font-mono); font-size: 16px; font-weight: 700; color: var(--cyan); }

/* ---------------------------- Ad slots ---------------------------- */
.ad-slot {
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(135deg, #10141D, #10141D 10px, #0D111A 10px, #0D111A 20px);
  border-bottom: 1px dashed var(--line);
  color: var(--text-dim);
  min-height: 46px;
  font-size: 11px;
}
.ad-slot--bottom { border-top: 1px dashed var(--line); border-bottom: none; }
.ad-slot__label { font-family: var(--font-mono); letter-spacing: .02em; }

/* ---------------------------- Join screen ---------------------------- */
.join-screen {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
  background:
    radial-gradient(circle at 20% 15%, rgba(182,255,60,.06), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(60,231,255,.07), transparent 45%);
}
.join-card {
  max-width: 480px;
  width: 100%;
  text-align: left;
}
.join-title {
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.12;
  font-weight: 800;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}
.join-sub {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.55;
  max-width: 42ch;
  margin: 0 0 26px;
}
.name-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
}
.name-input:focus { border-color: var(--lime); }
.btn-play {
  width: 100%;
  padding: 15px 18px;
  border-radius: 10px;
  border: none;
  background: var(--lime);
  color: #0B0E14;
  font-weight: 800;
  font-size: 15px;
  transition: transform .12s ease;
}
.btn-play:hover { transform: translateY(-1px); }
.btn-play--small { width: auto; padding: 11px 22px; font-size: 13px; }
.join-meta { margin-top: 14px; font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }

/* ---------------------------- Game screen ---------------------------- */
.game-screen {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}
.board-wrap {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  min-height: 0;
}
#board {
  width: 100%;
  height: 100%;
  max-width: 840px;
  max-height: 840px;
  aspect-ratio: 1 / 1;
  display: block;
  background: #0D111A;
}

.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(11,14,20,.72);
  backdrop-filter: blur(2px);
}
.overlay-inner { text-align: center; }
.overlay-title {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--lime);
  margin-bottom: 10px;
  text-shadow: 0 0 16px rgba(182,255,60,.4);
}
.overlay-sub { font-family: var(--font-mono); color: var(--text-dim); font-size: 13px; }

.kill-feed {
  position: absolute; top: 12px; left: 12px;
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
  max-width: 60%;
}
.kill-feed li {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(11,14,20,.7);
  border-left: 2px solid var(--pink);
  padding: 5px 9px;
  border-radius: 4px;
  color: var(--text);
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px);} to { opacity: 1; transform: none; } }

.spectator-banner {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(11,14,20,.85);
  border: 1px solid var(--line);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 8px;
}
.link-btn {
  background: none; border: none; color: var(--cyan); text-decoration: underline;
  font-size: 12px; padding: 0;
}

/* ---------------------------- Sidebar ---------------------------- */
.sidebar { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  overflow-y: auto;
}
.panel-title {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 12px;
  font-weight: 600;
}
.leaderboard-list, .roster-list { list-style: none; margin: 0; padding: 0; }
.leaderboard-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.leaderboard-list li:last-child { border-bottom: none; }
.leaderboard-list .lb-rank { color: var(--text-dim); font-family: var(--font-mono); width: 22px; }
.leaderboard-list .lb-name { flex: 1; padding: 0 8px; }
.leaderboard-list .lb-wins { font-family: var(--font-mono); color: var(--gold); font-weight: 700; }

.roster-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; font-size: 13px;
}
.roster-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.roster-dead { color: var(--text-dim); text-decoration: line-through; }

/* ---------------------------- Touch controls ---------------------------- */
.touch-controls {
  display: none;
  position: fixed; bottom: 76px; left: 0; right: 0;
  padding: 10px 16px 4px;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(2, 64px);
  justify-content: space-between;
  align-items: center;
  z-index: 20;
}
.tbtn {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(23,29,43,.85);
  color: var(--text);
  font-size: 20px;
  width: 60px; height: 60px;
  display: flex; align-items: center; justify-content: center;
}
.tbtn:active { background: var(--panel-raised); }
.tbtn--boost { color: var(--gold); border-color: var(--gold); }

@media (max-width: 880px) {
  .game-screen { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; }
  .panel { flex: 1; max-height: 180px; }
  .touch-controls { display: grid; }
}

/* ---------------------------- Round / interstitial modal ---------------------------- */
.round-modal {
  position: fixed; inset: 0;
  background: rgba(6,8,12,.82);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.round-modal__card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  width: min(92vw, 380px);
  text-align: center;
}
.round-modal__title {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.round-modal__winner {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 18px;
}
.round-modal__ad {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 24px 10px;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 18px;
  font-family: var(--font-mono);
}
