:root {
  --bg: #0f1115; --card: #181b22; --line: #2a2f3a; --text: #eef0f4; --muted: #9aa3b2;
  --accent: #1ed760; --accent-ink: #062b14; --warn: #f5b942; --bad: #ff6b6b;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 640px; margin: 0 auto; padding: 20px 16px 96px; }
main.wide { max-width: 1040px; padding-bottom: 64px; }
h1 { font-size: 1.6rem; margin: 8px 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.letter { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800; margin-right: 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 14px 0; }
label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type=text], input[type=number], textarea, select {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #0c0e12; color: var(--text); font: inherit; }
textarea { min-height: 84px; resize: vertical; }
button { font: inherit; font-weight: 650; border: 0; border-radius: 999px; padding: 11px 18px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--bad); color: #2b0606; }
button.small { padding: 6px 12px; font-size: 0.9rem; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; }
.msg { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #11151b; border: 1px solid var(--line); }
.msg.ok { border-color: #1f6b3b; } .msg.warn { border-color: #6b561f; } .msg.bad { border-color: #6b1f1f; }
.muted { color: var(--muted); } .hidden { display: none !important; }
iframe.embed { width: 100%; height: 152px; border: 0; border-radius: 12px; margin-top: 12px; }
.badge { display: inline-block; font-size: 0.78rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-right: 4px; }
.b-ok { background: #173d26; color: #7ff0a8; } .b-warn { background: #3d3317; color: #f5d27f; }
.b-bad { background: #3d1717; color: #ff9f9f; } .b-dim { background: #252a33; color: var(--muted); }

/* friend bottom nav & guessing / results */
.bnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(15, 17, 21, 0.94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  display: flex; justify-content: center; gap: 8px; }
.bnav button { flex: 1; max-width: 180px; background: transparent; color: var(--muted);
  border: 1px solid var(--line); padding: 9px 12px; font-size: 0.92rem; }
.bnav button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.song-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.song-row:last-child { border-bottom: 0; }
.song-row img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: #0c0e12; }
.song-row .meta { flex: 1; min-width: 0; }
.song-row .meta .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-row .meta .a { font-size: 0.88rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-row .pick { width: 165px; flex-shrink: 0; }
@media (max-width: 480px) {
  .song-row { flex-wrap: wrap; }
  .song-row .pick { width: 100%; }
}
.progress-bar { height: 8px; border-radius: 999px; background: #0c0e12; border: 1px solid var(--line); overflow: hidden; margin-top: 8px; }
.progress-bar > div { height: 100%; background: var(--accent); transition: width 0.2s ease; }

/* admin */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0; }
.tabs button { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.tabs button.on { background: var(--text); color: var(--bg); }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }
td img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; display: block; }
.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat { background: #11151b; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-width: 120px; }
.stat b { display: block; font-size: 1.5rem; }
.phase-pills { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 10px 0; }
.phase-pill { background: #11151b; border: 2px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; text-align: left; color: var(--text); }
.phase-pill.on { border-color: var(--accent); background: rgba(30, 215, 96, 0.08); }
.phase-pill b { display: block; font-size: 1rem; margin-bottom: 2px; }
.phase-pill span { font-size: 0.82rem; color: var(--muted); font-weight: 400; }

/* session / TV stage */
.stage { text-align: center; padding: 34px 20px; }
.stage .num { font-size: 1.05rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.stage .big { font-size: clamp(3.5rem, 8vw, 6rem); font-weight: 800; margin: 10px 0 18px; }
.reveal img { width: min(280px, 70vw); aspect-ratio: 1; border-radius: 14px; object-fit: cover; margin: 0 auto; display: block; }
.reveal .t { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; margin-top: 16px; }
.reveal .a { font-size: clamp(1.15rem, 2.5vw, 1.5rem); color: var(--muted); }
.reveal .by { margin-top: 16px; font-size: clamp(1.25rem, 3vw, 1.7rem); }
.score { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.score .p { display: flex; align-items: center; justify-content: space-between; gap: 6px;
  background: #11151b; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font-size: 1.02rem; }
.score .p b { font-size: 1.3rem; min-width: 2ch; text-align: center; }

/* greeting & nomination mode toggle */
.player-greeting { font-size: 1.15rem; font-weight: 700; color: var(--accent); margin: -8px 0 16px; }
.mode-toggle { display: flex; gap: 8px; margin: 12px 0 8px; }
.mode-toggle button { flex: 1; padding: 10px 12px; font-size: 0.92rem; border-radius: 10px; border: 1px solid var(--line); background: #0c0e12; color: var(--muted); }
.mode-toggle button.on { background: rgba(30, 215, 96, 0.12); color: var(--accent); border-color: var(--accent); }

/* modal dialogs */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.78); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-dialog { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 12px 36px rgba(0,0,0,0.6); }

/* sortable table headers */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sortable .arrow { font-size: 0.75rem; margin-left: 4px; color: var(--accent); }

/* spotify search results */
.search-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-bottom: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.search-item:hover { background: #11151b; }
.search-item img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }

/* type-ahead suggestions */
.typeahead-wrap { position: relative; width: 100%; margin-bottom: 10px; }
.suggestions-box { position: absolute; left: 0; right: 0; top: 100%; z-index: 50; background: var(--card); border: 1px solid var(--line); border-radius: 10px; max-height: 240px; overflow-y: auto; margin-top: 4px; box-shadow: 0 10px 30px rgba(0,0,0,0.7); }
.suggestion-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover, .suggestion-item.active { background: #11151b; color: var(--accent); }

/* session game grid */
.song-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); gap: 10px; margin: 16px 0; }
.song-grid-btn { padding: 12px 6px; border-radius: 12px; border: 2px solid var(--line); background: #11151b; color: var(--text); cursor: pointer; text-align: center; }
.song-grid-btn b { display: block; font-size: 1.3rem; }
.song-grid-btn span { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 4px; text-transform: uppercase; font-weight: 700; }
.song-grid-btn.open { border-color: var(--accent); background: rgba(30, 215, 96, 0.12); }
.song-grid-btn.closed { border-color: var(--warn); background: rgba(245, 185, 66, 0.12); }
.song-grid-btn.revealed { border-color: var(--line); opacity: 0.65; }
.song-grid-btn.selected { outline: 2px solid #fff; }

/* marking buttons */
.mark-btn { padding: 4px 10px; font-size: 0.88rem; border-radius: 999px; cursor: pointer; border: 1px solid var(--line); font-weight: 700; }
.mark-btn.ok { background: #173d26; color: #7ff0a8; border-color: #1f6b3b; }
.mark-btn.bad { background: #3d1717; color: #ff9f9f; border-color: #6b1f1f; }

/* prominent positive action button */
button.big-btn {
  width: 100%;
  padding: 14px 20px;
  font-size: 1.15rem;
  font-weight: 750;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 4px 16px rgba(30, 215, 96, 0.3);
  transition: transform 0.1s ease, filter 0.15s ease;
  cursor: pointer;
}
button.big-btn:hover { filter: brightness(1.08); }
button.big-btn:active { transform: scale(0.98); }
button.big-btn:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.5); }


