.screen { min-height: 100vh; padding: 18px; }
/* On phones, 100vh is the height with the browser's toolbars hidden (iPhone Safari especially), so the
   page scrolled a little. dvh is the height you can actually see; older browsers keep using vh. */
@supports (height: 100dvh) { .screen { min-height: 100dvh; } }
.center-col { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.join-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; }
.lbl { font-weight: 800; font-size: 18px; color: var(--ink); }
.big-input { font-size: 30px; }
.hint { opacity: .85; margin: 0; }
.quiz-name { font-size: 26px; font-weight: 800; }

.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.avatars button { font-size: 30px; border: 3px solid transparent; background: #f1eefb; border-radius: 12px; padding: 4px 0; cursor: pointer; }
.avatars button.on { border-color: var(--a3); background: #fff; transform: scale(1.12); }

.big-av { font-size: 110px; line-height: 1; }
.msg-title { margin: 0; font-size: 34px; text-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
.msg-text { margin: 0; font-size: 22px; opacity: .9; max-width: 420px; white-space: pre-line; overflow-wrap: anywhere; }
.me-chip { position: fixed; top: 12px; left: 12px; background: rgba(0, 0, 0, .35); border-radius: 30px; padding: 4px 14px; font-weight: 800; }

/* question */
#qScreen { display: flex; flex-direction: column; gap: 12px; }
#qScreen:not(.hidden) { display: flex; }
.q-top { display: flex; align-items: center; justify-content: space-between; }
.q-num, .q-score { background: rgba(0, 0, 0, .35); border-radius: 20px; padding: 4px 14px; font-weight: 800; }
.small-timer { width: 70px; height: 70px; }
.small-timer .num { font-size: 26px; }
.p-question { background: #fff; color: var(--ink); border-radius: var(--radius); padding: 12px 16px; font-size: 24px; font-weight: 800; text-align: center; box-shadow: var(--shadow); }
.p-img { max-height: 22vh; max-width: 100%; align-self: center; border-radius: 14px; }
.p-answers { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.p-answers.two { grid-template-columns: 1fr; }
.p-answers .ans { flex-direction: column; justify-content: center; text-align: center; font-size: 22px; min-height: min(120px, 15vh); }
.p-answers .ans .shape { width: 48px; height: 48px; }
.p-answers .ans:active { transform: scale(.96); }
.p-answers .ans.picked { outline: 5px solid #fff; transform: scale(1.03); }

.p-hint { text-align: center; font-weight: 800; font-size: 18px; color: var(--gold); margin: -4px 0; }
.p-action { display: flex; gap: 10px; }
.p-action:empty { display: none; }
.p-action .btn.big { flex: 1; }

/* multi-select tick boxes */
.ans .tickbox { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 8px; border: 3px solid #fff; display: grid; place-items: center; font-size: 20px; }
.ans.ticked { outline: 5px solid #fff; }
.ans.ticked .tickbox { background: #fff; }
.ans.ticked .tickbox::after { content: '✔'; color: var(--good); }

/* put in order */
.ans .order-pos { position: absolute; top: 8px; left: 8px; width: 34px; height: 34px; border-radius: 50%; background: rgba(0, 0, 0, .25);
  display: grid; place-items: center; font-size: 20px; }
.ans.placed { opacity: .75; }
.ans.placed .order-pos, .order-pos.on { background: #fff; color: var(--ink); }
.order-pos.on { position: static; flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; }

/* typed answers and sliders */
.p-answers.form { display: flex; flex-direction: column; justify-content: center; }
.typed-form { display: flex; flex-direction: column; gap: 14px; }
.slider-box { display: flex; flex-direction: column; gap: 14px; background: rgba(0, 0, 0, .25); border-radius: var(--radius); padding: 18px; }
.slider-value { text-align: center; font-size: 56px; font-weight: 800; color: var(--gold); line-height: 1; }
.slider-box input[type=range] { width: 100%; height: 40px; accent-color: var(--gold); }
.slider-ends { display: flex; justify-content: space-between; font-weight: 700; opacity: .85; margin-top: -10px; }
.slider-nudge { display: flex; justify-content: center; gap: 20px; }
.slider-nudge .btn { width: 70px; font-size: 26px; }
.p-answers.pin-mode { align-items: center; --maxh: 52vh; }
.p-answers.pin-mode .pin-board { cursor: crosshair; }
.res-pin { width: 100%; display: flex; justify-content: center; --maxh: 30vh; }
#qScreen { padding-bottom: 76px; padding-bottom: calc(70px + env(safe-area-inset-bottom)); }  /* keep Submit buttons clear of the sound button */
.res-guess { font-size: 20px; font-weight: 700; }
.res-answer-tile.small { font-size: 18px; padding: 6px 12px; justify-content: flex-start; gap: 10px; }
.final-sub { font-size: 18px; font-weight: 700; }

/* result */
#resultScreen.good { background: radial-gradient(circle, rgba(34, 197, 94, .55), transparent 70%); }
#resultScreen { overflow-y: auto; }
#resultScreen.bad { background: radial-gradient(circle, rgba(239, 68, 68, .5), transparent 70%); }
.result-icon { font-size: 110px; line-height: 1; }
.result-title { margin: 0; font-size: 40px; text-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
.result-points { font-size: 34px; font-weight: 800; background: rgba(0, 0, 0, .35); border-radius: 16px; padding: 6px 22px; }
.res-answer { display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(340px, 100%); }
.res-answer-label { font-size: 18px; font-weight: 800; opacity: .9; }
.res-answer-tile { width: 100%; cursor: default; font-size: 24px; justify-content: center; padding: 10px 16px; }
.res-answer-tile .shape { width: 34px; height: 34px; }
.result-streak { font-size: 24px; font-weight: 800; color: var(--gold); min-height: 1.2em; }
.result-rank { font-size: 22px; opacity: .95; }

/* final */
#finalScreen:not(.hidden) { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.final-wrap { display: flex; gap: 30px; align-items: center; justify-content: center; flex-wrap: wrap; width: 100%; max-width: 1000px;
  background: rgba(0, 0, 0, .25); border-radius: 24px; padding: 26px; }
.final-me { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.final-me .big-av { font-size: 96px; }
.final-text { font-size: 26px; font-weight: 800; text-align: center; }
.final-board { flex: 1; min-width: 280px; }
.final-board .row { font-size: 19px; grid-template-columns: 30px 38px 1fr auto; gap: 8px; padding: 8px 12px; }
.final-board .row .av { font-size: 28px; }
.final-board .row > div:nth-child(3) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 500px) { .final-wrap { padding: 16px; } }
.again { max-width: 320px; }

/* The question screen is exactly the visible screen height: everything scales to fit, and if the
   answers still can't fit (a long list), only the answers scroll, never the whole page.
   --vh is 1% of the height you can actually see (set by player.js; in Safari, with its toolbars
   showing, that's less than 1vh). */
#qScreen { height: calc(var(--vh, 1vh) * 100); min-height: 0; overflow: hidden; gap: clamp(6px, calc(var(--vh, 1vh) * 1.4), 12px); padding-top: clamp(8px, calc(var(--vh, 1vh) * 2), 18px); }
#qScreen .small-timer { width: clamp(44px, calc(var(--vh, 1vh) * 9), 70px); height: clamp(44px, calc(var(--vh, 1vh) * 9), 70px); }
#qScreen .small-timer .num { font-size: clamp(16px, calc(var(--vh, 1vh) * 3.4), 26px); }
#qScreen .p-question { font-size: clamp(16px, calc(var(--vh, 1vh) * 3.1), 24px); padding: clamp(6px, calc(var(--vh, 1vh) * 1.4), 12px) 14px; flex: none; }
/* The picture gives way first: it shrinks (down to a small strip) before the answers do. */
#qScreen .p-img { max-height: calc(var(--vh, 1vh) * 22); flex: 0 1 auto; min-height: 48px; object-fit: contain; }
#qScreen .p-answers { flex: 1 0 auto; min-height: 124px; overflow-y: auto; grid-auto-rows: minmax(52px, 1fr); container-type: size; }
#qScreen .p-answers.form, #qScreen .p-answers.pin-mode { grid-auto-rows: auto; container-type: normal; }
#qScreen .p-answers .ans { min-height: 0; font-size: clamp(15px, calc(var(--vh, 1vh) * 2.7), 22px); gap: clamp(4px, calc(var(--vh, 1vh) * 1), 10px); padding: 8px; line-height: 1.15; overflow: hidden; }
#qScreen .p-answers .ans .shape { width: clamp(24px, calc(var(--vh, 1vh) * 5.5), 48px); height: clamp(24px, calc(var(--vh, 1vh) * 5.5), 48px); }
/* Short buttons: the shape goes beside the word instead of above it, so the word always fits. */
@container (max-height: 250px) {
  #qScreen .p-answers .ans { flex-direction: row; gap: 8px; }
  #qScreen .p-answers .ans .shape { width: 26px; height: 26px; }
}
#qScreen .p-hint, #qScreen .p-action, #qScreen .q-top { flex: none; }

/* Flock Together */
.sheep { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; }
#flockQScreen { display: flex; flex-direction: column; gap: 12px; }
#flockQScreen.hidden { display: none; }
.fq-answer { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.fq-answer.hidden { display: none; }
.fq-input { text-align: center; }
.fq-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; overflow-y: auto; }
.fq-picks .ans { justify-content: center; text-align: center; font-size: 20px; min-height: 70px; border: 0; color: #fff; font-family: inherit; font-weight: 800; cursor: pointer; }
.fq-picks .ans.picked { outline: 5px solid #fff; transform: scale(1.03); }
.fq-picks .ans:disabled:not(.picked) { opacity: .45; }
.fq-locked { flex: 1; }
.fq-locked.hidden { display: none; }
.baa-btn { background: #fff; color: var(--ink); }
.hurry-toast { position: fixed; left: 50%; bottom: 76px; translate: -50% 0; z-index: 60; background: #fff; color: var(--ink); font-weight: 900;
  padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); white-space: nowrap; }
.hurry-toast.hidden { display: none; }
.fv-pairs { display: flex; flex-direction: column; gap: 12px; width: min(440px, 100%); }
.fv-pair { background: rgba(255, 255, 255, .95); color: var(--ink); border-radius: 18px; padding: 12px; box-shadow: var(--shadow); }
.fv-words { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: baseline; font-size: 20px; margin-bottom: 8px; }
.fv-words span { color: var(--muted); font-size: 15px; }
.fv-buttons { display: flex; gap: 8px; }
.fv-buttons .btn { flex: 1; background: #ece9f6; color: var(--ink); }
.fv-buttons .btn.on { background: var(--a3); color: #fff; }
.result-icon .sheep { font-size: 110px; }
.fr-sheep { font-size: 24px; background: rgba(0, 0, 0, .25); padding: 8px 18px; border-radius: 999px; }
.fr-sheep .sheep { font-size: 34px; vertical-align: -8px; }
.ff-table { width: min(440px, 100%); background: rgba(0, 0, 0, .25); border-radius: 16px; padding: 8px 12px; max-height: 45vh; overflow-y: auto; }
.ff-row { display: grid; grid-template-columns: 46px 1fr auto; gap: 8px; padding: 6px 4px; border-radius: 10px; align-items: center; text-align: left; }
.ff-row.me { background: rgba(255, 255, 255, .2); }
.ff-row .sheep { font-size: 20px; vertical-align: -4px; }

/* Colour questions: a grid of colour swatches to tick, and the picture in black and white. */
.p-answers.colour-grid { grid-template-columns: repeat(4, 1fr); gap: 7px; }
#qScreen .p-answers.colour-grid { grid-auto-rows: minmax(44px, 1fr); } /* player.js sets the columns and a height that fits every row */
#qScreen .p-answers.colour-grid .ans, .p-answers.colour-grid .ans { flex-direction: row; font-size: clamp(14px, calc(var(--vh, 1vh) * 2.6), 22px); min-height: 44px; padding: 14px 4px 6px; }
.ans.swatch { box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .14); }
.ans.swatch .tickbox { border-color: currentColor; top: 3px; right: 3px; width: 18px; height: 18px; border-width: 2px; border-radius: 6px; font-size: 12px; }
.ans.swatch.ticked { outline: 4px solid #fff; box-shadow: 0 0 0 7px #1b1250, inset 0 0 0 3px rgba(0, 0, 0, .14); }
.ans.swatch.ticked .tickbox { background: currentColor; }
.ans.swatch.ticked .tickbox::after { color: #fff; mix-blend-mode: difference; }
#pImg.greyscale { filter: grayscale(1) contrast(1.05); }
.res-colour-img { max-width: 100%; max-height: 26vh; border-radius: 16px; animation: colourIn 1.4s ease-out both; margin-bottom: 8px; }
@keyframes colourIn { from { filter: grayscale(1); } to { filter: none; } }
.res-swatches { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.res-swatches .swatch { width: auto; flex: 0 0 auto; margin: 0; min-height: 0; padding: 8px 16px; font-size: 18px; border-radius: 999px; }
.res-colour-img { display: block; margin-left: auto; margin-right: auto; max-height: 22vh; }
