:root {
  --bg1: #23145f; --bg2: #4a2bb5; --ink: #20164a; --paper: #fffaf0;
  --yellow: #ffd23f; --pink: #ff5d8f; --teal: #27d3a2; --blue: #4cc3ff;
  --shadow: 0 .4rem 0 rgba(0, 0, 0, .22);
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", Nunito, "Segoe UI", system-ui, sans-serif;
  color: #fff; font-weight: 700; overflow: hidden;
  background: radial-gradient(circle at 20% 10%, rgba(255, 255, 255, .08) 0 2px, transparent 3px) 0 0 / 44px 44px, linear-gradient(160deg, var(--bg1), var(--bg2));
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none;
}
#app { height: 100%; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; background: none; }
h1 { font-size: 2.2rem; font-weight: 900; } h2 { font-size: 1.1rem; margin: 1.3rem 0 .5rem; } h2 small, h3 small { font-weight: 600; opacity: .65; margin-left: .4rem; }

.logo { font-weight: 900; font-size: 3.4rem; letter-spacing: -.03em; color: var(--yellow); text-shadow: 0 .25rem 0 rgba(0, 0, 0, .25); }
.logo span { color: #fff; } .logo.sm { font-size: 1.6rem; }
.card { background: var(--paper); color: var(--ink); border-radius: 1.6rem; box-shadow: var(--shadow); }
.big { background: var(--yellow); color: var(--ink); font-weight: 900; font-size: 1.4rem; padding: .8rem 1.8rem; border-radius: 1rem; box-shadow: 0 .35rem 0 #c79a00; transition: transform .06s, box-shadow .06s; }
.big:active { transform: translateY(.25rem); box-shadow: 0 .1rem 0 #c79a00; }
.big:disabled { opacity: .4; cursor: default; }
.ghost { padding: .5rem .9rem; border-radius: .8rem; background: rgba(255, 255, 255, .14); }
.pill { background: rgba(255, 255, 255, .16); padding: .35rem .9rem; border-radius: 99px; font-size: 1rem; }
.swatch { display: inline-block; width: 1em; height: 1em; border-radius: .25em; border: .09em solid rgba(0, 0, 0, .55); vertical-align: -.12em; }

/* ---- timer bar ---- */
.tbar { height: .7rem; background: rgba(0, 0, 0, .25); flex: none; }
.tbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--yellow), var(--teal)); background-size: 100vw 100%; animation: shrink linear forwards; }
@keyframes shrink { from { width: 100%; } to { width: 0; } }

