/* Live Quiz — one stylesheet for the builder (.builder), host screen (.host) and player app (.player). */
:root {
  --ink: #17173a;
  --ink-2: #4b4b6b;
  --ink-3: #8a8aa6;
  --paper: #f4f4fb;
  --white: #fff;
  --line: #e2e2ef;
  --brand: #5b3df5;
  --brand-2: #4126c9;
  --brand-soft: #ece8ff;
  --ok: #26890c;
  --bad: #e21b3c;
  --warn: #d89e00;
  --stage: #1b1650;
  --stage-2: #2a2178;
  --sun: #ffd60a;
  --red: #e21b3c; --blue: #1368ce; --yellow: #d89e00; --green: #26890c;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(20, 16, 80, .12);
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper); line-height: 1.35; }
body.host { background: radial-gradient(1200px 700px at 50% -10%, var(--stage-2), var(--stage) 70%); color: #fff; min-height: 100vh; overflow: hidden; }
body.player { background: var(--paper); min-height: 100dvh; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.15; font-weight: 900; }
p { margin: 0 0 .8em; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: .88rem; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.sr { position: absolute; left: -9999px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 12px; border: 2px solid transparent; background: var(--white); color: var(--ink); font-weight: 800; cursor: pointer; text-decoration: none; box-shadow: 0 2px 0 rgba(0,0,0,.08); transition: transform .06s, filter .15s; user-select: none; }
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); box-shadow: none; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn-lg { padding: 16px 28px; font-size: 1.2rem; border-radius: 16px; }
.btn-block { width: 100%; }
.host .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-weight: 800; font-size: .92rem; color: var(--ink-2); }
.field .help { font-size: .82rem; color: var(--ink-3); }
input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 11px 13px; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { min-height: 80px; resize: vertical; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.error { background: #ffe8ec; color: #8f1024; padding: 10px 12px; border-radius: 10px; font-weight: 700; }
.notice { background: var(--brand-soft); color: var(--brand-2); padding: 10px 12px; border-radius: 10px; font-weight: 700; }

/* ---------- cards / layout ---------- */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 20px; background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .logo { font-weight: 900; font-size: 1.15rem; color: var(--brand); letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.topbar .logo span { background: var(--brand); color: #fff; border-radius: 8px; padding: 2px 7px; }
.topbar .logo img { height: 40px; width: auto; }
.joinlogo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 10px; }
.joinlogo img { height: 64px; width: auto; }
.joinlogo h2 { margin: 0; font-size: 2rem; color: var(--brand); }
.lobbylogo { display: flex; align-items: center; gap: 12px; font-weight: 900; font-size: 1.4rem; }
.lobbylogo img { height: 56px; width: auto; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 16px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 800; box-shadow: var(--shadow); z-index: 50; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; }
.toast.bad { background: var(--bad); }
.modal-bg { position: fixed; inset: 0; background: rgba(20,16,60,.55); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal { background: #fff; border-radius: 18px; padding: 24px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(0,0,0,.12); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
.host .spinner { border-color: rgba(255,255,255,.2); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login ---------- */
.hero { text-align: center; max-width: 560px; margin: 4vh auto 18px; }
.hero img { width: 100%; max-width: 520px; border-radius: 20px; box-shadow: var(--shadow); }
.hero h1 { font-size: 2.4rem; color: var(--brand); margin: 14px 0 4px; }
.hero p { color: var(--ink-2); font-weight: 700; font-size: 1.05rem; }
.login { max-width: 400px; margin: 0 auto 6vh; }
.edhead { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

/* ---------- quiz list ---------- */
.quizgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.quizcard { display: flex; flex-direction: column; gap: 10px; min-height: 150px; }
.quizcard h3 { font-size: 1.15rem; margin: 0; }
.quizcard .types { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { display: inline-block; background: var(--brand-soft); color: var(--brand-2); border-radius: 999px; padding: 2px 10px; font-size: .78rem; font-weight: 800; }
.quizcard .actions { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.newcard { border: 2px dashed var(--line); background: transparent; box-shadow: none; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--brand); font-weight: 900; font-size: 1.1rem; }
.newcard:hover { background: var(--brand-soft); }

/* ---------- reports ---------- */
.rtable { width: 100%; border-collapse: collapse; font-size: .92rem; }
.rtable th, .rtable td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.rtable th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); background: var(--paper); position: sticky; top: 0; }
.answers-t td { min-width: 120px; }
.answers-t td:nth-child(2) { min-width: 240px; }
.ans-t { font-weight: 700; word-break: break-word; }
.ans-p { font-size: .78rem; font-weight: 800; opacity: .8; }
.r-ok { background: #eaf6e6; } .r-part { background: #fff6df; } .r-no { background: #ffe8ec; } .r-skip, .r-none { background: #f0f0f5; color: var(--ink-3); }
@media print { .topbar, .btn, .toast { display: none !important; } body { background: #fff; } .card { box-shadow: none; border: 1px solid #ccc; } }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 20px; align-items: start; }
.qlist { position: sticky; top: 74px; max-height: calc(100vh - 90px); overflow: auto; padding: 12px; }
.qtile { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 10px; border-radius: 12px; border: 2px solid transparent; cursor: pointer; margin-bottom: 6px; background: var(--paper); }
.qtile:hover { border-color: var(--line); }
.qtile.active { border-color: var(--brand); background: var(--brand-soft); }
.qtile .n { font-weight: 900; color: var(--ink-3); }
.qtile .t { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qtile .t small { display: block; color: var(--ink-3); font-weight: 800; font-size: .75rem; }
.qtile .warn { color: var(--bad); font-weight: 900; }
.qtile .mv { display: flex; flex-direction: column; gap: 2px; }
.qtile .mv button { border: 0; background: transparent; cursor: pointer; padding: 0 4px; line-height: 1; color: var(--ink-3); font-size: .8rem; }
.qtile .mv button:hover { color: var(--brand); }
.roundhead { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 6px 6px; border-top: 2px solid var(--line); margin-top: 4px; }
.roundhead:first-child { border-top: 0; margin-top: 0; }
.roundhead .rt { font-weight: 900; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roundhead .rt small { display: block; color: var(--brand); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.roundhead .ra { display: flex; gap: 2px; flex: none; }
.roundhead .ra button { border: 0; background: transparent; cursor: pointer; color: var(--ink-3); padding: 2px 5px; font-size: .85rem; }
.roundhead .ra button:hover { color: var(--brand); }
.roundhead .ra button:disabled { opacity: .3; cursor: default; }
.chk { font-weight: 900; font-size: .85rem; padding: 0 5px; border-radius: 6px; color: #fff; }
.chk.ok { background: var(--ok); }
.chk.doubt { background: var(--warn); }
.chk.wrong { background: var(--bad); }
.chk.stale { background: var(--ink-3); }
.checknote { border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: .92rem; border-left: 5px solid var(--ink-3); background: var(--paper); }
.checknote.ok { border-color: var(--ok); background: #eaf6e6; }
.checknote.doubt { border-color: var(--warn); background: #fff6df; }
.checknote.wrong { border-color: var(--bad); background: #ffe8ec; }
.timegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.timegrid label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; font-size: .9rem; }
.timegrid input { width: 84px; }
.typepicker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.typetile { border: 2px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; background: #fff; text-align: left; }
.typetile:hover { border-color: var(--brand); }
.typetile .ic { font-size: 1.5rem; }
.typetile b { display: block; }
.typetile small { color: var(--ink-3); font-size: .78rem; }
.opt { display: grid; grid-template-columns: 34px 1fr 40px; gap: 8px; align-items: center; margin-bottom: 8px; }
.opt .sw { width: 34px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 900; }
.opt input[type=radio] { width: 22px; height: 22px; accent-color: var(--ok); cursor: pointer; }
.list-item { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.list-item .n { font-weight: 900; color: var(--ink-3); text-align: center; }
.pair { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.pair .rt { display: flex; gap: 6px; align-items: center; }
.pair .thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.media-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.media-tabs button { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 800; cursor: pointer; }
.media-tabs button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-2); }
.preview { border-radius: 12px; overflow: hidden; background: #000; max-height: 320px; display: flex; justify-content: center; }
.preview img { max-height: 320px; object-fit: contain; }
.preview iframe { width: 100%; aspect-ratio: 16/9; border: 0; }
.pinpick { position: relative; display: inline-block; max-width: 100%; cursor: crosshair; user-select: none; }
.pinpick img { display: block; max-height: 460px; }
.pinpick .pin, .pinboard .pin { position: absolute; width: 22px; height: 22px; margin: -22px 0 0 -11px; pointer-events: none; }
.pinpick .ring { position: absolute; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.pinpick.area { cursor: crosshair; touch-action: none; }
.pinpick .rect, .pinboard .rect { position: absolute; border: 3px solid var(--ok); background: rgba(38,137,12,.22); pointer-events: none; box-shadow: 0 0 0 2px rgba(255,255,255,.8); }
.pinpick .tile { position: absolute; border: 2px dashed rgba(91,61,245,.55); cursor: pointer; }
.pinpick .tile:hover { background: rgba(91,61,245,.15); }
.smashline { font-size: 1.4rem; font-weight: 900; padding: 10px 14px; background: var(--brand-soft); border-radius: 12px; color: var(--brand-2); }
.smashline mark { background: #ffd54a; color: var(--ink); border-radius: 4px; padding: 0 2px; }
.host .smashline { background: rgba(255,255,255,.12); color: #fff; font-size: clamp(1.4rem, 3vw, 2.4rem); display: inline-block; }
.pinboard .pp.hit { background: var(--green); } .pinboard .pp.miss { background: var(--red); }
.ring.full { border: 2px solid var(--ok); background: rgba(38,137,12,.18); }
.ring.zero { border: 2px dashed var(--warn); }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--paper) 30%); padding: 14px 0 4px; display: flex; gap: 10px; justify-content: flex-end; }
.gen-progress { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--brand-soft); border-radius: 12px; color: var(--brand-2); font-weight: 800; }
@media (max-width: 860px) {
  .editor { grid-template-columns: 1fr; }
  .qlist { position: static; max-height: none; }
}

/* ---------- host stage ---------- */
.stage { display: flex; flex-direction: column; height: 100vh; padding: 18px 28px; gap: 12px; }
.stage-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-weight: 900; font-size: 1.15rem; }
.stage-top .pillbox { display: flex; gap: 10px; align-items: center; }
.hpill { background: rgba(255,255,255,.12); border-radius: 999px; padding: 6px 16px; }
.timer { width: 84px; height: 84px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 900; background: conic-gradient(var(--sun) var(--p, 100%), rgba(255,255,255,.15) 0); position: relative; }
.timer::after { content: attr(data-s); position: absolute; inset: 7px; border-radius: 50%; background: var(--stage); display: flex; align-items: center; justify-content: center; }
.timer.low { background: conic-gradient(var(--red) var(--p, 100%), rgba(255,255,255,.15) 0); }
.stage-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; }
.qtext { font-size: clamp(1.6rem, 3.6vw, 3rem); font-weight: 900; max-width: 1400px; text-wrap: balance; margin: 0; }
.qmedia { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; width: 100%; }
.qmedia img { max-height: 100%; max-width: 100%; object-fit: contain; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.qmedia iframe { height: 100%; aspect-ratio: 16/9; max-width: 100%; border: 0; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ans { display: flex; align-items: center; gap: 14px; padding: 18px 22px; border-radius: 14px; font-size: clamp(1.1rem, 2.2vw, 1.8rem); font-weight: 900; color: #fff; min-height: 84px; position: relative; overflow: hidden; }
.ans .shape { font-size: 1.4em; opacity: .95; width: 1.4em; text-align: center; }
.ans.dim { opacity: .3; }
.ans .bar { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,.22); width: 0; transition: width .6s ease; }
.ans .count { margin-left: auto; background: rgba(0,0,0,.25); border-radius: 999px; padding: 2px 14px; font-size: .8em; }
.ans .tick { margin-left: auto; font-size: 1.3em; }
.items { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.item { background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.2); border-radius: 14px; padding: 14px 22px; font-size: clamp(1.1rem, 2vw, 1.6rem); font-weight: 900; display: flex; align-items: center; gap: 12px; }
.item .k { background: #fff; color: var(--stage); border-radius: 8px; padding: 0 10px; }
.item img { width: 180px; height: 130px; object-fit: cover; border-radius: 10px; }
.item.ok { border-color: var(--green); background: rgba(38,137,12,.35); }
.stage-bottom { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.hostbar { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.stage .btn-primary { background: var(--sun); color: var(--stage); }
.stage .btn-primary:hover { filter: brightness(1.04); }

/* race bank (builder) */
.bankhead, .bankrow { display: grid; grid-template-columns: 26px 2fr 1fr 1fr 1fr 1fr 34px; gap: 6px; align-items: center; margin-bottom: 6px; }
.bankhead { font-size: .72rem; font-weight: 800; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.bankrow .n { font-weight: 900; color: var(--ink-3); text-align: center; font-size: .85rem; }
.bankrow input { padding: 8px 10px; font-size: .9rem; }
.bankrow input.right { border-color: #bfe3b4; background: #f2fbef; }
@media (max-width: 900px) { .bankhead { display: none; } .bankrow { grid-template-columns: 26px 1fr 1fr 34px; } }

/* race track (host) */
.track { width: 100%; max-width: 1500px; display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; min-height: 0; justify-content: center; }
.lane { position: relative; height: clamp(44px, 7vh, 64px); background: rgba(255,255,255,.08); border-radius: 999px; border: 2px solid rgba(255,255,255,.12); }
.lane::after { content: '🏁'; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 1.4em; opacity: .7; }
.lane .runner { position: absolute; top: 50%; transform: translate(-50%, -50%); left: 3%; display: flex; align-items: center; gap: 8px; transition: left .5s cubic-bezier(.2,.8,.2,1); white-space: nowrap; }
.lane .runner .em { font-size: clamp(1.6rem, 3.4vh, 2.4rem); line-height: 1; }
.lane .runner .nm { font-weight: 900; font-size: clamp(.85rem, 1.5vw, 1.15rem); background: rgba(0,0,0,.35); border-radius: 999px; padding: 2px 10px; }
.lane .runner .ct { font-weight: 800; opacity: .8; font-size: .8em; }
.lane.out { opacity: .45; } .lane.out .runner .em { filter: grayscale(1); }
.track.many { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.track.many .lane { height: clamp(34px, 4.6vh, 46px); }
.track.many .lane .runner .em { font-size: clamp(1.2rem, 2.6vh, 1.7rem); }
.track.many .lane .runner .nm { font-size: clamp(.75rem, 1.2vw, .95rem); padding: 1px 8px; }
.wboard.dense .wtile { font-size: clamp(.8rem, 1.3vw, 1.15rem); padding: 7px 11px; max-width: 16vw; }
.lane.won { border-color: #ffd54a; background: rgba(255,213,74,.18); }
.lane.won .runner .nm { background: #ffd54a; color: var(--stage); }

/* race (phone) */
.raceplace { text-align: center; font-weight: 900; font-size: 1.35rem; padding: 10px; border-radius: 14px; background: var(--brand-soft); color: var(--brand-2); }
.raceplace b { font-size: 1.6rem; }
.raceplace.first { background: #fff3c4; color: #7a4a00; }
.racepts { font-size: .9rem; font-weight: 800; opacity: .85; margin-top: 2px; }
.rprog { display: flex; justify-content: space-between; font-weight: 900; font-size: .95rem; color: var(--ink-2); }
.rprog b { color: var(--brand); }
.rflash { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 5rem; pointer-events: none; animation: rflash .5s ease forwards; z-index: 30; }
@keyframes rflash { 0% { opacity: 0; transform: scale(.6); } 30% { opacity: 1; transform: scale(1.1); } 100% { opacity: 0; transform: scale(1); } }
.emopick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.emopick button { font-size: 1.6rem; padding: 6px 0; border: 2px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.emopick button.on { border-color: var(--brand); background: var(--brand-soft); }

/* Wheel of Fortune board */
.wof { display: inline-flex; flex-direction: column; gap: 4px; padding: 10px; background: #0b3d1f; border: 4px solid #d4a017; border-radius: 10px; --wt: clamp(22px, 4.6vw, 62px); }
.wof-row { display: flex; gap: 4px; justify-content: center; }
.wt { width: var(--wt); height: calc(var(--wt) * 1.25); border-radius: 3px; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: calc(var(--wt) * .78); color: #111; font-family: 'Arial Black', 'Nunito', sans-serif; }
.wt.off { background: #1f7a3a; }
.wt.gap { background: #0b3d1f; }
.wt.on { background: #f5f5f0; box-shadow: inset 0 0 0 2px #ddd; }
.wt.lit { animation: flip .5s ease; }
@keyframes flip { 0% { transform: rotateY(90deg); background: #ffd54a; } 100% { transform: rotateY(0); } }
.wof-cat { display: inline-block; background: #d4a017; color: #111; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; padding: 6px 22px; border-radius: 0 0 10px 10px; font-size: clamp(.8rem, 1.6vw, 1.3rem); }
.player .wof { --wt: 5.6vw; padding: 6px; border-width: 3px; }
.player .wof-row { gap: 2px; } .player .wof { gap: 2px; }

/* rounds planner (builder) */
.rplan { display: flex; flex-direction: column; gap: 14px; }
.rcard { border: 2px solid var(--line); border-radius: 14px; padding: 16px; background: #fff; }
.rcard .rhead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.rcard .rhead .badge { background: var(--brand); color: #fff; border-radius: 999px; padding: 3px 12px; font-weight: 900; font-size: .85rem; }
.rcard .types { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.mixgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 14px; }
.mixgrid label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; font-size: .88rem; }
.mixgrid input { width: 64px; padding: 6px 8px; }
.rcard .types label { font-size: .88rem; }

/* highbrow lowbrow / rhyme time */
.hlgrid { display: grid; grid-template-columns: 1fr; gap: 16px; width: 100%; max-width: 1400px; }
.hlgrid.both { grid-template-columns: 1fr 1fr; }
.hlcard { border-radius: 18px; padding: 22px 26px; background: rgba(255,255,255,.1); border: 3px solid rgba(255,255,255,.25); text-align: left; }
.hlcard.high { border-color: #8fb3ff; } .hlcard.low { border-color: #ffd54a; }
.hlcard.soon { opacity: .55; border-style: dashed; }
.hltag { font-weight: 900; font-size: clamp(.85rem, 1.5vw, 1.1rem); opacity: .85; margin-bottom: 8px; letter-spacing: .03em; text-transform: uppercase; }
.hltext { font-size: clamp(1.2rem, 2.6vw, 2.1rem); font-weight: 900; text-wrap: balance; }
@media (max-width: 900px) { .hlgrid.both { grid-template-columns: 1fr; } }

/* wipeout board */
.wboard { position: relative; width: 100%; height: 100%; min-height: 0; }
.wtile { position: absolute; transform: translate(-50%, -50%) rotate(var(--r, 0deg)); background: rgba(255,255,255,.14); border: 2px solid rgba(255,255,255,.35); border-radius: 12px; padding: 10px 16px; font-weight: 900; font-size: clamp(.95rem, 1.7vw, 1.5rem); white-space: nowrap; transition: opacity .5s, transform .5s; max-width: 22vw; overflow: hidden; text-overflow: ellipsis; }
.wtile.gone { opacity: .12; transform: translate(-50%, -50%) rotate(var(--r, 0deg)) scale(.85); text-decoration: line-through; }
.wtile.right { border-color: var(--green); background: rgba(38,137,12,.45); }
.wtile.wrong { border-color: var(--red); background: rgba(226,27,60,.55); }
.wtile.boom { animation: boom .6s ease; background: var(--red); border-color: #fff; opacity: 1; }
@keyframes boom { 0% { transform: translate(-50%, -50%) scale(1); } 40% { transform: translate(-50%, -50%) scale(1.5); } 100% { transform: translate(-50%, -50%) scale(1.15); } }
.turnbar { display: flex; align-items: center; justify-content: center; gap: 16px; font-size: clamp(1.2rem, 2.4vw, 2rem); font-weight: 900; }
.turnbar .who { background: var(--sun); color: var(--stage); border-radius: 999px; padding: 6px 22px; }
.turnbar .last { font-size: .75em; opacity: .85; }
.turnbar .last.ok { color: #b8ffb0; } .turnbar .last.no { color: #ffb3c0; }
.cats { display: grid; grid-auto-flow: column; gap: 14px; width: 100%; max-width: 1500px; }
.cat { background: rgba(255,255,255,.1); border-radius: 14px; padding: 12px; min-height: 100px; }
.cat h3 { font-size: clamp(1rem, 1.8vw, 1.5rem); text-align: center; margin-bottom: 8px; border-bottom: 2px solid rgba(255,255,255,.25); padding-bottom: 6px; }
.cat .item { display: block; text-align: center; margin: 6px 0; padding: 8px 12px; font-size: clamp(.9rem, 1.5vw, 1.25rem); }

/* player: sort + wipeout */
.sitem { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.sitem .txt { font-weight: 900; margin-bottom: 8px; }
.sitem .seg { display: flex; gap: 6px; flex-wrap: wrap; }
.sitem .seg button { flex: 1 1 auto; border: 2px solid var(--line); background: var(--paper); border-radius: 999px; padding: 8px 10px; font-weight: 800; font-size: .85rem; cursor: pointer; }
.sitem .seg button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.wgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wgrid button { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 8px; font-weight: 900; font-size: .95rem; cursor: pointer; min-height: 52px; word-break: break-word; }
.wgrid button:disabled { cursor: default; }
.wgrid.wait button:not(.gone) { background: #fff; color: var(--ink); border-color: #e6d3b0; }
.wgrid button.gone { opacity: .18; text-decoration: line-through; }
.wgrid.mine button:not(.gone):not(:disabled) { border-color: var(--ok); box-shadow: 0 3px 0 rgba(0,0,0,.12); background: #fff; }
.turnnote { text-align: center; font-weight: 900; padding: 10px; border-radius: 12px; background: rgba(255,255,255,.7); color: var(--ink-2); }
.turnnote.mine { background: var(--ok); color: #fff; font-size: 1.15rem; }
.turncount { text-align: center; font-weight: 900; font-size: 1.1rem; color: #7a4a00; margin-top: 6px; }
.turncount .big { font-size: 2rem; vertical-align: middle; }
.app.turn-mine { background: #dff7d8; }
.app.turn-wait { background: #ffe6c2; }
body.player:has(.app.turn-mine) { background: #dff7d8; }
body.player:has(.app.turn-wait) { background: #ffe6c2; }
.result.neg { background: #7a0f24; }

/* lobby */
.lobby { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: center; width: 100%; max-width: 1300px; flex: 1 1 auto; min-height: 0; }
.lobby .qr { background: #fff; border-radius: 20px; padding: 18px; display: inline-block; }
.lobby .qr canvas, .lobby .qr img { display: block; width: min(38vh, 380px); height: min(38vh, 380px); }
.code { font-size: clamp(3rem, 7vw, 6rem); letter-spacing: .12em; font-weight: 900; line-height: 1; margin: 6px 0; color: var(--sun); }
.joinurl { font-size: clamp(1rem, 1.8vw, 1.5rem); font-weight: 800; opacity: .85; word-break: break-all; }
.players { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-height: 40vh; overflow: auto; }
.pill { background: rgba(255,255,255,.15); border-radius: 999px; padding: 8px 18px; font-weight: 900; font-size: 1.2rem; animation: pop .25s ease; }
.autobar { width: 200px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; }
.autobar i { display: block; height: 100%; background: var(--sun); transform-origin: left; animation: autoshrink linear forwards; }
@keyframes autoshrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.btn-ghost.on { background: rgba(255,214,10,.22); border-color: var(--sun); color: var(--sun); }
.ctrlbtn { margin-top: 14px; max-width: 420px; }
.appqr { display: inline-flex; align-items: center; gap: 16px; margin-top: 22px; padding: 12px 18px 12px 12px; border-radius: 18px; background: rgba(255,255,255,.1); text-align: left; }
.appqr .qr { padding: 8px; border-radius: 12px; }
.appqr .qr canvas, .appqr .qr img { width: min(14vh, 120px); height: min(14vh, 120px); }
.appqr-text { font-size: clamp(.85rem, 1.3vw, 1.05rem); font-weight: 700; opacity: .9; line-height: 1.35; max-width: 260px; }
.appqr-text b { display: block; font-size: 1.1em; font-weight: 900; margin-bottom: 2px; }
.appqr-text span { display: block; margin-top: 4px; color: var(--sun); font-weight: 900; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@media (max-width: 900px) { .lobby { grid-template-columns: 1fr; } }

/* countdown / interstitial */
.big { font-size: clamp(2.5rem, 8vw, 6rem); font-weight: 900; line-height: 1.1; }
.huge { font-size: clamp(5rem, 18vw, 14rem); font-weight: 900; line-height: 1; }

/* scoreboard */
.board { width: min(900px, 100%); display: flex; flex-direction: column; gap: 10px; }
.brow { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 14px; background: rgba(255,255,255,.1); border-radius: 14px; padding: 12px 18px; font-size: clamp(1.1rem, 2vw, 1.6rem); font-weight: 900; position: relative; overflow: hidden; }
.brow .fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,.14); width: 0; transition: width .9s ease; }
.brow > * { position: relative; }
.brow .rank { text-align: center; font-size: 1.1em; }
.brow .delta { font-size: .7em; opacity: .8; margin-left: 10px; color: #b8ffb0; }
.brow.me { outline: 3px solid #fff; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 18px; height: 45vh; width: 100%; max-width: 900px; }
.pod { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 10px; }
.pod .name { font-size: clamp(1.2rem, 2.5vw, 2rem); font-weight: 900; text-align: center; }
.pod .score { opacity: .85; font-weight: 800; }
.pod .block { width: 100%; border-radius: 14px 14px 0 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 12px; font-size: 2.6rem; font-weight: 900; color: var(--stage); animation: rise 1s ease both; }
@keyframes rise { from { height: 0 !important; opacity: 0; } }
.pod.p1 .block { background: #ffd54a; height: 100%; }
.pod.p2 .block { background: #d9dbe6; height: 70%; }
.pod.p3 .block { background: #e0a06a; height: 48%; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -10px; width: 10px; height: 16px; opacity: .9; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

/* reveal extras */
.textlist { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 1200px; }
.tl { border-radius: 12px; padding: 8px 14px; font-weight: 800; background: rgba(255,255,255,.12); font-size: 1.1rem; }
.tl.ok { background: rgba(38,137,12,.45); }
.tl.no { background: rgba(226,27,60,.4); }
.pinboard { position: relative; display: inline-block; max-height: 100%; }
.pinboard img { display: block; max-height: 62vh; max-width: 100%; }
.pinboard .pp { position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 900; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.pinboard .pp.best { background: var(--green); }
.pinboard .target { position: absolute; width: 34px; height: 34px; margin: -34px 0 0 -17px; }
.badge-closest { background: #ffd54a; color: var(--stage); border-radius: 999px; padding: 4px 14px; font-weight: 900; }

/* ---------- player app ---------- */
.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding: calc(14px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); gap: 12px; }
.app-top { display: flex; align-items: center; justify-content: space-between; font-weight: 900; color: var(--ink-2); }
.app-top .score { background: var(--brand); color: #fff; border-radius: 999px; padding: 4px 12px; }
.ptimer { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.ptimer i { display: block; height: 100%; background: var(--brand); width: 100%; transition: width .25s linear; }
.ptimer.low i { background: var(--bad); }
.pq { font-weight: 900; font-size: 1.15rem; text-align: center; padding: 0 4px; text-wrap: balance; }
.pmedia img { width: 100%; max-height: 32vh; object-fit: contain; border-radius: 12px; background: #000; }
.ans-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: 1 1 auto; align-content: stretch; }
.abtn { border: 0; border-radius: 16px; color: #fff; font-weight: 900; font-size: 1.05rem; padding: 14px 12px; min-height: 108px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; cursor: pointer; text-align: center; box-shadow: 0 4px 0 rgba(0,0,0,.18); transition: transform .06s; word-break: break-word; }
.abtn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.abtn .shape { font-size: 1.8rem; }
.abtn:disabled { opacity: .5; }
.state { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 20px 10px; }
.state .em { font-size: 3.5rem; }
.state h2 { font-size: 1.6rem; }
.result { border-radius: 20px; padding: 24px 18px; color: #fff; text-align: center; flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.result.ok { background: var(--ok); }
.result.no { background: var(--bad); }
.result.part { background: var(--warn); }
.result .pts { font-size: 3rem; font-weight: 900; }
.result .rk { font-weight: 800; opacity: .95; }
.olist { display: flex; flex-direction: column; gap: 8px; }
.oitem { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; font-weight: 800; }
.oitem .n { text-align: center; color: var(--ink-3); font-weight: 900; }
.oitem .mv { display: flex; gap: 4px; }
.oitem .mv button { width: 38px; height: 38px; border-radius: 10px; border: 2px solid var(--line); background: var(--paper); font-weight: 900; cursor: pointer; }
.oitem.dragging { opacity: .5; }
.mleft { display: flex; flex-direction: column; gap: 8px; }
.mrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: stretch; }
.mword { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 10px; font-weight: 900; display: flex; align-items: center; cursor: pointer; min-height: 56px; }
.mword.sel { border-color: var(--brand); background: var(--brand-soft); }
.mslot { border: 2px dashed var(--line); border-radius: 12px; min-height: 56px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--ink-3); cursor: pointer; overflow: hidden; }
.mslot.filled { border-style: solid; border-color: var(--brand); color: var(--ink); background: #fff; }
.mslot img { width: 100%; height: 80px; object-fit: cover; }
.mchoices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.mc { background: #fff; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; font-weight: 800; text-align: center; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.mc img { width: 100%; height: 90px; object-fit: cover; }
.mc .cap { padding: 6px; }
.mc.used { opacity: .35; pointer-events: none; }
.mc.sel { border-color: var(--brand); background: var(--brand-soft); }
.pinboard.tap { cursor: crosshair; touch-action: manipulation; width: 100%; }
.pinboard.tap img { width: 100%; max-height: 55vh; object-fit: contain; background: #000; border-radius: 12px; }
.joinbox { max-width: 420px; margin: 8vh auto 0; width: 100%; }
.scan { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.scan video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan .scan-frame { position: relative; width: min(70vw, 300px); aspect-ratio: 1; border: 4px solid #fff; border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.scan .scan-hint { position: relative; color: #fff; font-weight: 800; text-align: center; padding: 0 20px; text-shadow: 0 1px 4px #000; }
.scan .btn { position: relative; }
.joinbox .codein { text-transform: uppercase; letter-spacing: .2em; font-size: 1.5rem; text-align: center; font-weight: 900; }
.player .brow { background: #fff; color: var(--ink); box-shadow: var(--shadow); font-size: 1rem; }
.player .brow .fill { background: var(--brand-soft); }

/* ---------------------------------------------------------------- TV (Fire TV app, D-pad) */
body.tv :focus { outline: none; }
body.tv .btn:focus, body.tv button:focus, body.tv a:focus, body.tv input:focus, body.tv select:focus, body.tv textarea:focus, body.tv [tabindex]:focus {
  outline: 5px solid var(--sun); outline-offset: 4px; box-shadow: 0 0 0 10px rgba(255,214,10,.22); position: relative; z-index: 2; }
body.tv .btn:focus { transform: scale(1.04); }
body.tv button, body.tv a, body.tv input, body.tv select, body.tv textarea, body.tv [tabindex] { scroll-margin: 90px 0; }
.tvrow .row { flex-wrap: nowrap; }
body.tvpage { overflow-y: auto; height: auto; min-height: 100vh; padding-bottom: 70px; }
.tvwrap { max-width: 1400px; margin: 0 auto; padding: 36px 56px; color: #fff; font-size: 1.15rem; }
.tvhead { display: flex; align-items: center; gap: 18px; margin-bottom: 26px; }
.tvhead h1 { text-wrap: balance; }
.tvfoot { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 56px; background: rgba(0,0,0,.4); color: #fff; font-weight: 800; opacity: .85; font-size: 1rem; }
.tvtiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.tvtiles-4 { grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tvtile { background: rgba(255,255,255,.1); color: #fff; border: 0; border-radius: 22px; padding: 30px 20px; font: inherit; font-weight: 900; font-size: 1.5rem; cursor: pointer; text-align: center; }
.tvtile.sm { padding: 20px 14px; font-size: 1.2rem; }
.tvtile .em { display: block; font-size: 3rem; margin-bottom: 8px; }
.tvtile.sel { background: var(--sun); color: var(--ink); }
.tvrow { display: flex; align-items: center; gap: 16px; width: 100%; background: rgba(255,255,255,.08); color: #fff; border: 0; border-radius: 16px; padding: 16px 22px; margin-bottom: 10px; font: inherit; font-weight: 800; font-size: 1.2rem; text-align: left; cursor: pointer; }
.tvround { background: rgba(255,255,255,.06); border-radius: 20px; padding: 18px 22px; margin-bottom: 16px; }
.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper .btn { min-width: 54px; font-size: 1.3rem; padding: 8px 14px; }
.stepper b { min-width: 44px; text-align: center; font-size: 1.5rem; }
.seg .btn.sel, body.tv .btn.sel { background: var(--sun); color: var(--ink); border-color: var(--sun); }
.typegrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.typegrid .trow { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: rgba(255,255,255,.08); border-radius: 14px; padding: 8px 8px 8px 16px; font-weight: 800; }
body.tvpage input, body.tvpage textarea, body.tvpage select { background: rgba(255,255,255,.12); color: #fff; border: 2px solid rgba(255,255,255,.25); border-radius: 12px; padding: 12px 14px; font: inherit; font-weight: 800; }
body.tvpage input::placeholder, body.tvpage textarea::placeholder { color: rgba(255,255,255,.5); }
body.tvpage select option { color: var(--ink); }
body.tvpage .btn { color: #fff; border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.1); }
body.tvpage .btn-primary { background: var(--sun); color: var(--ink); border-color: var(--sun); }
body.tvpage .btn-ghost { background: transparent; }
body.tvpage .muted { color: rgba(255,255,255,.7); }
body.tvpage .error { background: rgba(226,27,60,.25); color: #fff; }
@media (max-width: 900px) { .tvtiles, .tvtiles-4, .typegrid { grid-template-columns: repeat(2, 1fr); } .tvwrap, .tvfoot { padding-left: 20px; padding-right: 20px; } }

/* small TV viewports (a 1080p Fire TV renders at 960x540 CSS px) */
.hostbar .btn { white-space: nowrap; }
body.tv [data-act="auto"] { display: none; }
@media (max-height: 620px) { .appqr { display: none; } .lobby .qr canvas, .lobby .qr img { width: min(46vh, 380px); height: min(46vh, 380px); } .lobby { gap: 16px; } }
