/* AI Impostor, in the Gilded Ace theme (TAMU Datathon 2026):
   warm off-white canvas with a soft yellow glow, white rounded cards,
   charcoal pills and feature cards, one yellow accent, light large numerals. */
:root {
  --bg: #f1f0eb;
  --glow: #fbeeb4;
  --surface: #ffffff;
  --surface-2: #ecebe5;
  --ink: #1b1b1a;
  --muted: #696964;
  --faint: #95948e;
  --rule: #e3e2dc;
  --dark: #232322;
  --on-dark: #f4f3ee;
  --on-dark-muted: #b4b3ac;
  --yellow: #f4c542;
  --yellow-soft: #fbefc4;
  --on-yellow: #1b1b1a;
  --good: #2c7a4b;
  --good-soft: #e1f0e6;
  --bad: #c9392f;
  --bad-soft: #f9e0dd;
  --radius-lg: 24px;
  --radius: 14px;
  --display: "Manrope", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Manrope", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --glow: #2c2612; --surface: #1c1c1a; --surface-2: #272724; --ink: #f2f1ec; --muted: #aaa9a2;
    --faint: #84837d; --rule: #31312d; --dark: #2b2b28; --on-dark: #f4f3ee; --on-dark-muted: #b4b3ac;
    --yellow: #f2c544; --yellow-soft: #3a3115; --on-yellow: #1b1b1a;
    --good: #6ccf94; --good-soft: #17301f; --bad: #f08a80; --bad-soft: #3d1d1a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --glow: #2c2612; --surface: #1c1c1a; --surface-2: #272724; --ink: #f2f1ec; --muted: #aaa9a2;
  --faint: #84837d; --rule: #31312d; --dark: #2b2b28; --on-dark: #f4f3ee; --on-dark-muted: #b4b3ac;
  --yellow: #f2c544; --yellow-soft: #3a3115; --on-yellow: #1b1b1a;
  --good: #6ccf94; --good-soft: #17301f; --bad: #f08a80; --bad-soft: #3d1d1a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(1100px 520px at 88% -8%, var(--glow) 0%, transparent 62%), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 15px/1.55 var(--body);
}
h1, h2, h3, p { margin: 0; }
h1, h2 { text-wrap: balance; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.inner { max-width: 1080px; margin: 0 auto; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.eyebrow { font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.bar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; padding-block: 14px 12px; flex-wrap: wrap; }
.brand-pill {
  display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--ink); border-radius: 999px;
  padding: 6px 16px; font-weight: 600; font-size: 1rem; letter-spacing: -0.01em;
}
.brand-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--yellow); }
.me {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--rule); font-size: 0.88rem; color: var(--muted);
}
.me b { color: var(--ink); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-radius: 999px;
  padding: 10px 18px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: border-color .15s, background .15s, transform .15s var(--ease);
}
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--dark); color: var(--on-dark); border-color: var(--dark); }
.btn.primary:hover:not(:disabled) { background: var(--ink); color: var(--bg); }
.btn.yellow { background: var(--yellow); color: var(--on-yellow); border-color: var(--yellow); }
.btn.yellow:hover:not(:disabled) { border-color: var(--ink); }
.btn.link {
  border: 0; padding: 0; background: none; border-radius: 0; font-weight: 500; color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--yellow); text-decoration-thickness: 2px; text-underline-offset: 3px;
}