/* ---- the puzzle ---- */
.puzzle { font-size: var(--pz, 2rem); font-weight: 900; }
.eq { display: flex; align-items: center; justify-content: center; gap: .3em; margin: .12em 0; white-space: nowrap; }
.eq { position: relative; border-radius: .3em; padding: 0 .3em; }
.eq.cur { background: #fff1b8; box-shadow: 0 0 0 .08em var(--yellow); }
.stepn { position: absolute; left: -1.5em; font-size: .5em; width: 1.7em; height: 1.7em; border-radius: 50%; background: var(--pink); color: #fff; display: flex; align-items: center; justify-content: center; }
.howto { font-size: 1.45rem; font-weight: 700; text-align: center; margin-top: .8rem; padding: 0 1rem; }
.howto b { background: var(--pink); color: #fff; border-radius: 99px; padding: .1rem .8rem; margin-right: .4rem; }
.eq.ask { margin-top: .3em; padding-top: .25em; border-top: .09em dashed rgba(32, 22, 74, .22); }
.sym { display: inline-flex; flex-direction: column; align-items: center; }
.em { font-size: 1.45em; line-height: 1.12; font-family: "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Emoji", sans-serif; }
.sym b { font-size: .42em; background: var(--teal); color: var(--ink); border-radius: 99px; padding: .05em .6em; margin-top: -.2em; animation: pop .35s backwards; }
.num { color: #6b2bd9; font-size: 1.3em; } .op { opacity: .8; }
.q { color: var(--pink); font-size: 1.5em; animation: wobble 1.6s infinite; }
.q.done { color: #0a9a72; animation: pop .4s; }
.frac { display: inline-flex; flex-direction: column; align-items: center; font-size: .68em; line-height: 1.05; }
.frac > span:first-child { border-bottom: .1em solid currentColor; padding: 0 .25em .05em; }
.frac .num { font-size: 1.15em; } .frac .sym b { font-size: .5em; }
.prompt { font-size: .5em; font-weight: 800; text-align: center; line-height: 1.35; }
.grid { display: grid; grid-template-columns: repeat(10, 1fr); width: 7.4em; margin: .25em auto 0; border: .06em solid var(--ink); background: var(--ink); gap: .03em; }
.grid i { aspect-ratio: 1; }
.legend { display: flex; gap: .7em; justify-content: center; font-size: .45em; margin-top: .5em; }
.legend .hit { background: var(--teal); border-radius: 99px; padding: 0 .6em; }
@keyframes wobble { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) scale(1.08); } }
@keyframes pop { from { transform: scale(0); } 70% { transform: scale(1.25); } }
@keyframes shake { 20%, 60% { transform: translateX(-.5rem); } 40%, 80% { transform: translateX(.5rem); } }
.shake { animation: shake .35s; }

/* =============== HOST (big screen) =============== */
.host .top { display: flex; align-items: center; gap: .8rem; padding: .7rem 1.4rem; flex: none; }
.host .top .ghost { margin-left: auto; font-size: 1.2rem; }
.setup { width: min(46rem, 94vw); margin: auto; padding: 1.8rem 2.2rem; overflow: auto; max-height: calc(100vh - 5rem); }
.seg, .chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.seg button, .chips button { background: #ece4ff; border-radius: .8rem; padding: .55rem 1rem; border: .15rem solid transparent; }
.seg button.on, .chips button.on { background: var(--yellow); border-color: var(--ink); }
.modes button { flex: 1 1 9rem; font-size: 1.15rem; text-align: left; } .modes small { display: block; font-size: .8rem; font-weight: 600; opacity: .75; }
.two { display: flex; gap: 2rem; flex-wrap: wrap; }
.setup .big { margin-top: 1.6rem; width: 100%; }
.demo { margin-top: 1rem; font-size: .85rem; font-weight: 600; background: #fff1c2; padding: .6rem .8rem; border-radius: .7rem; }

.lobby, .final { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 0 2rem 1.4rem; min-height: 0; }
.joinbox { background: var(--paper); color: var(--ink); border-radius: 1.6rem; padding: 1rem 3rem; text-align: center; box-shadow: var(--shadow); font-size: 1.5rem; }
.code { font-size: min(7.5rem, 16vh); font-weight: 900; letter-spacing: .06em; line-height: 1; color: #6b2bd9; }
.lobby h2 { font-size: 1.6rem; }
.plist { flex: 1; display: flex; flex-wrap: wrap; gap: .7rem; align-content: flex-start; justify-content: center; overflow: auto; width: 100%; }
.pchip { background: rgba(255, 255, 255, .16); padding: .5rem 1.1rem; border-radius: 99px; font-size: 1.5rem; animation: pop .35s; }
.pchip:hover { background: var(--pink); text-decoration: line-through; }
.actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%; flex: none; }

.stage { flex: 1; display: flex; gap: 1.4rem; padding: .8rem 1.4rem 1.4rem; min-height: 0; }
.board-card { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; --pz: min(8.4vh, 5vw); min-width: 0; }
.side { width: min(22rem, 26vw); display: flex; flex-direction: column; gap: 1rem; }
.side .big { margin-top: auto; } .side .stepbtn { margin-top: auto; font-size: 1.2rem; padding: .7rem; background: var(--teal); color: var(--ink); } .side .stepbtn + .big { margin-top: 0; }
.clock { font-size: 5.5rem; font-weight: 900; text-align: center; line-height: 1; color: var(--yellow); }
.count { background: rgba(255, 255, 255, .14); border-radius: 1.2rem; padding: .8rem; text-align: center; }
.count b { display: block; font-size: 3.6rem; line-height: 1; } .count span { opacity: .85; }
.wrong span { display: inline-block; background: var(--pink); border-radius: .6rem; padding: .1rem .55rem; margin: .15rem; }
.lb { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.lb li { display: flex; justify-content: space-between; gap: .6rem; background: rgba(255, 255, 255, .14); border-radius: .8rem; padding: .45rem .8rem; font-size: 1.15rem; animation: pop .4s backwards; }
.lb li:first-child { background: var(--yellow); color: var(--ink); } .lb em { font-style: normal; font-size: .85em; }
.lb li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { height: 1.6rem; background: rgba(0, 0, 0, .25); border-radius: 99px; overflow: hidden; } .meter i { display: block; height: 100%; background: var(--teal); transition: width .8s; }
.big-num { font-size: 3rem; text-align: center; }

.final h1 { margin: .2rem 0 1rem; }
.podium { display: flex; align-items: flex-end; gap: 1rem; flex: 1; min-height: 0; }
.podium > div { display: flex; flex-direction: column; align-items: center; width: 13rem; animation: pop .6s backwards; }
.podium .av { font-size: 4rem; } .podium b { font-size: 1.5rem; } .podium i { font-style: normal; opacity: .85; }
.step { width: 100%; margin-top: .4rem; border-radius: 1rem 1rem 0 0; font-size: 3rem; font-weight: 900; color: var(--ink); display: flex; justify-content: center; padding-top: .4rem; }
.p1 .step { height: 26vh; background: var(--yellow); } .p2 .step { height: 18vh; background: #dfe3ee; } .p3 .step { height: 12vh; background: #f0a36b; }
.p1 { animation-delay: .9s !important; } .p2 { animation-delay: .5s !important; } .p3 { animation-delay: .1s !important; }
.lb.rest { flex-direction: row; flex-wrap: wrap; justify-content: center; margin: .8rem 0; } .lb.rest li:first-child { background: rgba(255, 255, 255, .14); color: #fff; }
.classwin { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 1.5rem; }
.stars { font-size: 5rem; } .huge { font-size: 9rem; font-weight: 900; color: var(--yellow); line-height: 1; }

/* =============== PLAYER (student device) =============== */
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .7rem; padding: 1.2rem; }
.center p { font-size: 1.15rem; font-weight: 600; } .bigicon { font-size: 5.5rem; line-height: 1.1; animation: pop .45s; }
.join form { display: flex; flex-direction: column; gap: .7rem; width: min(20rem, 88vw); }
.join input { font: inherit; font-size: 1.4rem; text-align: center; padding: .7rem; border-radius: 1rem; border: .2rem solid transparent; background: var(--paper); color: var(--ink); user-select: text; }
.join input:focus { outline: none; border-color: var(--yellow); }
.avpick { font-size: 3.2rem; background: rgba(255, 255, 255, .14); border-radius: 1rem; padding: .2rem; } .avpick small { display: block; font-size: .8rem; opacity: .7; }
.err { color: var(--yellow); min-height: 1.4em; } .teacher { color: #fff; opacity: .6; font-size: .9rem; font-weight: 600; margin-top: 1rem; }
.result.ok { background: #0f9d73; } .result.no { background: #c7365f; }
.pts { font-size: 3rem; font-weight: 900; color: var(--yellow); animation: pop .5s; } .streak { font-size: 1.4rem !important; }
.values { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: .6rem; }
.values > span { background: rgba(0, 0, 0, .22); border-radius: .8rem; padding: .3rem .7rem; font-size: 1.2rem; } .values .em { font-size: 1.2em; }

.play { flex: 1; display: flex; flex-direction: column; gap: 1.2vh; padding: 1.2vh 3vw 1.6vh; width: min(34rem, 100%); margin: 0 auto; min-height: 0; }
.play .card { flex: 1; display: flex; align-items: center; justify-content: center; --pz: min(4.3vh, 6.6vw); min-height: 0; padding: .3rem; }
.tip { text-align: center; font-size: .85rem; font-weight: 600; opacity: .85; }
.notes { display: flex; gap: 2vw; }
.field { background: rgba(255, 255, 255, .14); border: .18rem solid transparent; border-radius: .9rem; display: flex; align-items: center; gap: .35rem; padding: 0 .6rem; height: 6vh; min-height: 2.4rem; font-size: 1.15rem; }
.field.on { border-color: var(--yellow); background: rgba(255, 255, 255, .26); }
.field i { font-style: normal; flex: 1; text-align: right; overflow: hidden; }
.note { flex: 1; min-width: 0; } .note .em { font-size: 1.3em; }
.ans { height: 7.5vh; font-size: 1.7rem; background: var(--paper); color: var(--ink); } .ans.on { background: #fff; border-color: var(--yellow); box-shadow: 0 0 0 .2rem rgba(255, 210, 63, .5); }
.ans span { font-size: 1rem; opacity: .6; } .ans i { font-weight: 900; }
.pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1vh; }
.pad button { height: 7vh; min-height: 2.6rem; border-radius: .9rem; background: rgba(255, 255, 255, .92); color: var(--ink); font-size: 1.6rem; font-weight: 900; box-shadow: 0 .25rem 0 rgba(0, 0, 0, .25); }
.pad button:active { transform: translateY(.2rem); box-shadow: none; }
.pad .go { grid-column: span 2; background: var(--teal); font-size: 1.25rem; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; } .tbar i { animation: shrink linear forwards !important; } }

/* ---- lobby QR, answer bars, teams, report ---- */
.joinrow { display: flex; align-items: stretch; gap: 1.2rem; }
.qr { background: #fff; border-radius: 1.2rem; padding: .5rem; box-shadow: var(--shadow); width: min(11rem, 22vh); display: flex; } .qr:empty { display: none; } .qr svg { width: 100%; height: auto; border-radius: .6rem; }
.side { overflow-y: auto; } .side h3 { margin-bottom: -.4rem; }
.count.slim { display: flex; align-items: baseline; justify-content: center; gap: .6rem; padding: .5rem; } .count.slim b { font-size: 2.2rem; display: inline; }
.bars { display: flex; flex-direction: column; gap: .35rem; }
.bar { display: grid; grid-template-columns: 4.6rem 1fr 1.8rem; align-items: center; gap: .5rem; font-size: 1.15rem; }
.bar span { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .bar b { text-align: right; }
.bar i { height: 1.5rem; border-radius: .5rem; background: var(--blue); transition: width .5s; }
.bar.ok i { background: var(--teal); } .bar.ok span::after { content: ' ✓'; } .bar.no i { background: var(--pink); } .bar.none i { background: rgba(255, 255, 255, .3); } .bar.none span { font-size: .8rem; opacity: .8; }
.quiet { opacity: .8; font-weight: 600; text-align: center; }
.team { background: rgba(255, 255, 255, .16); border-radius: 99px; padding: .2rem 1rem; font-size: 1rem !important; font-weight: 800 !important; align-self: center; margin-top: .4rem; }
.play .team { margin: 0; font-size: .9rem !important; }
.final h3 { margin-top: .6rem; }
.report h1 small { font-size: 1rem; font-weight: 600; opacity: .8; margin-left: .6rem; }
.rep { flex: 1; width: min(60rem, 100%); padding: 1rem 1.6rem; overflow: auto; min-height: 0; margin-bottom: 1rem; font-weight: 600; }
.rep h3 { margin: .6rem 0 .5rem; } .rep h3 small, .rrow small { font-weight: 600; opacity: .6; }
.rrow { display: grid; grid-template-columns: 16rem 1fr 3.2rem 7rem; align-items: center; gap: .8rem; margin: .35rem 0; }
.rep .meter { background: #e7e0f7; height: 1.1rem; } .rep .meter i.low { background: var(--pink); } .rep .meter i.mid { background: var(--yellow); }
.rrow em { font-style: normal; font-size: .8rem; border-radius: 99px; padding: .1rem .6rem; text-align: center; } .t-low { background: #ffd3e0; } .t-mid { background: #fff1b8; } .t-high { background: #c9f5e6; }
.rep table { width: 100%; border-collapse: collapse; } .rep th, .rep td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid #e7e0f7; } .rep th { font-size: .8rem; opacity: .6; }
@media print { body { background: #fff; color: #000; overflow: visible; height: auto; } .top, .actions { display: none !important; } .rep { box-shadow: none; overflow: visible; } html, #app { height: auto; } }

/* ---- home / quick start ---- */
.home { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.1rem; padding: 1rem; text-align: center; }
.home .logo { font-size: min(6rem, 14vw); } .home .tag { font-size: 1.3rem; font-weight: 600; opacity: .85; }
.quick { font-size: min(3.2rem, 8vw); padding: 1.4rem 4rem; border-radius: 1.6rem; margin-top: 1rem; animation: pulse 1.8s infinite; }
.home .sum { font-weight: 600; opacity: .8; } .home .ghost { font-size: 1.1rem; } .home .demo { color: var(--ink); max-width: 34rem; }
@keyframes pulse { 50% { transform: scale(1.04); } }

.center small { opacity: .7; } .center .ghost { margin-top: 1.2rem; font-size: .95rem; }
.lobby .demo { color: var(--ink); }

/* ---- game feel: drum-roll reveal, answer slam, flames, sliding leaderboard ---- */
.stage { position: relative; }
.suspense { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; background: rgba(35, 20, 95, .82); font-size: 3rem; font-weight: 900; animation: fadein .25s; }
.suspense span { font-size: 7rem; animation: drum .12s infinite alternate; }
@keyframes drum { to { transform: rotate(-8deg) scale(1.08); } } @keyframes fadein { from { opacity: 0; } }
.fresh .q.done { animation: slam .65s cubic-bezier(.2, 1.5, .4, 1) .15s backwards; }
@keyframes slam { from { transform: scale(5); opacity: 0; } }
.side .lb li { animation: none; position: relative; } .lb .up { color: #0a9a72; background: #d9fbef; border-radius: 99px; padding: 0 .4em; font-size: .75em; animation: pop .4s 1.4s backwards; }
.result { animation: flash .5s; } @keyframes flash { from { filter: brightness(2.2); } }
.result.no { background: #7a4aa8; }
.streak span { display: inline-block; animation: flame .6s infinite alternate; }
.streak.s3 { font-size: 1.8rem !important; } .streak.s4 { font-size: 2.2rem !important; } .streak.s5 { font-size: 2.6rem !important; color: var(--yellow); }
.streak.s3 span { font-size: 1.3em; } .streak.s4 span { font-size: 1.6em; } .streak.s5 span { font-size: 2em; }
@keyframes flame { to { transform: scale(1.25) rotate(6deg); } }
.streak-lost { opacity: .9; }
.onfire { box-shadow: inset 0 0 0 .5rem var(--yellow), inset 0 0 6rem #ff7a00; animation: flash .5s, glow 1s infinite alternate; }
@keyframes glow { to { box-shadow: inset 0 0 0 .5rem #ff7a00, inset 0 0 9rem #ffb300; } }
.setup h1 small { display: block; font-size: 1rem; font-weight: 600; opacity: .65; }

/* ---- teacher preview ---- */
.actions .left { display: flex; gap: .5rem; }
.preview h1 small { font-size: 1rem; font-weight: 600; opacity: .8; margin-left: .6rem; }
.pgrid { flex: 1; width: 100%; overflow: auto; min-height: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: 1rem; align-content: start; padding: .2rem .2rem 1rem; }
.pcard { padding: .6rem .9rem 1rem; --pz: 1.35rem; } .pcard .q, .pcard .sym b { animation: none; }
.pcard header { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; font-size: .95rem; }
.pcard header b { background: var(--ink); color: #fff; border-radius: 50%; width: 1.7rem; height: 1.7rem; display: flex; align-items: center; justify-content: center; }
.pcard header .ghost { margin-left: auto; background: #ece4ff; color: var(--ink); padding: .25rem .7rem; font-size: .85rem; }
