/* Fredy 80 quiz. One dark, warm theme for phones at a party and a TV screen.
   Layout: player = single column, photo first; host = preview + controls; screen = photo beside text. */
:root {
  color-scheme: dark;
  --bg: #0e1726; --bg2: #132035; --card: #1a2a44; --card2: #22365a; --line: rgba(255,255,255,.12);
  --fg: #f4efe4; --muted: #a7b3c8; --gold: #e8b84a; --gold2: #ffd97a; --ok: #43d17e; --bad: #ff6b6b; --blue: #6fb6ff;
  --display: "Frank Ruhl Libre", "David", "Times New Roman", serif;
  --ui: "Heebo", "Arial Hebrew", "Noto Sans Hebrew", system-ui, sans-serif;
  --r: 18px;
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); font: 400 16px/1.45 var(--ui); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100svh; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; opacity: .55; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
a { color: var(--blue); }

.splash { min-height: 100vh; min-height: 100svh; display: grid; place-content: center; gap: 14px; color: var(--muted); text-align: center; padding: 20px; }
.splash.error { color: var(--bad); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin .9s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.screen { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }
.screen > main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding-right: var(--gutter-r); padding-left: var(--gutter-l); padding-block: 14px 40px; display: flex; flex-direction: column; gap: 14px; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px var(--gutter-r) 10px var(--gutter-l); background: rgba(14,23,38,.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); font-size: .95rem; }
.brand { display: flex; align-items: center; gap: 8px; font: 700 1rem var(--display); color: var(--gold2); white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 3px rgba(255,107,107,.18); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(67,209,126,.18); }
.qnum { color: var(--muted); white-space: nowrap; }
.me { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28vw; font-weight: 600; }
.score { background: var(--gold); color: #1b1608; font-weight: 800; border-radius: 999px; padding: 2px 10px; min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }
.badge { font: 600 .72rem var(--ui); letter-spacing: .04em; background: rgba(255,255,255,.1); color: var(--fg); border-radius: 999px; padding: 2px 8px; }
.badge.warn { background: rgba(232,184,74,.2); color: var(--gold2); }

/* join */
.hero { position: relative; height: min(58vh, 520px); overflow: hidden; }
.hero img { width: 100%; height: 100%; object-fit: cover; object-position: center 25%; display: block; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, var(--bg) 0%, rgba(14,23,38,.55) 35%, rgba(14,23,38,0) 70%); }
.hero-text { position: absolute; right: var(--gutter-r); left: var(--gutter-l); bottom: 14px; z-index: 1; }
.eyebrow { margin: 0 0 4px; color: var(--gold); font: 600 .9rem var(--ui); letter-spacing: .08em; }
.title { margin: 0; font: 900 clamp(2.4rem, 9vw, 4rem)/1.05 var(--display); text-wrap: balance; }
.sub { margin: 4px 0 0; color: var(--muted); }
.join-form { gap: 10px; }
.lbl { font-weight: 600; }
.name-input { width: 100%; font: 600 1.25rem var(--ui); padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--fg); }
.name-input:focus { border-color: var(--gold); outline: none; }
.primary { background: var(--gold); color: #1b1608; font-weight: 800; border-radius: 14px; padding: 14px 18px; font-size: 1.1rem; box-shadow: 0 8px 24px rgba(232,184,74,.25); transition: transform .08s; }
.primary:not(:disabled):active { transform: scale(.98); }
.primary.big { width: 100%; min-height: 58px; font-size: 1.2rem; }
.ghost { border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 14px; background: rgba(255,255,255,.04); font-weight: 600; }
.ghost.small { padding: 6px 10px; font-size: .9rem; }
.danger { border: 1.5px solid rgba(255,107,107,.5); color: var(--bad); border-radius: 12px; padding: 10px 14px; font-weight: 600; text-align: start; }
.armed { background: var(--bad) !important; color: #fff !important; border-color: var(--bad) !important; }
.err { color: var(--bad); margin: 0; min-height: 1.3em; }
.note { color: var(--muted); font-size: .9rem; margin: 0; }
.link-btn { color: var(--blue); text-decoration: underline; padding: 0; font-size: inherit; }

/* lobby */
.wait { text-align: center; padding-block: 20px; }
.pulse { width: 18px; height: 18px; border-radius: 50%; background: var(--gold); margin: 0 auto 16px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(232,184,74,.5); } 50% { transform: scale(1.1); box-shadow: 0 0 0 18px rgba(232,184,74,0); } }
.wait h1 { font: 700 1.6rem var(--display); margin: 0 0 8px; }
.wait p { margin: 0; color: var(--muted); }
.count { color: var(--muted); margin: 0; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 600; }

/* question */
.photo { margin: 0; background: #0a1220; border-radius: 20px; overflow: hidden; display: grid; place-items: center; box-shadow: 0 12px 40px rgba(0,0,0,.4); cursor: zoom-in; position: relative; }
.photo img { width: 100%; height: auto; max-height: min(62vh, 780px); object-fit: contain; display: block; }
.photo.small img { max-height: 42vh; }
.qtext { margin: 4px 0 0; font: 700 clamp(1.25rem, 4.6vw, 1.7rem)/1.3 var(--display); text-wrap: balance; }
.qnote { margin: 0; color: var(--gold2); font-weight: 600; }
.options { display: grid; gap: 10px; }
.opt { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; width: 100%; text-align: start; background: var(--card); color: var(--fg); border: 2px solid var(--line); border-radius: var(--r); padding: 12px 14px; font: 600 1.05rem/1.35 var(--ui); min-height: 62px; transition: border-color .15s, background .15s, transform .08s; overflow: hidden; }
button.opt:not(:disabled):active { transform: scale(.985); }
.opt .letter { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.08); display: grid; place-items: center; font: 700 1.15rem var(--display); flex: none; }
.opt .txt { min-width: 0; overflow-wrap: anywhere; }
.opt .tag { font-size: .78rem; font-weight: 700; color: var(--ok); white-space: nowrap; }
.opt.selected { border-color: var(--gold); background: rgba(232,184,74,.13); }
.opt.selected .letter { background: var(--gold); color: #1b1608; }
.opt.correct { border-color: var(--ok); background: rgba(67,209,126,.16); }
.opt.correct .letter { background: var(--ok); color: #06240f; }
.opt.wrong { border-color: var(--bad); background: rgba(255,107,107,.12); }
.opt.wrong .letter { background: var(--bad); color: #fff; }
.opt.wrong .tag { color: var(--bad); }
.opt:disabled { opacity: 1; }
.opt:disabled:not(.correct):not(.wrong) { opacity: .6; }
.status { color: var(--muted); text-align: center; margin: 0; min-height: 1.4em; }
.verdict { border-radius: 14px; padding: 12px 16px; font-weight: 800; font-size: 1.1rem; text-align: center; }
.verdict.ok { background: rgba(67,209,126,.18); color: var(--ok); border: 1.5px solid rgba(67,209,126,.5); }
.verdict.bad { background: rgba(255,107,107,.14); color: var(--bad); border: 1.5px solid rgba(255,107,107,.45); }
.verdict.none { background: rgba(255,255,255,.06); color: var(--muted); border: 1.5px solid var(--line); }

/* distribution rows (host and TV screen) */
.opt.dist { grid-template-columns: auto 1fr auto auto; cursor: default; }
.opt.dist.pickable { cursor: pointer; }
.opt.dist .bar { position: absolute; top: 0; bottom: 0; inset-inline-start: 0; width: 0; background: rgba(111,182,255,.16); transition: width .4s; z-index: 0; pointer-events: none; }
.opt.dist > :not(.bar) { position: relative; z-index: 1; }
.opt.dist .count { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.1rem; min-width: 1.5em; text-align: center; }
.opt.dist .who { grid-column: 2 / -1; color: var(--muted); font-size: .85rem; font-weight: 500; }
.opt.dist .who:empty { display: none; }
.opt.dist.key { border-color: var(--gold); }
.opt.dist.picked { border-color: var(--gold); background: rgba(232,184,74,.13); }
.opt.dist.correct .bar { background: rgba(67,209,126,.2); }
.hint { color: var(--muted); font-size: .9rem; margin: 0; }

/* leaderboard */
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.board .row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 12px; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 14px; font-weight: 600; }
.board .row.me { border-color: var(--gold); background: rgba(232,184,74,.12); }
.board .row.top { background: var(--card2); }
.board .rank { font: 800 1.2rem var(--display); color: var(--gold2); text-align: center; font-variant-numeric: tabular-nums; }
.board .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .pts { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.1rem; }
.board .empty { color: var(--muted); text-align: center; padding: 20px; }
.h { font: 700 1.8rem var(--display); margin: 0; }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; }
.pod { background: var(--card2); border-radius: 16px; padding: 14px 10px; text-align: center; border: 1.5px solid var(--line); min-width: 0; }
.pod.rank1 { order: 2; padding-top: 26px; border-color: var(--gold); background: rgba(232,184,74,.14); }
.pod.rank2 { order: 1; }
.pod.rank3 { order: 3; }
.pod .medal { font-size: 2rem; line-height: 1; }
.pod .pname { font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; margin-top: 6px; }
.pod .pts { color: var(--muted); }
.mine { text-align: center; font-weight: 700; color: var(--gold2); margin: 0; }
.outro-fig { cursor: default; }
.outro-fig img { max-height: 50vh; }
.bye { text-align: center; font: 700 1.3rem var(--display); color: var(--muted); margin: 0; }

/* host */
.host-top .phase { color: var(--gold2); font-weight: 600; font-size: .9rem; text-align: start; }
.host-grid { display: grid; gap: 16px; padding: 14px var(--gutter-r) 120px var(--gutter-l); max-width: 1200px; margin: 0 auto; width: 100%; }
.panel { background: var(--bg2); border: 1px solid var(--line); border-radius: 20px; padding: 16px; display: grid; gap: 12px; min-width: 0; }
.panel h2 { margin: 0; font: 700 1.3rem var(--display); }
.panel .qtext { font-size: clamp(1.15rem, 2vw, 1.5rem); }
.qhead { display: flex; justify-content: space-between; color: var(--muted); font-weight: 600; }
.qr { background: #fff; border-radius: 14px; padding: 10px; width: min(260px, 70vw); margin: 0 auto; }
.qr svg { width: 100%; height: auto; display: block; }
.qr.big { width: min(420px, 60vmin); }
.link { color: var(--blue); word-break: break-all; text-align: center; display: block; }
.controls { display: grid; gap: 12px; align-content: start; min-width: 0; }
.primary-wrap { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px var(--gutter-r) max(10px, env(safe-area-inset-bottom, 0px)) var(--gutter-l); background: linear-gradient(to top, var(--bg) 70%, rgba(14,23,38,0)); z-index: 6; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.jump { width: 100%; font: 600 1rem var(--ui); padding: 10px 12px; border-radius: 12px; background: var(--card); color: var(--fg); border: 1.5px solid var(--line); }
.controls h3 { margin: 6px 0 0; font: 700 1.1rem var(--display); }
.pcount { color: var(--muted); font-weight: 500; }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plist li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto auto auto auto; align-items: center; gap: 6px; background: var(--card); border-radius: 12px; padding: 8px 10px; }
.plist .st { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.07); font: 700 .95rem var(--display); color: var(--muted); }
.plist .st.yes { background: var(--ok); color: #06240f; }
.plist .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.plist .pts { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--gold2); font-size: .95rem; white-space: nowrap; }
.plist .empty { color: var(--muted); text-align: center; display: block; }
.mini { border: 1.5px solid var(--line); border-radius: 10px; min-width: 34px; height: 34px; font-weight: 800; font-size: 1.1rem; }
.mini.danger { font-size: .85rem; padding: 0 8px; border-color: rgba(255,107,107,.45); color: var(--bad); }
.danger-zone { margin-top: 10px; display: grid; gap: 8px; }
.danger-zone summary { cursor: pointer; color: var(--muted); font-weight: 600; }
@media (min-width: 900px) {
  .host-grid { grid-template-columns: minmax(0, 1.25fr) minmax(320px, .9fr); padding-bottom: 30px; }
  .primary-wrap { position: static; padding: 0; background: none; }
}

/* TV screen */
.tv { padding: 2vmin 3vmin; }
.tv-lobby { display: grid; grid-template-columns: 1.1fr 1fr; gap: 3vmin; align-items: center; }
.tv-hero { position: relative; border-radius: 24px; overflow: hidden; height: 90vh; height: 90svh; }
.tv-hero img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; display: block; }
.tv-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(14,23,38,.92), rgba(14,23,38,0) 60%); }
.tv-hero .hero-text { bottom: 3vmin; right: 3vmin; left: 3vmin; }
.tv-hero .title { font-size: clamp(2.5rem, 7vw, 6rem); }
.tv-hero .sub, .tv-hero .eyebrow { font-size: clamp(1rem, 1.8vw, 1.5rem); }
.tv-join { display: grid; gap: 1.6vmin; justify-items: center; text-align: center; }
.tv-join h2 { margin: 0; font: 700 clamp(1.6rem, 3.5vw, 3rem) var(--display); }
.tv-join .link { font-size: clamp(1rem, 2vw, 1.6rem); }
.tv-join .count { font-size: clamp(1rem, 1.8vw, 1.4rem); }
.tv-join .chip { font-size: clamp(.9rem, 1.6vw, 1.3rem); }
.tv-q { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 3vmin; align-items: start; }
.tv-photo { cursor: default; height: 94vh; height: 94svh; }
.tv-photo img { max-height: 94vh; max-height: 94svh; height: 100%; width: 100%; object-fit: contain; }
.tv-text { display: grid; gap: 1.6vmin; align-content: start; padding-top: 1vmin; min-width: 0; }
.tv-text .qnum { font-size: clamp(1rem, 1.8vw, 1.5rem); }
.tv-text .qtext { font-size: clamp(1.5rem, 3vw, 2.8rem); }
.tv-text .qnote { font-size: clamp(1rem, 1.8vw, 1.5rem); }
.tv-text .opt { font-size: clamp(1rem, 1.8vw, 1.6rem); min-height: 9vh; }
.tv-text .opt .letter { width: 3.2vw; height: 3.2vw; min-width: 40px; min-height: 40px; font-size: clamp(1rem, 1.8vw, 1.6rem); }
.tv-text .opt .who { font-size: clamp(.85rem, 1.3vw, 1.2rem); }
.tv-text .opt .count { font-size: clamp(1.1rem, 2vw, 1.8rem); }
.answered.big { font-size: clamp(1.1rem, 2vw, 1.8rem); color: var(--muted); font-weight: 600; }
.tv-board > main { max-width: 1000px; gap: 2vmin; }
.tv-board .h { font-size: clamp(2rem, 4vw, 3.5rem); text-align: center; }
.tv-board .board .row { font-size: clamp(1rem, 1.8vw, 1.6rem); padding: 1.2vmin 2vmin; }
.tv-board .pod .pname { font-size: clamp(1.2rem, 2.2vw, 2rem); }
@media (max-width: 800px) {
  .tv-lobby, .tv-q { grid-template-columns: 1fr; }
  .tv-hero { height: 50vh; }
  .tv-photo, .tv-photo img { height: auto; max-height: 60vh; }
}