/* ---------- Layout ---------- */
main { flex: 1; }
main > .inner { padding-block: 28px 64px; }
.screen { display: grid; gap: 22px; }
.card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 20px 22px;
  display: grid; gap: 12px; min-width: 0; align-content: start; box-shadow: 0 1px 0 var(--rule);
}
.card.dark { background: var(--dark); color: var(--on-dark); }
.card.dark .eyebrow, .card.dark .hint, .card.dark .muted { color: var(--on-dark-muted); }
.card h2 { font-size: 1.02rem; font-weight: 600; letter-spacing: -0.01em; }
.center { justify-items: center; text-align: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.center-row { justify-content: center; }
.hint { font-size: 0.83rem; color: var(--muted); }
.hint:empty { display: none; }
.hint.error { color: var(--bad); }

/* ---------- Lobby ---------- */
.hero { display: grid; gap: 10px; padding-block: 18px 6px; }
.hero h1 {
  font-family: var(--display); font-weight: 300; font-size: clamp(2.4rem, 6.5vw, 4.4rem);
  line-height: 1.04; letter-spacing: -0.035em; max-width: 14ch;
}
.hero h1 .mark { font-weight: 600; background: linear-gradient(transparent 62%, var(--yellow) 62%); padding: 0 .06em; }
.lede { color: var(--muted); max-width: 60ch; font-size: 1.04rem; }

.lobby-grid { display: grid; gap: 16px; grid-template-columns: 1.3fr 1fr; }
.join { grid-column: 1; }
.stats-card { grid-column: 2; grid-row: 1 / span 2; }
.board-card { grid-column: 1; }
input {
  flex: 1 1 200px; min-width: 0; background: var(--surface-2); border: 1px solid transparent; border-radius: 999px;
  padding: 11px 18px; transition: border-color .15s, background .15s;
}
input:focus { outline: none; border-color: var(--ink); background: var(--surface); }
.wake { display: flex; align-items: center; gap: 10px; background: var(--yellow-soft); color: var(--ink); padding: 10px 14px; border-radius: var(--radius); }
.spinner { width: 14px; height: 14px; flex: none; border-radius: 50%; border: 2px solid var(--rule); border-top-color: var(--ink); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: color-mix(in srgb, var(--on-dark) 7%, transparent); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; min-width: 0; }
.kpi .v { font-family: var(--display); font-size: 2rem; font-weight: 300; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .l { font-size: 0.78rem; color: var(--on-dark-muted); font-weight: 500; }
.kpi.accent .v { color: var(--yellow); }

.leaderboard { margin: 0; padding: 0; list-style: none; counter-reset: rank; display: grid; }
.leaderboard li { counter-increment: rank; display: flex; align-items: baseline; gap: 12px; padding: 9px 0; border-top: 1px solid var(--rule); }
.leaderboard li:first-child { border-top: 0; }
.leaderboard li:not(.muted)::before { content: counter(rank); font-family: var(--mono); font-size: 0.8rem; color: var(--faint); width: 1.4em; }
.leaderboard li:not(.muted):first-child::before { color: var(--on-yellow); background: var(--yellow); border-radius: 999px; text-align: center; }
.leaderboard li span:first-child { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard li span:last-child { font-family: var(--mono); font-size: 0.84rem; color: var(--muted); }

/* ---------- Searching ---------- */
.search { padding-block: 56px; gap: 14px; }
.search h2 { font-family: var(--display); font-weight: 300; font-size: clamp(1.5rem, 3.2vw, 2.1rem); letter-spacing: -0.02em; }
.pulse { width: 56px; height: 56px; margin-bottom: 6px; border-radius: 50%; background: var(--yellow); animation: pulse 1.4s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--yellow) 60%, transparent); }
  100% { box-shadow: 0 0 0 26px color-mix(in srgb, var(--yellow) 0%, transparent); }
}

/* ---------- Chat ---------- */
.game { max-width: 760px; margin: 0 auto; width: 100%; }
.chat { padding: 0; gap: 0; overflow: hidden; height: min(68vh, 620px); grid-template-rows: auto auto 1fr auto auto; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--rule); }
.who { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.live { width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); }
.timer { font-size: 1.15rem; font-weight: 500; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); }
.timer.low { background: var(--bad-soft); color: var(--bad); }
.progress { height: 3px; background: var(--surface-2); }
.progress div { height: 100%; width: 100%; background: var(--yellow); transition: width 1s linear; }

.messages { list-style: none; margin: 0; padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.messages li { max-width: 78%; padding: 9px 14px; border-radius: 18px; overflow-wrap: anywhere; white-space: pre-wrap; animation: pop .3s var(--ease) both; }
.messages .them { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 6px; }
.messages .me { align-self: flex-end; background: var(--dark); color: var(--on-dark); border-bottom-right-radius: 6px; }
.messages .system { align-self: center; background: none; color: var(--faint); font-size: 0.8rem; padding: 2px 0; animation: none; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--rule); }
.chat-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 16px 12px; min-height: 30px; }
.chat-foot .btn.link { margin-left: auto; }
.game.closed .chat { height: auto; max-height: min(38vh, 360px); }
.game.closed .timer { background: var(--surface-2); color: var(--muted); }

/* ---------- Verdict + result ---------- */
.guess, .result { justify-items: center; text-align: center; padding-block: 26px; }
.guess h2, .result h2 { font-family: var(--display); font-weight: 300; font-size: clamp(1.45rem, 3vw, 2rem); letter-spacing: -0.02em; line-height: 1.15; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; margin-top: 6px; }
.choice {
  display: grid; justify-items: center; gap: 6px; padding: 22px 12px; cursor: pointer;
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: var(--radius-lg);
  font-weight: 700; font-size: 1.05rem; transition: border-color .15s, background .15s, transform .15s var(--ease);
}
.choice .emoji { font-size: 2.2rem; line-height: 1; }
.choice:hover:not(:disabled) { border-color: var(--ink); background: var(--surface); transform: translateY(-2px); }
.choice.ai:hover:not(:disabled) { background: var(--yellow-soft); }
.choice:disabled { opacity: .5; cursor: progress; }

.badge { padding: 5px 14px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--surface-2); color: var(--muted); }
.badge.correct { background: var(--good-soft); color: var(--good); }
.badge.wrong { background: var(--bad-soft); color: var(--bad); }
.result .muted { max-width: 52ch; }
.points { font-size: 1.1rem; font-weight: 500; padding: 6px 16px; border-radius: 999px; background: var(--yellow-soft); }

