:root {
  --bg-0: #01030f;
  --bg-1: #061142;
  --bg-2: #0c2170;
  --line: #a9c4ff;
  --line-dim: #4a6cc4;
  --text: #ffffff;
  --muted: #9fb0dc;
  --gold: #f7a11a;
  --gold-hi: #ffd36b;
  --orange-1: #ffc04a;
  --orange-2: #f07f00;
  --green-1: #9bff8f;
  --green-2: #16a534;
  --red: #ff3b3b;
  --tip: 22px;
  --radius: 14px;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-cond: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --font-logo: 'Cinzel', Georgia, 'Times New Roman', serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- tło studia ---------- */
.bg { position: fixed; inset: 0; z-index: -2; overflow: hidden;
  background:
    radial-gradient(ellipse 70% 55% at 50% 38%, #12308f 0%, #081a5c 35%, #040b30 65%, var(--bg-0) 100%);
}
.beams { position: absolute; inset: -50%;
  background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(120,170,255,.10) 0deg 4deg, transparent 4deg 22deg);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent 8%, #000 30%, transparent 62%);
          mask-image: radial-gradient(circle at 50% 50%, transparent 8%, #000 30%, transparent 62%);
  animation: spin 120s linear infinite;
}
.floor { position: absolute; left: 50%; bottom: -30vh; width: 140vw; height: 60vh; transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(50,120,255,.35), transparent 65%); }
@keyframes spin { to { transform: rotate(360deg); } }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ---------- górny pasek ---------- */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.brand { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px; opacity: .95; }
.brand svg { width: 38px; height: 38px; }
.brand span { font-family: var(--font-logo); font-weight: 900; letter-spacing: .06em; font-size: 15px; text-transform: uppercase; }
body.on-title .brand { visibility: hidden; }
.top-status { flex: 1; text-align: center; font-family: var(--font-cond); font-weight: 600; font-size: 18px; letter-spacing: .04em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-status b { color: var(--gold); }
.top-actions { display: flex; gap: 6px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(169,196,255,.35); background: rgba(6,17,66,.6);
  display: grid; place-items: center; transition: background .2s, border-color .2s; }
.icon-btn:hover { background: rgba(30,60,160,.7); border-color: var(--line); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#btn-sound .off { display: none; }
body.muted #btn-sound .on { display: none; }
body.muted #btn-sound .off { display: block; }
.only-mobile { display: none !important; }

main { position: fixed; inset: 56px 0 0 0; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: grid; animation: fadeIn .5s ease; }
@keyframes fadeIn { from { opacity: 0; } }

/* ---------- kształt sześciokąta ---------- */
.hex { position: relative; isolation: isolate; display: flex; border: 0; background: none; padding: 0; text-align: left; }
.hex::before { /* linia biegnąca przez scenę */
  content: ''; position: absolute; top: 50%; left: -100vw; right: -100vw; height: 2px; margin-top: -1px; z-index: -2;
  background: linear-gradient(90deg, transparent, rgba(169,196,255,.55) 20%, rgba(169,196,255,.55) 80%, transparent);
}
.hex::after { /* obramowanie */
  content: ''; position: absolute; inset: 0; z-index: -1;
  clip-path: polygon(0 50%, var(--tip) 0, calc(100% - var(--tip)) 0, 100% 50%, calc(100% - var(--tip)) 100%, var(--tip) 100%);
  background: linear-gradient(180deg, #e4edff 0%, #7f9bd6 50%, #d5e2ff 100%);
  transition: background .25s;
}
.hex-in { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; margin: 2px;
  clip-path: polygon(0 50%, calc(var(--tip) - 1px) 0, calc(100% - var(--tip) + 1px) 0, 100% 50%, calc(100% - var(--tip) + 1px) 100%, calc(var(--tip) - 1px) 100%);
  background: linear-gradient(180deg, #0e1f63 0%, #030a2e 48%, #000514 52%, #0a1a57 100%);
  padding: 10px calc(var(--tip) + 12px);
  transition: background .25s, color .25s;
}

/* ---------- ekran tytułowy ---------- */
#screen-classes { place-items: center; overflow-y: auto; padding: 24px 16px; }
.selection-wrap { width: min(600px, 100%); display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.selection-emblem { width: min(26vh, 180px); aspect-ratio: 1; filter: drop-shadow(0 0 24px rgba(60,140,255,.55)); }
.selection-wrap h1 { margin: 0; font: 900 clamp(30px, 6vw, 46px) var(--font-logo); }
.class-list { display: grid; width: 100%; gap: 12px; }
.class-card { width: 100%; min-height: 100px; padding: 16px 24px; border: 1px solid rgba(169,196,255,.55); border-radius: var(--radius); background: linear-gradient(180deg, #16308a, #06124a); text-align: left; }
.class-card:hover, .class-card:focus-visible { border-color: var(--gold-hi); background: linear-gradient(180deg, #2447ad, #0b1c62); }
.class-card strong { display: block; color: #fff; font: 700 28px var(--font-cond); }
.class-card span { color: var(--muted); font-size: 15px; line-height: 1.4; }
#screen-title { place-items: center; overflow-y: auto; padding: 8px 16px 24px; }
.title-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(560px, 100%); text-align: center; }
.title-emblem { position: relative; width: min(46vh, 80vw, 380px); aspect-ratio: 1; }
.title-emblem svg { width: 100%; height: 100%; filter: drop-shadow(0 0 40px rgba(60,140,255,.55)); animation: emblemIn 1.4s cubic-bezier(.2,.8,.2,1) both, glow 4s ease-in-out 1.4s infinite; }
.logo-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; }
@keyframes emblemIn { from { transform: scale(.4) rotate(-40deg); opacity: 0; } }
@keyframes glow { 50% { filter: drop-shadow(0 0 60px rgba(90,170,255,.85)); } }
.set-title { margin: 0; font-family: var(--font-cond); font-size: clamp(18px, 2.6vh, 24px); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.set-title strong { display: block; color: #fff; font-size: 1.25em; letter-spacing: .03em; }
.start-form { display: flex; flex-direction: column; gap: 14px; width: 100%; align-items: stretch; }
.hex-input .hex-in { padding: 0 calc(var(--tip) + 8px); }
.hex-input input { width: 100%; height: 50px; background: transparent; border: 0; outline: 0; color: #fff; font: 600 20px var(--font); text-align: center; }
.hex-input input::placeholder { color: #6f82b8; font-weight: 500; }
.hex-input:focus-within::after { background: linear-gradient(180deg, #fff, var(--gold) 50%, #fff); }
.title-links { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; color: var(--muted); }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; padding: 6px; font-size: 16px; }
.link-btn:hover { color: #fff; }

/* ---------- przyciski ---------- */
.btn { --tip: 16px; position: relative; isolation: isolate; border: 0; background: none; padding: 0 30px; height: 48px; min-width: 120px;
  font: 700 17px var(--font-cond); letter-spacing: .08em; text-transform: uppercase; color: #fff; }
.btn::after { content: ''; position: absolute; inset: 0; z-index: -2;
  clip-path: polygon(0 50%, var(--tip) 0, calc(100% - var(--tip)) 0, 100% 50%, calc(100% - var(--tip)) 100%, var(--tip) 100%);
  background: linear-gradient(180deg, #e4edff, #7f9bd6 50%, #d5e2ff); }
.btn::before { content: ''; position: absolute; inset: 2px; z-index: -1;
  clip-path: polygon(0 50%, calc(var(--tip) - 1px) 0, calc(100% - var(--tip) + 1px) 0, 100% 50%, calc(100% - var(--tip) + 1px) 100%, calc(var(--tip) - 1px) 100%);
  background: linear-gradient(180deg, #16308a, #06124a 55%, #0b1c62); transition: filter .2s; }
.btn:hover::before { filter: brightness(1.45); }
.btn:active { transform: translateY(1px); }
.btn-gold { color: #1b0c00; }
.btn-gold::before { background: linear-gradient(180deg, var(--orange-1), var(--orange-2)); }
.btn-green { color: #032b0c; }
.btn-green::before { background: linear-gradient(180deg, var(--green-1), var(--green-2)); }
.btn-big { height: 60px; font-size: 22px; }
.btn:focus-visible, .answer:focus-visible, .lifeline:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--gold-hi); outline-offset: 3px; }

/* ---------- ekran gry ---------- */
#screen-game {
  grid-template-columns: minmax(0, 1fr) clamp(250px, 23vw, 340px);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "stage life" "stage ladder";
  gap: 10px 18px;
  padding: 4px max(18px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}
.stage { grid-area: stage; display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow-x: clip; }
.stage-center { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
.stage-emblem { height: 100%; max-height: 300px; aspect-ratio: 1; display: grid; place-items: center; }
.stage-emblem svg { width: 100%; height: 100%; filter: drop-shadow(0 0 30px rgba(60,140,255,.5)); animation: glow 5s ease-in-out infinite; }
.stage-center > .panel, .stage-center > .banner { position: absolute; }
.stage-center:has(.panel:not([hidden])) .stage-emblem,
.stage-center:has(.banner:not([hidden])) .stage-emblem { opacity: .15; }

.qa { position: relative; padding: 8px 0 0; }
.q-label { text-align: center; font-family: var(--font-cond); font-weight: 600; font-size: 17px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin-bottom: 8px; min-height: 1.2em; }
.question { --tip: 34px; margin: 0 auto 14px; width: 100%; }
.question .hex-in { justify-content: center; min-height: clamp(84px, 13vh, 132px); padding: 12px calc(var(--tip) + 20px); }
#q-text { margin: 0; text-align: center; font-weight: 500; line-height: 1.3; font-size: clamp(17px, 1.75vw, 30px); text-wrap: balance; }
#q-text.long { font-size: clamp(16px, 1.45vw, 25px); }
.math { font-family: 'Cambria Math', 'STIX Two Math', 'Times New Roman', serif; font-size: 1.08em; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .78em; line-height: 1.05; margin: 0 .12em; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 .15em; }
sup { font-size: .65em; line-height: 0; }

.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 26px; }
.answer { min-height: clamp(52px, 7.4vh, 78px); display: flex; transition: transform .15s; }
.answer .hex-in { gap: 10px; font-size: clamp(16px, 1.45vw, 26px); font-weight: 500; line-height: 1.2; color: #fff; }
.answer .letter { color: var(--gold); font-family: var(--font-cond); font-weight: 700; font-size: 1.1em; flex: none; }
.answer .letter::before { content: '◆'; font-size: .55em; margin-right: .45em; vertical-align: .25em; color: var(--gold); }
.answer .txt.long { font-size: .78em; }
.answer:not(:disabled):hover::after { background: linear-gradient(180deg, #fff, #ffc76a 50%, #fff); }
.answer:not(:disabled):hover .hex-in { background: linear-gradient(180deg, #19328a 0%, #07134a 48%, #020a2c 52%, #13287a 100%); }
.answer.pending::after { background: linear-gradient(180deg, #fff, var(--gold) 50%, #fff); }
.answer.pending .hex-in { background: linear-gradient(180deg, #2a4bb8 0%, #0d1f6e 48%, #06124a 52%, #1e3a9a 100%); animation: pendingPulse 1s ease-in-out infinite; }
@keyframes pendingPulse { 50% { filter: brightness(1.35); } }
.answer.selected::after, .answer.correct::after { background: linear-gradient(180deg, #fff, #fff4d8 50%, #fff); }
.answer.selected .hex-in { background: linear-gradient(180deg, var(--orange-1) 0%, #ff9d1c 48%, var(--orange-2) 52%, #ffb03a 100%); color: #140800; }
.answer.selected .letter, .answer.selected .letter::before { color: #fff; }
.answer.correct .hex-in { background: linear-gradient(180deg, var(--green-1) 0%, #43d552 48%, var(--green-2) 52%, #5ee86a 100%); color: #021a07; }
.answer.correct .letter, .answer.correct .letter::before { color: #fff; }
.answer.flash .hex-in { animation: flash .32s steps(1) 6; }
@keyframes flash { 50% { background: linear-gradient(180deg, #0e1f63, #030a2e 48%, #000514 52%, #0a1a57); color: #fff; } }
.answer.removed .letter, .answer.removed .txt { visibility: hidden; }
.answer.enter { animation: ansIn .45s cubic-bezier(.2,.8,.2,1) both; }
.question.enter { animation: qIn .6s cubic-bezier(.2,.8,.2,1) both; }
@keyframes ansIn { from { opacity: 0; transform: scaleX(.6); } }
@keyframes qIn { from { opacity: 0; transform: scaleX(.3); } }

.actions { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px 14px; min-height: 64px; padding-top: 14px; }
.actions .prompt { width: 100%; text-align: center; font-family: var(--font-cond); font-size: 22px; font-weight: 600; letter-spacing: .03em; }
.actions .hint { width: 100%; text-align: center; color: var(--muted); font-size: 14px; }
.actions .hubert { width: 100%; display: flex; justify-content: center; align-items: center; gap: 12px; animation: ansIn .35s cubic-bezier(.2,.8,.2,1) both; }
.hubert img { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--gold); flex: none; }
.hubert-bubble { position: relative; background: #fff; color: #10183a; border-radius: 14px; padding: 8px 14px; font-family: var(--font-cond); font-size: 22px; font-weight: 600; max-width: 480px; }
.hubert-bubble::before { content: ''; position: absolute; left: -8px; top: 50%; margin-top: -8px; border: 8px solid transparent; border-left: 0; border-right-color: #fff; }
.hubert-bubble .who { display: block; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }

/* ---------- koła ratunkowe ---------- */
.lifelines { grid-area: life; display: flex; justify-content: center; gap: 10px; padding-top: 4px; }
.lifeline { position: relative; background: none; border: 0; padding: 0; width: 96px; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: transform .2s; }
.lifeline svg { width: 100%; overflow: visible; }
.lifeline ellipse { fill: #0a1c63; stroke: #d7e3ff; stroke-width: 3; transition: fill .2s, stroke .2s; }
.lifeline text { fill: #fff; font: 700 25px var(--font-cond); }
.lifeline .glyph { fill: #fff; }
.lifeline .ll-label { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.lifeline:not(:disabled):hover { transform: translateY(-2px); }
.lifeline:not(:disabled):hover ellipse { fill: #1a3aa8; stroke: var(--gold-hi); }
.lifeline.used svg { opacity: .45; }
.lifeline.used::after { content: ''; position: absolute; left: 22%; right: 22%; top: 8%; height: 58%;
  background:
    linear-gradient(to top right, transparent calc(50% - 3px), var(--red) calc(50% - 3px), var(--red) calc(50% + 3px), transparent calc(50% + 3px)),
    linear-gradient(to top left, transparent calc(50% - 3px), var(--red) calc(50% - 3px), var(--red) calc(50% + 3px), transparent calc(50% + 3px));
  filter: drop-shadow(0 0 4px rgba(0,0,0,.8)); }
.lifeline.active ellipse { fill: #f07f00; stroke: #fff; }

/* ---------- drabinka ---------- */
.ladder-wrap { grid-area: ladder; min-height: 0; display: flex; flex-direction: column; }
.ladder { list-style: none; margin: 0; padding: 10px 8px; flex: 1; display: flex; flex-direction: column-reverse; justify-content: center; gap: 2px;
  border: 1px solid rgba(169,196,255,.35); border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(7,20,80,.82), rgba(2,8,40,.9)); box-shadow: inset 0 0 40px rgba(40,100,255,.15); }
.ladder li { position: relative; display: grid; grid-template-columns: 2.1em 1.2em 1fr; align-items: center; padding: 0 14px 0 10px;
  flex: 1 1 0; max-height: 52px; min-height: 24px; font-family: var(--font-cond); font-weight: 700; font-size: clamp(16px, 2.6vh, 24px); color: var(--gold); letter-spacing: .03em;
  --tip: 14px; }
.ladder li .n { text-align: right; padding-right: 2px; }
.ladder li .d { text-align: center; font-size: .6em; opacity: 0; }
.ladder li .a { text-align: right; }
.ladder li.threshold { color: #fff; }
.ladder li.done .d { opacity: 1; }
.ladder li.current { color: #0d0600; }
.ladder li.current::before { content: ''; position: absolute; inset: 0; z-index: -1;
  clip-path: polygon(0 50%, var(--tip) 0, calc(100% - var(--tip)) 0, 100% 50%, calc(100% - var(--tip)) 100%, var(--tip) 100%);
  background: linear-gradient(90deg, var(--orange-2), var(--orange-1) 30%, #fff5dd 50%, var(--orange-1) 70%, var(--orange-2)); animation: ladderIn .5s ease both; }
.ladder li { isolation: isolate; }
.ladder li.won::before { background: linear-gradient(90deg, var(--green-2), var(--green-1) 50%, var(--green-2)); }
.ladder li.lost::before { background: linear-gradient(90deg, #7a0000, var(--red) 50%, #7a0000); }
@keyframes ladderIn { from { opacity: 0; transform: scaleX(.3); } }

/* ---------- panele kół ratunkowych i baner ---------- */
.panel { width: min(520px, 94%); max-height: 100%; overflow: auto; padding: 16px 20px; border-radius: var(--radius);
  border: 1px solid rgba(169,196,255,.5); background: linear-gradient(180deg, rgba(10,28,100,.94), rgba(3,10,46,.96));
  box-shadow: 0 0 40px rgba(40,110,255,.35); animation: popIn .4s cubic-bezier(.2,.8,.2,1) both; }
@keyframes popIn { from { opacity: 0; transform: scale(.9); } }
.panel h3 { margin: 0 0 10px; font: 700 18px var(--font-cond); letter-spacing: .1em; text-transform: uppercase; color: var(--gold); text-align: center; }
.chart { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: end; height: clamp(110px, 22vh, 200px); padding: 0 6px; }
.bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 4px; }
.bar .pct { font: 700 18px var(--font-cond); }
.bar .col { width: 100%; max-width: 70px; height: 0; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, var(--gold-hi), var(--orange-2)); transition: height 1.6s cubic-bezier(.2,.8,.2,1); box-shadow: 0 0 16px rgba(255,160,40,.4); }
.bar .lbl { font: 700 18px var(--font-cond); color: var(--gold); border-top: 2px solid rgba(169,196,255,.5); width: 100%; text-align: center; padding-top: 2px; }
.bar.off { opacity: .3; }
.vote-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 8px 0 14px; }
.vote { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 10px; background: rgba(255,255,255,.05); }
.vote b { font: 700 22px var(--font-cond); color: var(--gold); }
.vote .count { font: 700 30px var(--font-cond); min-width: 2ch; text-align: center; }
.vote .pm { display: flex; gap: 6px; }
.vote .pm button { width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(169,196,255,.5); background: rgba(20,50,150,.6); font-size: 22px; line-height: 1; }
.vote.off { opacity: .3; pointer-events: none; }
.panel-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.choice-list { display: grid; gap: 10px; }
.choice { display: flex; align-items: center; gap: 14px; text-align: left; padding: 12px 16px; border-radius: 12px; border: 1px solid rgba(169,196,255,.35); background: rgba(255,255,255,.04); }
.choice:hover { background: rgba(60,110,255,.25); border-color: var(--line); }
.choice .emoji { font-size: 30px; }
.choice strong { display: block; font-size: 17px; }
.choice small { color: var(--muted); }
.phone-call { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.timer { --p: 1; width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--gold) calc(var(--p) * 360deg), rgba(255,255,255,.1) 0); position: relative; }
.timer::before { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: #06124a; }
.timer span { position: relative; font: 700 38px var(--font-cond); }
.timer.low { background: conic-gradient(var(--red) calc(var(--p) * 360deg), rgba(255,255,255,.1) 0); }
.bubble { position: relative; padding: 12px 16px; border-radius: 14px; background: #fff; color: #0a1440; font-size: 18px; line-height: 1.35; min-height: 52px; }
.bubble::before { content: ''; position: absolute; left: -8px; top: 20px; border: 8px solid transparent; border-left: 0; border-right-color: #fff; }
.bubble .who { display: block; font-size: 13px; font-weight: 700; color: #3552b8; margin-bottom: 2px; text-transform: uppercase; letter-spacing: .05em; }
.dots::after { content: '…'; animation: dots 1s steps(3) infinite; }
@keyframes dots { 0% { content: '.'; } 33% { content: '..'; } 66% { content: '...'; } }

.banner { width: min(640px, 96%); text-align: center; animation: popIn .5s cubic-bezier(.2,.8,.2,1) both; }
.banner .kicker { font: 600 20px var(--font-cond); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; text-shadow: 0 2px 8px #000; }
.banner .hex { --tip: 30px; }
.banner .hex::before { display: none; }
.banner .hex-in { justify-content: center; min-height: 86px; font: 700 clamp(34px, 5vw, 58px) var(--font-cond); letter-spacing: .04em; color: var(--gold-hi);
  background: linear-gradient(180deg, #16308a 0%, #06124a 50%, #0b1c62 100%); text-shadow: 0 0 20px rgba(255,190,80,.6); }
.banner.lost .hex-in { color: #fff; }
.banner .sub { margin-top: 10px; color: var(--muted); font-size: 16px; text-shadow: 0 2px 8px #000; }

/* ---------- ekran końcowy ---------- */
#screen-end { place-items: center; overflow-y: auto; padding: 16px; }
.end-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; width: min(640px, 100%); }
.end-emblem { width: min(30vh, 220px); height: min(30vh, 220px); filter: drop-shadow(0 0 40px rgba(60,140,255,.6)); animation: glow 4s ease-in-out infinite; }
.end-kicker { margin: 0; font: 600 22px var(--font-cond); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.end-amount { --tip: 34px; width: 100%; }
.end-amount::before { display: none; }
.end-amount .hex-in { justify-content: center; min-height: 100px; font: 700 clamp(40px, 8vw, 72px) var(--font-cond); color: var(--gold-hi); text-shadow: 0 0 24px rgba(255,190,80,.6); }
.end-msg { margin: 0; font-size: 18px; color: #dfe7ff; line-height: 1.45; max-width: 520px; }
.end-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
body.million .end-amount .hex-in { background: linear-gradient(180deg, var(--orange-1), var(--orange-2)); color: #fff; text-shadow: 0 2px 0 #9a4c00, 0 0 30px #fff3c0; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(0,3,20,.72); backdrop-filter: blur(4px); animation: fadeIn .25s; }
.modal-box { position: relative; width: min(760px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 26px 26px 22px;
  border-radius: 18px; border: 1px solid rgba(169,196,255,.5); background: linear-gradient(180deg, #0c2170, #040b34); box-shadow: 0 20px 80px rgba(0,0,0,.6); animation: popIn .3s; }
.modal-close { position: absolute; top: 12px; right: 12px; }
.modal h2 { margin: 0 44px 14px 0; font: 700 26px var(--font-cond); letter-spacing: .06em; text-transform: uppercase; color: var(--gold); }
.modal p, .modal li { line-height: 1.5; color: #e2e9ff; }
.modal .explain { font-size: 18px; }
.modal .explain .frac { font-size: .85em; }
.modal .row { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.review-item { padding: 14px 0; border-top: 1px solid rgba(169,196,255,.2); }
.review-item h4 { margin: 0 0 6px; font: 700 16px var(--font-cond); letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }
.review-item .rq { margin: 0 0 8px; font-weight: 600; }
.review-item .ra { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; margin-bottom: 8px; color: var(--muted); }
.review-item .ra .ok { color: var(--green-1); font-weight: 700; }
.review-item .rs { font-size: 15px; color: #c9d5f7; }
.setting { display: grid; grid-template-columns: 140px 1fr 3.5em; align-items: center; gap: 12px; margin: 10px 0; }
.setting input[type=range] { width: 100%; accent-color: var(--gold); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; color: var(--muted); }
kbd { display: inline-block; min-width: 1.8em; padding: 1px 6px; border-radius: 5px; border: 1px solid rgba(169,196,255,.5); background: rgba(255,255,255,.08); font: 600 14px var(--font); text-align: center; color: #fff; }

.rotate-hint { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; padding: 10px 18px; border-radius: 999px; background: rgba(6,17,66,.95); border: 1px solid var(--line-dim); font-size: 15px; animation: popIn .3s; }

/* ---------- mniejsze ekrany ---------- */
@media (max-width: 900px) {
  .only-mobile { display: grid !important; }
  .ladder-head.only-mobile { display: flex !important; }
  .brand span { display: none; }
  #screen-game { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "life" "stage"; gap: 6px; }
  .lifeline { width: 76px; }
  .lifeline .ll-label { display: none; }
  .ladder-wrap { position: fixed; top: 0; right: 0; bottom: 0; width: min(340px, 88vw); z-index: 30; padding: 14px 14px max(14px, env(safe-area-inset-bottom));
    background: #030a30; border-left: 1px solid rgba(169,196,255,.35); box-shadow: -20px 0 60px rgba(0,0,0,.6);
    transform: translateX(105%); transition: transform .3s cubic-bezier(.2,.8,.2,1); }
  .ladder-wrap.open { transform: none; }
  .ladder-head { justify-content: space-between; align-items: center; margin-bottom: 10px; font-family: var(--font-cond); font-size: 20px; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); }
  .ladder li { height: auto; min-height: 36px; font-size: 21px; }
  .stage { overflow-y: auto; }
  .stage-center { flex: 1 0 auto; min-height: 90px; }
  .stage-emblem { max-height: 180px; }
  .stage-center > .panel, .stage-center > .banner { position: relative; max-height: none; }
  .stage-center:has(.panel:not([hidden])) .stage-emblem,
  .stage-center:has(.banner:not([hidden])) .stage-emblem { display: none; }
  .panel { padding: 12px 14px; }
  .banner .hex-in { min-height: 64px; }
  #q-text, #q-text.long { font-size: clamp(16px, 2.6vw, 24px); }
  .answer .hex-in { font-size: clamp(15px, 2.4vw, 22px); }
}
@media (max-width: 640px) {
  :root { --tip: 16px; }
  .topbar { height: 50px; }
  main { top: 50px; }
  .top-status { font-size: 17px; }
  .wide-only { display: none; }
  .icon-btn { width: 38px; height: 38px; }
  .question { --tip: 20px; margin-bottom: 10px; }
  .question .hex-in { padding: 10px calc(var(--tip) + 10px); min-height: 70px; }
  .answers { grid-template-columns: 1fr; gap: 8px; }
  .answer { min-height: 48px; }
  .answer .hex-in { padding: 8px calc(var(--tip) + 8px); }
  .q-label { font-size: 14px; margin-bottom: 4px; }
  .actions { min-height: 54px; padding-top: 10px; gap: 8px; }
  .actions .prompt { font-size: 18px; }
  .btn { height: 44px; padding: 0 22px; font-size: 15px; min-width: 0; }
  .chart { gap: 8px; }
  .phone-call { grid-template-columns: 1fr; justify-items: center; }
  .bubble::before { display: none; }
  .vote .pm button { width: 34px; height: 34px; }
  .review-item .ra { grid-template-columns: 1fr; }
  .setting { grid-template-columns: 1fr 3em; }
  .setting label { grid-column: 1 / -1; }
}
@media (max-height: 560px) and (min-width: 641px) {
  .stage-emblem { display: none; }
  .question .hex-in { min-height: 64px; }
  .answer { min-height: 44px; }
  .ladder li { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .beams, .emblem-anim { animation: none !important; }
}

/* linia sceny: lewa kolumna odpowiedzi wychodzi w lewo, prawa w prawo */
.answers .answer:nth-child(odd)::before { right: 50%; }
.answers .answer:nth-child(even)::before { left: 50%; }
@media (max-width: 640px) {
  .answers .answer:nth-child(odd)::before, .answers .answer:nth-child(even)::before { left: -100vw; right: -100vw; }
}
#resume { height: auto; min-height: 46px; padding: 8px 34px; font-size: 16px; letter-spacing: .03em; text-transform: none; line-height: 1.25; }

/* Scenariusze i materiały do zadań — czytelne również na telefonie. */
.scenario-picker { border: 0; margin: 0; padding: 0; min-width: 0; text-align: left; }
.scenario-picker legend { color: var(--gold, #f6c85c); font-weight: 700; margin-bottom: 10px; }
#scenario-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.scenario-card { display: flex; align-items: flex-start; gap: 10px; padding: 14px; border: 1px solid #465482; border-radius: 12px; background: #101b3b; cursor: pointer; }
.scenario-card[aria-pressed="true"] { border-color: #f6c85c; background: #263051; box-shadow: inset 0 0 0 1px #f6c85c; }
.scenario-card:focus-within { outline: 2px solid white; outline-offset: 3px; }
.scenario-card input { accent-color: #f6c85c; margin-top: 4px; flex-shrink: 0; }
.scenario-card strong, .scenario-card small { display: block; }
.scenario-card strong { color: white; font-size: 16px; line-height: 1.3; }
.scenario-card small { color: #c2cbe4; font-size: 13px; line-height: 1.4; margin-top: 5px; }
.task-table-wrap { max-width: 100%; overflow-x: auto; margin: 14px auto; }
.task-table { border-collapse: collapse; width: 100%; font-size: clamp(12px, 2vw, 17px); line-height: 1.4; text-align: center; }
.task-table caption { margin-bottom: 7px; font-size: .85em; color: #c2cbe4; }
.task-table th, .task-table td { border: 1px solid #6676a1; padding: 6px 8px; }
.task-table thead { background: #263051; }
.task-table tbody th { font-weight: 500; }
.task-statements { margin: 14px 0; text-align: left; }
.fraction-strip { display: flex; width: min(100%, 340px); height: 46px; margin: 14px auto; border: 2px solid white; }
.fraction-strip span { flex: 1; border-right: 1px solid #35451c; }
.fraction-strip .green { background: #97c45f; }.fraction-strip .yellow { background: #f4e732; }
.photo-scale { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 18px; }
.photo-scale span { display: grid; place-items: center; width: 105px; height: 70px; border: 2px solid #f6c85c; font-size: 15px; }
.photo-scale span:last-child { width: 147px; height: 98px; }
.task-photo { margin: 10px auto 12px; max-width: min(100%, 520px); }
.task-photo img { display: block; width: 100%; max-height: 30vh; object-fit: contain; border-radius: 10px; border: 2px solid #465482; }
.task-photo figcaption { margin-top: 6px; font-size: .7em; color: #c2cbe4; }
.answer-box { display: inline-block; width: 1.3em; height: 1.3em; margin: 0 .12em; border: 2px solid currentColor; border-radius: 4px; vertical-align: -.25em; }
.task-table.magic-square { width: auto; margin: 0 auto; font-size: clamp(18px, 3vw, 26px); }
.task-table.receipt { width: auto; min-width: 14em; margin: 0 auto; }
.receipt tbody th { text-align: left; }
.magic-square td { width: 2.4em; height: 2.4em; padding: 0; }
.roman { font-family: Georgia, 'Times New Roman', serif; letter-spacing: .06em; }
.roman-big { display: block; margin: 12px 0; font-size: 1.6em; }
.blot { display: inline-block; width: .9em; height: 1em; vertical-align: -.12em; border-radius: 45% 55% 40% 60%; background: radial-gradient(circle at 40% 40%, #6a5bd8 0 45%, #4b3fb0 70%); box-shadow: .12em -.1em 0 -.04em #4b3fb0, -.12em .12em 0 -.05em #4b3fb0; }
@media (max-width: 540px) { #scenario-options { grid-template-columns: 1fr; } .scenario-card { padding: 11px; } }
#screen-title { align-items: start; }
.title-wrap { margin: 12px auto; }
.title-emblem { width: min(22vh, 160px); flex-shrink: 0; }
.stage { overflow-y: auto; }
.stage-center { min-height: 100px; }
#q-text { width: 100%; min-width: 0; }
#screen-end { align-items: start; }
.end-wrap { margin: 16px auto; }
.teacher-award { margin: 0; width: 100%; }
.teacher-award img { display: block; width: 100%; height: auto; border-radius: 16px; border: 2px solid var(--gold); }
.teacher-award figcaption { margin-top: 12px; line-height: 1.5; color: #fff1cd; }
.teacher-award strong { display: block; }
.award-password { display: inline-block; margin: 6px 0; padding: 4px 16px; border: 2px solid var(--gold); border-radius: 10px; color: var(--gold-hi); font-size: 28px; font-weight: 900; letter-spacing: .15em; }
.award-pluses { color: var(--gold-hi); font-size: 36px; font-weight: 900; letter-spacing: .3em; margin-top: 6px; }
#resume { height: auto; min-height: 58px; padding-top: 12px; padding-bottom: 12px; font-size: 14px; line-height: 1.4; }
.stage-center:has(.banner:not([hidden])), .stage-center:has(.panel:not([hidden])) { min-height: 210px; }

/* Natywny wybór uruchamia systemową listę iPhone/Android. */
.scenario-mobile { display: none; }
.scenario-card { text-align: left; font: inherit; touch-action: manipulation; width: 100%; }
#scenario-select { display: block; width: 100%; min-height: 52px; border: 2px solid var(--gold); border-radius: 10px; padding: 12px; background: #101b3b; color: white; font: 16px var(--font); }
#scenario-select:focus-visible { outline: 2px solid white; outline-offset: 3px; }
#scenario-description { color: #c2cbe4; font-size: 14px; line-height: 1.5; margin: 10px 0 0; }
@media (max-width: 700px), (pointer: coarse) {
  .scenario-mobile { display: block; }
  #scenario-options { display: none; }
}
#screen-title { overflow-x: hidden; }
.prize-cheque { position: relative; width: 94%; margin: -12px auto 0; padding: 16px 10px; border: 3px double #956810; border-radius: 8px; background: #fff2cc; color: #513506; box-shadow: 0 8px 25px #0008; }
.prize-cheque span { display: block; text-transform: uppercase; font-size: 11px; letter-spacing: .08em; }
.prize-cheque strong { font-family: Georgia, serif; font-size: clamp(28px, 7vw, 54px); line-height: 1.3; }
.prize-cheque b { display: block; font-size: 30px; letter-spacing: .2em; }

/* Diagramy mają stałą skalę wewnętrzną i dopasowują się do szerokości telefonu. */
.exam-chart { width: 100%; max-width: 460px; margin: 10px auto 14px; padding: 10px 4px 2px; border: 1px solid #465478; border-radius: 12px; background: #101b3b; }
.exam-chart figcaption { font-size: clamp(13px, 2vw, 17px); line-height: 1.35; padding: 0 8px 6px; color: #f6c85c; }
.exam-chart svg { display: block; width: 100%; height: auto; }
.clock-chart { max-width: 230px; }
.axis-row { display: flex; align-items: center; gap: 6px; }
.axis-row b { color: #f6c85c; min-width: 1.4em; }
.axis-row svg { flex: 1; min-width: 0; }
.exam-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin: -8px auto 12px; font-size: 14px; }
.exam-legend span { display: inline-flex; align-items: center; gap: 6px; }
.exam-legend i { display: inline-block; width: 12px; height: 12px; }
@media (max-width: 640px) {
 .question:has(.exam-chart) .hex-in { padding-inline: 10px; }
 .question:has(.exam-chart) { --tip: 8px; }
}
.number-cloud { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; max-width: 420px; margin: 12px auto; padding: 14px 22px; border: 2px dashed #8fb4e8; border-radius: 48px; background: #101b3b; font-weight: 700; }
