/* The student's screen: phone first. */
body { min-height: 100vh; }
.top, main {
  max-width: 980px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.top { display: flex; align-items: center; gap: 10px; padding-block: 10px; }
.top h1 { font-size: 1.25rem; white-space: nowrap; }
.top .titles { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.top .spacer { flex: 1; }
.top .brand { height: 34px; }
.progress { font-weight: var(--w-bold); white-space: nowrap; }
/* During a quiz on a phone, the counter and Leave need the room more than the title does. */
@media (max-width: 560px) { body.quizzing .top h1, body.quizzing .top .fsBtn { display: none; } }
#leaveBtn { padding: 6px 10px; font-size: .85rem; }
.themeBtn { padding: 7px 9px; }
main { padding-block: 4px 36px; }
.btn { white-space: normal; text-align: center; }
.btn.big { width: 100%; padding: 13px; font-size: 1.1rem; }
.card { padding: 16px; display: grid; gap: 10px; align-content: start; }
.card h2 { font-size: 1.25rem; }
.card.narrow { max-width: 520px; margin: 18px auto 0; }
.card.wide { max-width: 900px; margin: 8px auto 0; }

.intro { display: grid; gap: 6px; margin: 6px 0 16px; max-width: 760px; }
.lead { font-size: 1.12rem; font-weight: var(--w-semi); }
.homeGrid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .homeGrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.joinForm { display: grid; gap: 10px; }
#code { width: 100%; font: var(--w-bold) 2rem/1 var(--font); letter-spacing: .3em; text-transform: uppercase; text-align: center; padding: 11px 8px 11px calc(8px + .3em); }
#name { width: 100%; font-size: 1.2rem; }
#joinError, #nameError { min-height: 1.3em; }

.ready { max-width: 620px; margin: 18px auto 0; }
.rules { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }

.countdown { display: grid; place-items: center; align-content: center; min-height: 50vh; text-align: center; }
.count { font-size: 7rem; font-weight: 700; line-height: 1; color: var(--answer); }

/* The quiz: question, answer and keypad fit one phone screen. */
.quiz { max-width: 440px; margin: 0 auto; display: grid; gap: 12px; justify-items: center; padding-top: 4px; }
.timer { position: relative; width: 100%; height: 10px; border-radius: 99px; background: var(--hover); border: 1px solid var(--line); overflow: hidden; }
.timerFill { position: absolute; inset: 0 auto 0 0; width: 0; background: #1f9d55; }
.timerMark { position: absolute; top: 0; bottom: 0; left: 33.33%; width: 2px; background: var(--ink); opacity: .55; }
.question { font-size: clamp(3rem, 15vw, 5.2rem); font-weight: 700; line-height: 1.05; margin-top: 6px; white-space: nowrap; }
.answer { min-width: 4.2ch; height: 1.5em; font-size: clamp(2.4rem, 11vw, 3.6rem); font-weight: 700; line-height: 1; border: 2.5px solid var(--line); border-radius: 14px; background: var(--board); color: var(--answer); padding: 0 14px; display: flex; align-items: center; justify-content: center; }
.answer.right { border-color: #1f9d55; background: rgba(31, 157, 85, .16); }
.answer.wrong { border-color: #8f1018; background: rgba(143, 16, 24, .16); animation: shake .28s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.caret { width: 3px; height: .9em; background: var(--answer); margin-left: 3px; animation: blink 1s steps(1) infinite; }
.answer.right .caret, .answer.wrong .caret { visibility: hidden; }
@keyframes blink { 50% { opacity: 0; } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.key { font: var(--w-bold) 1.7rem/1 var(--font); padding: 14px 0; border-radius: 12px; border: 1.5px solid var(--line); background: var(--board); cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.key:active { background: var(--hover); transform: translateY(1px); }
.key.go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.key.back { color: var(--muted); }
@media (min-height: 760px) { .key { padding: 18px 0; } }
.keyHint { text-align: center; }

.result { max-width: 640px; margin: 8px auto 0; }
.score { font-size: 1.2rem; color: var(--muted); }
.score b { font-size: 4.2rem; color: var(--answer); line-height: 1; }
.attempts { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.attempts li { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 10px; }
.attempts li.todo { color: var(--muted); border-style: dashed; }
.linkish { background: none; border: 0; padding: 0; font-weight: var(--w-semi); text-decoration: underline; cursor: pointer; }

/* My results */
.tabs { display: flex; gap: 6px; border-bottom: 1.5px solid var(--line); }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 14px; font-weight: var(--w-bold); color: var(--muted); cursor: pointer; margin-bottom: -1.5px; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--answer); }
.summaryRow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.summaryRow div { display: grid; }
.summaryRow b { font-size: 1.7rem; line-height: 1.1; }
.chartTitle { font-size: 1rem; margin-top: 6px; }
.chartBox { position: relative; }
.chart { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axisLine { stroke: var(--muted); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--answer); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--answer); stroke: var(--board); stroke-width: 2; }
.chart .dot.on { r: 6.5; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--board); border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: .84rem; pointer-events: none; box-shadow: var(--shadow); white-space: nowrap; }
.tableScroll { overflow-x: auto; }
table.history tr[data-k] { cursor: pointer; }
table.history tr[data-k]:hover, table.history tr.sel { background: var(--hover); }
.detail { display: grid; gap: 6px; border-top: 1.5px solid var(--line); padding-top: 12px; scroll-margin-top: 12px; }
.detail:empty { display: none; }
.detail h3 { font-size: 1.05rem; }
