/* Quizoke – quiz + karaoke night */
:root {
  --bg: #120f1f;
  --bg2: #1b1730;
  --card: #221d3a;
  --line: #3a3360;
  --text: #f3f0ff;
  --muted: #a39dc2;
  --accent: #ff4fa3;
  --accent2: #ffc94d;
  --good: #2ed47a;
  --bad: #ff5b5b;
  --A: #e5484d; --B: #3e7bfa; --C: #f5a524; --D: #2fb36d;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at 20% -10%, #2c2257, var(--bg) 60%) fixed; color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent2); }
h1, h2, h3 { margin: .2em 0 .5em; line-height: 1.2; }
.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.big { font-size: 1.4rem; font-weight: 700; }
.center { text-align: center; }
.right { text-align: right; }
.inline { display: inline; }
[hidden] { display: none !important; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 20px; background: rgba(0,0,0,.25); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none; letter-spacing: .02em; }
.topbar nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.topbar nav a { color: var(--text); text-decoration: none; opacity: .85; }
.topbar nav a:hover { opacity: 1; color: var(--accent2); }
.who { background: var(--card); padding: 4px 10px; border-radius: 99px; font-size: .85rem; }
.foot { text-align: center; padding: 16px; color: var(--muted); font-size: .8rem; }

/* cards, layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.narrow { max-width: 420px; margin: 40px auto; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row.between { justify-content: space-between; align-items: center; }
.row > label { flex: 1; min-width: 160px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
details > summary { cursor: pointer; }
details[open] > summary { margin-bottom: 12px; }

/* forms */
label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn { font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); cursor: pointer; text-decoration: none; font-weight: 600; }
.btn:hover { border-color: var(--accent2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: .82rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
button.link:hover { color: var(--text); }
.danger-text { color: var(--bad) !important; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* flash */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; background: var(--card); border-left: 4px solid var(--accent2); }
.flash.error { border-color: var(--bad); }
.flash.success { border-color: var(--good); }

/* badges */
.badge { display: inline-block; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; padding: 3px 8px; border-radius: 99px; background: var(--bg2); color: var(--muted); }
.badge.live, .badge.singing { background: var(--accent); color: #fff; animation: glow 1.6s infinite; }
.badge.open, .badge.queued { background: #3e7bfa33; color: #8fb2ff; }
.badge.ended, .badge.done { background: #2ed47a22; color: var(--good); }
.badge.skipped { background: #ff5b5b22; color: var(--bad); }
@keyframes glow { 50% { box-shadow: 0 0 12px var(--accent); } }

/* tables */
.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }
.table tr.me td { background: #ff4fa322; }
.table tr.dim td { opacity: .5; }
.board-table .rank { font-size: 1.3rem; width: 50px; }
.board-table .pts { font-weight: 800; color: var(--accent2); font-size: 1.15rem; }

/* question editor */
.opts-edit { display: grid; gap: 8px; }
.opt-edit { flex-direction: row; align-items: center; gap: 10px; }
.opt-edit input[name^="option_"] { flex: 1; }
.opt-edit input[type=radio] { width: 20px; height: 20px; accent-color: var(--good); }
.qlist { list-style: none; padding: 0; }
.optlist { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.optlist li.right { color: var(--good); font-weight: 700; }

/* live stage */
.stage-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.stage-title { font-size: 1.3rem; }
.scorechip { background: var(--accent2); color: #2a1d00; font-weight: 800; padding: 8px 14px; border-radius: 99px; white-space: nowrap; }
.qtext { font-size: clamp(1.3rem, 3.5vw, 2.2rem); margin: 18px 0 6px; }
.timer { position: relative; height: 34px; background: var(--bg2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.timer-bar { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: background .3s; }
.timer-bar.low { background: var(--bad); }
.timer span { position: relative; display: block; text-align: center; font-weight: 800; line-height: 32px; font-size: 1.1rem; text-shadow: 0 1px 3px #0008; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
@media (max-width: 560px) { .options { grid-template-columns: 1fr; } }
.opt { position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; text-align: left; font: inherit; font-size: 1.1rem; color: #fff; border: 3px solid transparent; border-radius: var(--radius); padding: 18px; min-height: 76px; cursor: pointer; transition: transform .1s, opacity .2s; }
.opt b { background: #0003; border-radius: 8px; padding: 4px 10px; }
.opt span { position: relative; z-index: 1; flex: 1; }
.opt-A { background: var(--A); } .opt-B { background: var(--B); } .opt-C { background: var(--C); } .opt-D { background: var(--D); }
button.opt:not(:disabled):hover { transform: translateY(-2px); }
.opt:disabled { cursor: default; opacity: .55; }
.opt.picked { opacity: 1; border-color: #fff; box-shadow: 0 0 0 3px #fff4; }
.opt.right { opacity: 1; border-color: var(--good); box-shadow: 0 0 18px var(--good); }
.opt.wrong { opacity: 1; border-color: #fff; filter: grayscale(.6); }
.opt.dim { opacity: .35; }
.host-opts .opt i { position: absolute; inset: auto auto 0 0; height: 6px; background: #fff9; }
.host-opts .opt em { font-style: normal; font-weight: 800; font-size: 1.4rem; z-index: 1; }

.typed { display: flex; gap: 10px; margin-top: 18px; }
.typed input { flex: 1; font-size: 1.2rem; padding: 16px; }

.feedback { margin-top: 18px; padding: 16px; border-radius: var(--radius); font-size: 1.2rem; font-weight: 700; text-align: center; animation: pop .25s ease-out; }
.feedback.waiting { background: var(--bg2); color: var(--muted); animation: none; }
.feedback.good { background: #2ed47a26; color: var(--good); border: 2px solid var(--good); }
.feedback.bad { background: #ff5b5b22; color: #ffb3b3; border: 2px solid var(--bad); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.pulse { font-size: 3rem; animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }

/* mini boards */
.board { list-style: none; padding: 0; margin: 0; }
.board li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.board li.me { background: #ff4fa322; border-radius: 8px; }
.board .rank { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--bg2); font-weight: 800; font-size: .85rem; }
.board li:nth-child(1) .rank { background: var(--accent2); color: #2a1d00; }
.board .name { flex: 1; }
.board .pts { font-weight: 800; color: var(--accent2); }

/* host */
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.controls .auto { flex-direction: row; align-items: center; }
.host-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 860px) { .host-grid { grid-template-columns: 1fr; } }
body.host .qtext { font-size: clamp(1.6rem, 3.5vw, 2.6rem); }

/* tv leaderboard */
body.tv .topbar, body.tv .foot, body.tv form { display: none; }
body.tv .wrap { max-width: 1400px; }
body.tv h1 { font-size: 2.6rem; text-align: center; width: 100%; }
body.tv .table td { font-size: 1.5rem; padding: 16px; }

/* karaoke */
.song-row { display: grid; grid-template-columns: 1.3fr 1fr; gap: 8px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.song-row input { width: 100%; min-width: 0; }
.song-row input[name="video_url[]"] { grid-column: 1 / -1; }
.queue { padding: 0; list-style: none; counter-reset: q; }
.queue li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); counter-increment: q; }
.queue li::before { content: counter(q); width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--bg2); font-size: .8rem; font-weight: 700; }
.queue li > div:first-child { flex: 1; }
.queue li.me { background: #ff4fa318; border-radius: 8px; }
.queue li.muted::before { display: none; }
.now { background: linear-gradient(135deg, #ff4fa333, #ffc94d22); border-radius: 12px; padding: 16px; margin-bottom: 14px; display: grid; gap: 8px; }
