:root {
  --bg: #0b0b12;
  --panel: #151526;
  --ink: #f4efe2;
  --muted: #8b86a3;
  --red: #e03c28;
  --gold: #f0c800;
  --sky: #5c94fc;
  --accent: #3dd68c;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: #0b0b12;
  color: var(--ink);
  font-family: "Press Start 2P", ui-monospace, monospace;
  overflow: hidden;
}
#wrap {
  max-width: 960px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 6px;
}
#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 8px;
}
.toggles { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.cpu-toggle {
  font-family: inherit;
  font-size: 8px;
  padding: 6px 8px;
  background: #111;
  color: var(--muted);
  border: 2px solid #555;
  cursor: pointer;
  white-space: nowrap;
}
.cpu-toggle.on {
  color: #0b0b12;
  background: var(--gold);
  border-color: #fff;
}
.scores-table {
  width: min(560px, 94vw);
  max-height: 52vh;
  overflow: auto;
  border: 4px solid #000;
  background: #111;
}
.score-row {
  display: grid;
  grid-template-columns: 36px 1fr 48px 48px 48px;
  gap: 8px;
  font-size: 8px;
  padding: 8px 8px;
  border-bottom: 2px solid #2a2a3a;
}
.score-row.me { color: var(--gold); background: #2a2208; }
.score-row.head { color: var(--gold); }
.logo { font-size: 11px; letter-spacing: 1px; }
.logo span { color: var(--gold); }
.net {
  font-size: 8px;
  padding: 4px 8px;
  border: 2px solid #333;
}
.net.ok { color: var(--accent); border-color: var(--accent); }
.net.wait { color: var(--gold); border-color: var(--gold); }
.net.offline { color: var(--red); border-color: var(--red); }

.screen { display: none; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 0; }
.screen.active { display: flex; }

.hero { text-align: center; }
.hero h1 {
  font-size: 20px;
  margin-top: 8px;
  color: #fff;
  text-shadow: 3px 3px 0 #000, -2px 0 0 var(--red);
}
.tag { font-size: 7px; color: var(--muted); margin-top: 10px; line-height: 1.6; }
#title-art {
  width: 512px;
  max-width: 90vw;
  height: auto;
  image-rendering: pixelated;
  background: #5c94fc;
  border: 4px solid #000;
  box-shadow: 8px 8px 0 #000;
}

#join-form, .lobby-actions { display: flex; flex-direction: column; gap: 10px; width: min(360px, 92vw); }
#join-form label { font-size: 8px; color: var(--muted); }
#name-input {
  font-family: inherit;
  font-size: 12px;
  padding: 12px;
  background: #000;
  color: var(--gold);
  border: 4px solid #fff;
  text-transform: uppercase;
}
.btn {
  font-family: inherit;
  font-size: 10px;
  padding: 14px 12px;
  background: #2a2a44;
  color: #fff;
  border: 4px solid #fff;
  cursor: pointer;
  box-shadow: 4px 4px 0 #000;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 #000; }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 #000; }
.btn.primary { background: var(--red); }
.btn.ghost { background: transparent; color: var(--muted); border-color: #555; }
.hidden { display: none !important; }
.hint { font-size: 7px; color: var(--muted); text-align: center; line-height: 1.7; max-width: 520px; }

h2 { font-size: 14px; color: var(--gold); }
.lobby-msg { font-size: 8px; color: var(--muted); text-align: center; line-height: 1.7; }
.live-matches {
  width: min(420px, 94vw);
  margin: 0 auto 12px;
  background: #111;
  border: 3px solid #333;
  color: var(--ink);
  font-size: 8px;
  line-height: 1.7;
  text-align: left;
  padding: 8px;
}
.live-matches strong { color: var(--gold); }
  width: min(420px, 94vw);
  max-height: 28vh;
  overflow: auto;
  font-size: 8px;
  line-height: 1.6;
  color: var(--ink);
  background: #111;
  border: 3px solid #333;
  padding: 8px;
  text-align: left;
}
.queue-list div { margin: 4px 0; }
.howto {
  width: min(640px, 94vw);
  background: var(--panel);
  border: 4px solid #000;
  padding: 14px 16px;
}
.howto h3 { font-size: 8px; margin-bottom: 10px; color: var(--sky); }
.howto ul { list-style: none; }
.howto li { font-size: 7px; line-height: 1.8; color: #d7d2ea; margin-bottom: 8px; }
.howto em { color: var(--red); font-style: normal; }

#stage {
  position: relative;
  width: min(768px, 96vw);
  aspect-ratio: 256 / 240;
  background: #000;
  border: 4px solid #fff;
  box-shadow: 8px 8px 0 #000;
}
#game {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  background: #5c94fc;
}
#hud {
  position: absolute;
  left: 0; right: 0; top: 0;
  padding: 6px 8px 0;
  pointer-events: none;
  text-shadow: 2px 2px 0 #000;
}
.hud-row {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  color: #fff;
}
#hud-doom { color: #e03c28; }
.bars { margin-top: 6px; display: flex; gap: 8px; }
.bar {
  flex: 1;
  height: 8px;
  background: #111;
  border: 2px solid #fff;
  position: relative;
}
.bar span {
  position: absolute;
  left: 3px; top: -1px;
  font-size: 5px;
  color: #fff;
  z-index: 2;
}
.bar i { display: block; height: 100%; width: 20%; background: #3dd68c; }
.bar.turbo i { background: #f0c800; }
.min-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  width: min(640px, 94vw);
  font-size: 8px;
  color: var(--muted);
}
#min-field {
  font-family: inherit;
  font-size: 12px;
  width: 72px;
  padding: 8px;
  background: #000;
  color: var(--gold);
  border: 4px solid #fff;
}
#min-hint { font-size: 7px; color: var(--accent); line-height: 1.5; }
#banner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  text-shadow: 4px 4px 0 #000;
  pointer-events: none;
  background: rgba(0,0,0,.2);
}
.touch {
  position: absolute;
  left: 0; right: 0; bottom: 6px;
  display: none;
  justify-content: space-between;
  padding: 0 6px;
  gap: 6px;
}
.touch button {
  flex: 1;
  font-family: inherit;
  font-size: 10px;
  padding: 12px 0;
  background: rgba(0,0,0,.45);
  color: #fff;
  border: 2px solid #fff;
}
@media (pointer: coarse) {
  .touch { display: flex; }
}

#results-list {
  list-style: none;
  width: min(520px, 92vw);
  max-height: 46vh;
  overflow: auto;
}
#results-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 8px;
  padding: 8px 6px;
  border-bottom: 2px solid #333;
}
#results-list li.me { background: #2a1a10; }
#results-list .place { color: var(--gold); width: 28px; }
footer {
  font-size: 6px;
  color: #5c5870;
  text-align: center;
  padding: 8px 0 4px;
}
