html, body { height: 100%; overflow: hidden; }
#host { position: fixed; inset: 0; }

#quiz {
  position: fixed; inset: 0; overflow-y: auto; padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px; max-width: 560px; margin: 0 auto;
}
/* centred when it fits, scrolls from the top when it doesn't (justify-content: center would cut the top off) */
#quiz { justify-content: flex-start; }
#quiz > :first-child { margin-top: auto; }
#quiz > :last-child { margin-bottom: auto; }
.qprompt { font-size: clamp(20px, 5.5vw, 26px); font-weight: 600; line-height: 1.25; margin: 0 0 6px; }
#quiz pre { margin: 0; font: 14px/1.45 ui-monospace, monospace; background: #0F2B32; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; white-space: pre-wrap; overflow-x: auto; }
.col { display: flex; flex-direction: column; gap: 10px; }

.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; gap: 14px; align-items: center; text-align: left; padding: 14px 16px; background: #0F2B32; border: 1px solid var(--line); border-radius: 10px; }
.opt b { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; border: 1px solid #344F54; font-size: 14px; color: var(--mute); }
.opt.pick, .opt.sel { border-color: var(--accent); }
.opt.pick b, .opt.sel b { background: var(--accent); border-color: var(--accent); color: #0F2B32; }

.scale { display: grid; grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)); gap: 8px; }
.scale button { font-size: 18px; font-weight: 600; padding: 14px 0; background: #0F2B32; border: 1px solid var(--line); }
.scale button.sel { background: var(--accent); border-color: var(--accent); color: #0F2B32; }
.scale-l { display: flex; justify-content: space-between; color: var(--mute); font-size: 13px; }

.saved { margin: 0; min-height: 1.2em; color: var(--mute); font-size: 14px; }

/* results on a phone (#results itself gets the .res class) */
#results { margin-top: 10px; font-size: 14px; }
#results .bar { grid-template-columns: 28px 1fr 44px; grid-template-rows: auto 8px; gap: 4px 12px; font-size: 15px; }
#results .key { width: 28px; height: 28px; font-size: 13px; border-width: 1px; grid-row: 1 / 3; grid-column: 1; }
#results .lbl { grid-row: 1; grid-column: 2; white-space: normal; overflow: visible; }
#results .track { grid-row: 2; grid-column: 2; height: 6px; }
#results .num { grid-row: 1 / 3; grid-column: 3; font-size: 13px; }
#results .hist { height: 140px; gap: 4px; }
#results .cnt, #results .clbl { font-size: 12px; }
#results .cloud { min-height: 0; font-size: 12px; }

/* "this or that" (waiting room game, at your own pace) */
.tot-top { display: flex; justify-content: space-between; color: var(--mute); font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.tot-progress { height: 4px; border-radius: 2px; background: #1D383F; overflow: hidden; margin-top: -4px; }
.tot-progress i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.tot-btns { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.tot-btn { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 96px; padding: 18px 20px; text-align: left; background: #0F2B32; border: 2px solid var(--line); border-radius: 16px; font-size: 22px; transition: border-color .15s, background .15s; }
.tot-btn b { font-weight: 800; }
.tot-btn .tot-pct { flex: none; font-size: 22px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.tot-btn.sel { border-color: var(--accent); background: rgba(0,170,170,.14); }
.tot-ou { align-self: center; color: var(--mute); font-size: 14px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }
.tot-note { margin: -4px 0 0; text-align: center; color: var(--mute); font-size: 14px; }
.tot-mine { display: flex; flex-direction: column; gap: 4px; }
.tot-li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 12px; background: #0F2B32; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.tot-li b { flex: none; color: var(--accent); font-variant-numeric: tabular-nums; }

#off { position: fixed; top: 8px; right: 10px; font-size: 12px; color: var(--mute); z-index: 9; }

/* laptops: same layout, just bigger (most students follow on a PC) */
@media (min-width: 900px) and (min-height: 560px) {
  #quiz { max-width: 760px; gap: 18px; }
  .qprompt { font-size: 34px; margin-bottom: 10px; }
  #quiz pre { font-size: 17px; padding: 16px 18px; }
  .opts { gap: 10px; }
  .opt { font-size: 20px; padding: 18px 20px; gap: 18px; }
  .opt:hover { border-color: #344F54; }
  .opt b { width: 34px; height: 34px; font-size: 16px; }
  .scale button { font-size: 22px; padding: 18px 0; }
  .scale button:hover { border-color: #344F54; }
  .scale-l, .saved { font-size: 16px; }
  #quiz input { font-size: 20px; padding: 16px 18px; }
  #quiz .send { font-size: 18px; padding: 14px; }
  #results { font-size: 16px; }
  #results .bar { grid-template-columns: 34px 1fr 56px; grid-template-rows: auto 10px; font-size: 18px; }
  #results .key { width: 34px; height: 34px; font-size: 15px; }
  #results .track { height: 10px; }
  #results .num { font-size: 16px; }
  #results .hist { height: 200px; }
  #results .cnt, #results .clbl { font-size: 15px; }
  #results .cloud { font-size: 15px; }
}