/* ---------- Footer ---------- */
.foot { color: var(--faint); font-size: 0.8rem; border-top: 1px solid var(--rule); }
.foot .inner { padding-block: 18px 26px; }

@media (max-width: 760px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .join, .stats-card, .board-card { grid-column: auto; grid-row: auto; }
  .messages li { max-width: 88%; }
  .chat { height: 66vh; }
}
@media (prefers-reduced-motion: reduce) {
  .pulse, .spinner, .messages li { animation: none; }
  .progress div, .btn, .choice { transition: none; }
}

/* Dark theme: white text on the yellow highlight is hard to read, so color the word instead. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero h1 .mark { background: none; color: var(--yellow); }
}
:root[data-theme="dark"] .hero h1 .mark { background: none; color: var(--yellow); }

/* ---------- Mode picker (lobby) ---------- */
#nickname { width: 100%; flex: none; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-btn {
  display: grid; gap: 2px; text-align: left; padding: 14px 16px; border-radius: var(--radius);
  border: 1.5px solid transparent; cursor: pointer; transition: border-color .15s, transform .15s var(--ease);
}
.mode-btn:hover:not(:disabled) { border-color: var(--ink); transform: translateY(-1px); }
.mode-btn:disabled { opacity: .45; cursor: not-allowed; }
.mode-btn.yellow { background: var(--yellow); color: var(--on-yellow); }
.mode-btn.dark { background: var(--dark); color: var(--on-dark); }
.mode-btn.dark:hover:not(:disabled) { border-color: var(--yellow); }
.mode-name { font-weight: 700; font-size: 1.02rem; }
.mode-desc { font-size: 0.8rem; opacity: .78; }

/* ---------- Alias colors (six, readable in both themes) ---------- */
:root { --a0: #d9a514; --a1: #2c7a4b; --a2: #3d6db5; --a3: #c4562d; --a4: #8a55b3; --a5: #1d8a8a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --a0: #f2c544; --a1: #6ccf94; --a2: #86aef0; --a3: #f0936d; --a4: #c69ae8; --a5: #5fd0cf; }
}
:root[data-theme="dark"] { --a0: #f2c544; --a1: #6ccf94; --a2: #86aef0; --a3: #f0936d; --a4: #c69ae8; --a5: #5fd0cf; }
.c0 { --alias: var(--a0); } .c1 { --alias: var(--a1); } .c2 { --alias: var(--a2); }
.c3 { --alias: var(--a3); } .c4 { --alias: var(--a4); } .c5 { --alias: var(--a5); }

.chip-alias {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
  background: var(--surface-2); font-weight: 600; font-size: 0.82rem; white-space: nowrap;
}
.chip-alias::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--alias, var(--faint)); }
.chip-alias.me { background: var(--dark); color: var(--on-dark); }

/* ---------- Room chat ---------- */
.room { max-width: 760px; margin: 0 auto; width: 100%; }
.room-chat { grid-template-rows: auto auto auto 1fr auto auto; height: min(72vh, 680px); }
.members { list-style: none; margin: 0; padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--rule); }
.room-chat .messages .them { border-left: 3px solid var(--alias, var(--rule)); }
.who-said { display: block; font-size: 0.74rem; font-weight: 700; color: var(--alias, var(--muted)); margin-bottom: 1px; }
.room.closed .room-chat { height: auto; max-height: min(40vh, 380px); }
.room.closed #room-timer { background: var(--surface-2); color: var(--muted); }

/* ---------- Vote ---------- */
.vote { justify-items: stretch; padding-block: 24px; }
.vote h2 { font-family: var(--display); font-weight: 300; font-size: clamp(1.45rem, 3vw, 2rem); letter-spacing: -0.02em; }
.ballot { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.ballot li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface); border-radius: 999px; border: 1px solid var(--rule); }
.seg label { position: relative; padding: 6px 16px; border-radius: 999px; font-weight: 600; font-size: 0.86rem; cursor: pointer; color: var(--muted); }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--dark); color: var(--on-dark); }
.seg label:has(input[value="ai"]:checked) { background: var(--yellow); color: var(--on-yellow); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.vote .btn { justify-self: center; margin-top: 4px; }

/* ---------- Reveal ---------- */
.room-result { justify-items: stretch; text-align: left; }
.room-result .eyebrow, .room-result h2, .room-result .points { justify-self: center; text-align: center; }
.reveal-list { list-style: none; margin: 4px 0 6px; padding: 0; display: grid; gap: 8px; }
.reveal-list li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); }
.reveal-list li.is-ai { background: var(--yellow-soft); }
.reveal-body { display: grid; gap: 2px; min-width: 0; }
.reveal-body .muted { font-size: 0.8rem; }

@media (max-width: 560px) {
  .modes { grid-template-columns: 1fr; }
  .reveal-list li { grid-template-columns: 1fr auto; }
  .reveal-list li .chip-alias { grid-column: 1 / -1; justify-self: start; }
  .ballot li { flex-wrap: wrap; }
}
