/* Layout idea: one centered column on phones; the host screen widens into
   a stage (left) and a scoreboard rail (right) on anything TV-sized. */
:root {
  color-scheme: dark;
  --bg: #1b1440;          /* late-night violet */
  --panel: #2a2060;
  --panel-hi: #3a2d80;
  --ink: #f6f1ff;
  --muted: #b3a8dc;
  --accent: #ff7a3d;      /* tangerine: the thing to press */
  --accent-ink: #2a1000;
  --pop: #ffe45c;         /* lemon: the word in play */
  --good: #5fe0a0;
  --bad: #ff6b8a;
  --font-display: "Bricolage Grotesque", "Arial Black", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(120% 80% at 50% -10%, #3b2a8f 0%, transparent 60%);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 17px/1.45 var(--font-body);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
#app {
  min-height: 100%;
  display: flex; flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.boot { margin: auto; color: var(--muted); }

h1, h2, h3 { font-family: var(--font-display); font-weight: 800; line-height: 1.05; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2rem, 7vw, 3.2rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.4rem, 4.5vw, 2rem); }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.col { width: 100%; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.grow { flex: 1; }
.center { text-align: center; align-items: center; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* ---- Top bar ---- */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.brand { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand b { color: var(--accent); }
.conn { font-size: 0.8rem; color: var(--bad); }

/* ---- Controls ---- */
button, input, select { font: inherit; color: inherit; }
.btn {
  appearance: none; border: 0; cursor: pointer;
  min-height: 52px; padding: 12px 22px; border-radius: 999px;
  font-family: var(--font-display); font-weight: 800; font-size: 1.05rem;
  background: var(--accent); color: var(--accent-ink);
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--panel-hi); }
.btn.good { background: var(--good); color: #05301b; }
.btn.bad { background: var(--bad); color: #3d0012; }
.btn.wide { width: 100%; }
.btn.tiny { min-height: 36px; padding: 6px 14px; font-size: 0.85rem; }
:focus-visible { outline: 3px solid var(--pop); outline-offset: 3px; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; color: var(--muted); }
input[type=text], select {
  min-height: 54px; padding: 10px 16px; border-radius: 14px; border: 2px solid var(--panel-hi);
  background: var(--panel); color: var(--ink); font-size: 1.15rem; width: 100%;
}
input.code { font-family: var(--font-display); font-weight: 800; font-size: 1.8rem; letter-spacing: 0.3em; text-align: center; text-transform: uppercase; }

/* ---- Panels ---- */
.panel { background: var(--panel); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.game-card h2 { color: var(--pop); }
.tag { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--panel-hi); font-size: 0.8rem; font-weight: 600; }
ol.steps { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--panel-hi); }

/* ---- Host lobby ---- */
.lobby { display: grid; gap: 24px; width: 100%; max-width: 1100px; margin: 0 auto; }
.qr-box { background: #fff; border-radius: var(--radius); padding: 12px; width: min(100%, 320px); aspect-ratio: 1; }
.qr-box img { width: 100%; height: 100%; display: block; }
.big-code { font-family: var(--font-display); font-weight: 800; font-size: clamp(3rem, 12vw, 5.5rem); letter-spacing: 0.12em; color: var(--pop); line-height: 1; }
.join-url { font-weight: 600; word-break: break-all; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-radius: 999px; background: var(--panel-hi); font-weight: 600; }
.chip.off { opacity: 0.5; }
.chip button { all: unset; cursor: pointer; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,0.25); font-size: 0.9rem; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* ---- Game stage (shared by game screens) ---- */
.stage { display: grid; gap: 24px; width: 100%; max-width: 1200px; margin: 0 auto; flex: 1; align-content: start; }
.stage-main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; text-align: center; min-height: 46vh; }
.eyebrow { font-weight: 600; font-size: 0.85rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.status { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.3rem, 4vw, 2.4rem); }
.status.good { color: var(--good); } .status.bad { color: var(--bad); }
.timer { font-family: var(--font-display); font-weight: 800; font-size: clamp(2.4rem, 8vw, 5rem); font-variant-numeric: tabular-nums; color: var(--accent); }
.timer.out { color: var(--bad); }

.scores { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.scores li { display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; align-items: center; background: var(--panel); border-radius: 14px; padding: 10px 16px; font-weight: 600; }
.scores li.me { box-shadow: inset 0 0 0 2px var(--accent); }
.scores li.off .who { opacity: 0.5; }
.scores .pts { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; font-variant-numeric: tabular-nums; color: var(--pop); }
.scores .track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--panel-hi); overflow: hidden; }
.scores .track i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s ease; }

.corner-join { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 0.85rem; color: var(--muted); }
.corner-join img { width: 56px; height: 56px; border-radius: 8px; background: #fff; padding: 3px; }
.corner-join b { font-family: var(--font-display); color: var(--pop); font-size: 1.2rem; letter-spacing: 0.1em; }

/* ---- Player controller ---- */
.player-view { flex: 1; display: flex; flex-direction: column; gap: 18px; width: 100%; max-width: 520px; margin: 0 auto; text-align: center; }
.grab {
  appearance: none; border: 0; cursor: pointer; flex: 1; min-height: 220px; width: 100%;
  border-radius: 32px; background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-display); font-weight: 800; font-size: clamp(2rem, 9vw, 3rem); line-height: 1;
  box-shadow: 0 10px 0 #b84a17; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.grab:active { transform: translateY(8px); box-shadow: 0 2px 0 #b84a17; }
.grab:disabled { background: var(--panel-hi); color: var(--muted); box-shadow: none; cursor: default; }
.spotlight { flex: 1; min-height: 220px; border-radius: 32px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; background: var(--panel); }
.spotlight.you { background: var(--pop); color: #2b2400; }
.spotlight.you .timer { color: #2b2400; }

#toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); max-width: calc(100% - 32px); padding: 12px 20px; border-radius: 14px; background: #fff; color: #1b1440; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 10; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 860px) {
  .lobby { grid-template-columns: 340px 1fr; align-items: start; }
  .stage { grid-template-columns: 1fr 320px; }
  .stage-main { min-height: 60vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.scores li { text-align: left; }
.spotlight.you .eyebrow, .spotlight.you .muted { color: inherit; opacity: 0.75; }
