/* Mr. Whipple's Game Night */
:root {
  --bg: #0d0b1a;
  --bg2: #171430;
  --line: #2e2856;
  --text: #f3efff;
  --muted: #a8a1cc;
  --accent: #ffcc33;
  --accent2: #ff4fa3;
  --danger: #ff5a5f;
  --ok: #3ee08f;
  --ink: #120f22;
  --display: 'Bungee', 'Nunito', sans-serif;
  --body: 'Nunito', system-ui, sans-serif;
  --radius: 18px;
  --art: radial-gradient(circle at 20% -10%, rgba(255, 79, 163, 0.25), transparent 45%), radial-gradient(circle at 90% 10%, rgba(255, 204, 51, 0.18), transparent 40%), radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1.5px);
  --art-size: auto, auto, 22px 22px;
}
body[data-theme='werewolf'] {
  --bg: #070b18; --bg2: #101833; --line: #25315a; --text: #ece8d8; --muted: #9aa3c2;
  --accent: #efe9c9; --accent2: #c0303a; --ink: #070b18; --moon: #efe9c9;
  --display: 'Cinzel', Georgia, serif;
  --art: radial-gradient(circle at 82% 8%, rgba(239, 233, 201, 0.35) 0, rgba(239, 233, 201, 0.08) 9%, transparent 22%), linear-gradient(180deg, #0b1330 0%, #070b18 60%);
  --art-size: auto, auto;
}
body[data-theme='werewolf'].is-day {
  --bg: #2a3d5c; --bg2: #34507a; --line: #5a78a6; --muted: #cdd8ea;
  --art: radial-gradient(circle at 82% 8%, rgba(255, 214, 102, 0.55) 0, rgba(255, 214, 102, 0.12) 10%, transparent 24%), linear-gradient(180deg, #6f97cf 0%, #2a3d5c 70%);
}
body[data-theme='spyfall'] {
  --bg: #111010; --bg2: #1c1a17; --line: #3a342a; --text: #f1e9d6; --muted: #b3a88f;
  --accent: #e0a526; --accent2: #b8322a; --ink: #1a1408;
  --display: 'Special Elite', 'Courier New', monospace;
  --art: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 9px), radial-gradient(circle at 50% -20%, rgba(224, 165, 38, 0.18), transparent 55%);
  --art-size: auto, auto;
}
body[data-theme='imposter'] {
  --bg: #08031c; --bg2: #140a36; --line: #33206b; --text: #eef3ff; --muted: #a59ad6;
  --accent: #39e1ff; --accent2: #ff3df0; --ink: #08031c;
  --display: 'Audiowide', 'Nunito', sans-serif;
  --art: radial-gradient(rgba(255, 255, 255, 0.5) 1px, transparent 1.6px), radial-gradient(rgba(57, 225, 255, 0.35) 1px, transparent 1.6px), radial-gradient(circle at 50% 120%, rgba(255, 61, 240, 0.25), transparent 50%);
  --art-size: 90px 90px, 140px 140px, auto;
}
body[data-theme='chameleon'] {
  --bg: #06231c; --bg2: #0c3429; --line: #1f5a46; --text: #f0fff4; --muted: #a6d4bf;
  --accent: #7ee04a; --accent2: #ffb020; --ink: #06231c;
  --display: 'Baloo 2', 'Nunito', sans-serif;
  --art: radial-gradient(circle at 10% 20%, rgba(126, 224, 74, 0.18), transparent 35%), radial-gradient(circle at 90% 80%, rgba(255, 176, 32, 0.16), transparent 35%), radial-gradient(circle at 60% 10%, rgba(47, 193, 176, 0.16), transparent 30%);
  --art-size: auto, auto, auto;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background-color: var(--bg); background-image: var(--art); background-size: var(--art-size);
  background-attachment: fixed; color: var(--text); font-family: var(--body); font-size: 17px; line-height: 1.45;
  transition: background-color 0.6s;
}
a { color: var(--accent); }
h1, h2, h3, .display { font-family: var(--display); font-weight: 700; letter-spacing: 0.01em; margin: 0 0 0.4em; line-height: 1.15; }
h1 { font-size: clamp(30px, 6vw, 54px); }
h2 { font-size: clamp(22px, 3.6vw, 30px); }
h3 { font-size: 20px; }
p { margin: 0 0 0.7em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.hide { display: none !important; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 18px 16px 60px; }
.narrow { max-width: 560px; }

.demo-banner { background: #ffcc33; color: #1a1300; text-align: center; font-weight: 800; font-size: 14px; padding: 6px 12px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); }
.brand { font-family: 'Bungee', sans-serif; font-size: 18px; color: var(--accent); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand small { font-family: var(--body); font-size: 13px; color: var(--muted); font-weight: 700; }
.topbar .spacer { flex: 1; }

.panel { background: color-mix(in srgb, var(--bg2) 92%, transparent); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel h3 { margin-top: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 820px) { .grid2 { grid-template-columns: 1fr; } }

.btn {
  font-family: var(--body); font-weight: 800; font-size: 16px; border: 2px solid var(--line); background: var(--bg2); color: var(--text);
  padding: 10px 16px; border-radius: 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.08s, filter 0.15s; min-height: 44px;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn.alt { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn.ghost { background: transparent; }
.btn.big { font-size: 20px; padding: 14px 22px; border-radius: 16px; }
.btn.full { width: 100%; }
.btn.sm { font-size: 14px; padding: 6px 10px; min-height: 34px; border-radius: 9px; }
.btn.on { outline: 3px solid var(--accent); outline-offset: 2px; }

input[type='text'], input[type='password'], input[type='number'], select {
  font-family: var(--body); font-size: 18px; font-weight: 700; padding: 11px 13px; border-radius: 12px; border: 2px solid var(--line);
  background: rgba(0, 0, 0, 0.35); color: var(--text); width: 100%; min-height: 46px;
}
input:focus, select:focus, .btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
label.field { display: block; font-weight: 800; margin: 0 0 12px; }
label.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 700; margin: 8px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.code-input { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; font-family: 'Bungee', sans-serif !important; font-size: 28px !important; }

/* ---------- Hub ---------- */
.hero { text-align: center; padding: 26px 0 8px; }
.hero h1 { color: var(--accent); text-shadow: 0 0 18px rgba(255, 204, 51, 0.45), 0 3px 0 #7a2a5a; margin-bottom: 4px; }
.hero .sub { font-family: 'Bungee', sans-serif; color: var(--accent2); font-size: 15px; letter-spacing: 0.2em; }
.marquee { display: flex; justify-content: center; gap: 10px; margin: 10px 0 18px; }
.marquee i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: blink 1.6s infinite; }
.marquee i:nth-child(2n) { animation-delay: 0.8s; background: var(--accent2); box-shadow: 0 0 10px var(--accent2); }
@keyframes blink { 50% { opacity: 0.25; } }
.join-card { max-width: 440px; margin: 0 auto 26px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 640px) { .tiles { grid-template-columns: 1fr; } }
.tile {
  position: relative; display: flex; gap: 14px; align-items: center; padding: 18px; border-radius: 22px; text-decoration: none; color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.12); overflow: hidden; min-height: 140px; transition: transform 0.15s, box-shadow 0.15s; cursor: pointer; text-align: left; font: inherit;
}
.tile:hover, .tile:focus-visible { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.tile svg { width: 96px; height: 96px; flex: none; }
.tile .tname { font-size: 26px; margin: 0 0 4px; }
.tile .ttag { font-size: 15px; opacity: 0.85; margin: 0 0 6px; }
.tile .tmeta { font-size: 13px; font-weight: 800; opacity: 0.7; }
.tile.werewolf { background: radial-gradient(circle at 85% 0%, rgba(239, 233, 201, 0.3), transparent 40%), linear-gradient(160deg, #142048, #070b18); --accent: #efe9c9; }
.tile.werewolf .tname { font-family: 'Cinzel', serif; color: #efe9c9; }
.tile.spyfall { background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.03) 0 2px, transparent 2px 9px), linear-gradient(160deg, #2a2418, #0e0d0c); --accent: #e0a526; }
.tile.spyfall .tname { font-family: 'Special Elite', monospace; color: #e0a526; }
.tile.imposter { background: radial-gradient(circle at 50% 130%, rgba(255, 61, 240, 0.4), transparent 60%), linear-gradient(160deg, #1d0d4a, #08031c); --accent: #39e1ff; --accent2: #ff3df0; }
.tile.imposter .tname { font-family: 'Audiowide', sans-serif; color: #39e1ff; }
.tile.chameleon { background: radial-gradient(circle at 15% 10%, rgba(126, 224, 74, 0.3), transparent 45%), radial-gradient(circle at 95% 95%, rgba(255, 176, 32, 0.3), transparent 45%), linear-gradient(160deg, #0f4a38, #06231c); }
.tile.chameleon .tname { font-family: 'Baloo 2', sans-serif; color: #b7f58f; }
.tile.selected { outline: 4px solid #ffcc33; outline-offset: 3px; }
.tiles.small .tile { min-height: 84px; padding: 10px 12px; }
.tiles.small .tile svg { width: 56px; height: 56px; }
.tiles.small .tile .tname { font-size: 19px; }
.tiles.small .tile .ttag, .tiles.small .tile .tmeta { display: none; }
.footer { text-align: center; margin-top: 30px; font-size: 14px; }
.footer a { color: var(--muted); }

/* ---------- Players ---------- */
.plist { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.plist li:last-child { border-bottom: 0; }
.plist .nm { font-weight: 800; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.plist li.out .nm { text-decoration: line-through; opacity: 0.55; }
.tag { font-size: 12px; font-weight: 900; padding: 3px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); white-space: nowrap; }
.tag.bad { background: var(--accent2); color: #fff; }
.tag.good { background: rgba(62, 224, 143, 0.2); color: var(--ok); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 999px; background: var(--bg2); border: 2px solid var(--line); font-weight: 800; animation: pop 0.35s; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }

.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pcard { border-radius: 16px; padding: 14px 10px; text-align: center; background: var(--bg2); border: 2px solid var(--line); position: relative; transition: all 0.4s; }
.pcard .av { width: 54px; height: 54px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-size: 24px; color: var(--ink); background: var(--accent); }
.pcard .nm { font-weight: 900; font-size: 18px; overflow-wrap: anywhere; }
.pcard .rl { font-size: 13px; color: var(--muted); font-weight: 800; min-height: 1em; }
.pcard.out { opacity: 0.4; filter: grayscale(1); transform: scale(0.95); }
.pcard.out::after { content: 'OUT'; position: absolute; top: 8px; right: 8px; font-size: 11px; font-weight: 900; background: var(--danger); color: #fff; padding: 2px 6px; border-radius: 6px; }
.pcard.target { border-color: var(--accent2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent2) 40%, transparent); }

/* ---------- Room code + banners ---------- */
.codebig { font-family: 'Bungee', sans-serif; font-size: clamp(48px, 12vw, 120px); letter-spacing: 0.12em; color: var(--accent); line-height: 1; }
.codebox { text-align: center; padding: 20px; }
.banner { border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; font-weight: 800; font-size: 20px; text-align: center; background: color-mix(in srgb, var(--accent2) 30%, var(--bg2)); border: 2px solid var(--accent2); animation: pop 0.4s; }
.phase { display: flex; align-items: center; justify-content: center; gap: 12px; font-family: var(--display); font-size: clamp(26px, 5vw, 44px); margin: 6px 0 14px; text-align: center; }
.timer { font-family: 'Bungee', sans-serif; font-size: 26px; padding: 6px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.35); border: 2px solid var(--line); display: inline-block; }
.timer.low { color: var(--danger); border-color: var(--danger); animation: blink 1s infinite; }
.timer.huge { font-size: clamp(44px, 9vw, 90px); }

/* ---------- Role card (student) ---------- */
.rolecard { perspective: 1000px; cursor: pointer; margin: 0 auto 16px; max-width: 460px; user-select: none; }
.rolecard .inner { position: relative; min-height: 230px; transition: transform 0.5s; transform-style: preserve-3d; }
.rolecard.open .inner { transform: rotateY(180deg); }
.rolecard .face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 22px; padding: 22px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; border: 3px solid var(--accent); }
.rolecard .front { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--accent) 14%, var(--bg2)) 0 14px, var(--bg2) 14px 28px); }
.rolecard .back { background: var(--bg2); transform: rotateY(180deg); }
.rolecard .big { font-family: var(--display); font-size: clamp(30px, 8vw, 44px); color: var(--accent); margin: 4px 0; line-height: 1.1; }
.rolecard .big.bad { color: var(--accent2); }
.rolecard .lbl { font-size: 13px; font-weight: 900; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
body[data-theme='spyfall'] .rolecard .back { background: #efe6cf; color: #2b2214; border-color: #2b2214; }
body[data-theme='spyfall'] .rolecard .back .big { color: #7a1f17; }
body[data-theme='spyfall'] .rolecard .back .lbl, body[data-theme='spyfall'] .rolecard .back .muted { color: #6b5d43; }
.stamp { display: inline-block; border: 3px solid var(--accent2); color: var(--accent2); padding: 2px 10px; transform: rotate(-6deg); font-family: 'Special Elite', monospace; font-weight: 700; letter-spacing: 0.1em; margin-bottom: 8px; }

/* ---------- Voting ---------- */
.votebox { text-align: center; }
.votebox .who { font-family: var(--display); font-size: clamp(30px, 7vw, 54px); color: var(--accent); margin: 4px 0 10px; overflow-wrap: anywhere; }
.yn { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0; }
.yn .btn { font-size: 26px; min-height: 90px; border-radius: 20px; }
.yn .yay { border-color: var(--ok); color: var(--ok); background: transparent; }
.yn .nay { border-color: var(--danger); color: var(--danger); background: transparent; }
.yn .yay.on { background: var(--ok); color: #062014; outline: none; }
.yn .nay.on { background: var(--danger); color: #fff; outline: none; }
.tally { display: flex; justify-content: center; gap: 22px; font-family: 'Bungee', sans-serif; font-size: 30px; margin: 8px 0; }
.tally .y { color: var(--ok); }
.tally .n { color: var(--danger); }
.result { font-family: var(--display); font-size: 28px; }
.result.pass { color: var(--ok); }
.result.fail { color: var(--danger); }
.bar { height: 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin: 8px 0; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width 0.4s; }

/* ---------- Pick lists (night actions, guesses) ---------- */
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.picks .btn { min-height: 56px; font-size: 17px; overflow-wrap: anywhere; }
.picks .btn.on { background: var(--accent); color: var(--ink); border-color: var(--accent); outline: none; }

/* ---------- Chameleon grid ---------- */
.cgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cgrid .cell { border-radius: 12px; padding: 12px 6px; text-align: center; font-weight: 900; background: var(--bg2); border: 2px solid var(--line); font-size: 16px; overflow-wrap: anywhere; min-height: 54px; display: flex; align-items: center; justify-content: center; }
.cgrid .cell .ix { display: block; font-size: 11px; opacity: 0.6; }
.cgrid .cell.secret { background: var(--accent); color: var(--ink); border-color: var(--accent); box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 60%, transparent); }
.cgrid button.cell { cursor: pointer; color: var(--text); font-family: var(--body); }
.cgrid button.cell.on { outline: 3px solid var(--accent2); }
@media (max-width: 420px) { .cgrid { gap: 5px; } .cgrid .cell { font-size: 12px; padding: 8px 2px; overflow-wrap: normal; word-break: normal; hyphens: auto; -webkit-hyphens: auto; } }
.loclist { columns: 2; column-gap: 18px; font-weight: 700; font-size: 15px; padding-left: 18px; margin: 0; }
@media (min-width: 900px) { .loclist.wide { columns: 4; } }

.order { display: flex; flex-wrap: wrap; gap: 8px; counter-reset: o; list-style: none; padding: 0; margin: 0; }
.order li { counter-increment: o; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--bg2); border: 2px solid var(--line); font-weight: 800; }
.order li::before { content: counter(o); display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--ink); margin-right: 6px; font-size: 14px; }
.order li.out { opacity: 0.4; text-decoration: line-through; }

/* ---------- Teacher console bits ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; }
.kv b { color: var(--muted); font-weight: 800; }
.secret-box { border: 2px dashed var(--accent2); border-radius: 14px; padding: 12px; background: rgba(0, 0, 0, 0.2); }
.secret-box .lbl { font-size: 12px; font-weight: 900; letter-spacing: 0.12em; color: var(--accent2); text-transform: uppercase; }
.night-log li { margin-bottom: 6px; }
.big-out { font-family: var(--display); font-size: 26px; text-align: center; }
.reveal-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.reveal-list li { background: var(--bg2); border: 2px solid var(--line); padding: 8px 12px; border-radius: 12px; font-weight: 800; }
.reveal-list li.bad { border-color: var(--accent2); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px); background: #111; color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 800; z-index: 99; transition: transform 0.25s; max-width: calc(100% - 32px); border: 2px solid var(--accent); }
#toast.show { transform: translate(-50%, 0); }
#toast.bad { border-color: var(--danger); }

.outband { background: var(--danger); color: #fff; text-align: center; font-weight: 900; padding: 10px; border-radius: 14px; margin-bottom: 14px; }
.nightcover { text-align: center; }
.nightcover .moon { width: 90px; height: 90px; border-radius: 50%; margin: 0 auto 10px; background: var(--moon, #efe9c9); box-shadow: 0 0 40px rgba(239, 233, 201, 0.5); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
aside .codebig { font-size: 64px; letter-spacing: 0.08em; }
