/* Live Training Quiz - look and feel. Dark, big and high-contrast so it reads well on a projector. */
:root {
  --bg: #130d2b;
  --panel: #221a47;
  --panel2: #2d2360;
  --ink: #ffffff;
  --muted: #b9b3dc;
  --accent: #8a6bff;
  --good: #2fd27a;
  --bad: #ff5b6e;
  --a: #e21b3c;
  --b: #1368ce;
  --c: #d89e00;
  --d: #26890c;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 18px; line-height: 1.35; -webkit-text-size-adjust: 100%; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.15; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- buttons & forms ---------- */
.btn { border: 0; border-radius: 14px; padding: .7em 1.2em; font-weight: 800; background: var(--panel2); color: var(--ink); transition: transform .08s, filter .15s; }
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .35; cursor: not-allowed; filter: none; transform: none; }
.btn.primary { background: var(--accent); }
.btn.good { background: #1f9d5b; }
.btn.danger { background: #b5233a; }
.btn.ghost { background: transparent; border: 2px solid var(--panel2); }
.btn.small { padding: .35em .8em; font-size: .85em; border-radius: 10px; }
.btn.big { font-size: 1.35em; padding: .75em 1.6em; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; background: #0e0922; border: 2px solid var(--panel2); border-radius: 12px; padding: .7em .9em; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; min-height: 340px; resize: vertical; line-height: 1.45; }
label { display: block; font-weight: 700; margin: 1em 0 .35em; }
.hint { color: var(--muted); font-size: .9em; }
.err { color: var(--bad); font-weight: 700; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* ---------- management pages (login, home, editor) ---------- */
.page { max-width: 980px; margin: 0 auto; padding: 28px 18px 80px; }
.card { background: var(--panel); border-radius: var(--radius); padding: 20px 22px; margin: 16px 0; }
.card h2 { font-size: 1.3em; }
.list-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--panel2); }
.list-item:first-of-type { border-top: 0; }
.list-item .grow { flex: 1; min-width: 180px; }
.list-item .title { font-weight: 800; }
.badge { display: inline-block; font-size: .75em; font-weight: 800; padding: .15em .65em; border-radius: 99px; background: var(--panel2); vertical-align: middle; }
.badge.comp { background: #7a3cff; } .badge.disc { background: #138a8a; }
.choice { display: flex; gap: 14px; flex-wrap: wrap; }
.choice label { flex: 1; min-width: 240px; margin: 0; background: #0e0922; border: 3px solid var(--panel2); border-radius: 14px; padding: 14px 16px; cursor: pointer; }
.choice input { width: auto; margin-right: 8px; }
.choice label.on { border-color: var(--accent); background: #1a1340; }
.preview-q { background: #0e0922; border-radius: 12px; padding: 10px 14px; margin: 8px 0; font-size: .95em; }
.preview-q .o { color: var(--muted); } .preview-q .o.ok { color: var(--good); font-weight: 800; }
.toast { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); background: #b5233a; padding: .7em 1.2em; border-radius: 12px; font-weight: 800; z-index: 99; max-width: 90vw; box-shadow: 0 6px 24px #0008; }
.toast.ok { background: #1f9d5b; }
pre.example { background: #0e0922; padding: 12px 14px; border-radius: 12px; overflow-x: auto; font-size: 14px; }
details summary { cursor: pointer; font-weight: 800; }

/* ---------- session (projector) screen ---------- */
body.stage { font-size: clamp(16px, 1.45vw, 30px); overflow-x: hidden; }
.stage-wrap { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 1em; padding: .6em 1.2em; background: #0e0922; font-weight: 700; flex-wrap: wrap; }
.topbar .grow { flex: 1; }
.topbar .code { background: var(--accent); padding: .1em .7em; border-radius: 99px; font-weight: 900; letter-spacing: .08em; }
.main { flex: 1; min-height: 0; overflow-y: auto; padding: .8em 2em; display: flex; flex-direction: column; gap: .7em; }
.controls { position: sticky; bottom: 0; display: flex; gap: .8em; align-items: center; padding: .8em 1.2em; background: #0e0922; border-top: 2px solid var(--panel2); flex-wrap: wrap; z-index: 5; }
.controls .grow { flex: 1; }
.controls .btn { font-size: 1.05em; }

.lobby { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 2em; align-items: start; }
@media (max-width: 900px) { .lobby { grid-template-columns: 1fr; } }
.join-box { background: var(--panel); border-radius: 24px; padding: 1.2em 1.6em; text-align: center; }
.join-url { font-size: 1.1em; word-break: break-all; color: var(--muted); }
.join-code { font-size: clamp(56px, min(9vw, 17vh), 170px); font-weight: 900; letter-spacing: .12em; line-height: 1; margin: .1em 0; }
.qr { background: #fff; border-radius: 16px; padding: 14px; display: inline-block; margin-top: .4em; }
.qr svg, .qr img { display: block; width: min(22vw, 30vh, 320px); height: auto; min-width: 150px; }
.chips { display: flex; flex-wrap: wrap; gap: .6em; }
.chip { background: var(--panel2); border-radius: 99px; padding: .35em .5em .35em 1em; font-weight: 800; display: inline-flex; align-items: center; gap: .6em; animation: pop .25s ease-out; }
.chip.plain { padding: .35em 1em; }
.chip button { background: #b5233a; border: 0; color: #fff; border-radius: 99px; padding: .15em .7em; font-weight: 800; font-size: .75em; }
.count-big { font-size: 1.5em; font-weight: 900; }

.qhead { display: flex; align-items: center; gap: 1em; }
.qhead .grow { flex: 1; }
.qnum { color: var(--muted); font-weight: 800; }
.qtext { font-size: clamp(26px, min(3.6vw, 7vh), 80px); font-weight: 900; line-height: 1.12; margin: 0; }
.timer { min-width: 2em; height: 2em; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 2em; font-weight: 900; font-variant-numeric: tabular-nums; }
.timer.low { background: var(--bad); animation: pulse .5s infinite alternate; }
.timebar { height: 12px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.timebar > i { display: block; height: 100%; background: var(--accent); width: 100%; transition: width .12s linear; }
.cards { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: minmax(0, 1fr); gap: .7em; flex: 1; min-height: 9em; }
.ans { border-radius: 16px; padding: .5em 1em; display: flex; flex-direction: column; justify-content: center; gap: .3em; height: 100%; font-size: clamp(20px, min(2.6vw, 5vh), 52px); font-weight: 800; position: relative; animation: rise .35s ease-out both; overflow: hidden; }
.ans.still { animation: none; }
.ans .top { display: flex; align-items: center; gap: .7em; }
.ans.right { animation: glow .6s ease-out both; }
.ans .shape { font-size: .9em; opacity: .9; }
.ans .letter { background: #0003; border-radius: 10px; min-width: 1.5em; text-align: center; font-weight: 900; padding: 0 .3em; }
.ans .txt { flex: 1; }
.ans.c0, .pbtn.c0 { background: var(--a); } .ans.c1, .pbtn.c1 { background: var(--b); }
.ans.c2, .pbtn.c2 { background: var(--c); } .ans.c3, .pbtn.c3 { background: var(--d); }
.ans.dim { opacity: .3; }
.ans.right { box-shadow: 0 0 0 6px #fff, 0 0 40px 10px #fff8; }
.ans .tick { font-weight: 900; font-size: 1.2em; }
.who { font-size: .6em; font-weight: 700; display: flex; flex-wrap: wrap; gap: .3em; max-height: 4.2em; overflow: hidden; }
.who span { background: #0004; border-radius: 99px; padding: .05em .7em; }
.cardwrap { display: flex; flex-direction: column; min-height: 0; }
.explain { background: var(--panel); border-left: 10px solid var(--good); border-radius: 12px; padding: .7em 1em; font-size: 1.15em; }
.statusline { display: flex; gap: 1.2em; align-items: center; flex-wrap: wrap; }
.waiting-names { color: var(--muted); }

.lb-row { display: flex; align-items: center; gap: 1em; background: var(--panel); border-radius: 16px; padding: .3em 1em; font-size: clamp(18px, 4.8vh, 44px); font-weight: 800; margin: .15em 0; animation: slide .5s ease-out both; }
.lb-row .rk { background: var(--accent); width: 1.6em; height: 1.6em; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.lb-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .add { color: var(--good); font-size: .8em; }
.lb-row .tot { min-width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 1.2em; min-height: 46vh; margin-top: 1em; }
.pod { width: min(26vw, 380px); text-align: center; }
.pod .who-name { font-size: 1.7em; font-weight: 900; margin-bottom: .2em; min-height: 1.3em; word-break: break-word; }
.pod .block { border-radius: 16px 16px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: .4em; font-weight: 900; transition: transform .6s cubic-bezier(.2, 1.4, .4, 1); }
.pod .block .medal { font-size: 2.6em; }
.pod .block .pts { font-size: 1.1em; opacity: .9; }
.pod.p1 .block { height: 34vh; background: linear-gradient(#ffd34d, #c99400); color: #4b3600; }
.pod.p2 .block { height: 26vh; background: linear-gradient(#e6e9f2, #9aa1b5); color: #2d3040; }
.pod.p3 .block { height: 20vh; background: linear-gradient(#e0a070, #a1612f); color: #3d2209; }
.pod.hidden .block { background: var(--panel); color: var(--muted); }
.pod.hidden .who-name, .pod.hidden .medal, .pod.hidden .pts { visibility: hidden; }
.pod.hidden .block::after { content: "?"; font-size: 3em; }
.pod.show { animation: bounce .8s both; }
canvas#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }

.overlay { position: fixed; inset: 0; background: #0b0720ee; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1em; text-align: center; padding: 1em; }
.overlay .pickname { font-size: clamp(48px, 9vw, 190px); font-weight: 900; line-height: 1.05; word-break: break-word; }
.overlay .pickname.spin { opacity: .6; }
.overlay .lead { font-size: 1.6em; color: var(--muted); font-weight: 800; }

.results-wrap { overflow: auto; background: var(--panel); border-radius: 16px; flex: 1; min-height: 0; }
table.res { border-collapse: collapse; width: 100%; font-size: .72em; }
table.res th, table.res td { padding: .45em .7em; border-bottom: 1px solid var(--panel2); text-align: center; white-space: nowrap; }
table.res th { position: sticky; top: 0; background: #0e0922; z-index: 2; }
table.res td.name, table.res th.name { text-align: left; position: sticky; left: 0; background: #1a1340; z-index: 1; font-weight: 800; }
table.res th.name { z-index: 3; background: #0e0922; }
table.res td.ok { background: #14532d; } table.res td.no { background: #5c1a26; } table.res td.skip { color: var(--muted); }
table.res td small { display: block; opacity: .85; }

/* ---------- phone (learner) page ---------- */
body.phone { font-size: 20px; }
.phone-wrap { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: 18px; max-width: 560px; margin: 0 auto; }
.phone-top { display: flex; justify-content: space-between; font-weight: 800; color: var(--muted); font-size: .85em; margin-bottom: 10px; min-height: 1.4em; }
.phone-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; text-align: center; }
.phone-body h1 { font-size: 1.9em; }
.bigmsg { font-size: 1.6em; font-weight: 900; }
.pgrid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-height: 55vh; }
.pbtn { border: 0; border-radius: 20px; color: #fff; font-weight: 900; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px; box-shadow: 0 6px 0 #0005; }
.pbtn .L { font-size: 3.2em; line-height: 1; }
.pbtn .T { font-size: .7em; font-weight: 700; opacity: .95; word-break: break-word; }
.pbtn:active { transform: translateY(4px); box-shadow: 0 2px 0 #0005; }
.pbtn.chosen { outline: 6px solid #fff; }
.pgrid.locked .pbtn { opacity: .35; pointer-events: none; }
.pgrid.locked .pbtn.chosen { opacity: 1; }
.result-ok { color: var(--good); } .result-no { color: var(--bad); }
.rank { font-size: 3em; font-weight: 900; }
.pill { display: inline-block; background: var(--panel2); border-radius: 99px; padding: .3em 1em; font-weight: 800; }
.picked { background: var(--accent); border-radius: 18px; padding: 14px; font-weight: 900; font-size: 1.3em; animation: pulse .6s infinite alternate; }
.spinner { width: 46px; height: 46px; border: 6px solid var(--panel2); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto; }

/* ---------- animations ---------- */
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slide { from { transform: translateX(-60px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.07); } }
@keyframes bounce { 0% { transform: translateY(80px) scale(.8); opacity: 0; } 60% { transform: translateY(-14px) scale(1.04); opacity: 1; } 100% { transform: none; } }
@keyframes glow { from { transform: scale(.94); } 60% { transform: scale(1.03); } to { transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
