/* Værtsskærmen (tv). Alt skalerer med skærmen: 1rem = 16px ved 1280×720 og 24px ved 1920×1080. */
html { font-size: clamp(10px, min(1.25vw, 2.2222vh), 44px); }
body { overflow: hidden; }

/* ---------- startside ---------- */
#home { height: 100vh; overflow: auto; padding: 3.5rem max(2rem, calc(50vw - 30rem)); }
.home-head { display: flex; justify-content: space-between; align-items: flex-start; }
.home-right { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.logo { font-size: 5.6rem; font-weight: 900; line-height: .92; letter-spacing: -.02em; color: var(--text); text-shadow: .28rem .28rem 0 var(--pink); }
.home-lead { font-size: 1.35rem; color: var(--muted); margin: 2.2rem 0 1rem; }
.pick-note { background: var(--panel); border: .12rem solid var(--ice); border-radius: var(--r); padding: .9rem 1.2rem; margin: 2rem 0 0; font-weight: 600; }
.quiz-list { display: grid; gap: .7rem; }
.quiz-group { font: 700 1.05rem var(--body); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 1.1rem 0 0; }
.quiz-group:first-child { margin-top: 0; }
.quiz-none { margin: 0; color: var(--muted); font-size: 1.05rem; }
.quiz-item { display: flex; align-items: center; gap: .8rem; background: var(--panel); border: .12rem solid var(--line); border-radius: var(--r); padding-right: 1.1rem; }
.quiz-item:hover { border-color: var(--pink); }
.quiz-item.is-broken:hover { border-color: var(--line); }
.qi-main { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1rem; text-align: left; cursor: pointer;
  font: inherit; color: var(--text); background: none; border: 0; padding: 1.1rem .3rem 1.1rem 1.4rem; }
.qi-main:disabled { cursor: not-allowed; opacity: .75; }
.qi-main strong { font: 700 1.5rem var(--display); display: block; }
.qi-main span { color: var(--muted); }
.qi-main .broken { color: var(--bad); font-weight: 600; }
.qi-main .go { font: 700 1rem var(--body); color: #2a0619; background: var(--pink); border-radius: 999px; padding: .6em 1.2em; }
.qi-main:disabled .go { display: none; }
.qi-import { flex: none; }
.qi-done { flex: none; color: var(--ok); font-weight: 700; font-size: .9rem; }
/* søg og filtre */
.quiz-tools { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 0 0 .6rem; }
.qt-search { flex: 1 1 11rem; width: auto; font-size: 1.05rem; }
.qt-seg { display: inline-flex; border: .12rem solid var(--line); border-radius: 999px; overflow: hidden; }
.qt-seg button { font: 600 .95rem var(--body); color: var(--muted); background: none; border: 0; padding: .65em 1.1em; cursor: pointer; }
.qt-seg button[aria-pressed=true] { background: var(--text); color: var(--bg); }
.quiz-tools select { padding: .65em .8em; }
.qt-count { margin: 0 0 .5rem; color: var(--muted); min-height: 1.4em; }
.qt-reset { background: none; border: 0; padding: 0; color: var(--ice); font: 600 1rem var(--body); cursor: pointer; text-decoration: underline; }
.home-links { display: flex; gap: .8rem; margin-top: 2rem; flex-wrap: wrap; }

/* ---------- spil-layout ---------- */
#game { height: 100vh; display: grid; grid-template-rows: 3.4rem minmax(0, 1fr); }
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1.5rem; padding: 0 10.5rem 0 1.6rem; border-bottom: .1rem solid var(--line); background: rgba(12,7,22,.45); }
.tb-title { font: 700 1.1rem var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-meta { font-weight: 700; font-size: 1.1rem; color: var(--ice); white-space: nowrap; }
.tb-right { display: flex; justify-content: flex-end; align-items: center; gap: 1.1rem; white-space: nowrap; }
.tb-style { color: var(--muted); font-size: .85rem; }
.tb-style select { padding: .3em .6em; font-size: .85rem; }
.tb-code { font: 800 1.3rem var(--display); letter-spacing: .14em; }
.tb-ctrl { font-weight: 700; color: var(--ice); font-size: .9rem; }
.close-quiz {
  position: fixed; top: .6rem; right: 1.2rem; z-index: 100; /* skal kunne klikkes også over svar-overlayet */
  font: 700 .9rem var(--body); color: var(--text); background: var(--panel); border: .12rem solid var(--line); border-radius: 999px; padding: .55em 1.1em; cursor: pointer;
}
.close-quiz.armed { background: var(--bad); border-color: var(--bad); color: #36060c; }
.offline-note { position: fixed; left: 1.2rem; bottom: 1rem; z-index: 120; background: var(--bad); color: #36060c; font-weight: 700; padding: .5em 1em; border-radius: 999px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; min-height: 0; }
body[data-view=lobby] .layout, body[data-view=final] .layout, body[data-view=recap] .layout { grid-template-columns: minmax(0, 1fr); }
body[data-view=lobby] .sidebar, body[data-view=final] .sidebar, body[data-view=recap] .sidebar { display: none; }
main { min-height: 0; min-width: 0; padding: 1.5rem 2rem; }
.view { display: none; height: 100%; min-height: 0; }
body[data-view=lobby] #vLobby { display: grid; }
body[data-view=category] #vCategory { display: flex; }
body[data-view=question] #vQuestion { display: grid; }
body[data-view=final] #vFinal { display: flex; }
body[data-view=recap] #vRecap { display: grid; }
body.has-ctrl .host-only { display: none !important; }

.sidebar { border-left: .1rem solid var(--line); padding: 1.2rem 1rem; display: flex; flex-direction: column; gap: .8rem; min-height: 0; background: rgba(12,7,22,.3); }
.sidebar h2 { font-size: 1rem; color: var(--muted); }
.sb-wrap { overflow-y: auto; min-height: 0; flex: 1; }

/* ---------- lobby ---------- */
#vLobby { grid-template-columns: 1.25fr 1fr; gap: 3rem; align-items: start; }
.lobby-how { font-size: 1.5rem; color: var(--muted); margin: .5rem 0 0; }
.lobby-url { font: 700 2.3rem var(--display); margin: .3rem 0 1.2rem; color: var(--ice); word-break: break-all; }
.lobby-codeqr { display: flex; align-items: center; gap: 2.5rem; }
.lobby-code { font: 900 9.5rem/1 var(--display); letter-spacing: .06em; text-shadow: .4rem .4rem 0 var(--pink); }
.qr { width: 12rem; height: 12rem; background: #fff; border-radius: 1rem; padding: .5rem; flex: none; }
.lobby-actions { display: flex; flex-wrap: wrap; gap: .9rem; align-items: center; margin-top: 2rem; }
.btn-big { font-size: 1.4rem; }
.ctrl-panel { display: flex; gap: 1.5rem; align-items: center; margin-top: 1.2rem; background: var(--panel); border: .12rem solid var(--line); border-radius: var(--r); padding: 1rem 1.3rem; }
.ctrl-panel .qr { width: 8.5rem; height: 8.5rem; }
.ctrl-panel p { margin: 0 0 .4rem; }
.ctrl-pin { font: 700 1.3rem var(--display); }
.ctrl-pin strong { font-size: 2.2rem; letter-spacing: .14em; color: var(--ice); margin-left: .4em; }
.ctrl-warn { color: var(--muted); font-size: .9rem; }
.lobby-players { background: rgba(12,7,22,.35); border-radius: 1.4rem; padding: 1.5rem; max-height: 100%; overflow-y: auto; }
.lobby-players h2 { font-size: 1.4rem; margin-bottom: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: .6rem; }
.chip { display: inline-flex; align-items: center; gap: .5rem; background: var(--panel); border: .14rem solid var(--tc, var(--line)); border-radius: 999px; padding: .45rem .5rem .45rem 1rem; font-weight: 700; font-size: 1.2rem; animation: pop .3s ease-out; }
.chip small { color: var(--muted); font-weight: 500; font-size: .75em; }
.chip.is-offline { opacity: .45; }
.chip button { width: 1.7rem; height: 1.7rem; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); color: var(--text); cursor: pointer; font-size: 1rem; line-height: 1; }
.chip button:hover { background: var(--bad); color: #36060c; }
body.has-ctrl .chip { padding-right: 1rem; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

/* ---------- kategori ---------- */
#vCategory { flex-direction: column; align-items: center; justify-content: center; gap: 1.6rem; text-align: center; }
.round-banner { font: 800 2.4rem var(--display); padding: .5em 1em; border-radius: 1rem; background: var(--pink); color: #2a0619; animation: banner .6s cubic-bezier(.2,1.4,.4,1); }
@keyframes banner { from { transform: scale(.5) rotate(-4deg); opacity: 0; } }
.cat-title { font-size: 1.5rem; color: var(--muted); font-family: var(--body); }
.cat-options { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 20rem); gap: 1.3rem; }
.cat-card { font: inherit; color: var(--text); background: var(--panel); border: .16rem solid var(--line); border-radius: 1.5rem; padding: 2rem 1.3rem 1.5rem; cursor: pointer; display: grid; gap: .9rem; justify-items: center; min-height: 13rem; align-content: center; }
.cat-card:hover { border-color: var(--pink); transform: translateY(-.25rem); }
body.has-ctrl .cat-card { pointer-events: none; }
.cat-card kbd { font: 800 1.1rem var(--display); background: var(--text); color: var(--bg); border-radius: .5rem; width: 2.2rem; height: 2.2rem; display: grid; place-items: center; }
.cat-card strong { font: 700 1.8rem/1.15 var(--display); overflow-wrap: anywhere; }
.cat-card span { color: var(--muted); font-size: 1.05rem; }
.cat-all { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; max-width: 56rem; }
.cat-all span { font-size: .9rem; color: var(--muted); border: .1rem solid var(--line); border-radius: 999px; padding: .25em .8em; }
.cat-all span.empty { opacity: .4; text-decoration: line-through; }

/* ---------- spørgsmål ---------- */
#vQuestion { grid-template-columns: auto minmax(0, 1fr); gap: 2.2rem; }
/* Uret fylder hele højden og har samme størrelse med og uden medie – mediet ligger i kolonnen ved siden af. */
.clock-col { display: grid; grid-template-columns: 8.5rem 6.5rem; gap: .8rem; height: 100%; min-height: 0; }
.clock-box { min-height: 0; height: 100%; }
.scale { display: grid; grid-template-columns: 1rem 1fr; gap: .5rem; min-height: 0; }
.scale-track { grid-row: 1 / span 2; position: relative; margin: .9rem 0; border-right: .14rem dashed var(--line); }
#scaleMark { position: absolute; left: 0; bottom: calc(var(--f, 1) * 100%); margin-bottom: -.5rem; width: 1rem; height: 1rem; background: var(--text); clip-path: polygon(0 50%, 100% 0, 100% 100%); }
.scale-end { grid-column: 2; line-height: 1.15; }
.scale-end b { font: 800 1.5rem var(--display); display: block; }
.scale-end span { color: var(--muted); font-size: .85rem; }
.scale-bottom { align-self: end; }

.q-col { display: flex; flex-direction: column; gap: 1rem; min-height: 0; min-width: 0; }
.q-head { display: flex; gap: 1rem; align-items: baseline; flex: none; }
#qCat { font: 700 1.3rem var(--display); color: var(--ice); }
#qMax { color: var(--muted); font-weight: 700; font-size: 1.1rem; }
.q-text { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; overflow: hidden; font-weight: 800; line-height: 1.14; font-size: var(--qs, 3.4rem); overflow-wrap: anywhere; text-wrap: balance; }
body.has-media .q-text { flex: 0 0 auto; }
.media-slot { display: none; }
.media-slot.on { display: block; }
#qSlot.on { flex: 1 1 0; min-height: 5rem; }
.q-live { flex: none; display: grid; justify-items: center; text-align: center; }
.q-buzz { font: 800 2rem var(--display); color: var(--pink); min-height: 1.25em; }
.q-value-label { color: var(--muted); font-size: 1.15rem; font-weight: 600; }
.q-value { font: 900 6.6rem/1.05 var(--display); font-variant-numeric: tabular-nums; }
body.has-media .q-value { font-size: 4rem; }
body.has-media .q-buzz { font-size: 1.5rem; }
body[data-phase=running].is-danger .q-value { color: var(--pink); }
body[data-phase=buzzed] .q-value { color: var(--ice); }
.q-actions { display: flex; gap: .8rem; margin-top: .7rem; min-height: 3rem; }
body:not([data-phase=buzzed]) #correctBtn, body:not([data-phase=buzzed]) #wrongBtn { display: none; }

/* ---------- medier ---------- */
#mediaStage { position: fixed; z-index: 60; }
.media { position: relative; width: 100%; height: 100%; }
.media img, .media video, .media iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border: 0; border-radius: .8rem; }
.media iframe { background: #000; }
.media audio { position: absolute; opacity: 0; pointer-events: none; }
.media-eq { position: absolute; inset: 0; margin: auto; width: fit-content; display: flex; align-items: center; gap: .6rem; height: min(100%, 9rem); }
.media-eq i { width: 1rem; height: 25%; border-radius: 999px; background: var(--pink); }
.media-eq.on i { animation: eq .7s ease-in-out infinite alternate; }
.media-eq i:nth-child(2n) { animation-delay: -.2s; background: var(--violet); }
.media-eq i:nth-child(3n) { animation-delay: -.45s; background: var(--ice); }
@keyframes eq { to { height: 100%; } }

/* ---------- afsløring ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(12,7,22,.74); backdrop-filter: blur(.7rem); -webkit-backdrop-filter: blur(.7rem); animation: fade .25s; }
@keyframes fade { from { opacity: 0; } }
.reveal-card { width: min(70rem, 90vw); max-height: 90vh; background: var(--bg-2); border: .5rem solid var(--line); border-radius: 2.2rem; padding: 2.2rem 2.5rem; display: flex; flex-direction: column; align-items: center; gap: 1rem; text-align: center; }
.reveal-card.is-correct { border-color: var(--ok); box-shadow: 0 0 6rem rgba(46,229,143,.35); }
.reveal-card.is-wrong { border-color: var(--bad); box-shadow: 0 0 6rem rgba(255,77,94,.35); }
.reveal-result { font: 700 1.7rem var(--display); }
.is-correct .reveal-result { color: var(--ok); } .is-wrong .reveal-result { color: var(--bad); } .is-none .reveal-result { color: var(--muted); }
.reveal-q { color: var(--muted); font-size: 1.15rem; max-width: 50rem; }
.reveal-answer { font: 900 var(--as, 4.4rem)/1.08 var(--display); overflow-wrap: anywhere; }
#rSlot.on { width: 100%; height: 15rem; flex: none; }

/* ---------- slutstilling ---------- */
#vFinal { flex-direction: column; align-items: center; gap: 1.3rem; }
.final-title { font-size: 2.6rem; }
.final-list { width: min(46rem, 100%); flex: 1; min-height: 0; overflow-y: auto; display: grid; gap: .6rem; align-content: start; padding: .3rem; }
.final-row { background: var(--panel); border-radius: 1rem; border-left: .5rem solid var(--tc, var(--line)); padding: .7rem 1.3rem; opacity: 0; animation: rise .55s cubic-bezier(.2,1.2,.4,1) forwards; animation-delay: var(--d, 0s); }
.final-row .top { display: flex; align-items: baseline; gap: 1rem; }
.final-row .rank { font: 800 1.3rem var(--display); color: var(--muted); width: 2.2em; }
.final-row .name { flex: 1; font-weight: 800; font-size: 1.5rem; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.final-row .score { font: 800 1.6rem var(--display); }
.final-row .members { color: var(--muted); padding-left: 3.9rem; font-size: 1rem; text-align: left; }
.final-row.first { background: var(--text); color: var(--bg); padding: 1.1rem 1.3rem; box-shadow: .4rem .4rem 0 var(--pink); }
.final-row.first .rank, .final-row.first .members { color: #5b4590; }
.final-row.first .name { font-size: 2.1rem; } .final-row.first .score { font-size: 2.2rem; }
@keyframes rise { from { opacity: 0; transform: translateY(1.5rem) scale(.96); } to { opacity: 1; transform: none; } }
.final-actions { display: flex; gap: .9rem; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 150; }

@media (prefers-reduced-motion: reduce) {
  .final-row { animation-duration: .01s; }
  .round-banner, .chip, .overlay, .media-eq.on i { animation: none; }
}

/* ---------- rundeopsummering ---------- */
#vRecap { grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 1.1rem; max-width: 84rem; margin: 0 auto; width: 100%; }
.recap-head { text-align: center; }
.recap-title { font-size: clamp(2rem, 4vw, 3.2rem); display: inline-block; padding: .2em .7em; border-radius: 1rem; background: var(--pink); color: #2a0619; animation: banner .6s cubic-bezier(.2,1.4,.4,1); }
.recap-sub { margin: .7rem 0 0; color: var(--muted); font-size: 1.25rem; font-weight: 600; }
.recap-hl { display: flex; flex-wrap: wrap; justify-content: center; gap: .7rem; }
.recap-hl > div { background: var(--panel); border: .12rem solid var(--line); border-radius: 999px; padding: .45rem 1.1rem; display: flex; gap: .6rem; align-items: baseline; opacity: 0; animation: rise .5s cubic-bezier(.2,1.2,.4,1) forwards; animation-delay: var(--d, 0s); }
.recap-hl small { color: var(--ice); font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.recap-hl b { font-size: 1.1rem; }
.recap-grid { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: fit-content(100%); width: min(52rem, 100%); justify-self: center; min-height: 0; }
.recap-box { background: rgba(255,255,255,.04); border-radius: 1.2rem; padding: 1rem 1.2rem; min-height: 0; display: flex; flex-direction: column; gap: .7rem; }
.recap-box h3 { font-size: 1.1rem; color: var(--muted); }
.recap-st { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; overflow-y: auto; min-height: 0; align-content: start; }
.recap-st li { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto 2.6rem 4.5rem; align-items: center; gap: .7rem; background: var(--panel); border-left: .4rem solid var(--tc, var(--line));
  border-radius: .8rem; padding: .5rem .8rem; opacity: 0; animation: rise .5s cubic-bezier(.2,1.2,.4,1) forwards; animation-delay: var(--d, 0s); }
.recap-st li.first { background: var(--text); color: var(--bg); }
.recap-st li.first .r-rank, .recap-st li.first .r-gain.zero { color: #5b4590; }
.recap-st .r-rank { font: 800 1rem var(--display); color: var(--muted); }
.recap-st .r-name { font-weight: 800; font-size: 1.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recap-st .r-gain { font-weight: 800; font-size: .95rem; padding: .15em .6em; border-radius: 999px; background: rgba(46,229,143,.16); color: var(--ok); white-space: nowrap; }
.recap-st .r-gain.neg { background: rgba(255,77,94,.16); color: var(--bad); }
.recap-st .r-gain.zero { background: none; color: var(--muted); }
.recap-st li.first .r-gain { background: rgba(0,0,0,.08); }
.recap-st li.first .r-gain:not(.neg):not(.zero) { color: #0b7a49; }
.recap-st .r-move { font-weight: 800; font-size: .9rem; text-align: center; }
.recap-st .r-move.up { color: var(--ok); } .recap-st .r-move.down { color: var(--bad); }
.recap-st li.first .r-move.up { color: #0b7a49; }
.recap-st .r-score { font: 800 1.2rem var(--display); text-align: right; font-variant-numeric: tabular-nums; }
.recap-actions { display: flex; justify-content: center; }
@media (prefers-reduced-motion: reduce) { .recap-hl > div, .recap-st li { animation-duration: .01s; } .recap-title { animation: none; } }

/* ---------- hvis tur til at vælge kategori ---------- */
.cat-title.has-turn { font: 800 clamp(1.8rem, 3.2vw, 2.6rem)/1.15 var(--display); color: var(--text); text-align: center; }
.cat-title .turn-name { display: inline-block; color: var(--pink); animation: turn-pop .5s cubic-bezier(.2,1.5,.4,1); }
@keyframes turn-pop { from { transform: scale(.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cat-title .turn-name { animation: none; } }

/* spørgsmål pr. runde i lobbyen */
.per-round { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--muted); }
.per-round select { padding: .55em .7em; }
.per-round-hint { margin: .2rem 0 0; color: var(--muted); }
.per-round-hint.warn { color: var(--bad); font-weight: 600; }
.qi-main strong .flag { font-size: .72em; margin-right: .5em; vertical-align: .08em; }
.tb-title .flag { font-size: .9em; }

/* ⋮-menu pr. quiz */
.qi-more { flex: none; width: 2.6rem; height: 2.6rem; border-radius: 50%; border: .12rem solid var(--line); background: none; color: var(--text);
  font: 800 1.35rem/1 var(--body); cursor: pointer; display: grid; place-items: center; }
.qi-more:hover, .qi-more[aria-expanded=true] { border-color: var(--pink); color: var(--pink); }
.qi-menu { position: absolute; z-index: 60; min-width: 14rem; background: var(--panel); border: .12rem solid var(--line); border-radius: .9rem; padding: .35rem;
  box-shadow: 0 .8rem 2.4rem rgba(0,0,0,.55); display: grid; gap: .15rem; }
.qi-menu[hidden] { display: none; }
.qi-menu button { text-align: left; font: 600 1rem var(--body); color: var(--text); background: none; border: 0; border-radius: .6rem; padding: .7em 1em; cursor: pointer; }
.qi-menu button:hover:not(:disabled), .qi-menu button:focus-visible { background: rgba(255,255,255,.08); outline: none; }
.qi-menu button:disabled { color: var(--ok); cursor: default; }
.qi-menu .danger { color: var(--bad); }
.qi-menu .danger.armed, .qi-menu .danger.armed:hover { background: var(--bad); color: #36060c; }
.quiz-group { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.qg-new { font: 700 .95rem var(--body); text-transform: none; letter-spacing: 0; color: var(--ice); text-decoration: none; border: .12rem solid var(--line); border-radius: 999px; padding: .35em .95em; }
.qg-new:hover { border-color: var(--ice); }
