@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  --bg: #0d0221;
  --panel: #1a1038;
  --fg: #f4f4ff;
  --dim: #8a82b5;
  --accent: #ffec27;
  --pink: #ff004d;
  --green: #00e436;
  --blue: #29adff;
  --font: 'Press Start 2P', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.6;
  image-rendering: pixelated;
  -webkit-tap-highlight-color: transparent;
}

/* CRT scanlines + vignette */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.45) 100%);
  z-index: 100;
}

#app { min-height: 100vh; padding: 16px; display: flex; flex-direction: column; align-items: center; }
.center { justify-content: center; text-align: center; }
.stack { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 520px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

h1, h2, h3 { margin: 0; font-weight: normal; text-transform: uppercase; }
h1 { font-size: clamp(20px, 5vw, 44px); color: var(--accent); text-shadow: 4px 4px 0 var(--pink); line-height: 1.3; }
h2 { font-size: clamp(14px, 3vw, 24px); color: var(--blue); }
.dim { color: var(--dim); }
.error { color: var(--pink); min-height: 1.6em; }
.blink { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* chunky pixel panel / buttons */
.panel {
  background: var(--panel);
  border: 4px solid var(--fg);
  box-shadow: 6px 6px 0 #000;
  padding: 16px;
}

button, .btn {
  font-family: var(--font);
  font-size: 14px;
  text-transform: uppercase;
  color: #000;
  background: var(--accent);
  border: 4px solid #000;
  box-shadow: 4px 4px 0 var(--pink);
  padding: 14px 20px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}
button:active, .btn:active { transform: translate(4px, 4px); box-shadow: none; }
button:disabled { background: #555; color: #999; box-shadow: none; cursor: not-allowed; }
button.secondary { background: var(--blue); }
button.danger { background: var(--pink); color: #fff; }

input {
  font-family: var(--font);
  font-size: 18px;
  text-transform: uppercase;
  text-align: center;
  width: 100%;
  padding: 14px;
  color: var(--accent);
  background: #000;
  border: 4px solid var(--fg);
  outline: none;
}
input:focus { border-color: var(--accent); }

/* host lobby */
.room-code {
  font-size: clamp(40px, 12vw, 120px);
  color: var(--green);
  letter-spacing: 0.2em;
  text-shadow: 0 0 12px var(--green);
  margin: 8px 0;
}

.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; width: 100%; max-width: 960px; }
.player-chip { border: 4px solid var(--c, #fff); padding: 12px; background: #000; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.player-chip.offline { opacity: 0.4; }
.player-chip .x { background: none; color: var(--dim); border: none; box-shadow: none; padding: 0 4px; font-size: 12px; }

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 380px));
  justify-content: center;
  gap: 24px;
  width: 100%;
  max-width: 960px;
}
.game-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  text-align: left;
  font-size: 16px;
  line-height: 1.5;
  background: var(--panel);
  color: var(--fg);
  border: 4px solid var(--dim);
  box-shadow: 6px 6px 0 #000;
}
.game-card:hover { border-color: var(--blue); }
.game-card.selected { border-color: var(--accent); color: var(--accent); }
.game-card .desc { font-size: 10px; line-height: 2; color: var(--dim); text-transform: uppercase; }
.game-card .meta {
  margin-top: auto;
  padding-top: 14px;
  border-top: 2px dashed var(--dim);
  font-size: 10px;
  color: var(--blue);
}
.game-card.selected .meta { color: var(--accent); border-top-color: var(--accent); }

/* generic big text for in-game screens */
.huge { font-size: clamp(32px, 14vw, 140px); line-height: 1.1; }
.big { font-size: clamp(18px, 5vw, 40px); }

/* score bars */
.bars { width: 100%; max-width: 960px; display: flex; flex-direction: column; gap: 10px; }
.bar { display: flex; align-items: center; gap: 12px; }
.bar .name { width: 11ch; text-align: left; overflow: hidden; white-space: nowrap; }
.bar .track { flex: 1; height: 28px; background: #000; border: 3px solid var(--fg); }
.bar .fill { height: 100%; background: var(--c); width: 0; transition: width 0.1s linear; }
.bar .val { width: 6ch; text-align: right; }

/* phone controller */
.pad {
  width: 100%;
  flex: 1;
  min-height: 55vh;
  font-size: 28px;
  border-radius: 0;
  background: var(--c, var(--accent));
}
.me-tag { border: 4px solid var(--c); padding: 8px 12px; background: #000; }

.results li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 2px dashed var(--dim); }
.results { list-style: none; padding: 0; margin: 0; width: 100%; }
.results li:first-child { color: var(--accent); }

/* sound toggle */
.sfx-toggle {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 200;
  font-size: 9px;
  padding: 8px 10px;
  background: var(--panel);
  color: var(--fg);
  border: 3px solid var(--dim);
  box-shadow: 3px 3px 0 #000;
}

/* high scores */
.results-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; width: 100%; align-items: start; }
.results-cols .panel h2 { margin-bottom: 12px; }
@media (max-width: 800px) { .results-cols { grid-template-columns: 1fr; } }

.results.hs li { display: grid; grid-template-columns: 3.5ch 1fr auto auto 4.5ch; gap: 14px; text-align: left; align-items: center; }
.results.hs .score { text-align: right; color: var(--green); }
.results.hs .date { color: var(--dim); font-size: 10px; }
.results.hs .tag { color: var(--pink); font-size: 10px; }
.results.hs li.new { color: var(--accent); background: rgba(255, 236, 39, 0.12); }
.results.hs li.new .score { color: var(--accent); }

/* host EXIT button, opposite the sound toggle */
.exit-btn { right: auto; left: 8px; border-color: var(--pink); color: var(--pink); }

/* credits line (music attribution) */
.credits { position: fixed; left: 0; right: 0; bottom: 10px; text-align: center; font-size: 8px; line-height: 1.8; color: var(--dim); padding: 0 16px; }
.credits a { color: var(--blue); }


/* generation range slider (game select screen) */
.gs { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 22px; text-align: center; }
.gs-label { color: var(--accent); font-size: clamp(11px, 1.6vw, 16px); min-height: 1.6em; margin-bottom: 14px; }
.gs-track { position: relative; height: 14px; margin: 18px 0 8px; background: #000; border: 3px solid #fff; touch-action: none; cursor: pointer; }
.gs-fill { position: absolute; top: 0; bottom: 0; background: var(--accent); }
.gs-dot { position: absolute; top: 50%; width: 6px; height: 6px; background: var(--dim); transform: translate(-50%, -50%); }
.gs-handle { position: absolute; top: 50%; width: 34px; height: 34px; padding: 0; transform: translate(-50%, -50%); display: grid; place-items: center; font-size: 12px; background: var(--blue); color: #000; border: 3px solid #fff; box-shadow: 3px 3px 0 #000; cursor: grab; touch-action: none; }
.gs-handle:active { transform: translate(-50%, -50%); box-shadow: 3px 3px 0 #000; cursor: grabbing; }
.gs-handle:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.gs-ticks { position: relative; height: 3.2em; margin-top: 18px; }
.gs-ticks span { position: absolute; top: 0; transform: translateX(-50%); font-size: 11px; color: var(--dim); }
.gs-ticks span small { display: block; margin-top: 4px; font-size: 7px; letter-spacing: 0; }
.gs-ticks span.on { color: var(--fg); }
.gs.compact .gs-ticks span small { display: none; }
.gs.compact .gs-ticks { height: 1.6em; }

/* topic picker and the topic's options (game select screen) */
.topic-picker { width: 100%; }
.topic-row { flex-wrap: wrap; justify-content: center; }
.settings { display: flex; flex-direction: column; gap: 14px; width: 100%; align-items: center; }
.setting { width: 100%; display: flex; flex-direction: column; align-items: center; }

/* re-rendering the lobby must not make the browser shift the scroll position to keep an "anchor" element in place */
body, #app { overflow-anchor: none; }

/* game cards: tags */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { font-size: 8px; line-height: 1; padding: 5px 7px; border: 2px solid var(--dim); color: var(--fg); text-transform: uppercase; }
.tag.time { border-color: var(--blue); color: var(--blue); }
.tag.mode { border-color: var(--pink); color: var(--pink); }
.tag.help { border-color: var(--green); color: var(--green); }
.tag.style { color: var(--dim); }

/* a topic whose pictures are not cut-outs (card art) blurs them instead of blacking them out */
body[data-hide="blur"] .tq-image img.hidden, body[data-hide="blur"] .pb-qimg img.hidden { filter: blur(16px) saturate(0.4) brightness(0.8); }
body[data-hide="blur"] .tq-image { overflow: hidden; }
.gs-ticks span.bare::before { content: ''; display: block; width: 1px; height: 4px; margin: 0 auto; background: var(--dim); }
.gs-handle.long { width: auto; min-width: 34px; padding: 0 4px; font-size: 9px; }

/* the picture clears up over the question's clock, then the reveal removes .hidden and shows it sharp */
@keyframes unblur { from { filter: blur(22px) saturate(0.4) brightness(0.8); } to { filter: blur(3px) saturate(0.8) brightness(0.95); } }
body[data-hide="blur"] .tq-image img.hidden.unblur { animation: unblur var(--ms, 15s) linear forwards; }

/* ── game select screen: topic tiles, settings bar, game cards and the pinned start bar ── */
h2.step { font-size: 11px; color: var(--dim); letter-spacing: 0.14em; margin-top: 8px; }

.topic-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; width: 100%; max-width: 960px; }
.topic-tile { display: flex; flex-direction: column; gap: 10px; text-align: left; padding: 14px 16px; background: var(--panel); color: var(--fg); border: 3px solid #2e2557; box-shadow: none; font-size: 12px; line-height: 1.4; }
.topic-tile .nm { color: var(--fg); }
.topic-tile .blurb { font-size: 8px; line-height: 1.9; color: var(--dim); }
.topic-tile:hover { border-color: var(--blue); }
.topic-tile:active { transform: none; }
.topic-tile.selected { border-color: var(--accent); box-shadow: 4px 4px 0 var(--pink); }
.topic-tile.selected .nm { color: var(--accent); }

.settings { max-width: 960px; padding: 6px 18px 2px; background: var(--panel); border: 3px solid #2e2557; gap: 0; }
.settings:empty { display: none; }
.setting h2 { font-size: 10px; color: var(--dim); letter-spacing: 0.14em; margin-top: 8px; }
.setting .gs { max-width: 640px; margin: 0 auto; }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; width: 100%; max-width: 960px; }
.pick-card { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; text-align: left; padding: 14px 16px; background: var(--panel); color: var(--fg); border: 3px solid #2e2557; box-shadow: none; font-size: 12px; line-height: 1.4; }
.pick-card .tags { margin-top: 0; }
.pick-card:hover { border-color: var(--blue); }
.pick-card:active { transform: none; }
.pick-card.selected { border-color: var(--accent); color: var(--accent); box-shadow: 4px 4px 0 var(--pink); }
.picker { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }

.pick-detail { width: 100%; max-width: 960px; text-align: left; padding: 16px 20px; background: rgba(255, 255, 255, 0.04); border-left: 4px solid var(--accent); }
.pick-detail h3 { margin: 0 0 8px; font-size: 14px; color: var(--accent); }
.pick-detail .desc { margin: 0; font-size: 10px; line-height: 2; color: var(--dim); text-transform: uppercase; }
.pick-detail .meta { margin: 10px 0 0; font-size: 9px; color: var(--blue); }

.start-bar { position: sticky; bottom: 0; z-index: 5; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-top: 8px; padding: 12px 16px; background: rgba(13, 2, 33, 0.96); border-top: 4px solid var(--accent); }
.start-bar .picked { font-size: 11px; color: var(--accent); text-align: left; line-height: 1.6; }
.start-bar .go { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.start-bar input { width: 190px; font-size: 14px; padding: 10px; }
.start-bar .error { margin: 0; min-height: 0; font-size: 10px; }
@media (max-width: 640px) {
  .start-bar { justify-content: center; }
  .start-bar .picked, .start-bar .go { justify-content: center; text-align: center; width: 100%; }
}
@media (max-width: 640px) {
  .topic-tiles { grid-template-columns: 1fr 1fr; }
  .topic-tile { padding: 12px; }
  .topic-tile .blurb { display: none; }
  .pick-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .start-bar { gap: 8px; padding: 10px 12px; }
  .start-bar .picked { font-size: 9px; }
  .start-bar .go { flex-wrap: nowrap; }
  .start-bar input { flex: 1 1 0; min-width: 0; width: auto; }
  .start-bar button { padding: 12px 14px; font-size: 12px; white-space: nowrap; }
}