/* lightbox + confetti */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(5,9,16,.96); display: grid; place-items: center; cursor: zoom-out; padding: 2vmin; }
.lightbox img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.lb-hint { position: absolute; bottom: max(14px, env(safe-area-inset-bottom, 0px)); color: var(--muted); font-size: .85rem; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* TV fullscreen button */
.fs-btn { position: fixed; bottom: max(14px, env(safe-area-inset-bottom, 0px)); inset-inline-end: max(14px, env(safe-area-inset-left, 0px)); z-index: 40; border: 1.5px solid var(--line); background: rgba(14,23,38,.88); color: var(--fg); border-radius: 999px; padding: 10px 16px; font-weight: 600; font-size: 1rem; box-shadow: 0 6px 20px rgba(0,0,0,.35); transition: opacity .3s; }
.fs-btn:hover { border-color: var(--gold); }
html.is-fullscreen.idle .fs-btn { opacity: 0; pointer-events: none; }
html.is-fullscreen.idle, html.is-fullscreen.idle * { cursor: none; }
.fs-hint { position: fixed; bottom: max(14px, env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 39; background: rgba(232,184,74,.95); color: #1b1608; font-weight: 700; font-size: clamp(1rem, 1.6vw, 1.3rem); padding: 10px 22px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.35); pointer-events: none; white-space: nowrap; }

/* live ranking page (#board) */
.board-live > main { max-width: 1400px; }
.board-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.board-live .h { text-align: start; }
.board-live .sub, .board-live .now { margin: 0; color: var(--muted); font-size: clamp(1rem, 1.6vw, 1.4rem); }
.board-live .now { color: var(--gold2); font-weight: 600; }
.board-live .board { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.board-live .board .row { font-size: clamp(1rem, 1.5vw, 1.4rem); }

/* winner announcement, multi-column boards, host extras */
.winner { text-align: center; display: grid; gap: 4px; padding: 10px 0 6px; }
.winner .eyebrow { margin: 0; }
.winner-name { font: 900 clamp(2rem, 6vw, 4.5rem)/1.1 var(--display); color: var(--gold2); text-wrap: balance; overflow-wrap: anywhere; }
.winner-pts { color: var(--muted); font-weight: 600; font-size: clamp(1rem, 2vw, 1.6rem); }
.board.cols { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.tv-board .winner-name { font-size: clamp(2.5rem, 7vw, 6rem); }
.primary-wrap { display: grid; gap: 8px; justify-items: stretch; }
.primary-wrap .ghost { justify-self: center; }
.mine.big { font-size: 1.3rem; }
.board-screen .wait h1 { font-size: 1.5rem; }

.tv-board .sub { text-align: center; margin: 0; }
