:root {
  --ink: #171433; --panel: #221e47; --raised: #2e2960; --line: #453f80; --text: #f4f2ff; --muted: #b7b2dc;
  --gold: #ffc93c; --pink: #e5446d; --green: #1f9d55; --red: #c93434;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--ink); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color-scheme: dark; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }
h2 { font-size: 20px; }
a { color: var(--gold); }
.muted { color: var(--muted); }
kbd { font: inherit; font-size: .75em; border: 1px solid currentColor; border-radius: 5px; padding: 0 5px; opacity: .75; }

button, input, select, textarea, .file { font: inherit; color: var(--text); border-radius: 9px; border: 1px solid var(--line); }
button, .file { background: var(--raised); padding: 8px 14px; font-weight: 600; cursor: pointer; }
button:hover:not(:disabled), .file:hover { filter: brightness(1.15); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--gold); border-color: var(--gold); color: #1c1500; }
button.big { font-size: 20px; padding: 12px 24px; }
button.danger { color: #ff9a9a; }
button.quiet { background: transparent; border: 0; font-weight: 400; color: var(--muted); text-decoration: underline; }
button[aria-pressed="true"] { background: var(--pink); border-color: var(--pink); }
:focus-visible, .file:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }
input, select, textarea { background: #12102a; padding: 7px 10px; }
input[type=number] { width: 76px; }
input[type=checkbox], input[type=range] { padding: 0; accent-color: var(--gold); }
textarea { width: 100%; resize: vertical; }
.file { display: inline-block; }
.file input, .drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

header { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; padding: 12px 16px; background: var(--panel); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--text); text-decoration: none; }
nav { display: flex; flex-wrap: wrap; gap: 4px; }
nav a { color: var(--muted); text-decoration: none; padding: 7px 12px; border-radius: 9px; font-weight: 600; }
nav a[aria-current] { background: var(--raised); color: var(--text); }
.pick { margin-left: auto; }
.join-badge { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 14px;
  padding: 3px 16px; border: 2px solid var(--gold); }
.join-badge span { font-weight: 400; overflow-wrap: anywhere; }
.join-badge strong { font-size: 34px; line-height: 1.15; letter-spacing: 3px; color: var(--gold); }
.join-badge:not([hidden]) + .pick { margin-left: 0; }
/* While students can join, the top bar stays put as the page scrolls. */
@media (min-width: 640px) and (min-height: 500px) {
  body.hosting header { position: sticky; top: 0; z-index: 5; }
}
#notice { margin: 0; padding: 10px 16px; background: #5b4a1f; text-align: center; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.toolbar, .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.centre { justify-content: center; }
.banner { background: #4a2340; border-radius: 10px; padding: 10px 14px; }
.panel { background: var(--panel); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
label { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tiles button { min-height: 84px; font-size: 20px; overflow-wrap: anywhere; position: relative; }
.tiles .called { opacity: .5; }
.tiles .called::after { content: "✓"; position: absolute; top: 4px; right: 9px; font-size: 14px; }
.tiles .away { background: transparent; border-style: dashed; text-decoration: line-through; color: var(--muted); }
.tiles .picked { background: var(--gold); border-color: var(--gold); color: #1c1500; opacity: 1; }
.empty { grid-column: 1 / -1; text-align: center; padding: 40px 16px; }

.segmented { display: inline-flex; }
.segmented button { border-radius: 0; }
.segmented button:first-child { border-radius: 9px 0 0 9px; }
.segmented button:last-child { border-radius: 0 9px 9px 0; }
#onlineOff { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
#onlineOff p { margin: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 8px 22px; }
#onlineOn, #microbitPanel { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
#microbitPanel .banner { flex-basis: 100%; margin: 0; }
.join-box { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-right: auto; font-size: 18px; }
.join-box strong { font-size: 40px; letter-spacing: 4px; color: var(--gold); }
.pill { border-radius: 99px; padding: 4px 12px; background: #5b4a1f; }
.pill.good { background: #1f5b34; }
.pill.bad { background: #6b2530; }
#roundStatus { text-align: center; font-size: clamp(22px, 3.5vw, 34px); margin: 8px 0 14px; color: var(--muted); }
#roundStatus.open { color: #6ee7a0; }
#roundStatus.buzzed { color: var(--gold); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--panel); border: 3px solid var(--panel); border-radius: 12px; padding: 10px; display: flex;
  flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.card.won { border-color: var(--gold); }
.card.out { opacity: .45; }
.card .top { align-self: stretch; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.card .on { color: #6ee7a0; }
.card h3 { font-size: 18px; margin: 0; overflow-wrap: anywhere; }
.card input { width: 100%; text-align: center; font-weight: 700; }
.card .score { font-size: 40px; font-weight: 800; line-height: 1.1; }
.card .row { margin: 0; justify-content: center; gap: 6px; }
.card button { padding: 3px 10px; font-size: 13px; }

.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 0 16px; align-items: start; }
.columns .panel > label:not(.drop):not(.file) { display: flex; margin-bottom: 10px; }
.drop { display: flex; flex-direction: column; text-align: center; border: 2px dashed var(--line); border-radius: 12px;
  padding: 18px; cursor: pointer; margin-bottom: 14px; }
.drop:hover, .drop.over, .drop:focus-within { border-color: var(--gold); }
table { width: 100%; border-collapse: collapse; }
td { border-top: 1px solid var(--line); padding: 8px 4px; vertical-align: top; }
td:first-child { font-weight: 700; width: 30%; overflow-wrap: anywhere; }
td:last-child { text-align: right; }
.sounds { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.sounds li { display: flex; gap: 6px; align-items: center; }
.sounds li span { flex: 1; overflow-wrap: anywhere; }
.sounds button, td .file, td button, #unsorted button { padding: 2px 9px; font-size: 13px; }
#sharedList { margin-top: 10px; }
#unsorted:not(:empty) { background: #4a3a14; border-radius: 10px; padding: 12px; margin-bottom: 14px; }

.prose { max-width: 720px; }
.prose li { margin-bottom: 6px; }

.overlay { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: 20px; text-align: center; background: var(--ink); cursor: pointer; }
.overlay.dim { background: rgba(8, 6, 24, .85); cursor: default; }
#flashScreen { z-index: 20; }
#flashScreen p { margin: 0; font-size: clamp(56px, 15vw, 220px); font-weight: 900; line-height: 1.05; color: var(--gold);
  overflow-wrap: anywhere; animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #flashScreen p { animation: none; } }
#codeScreen div { display: flex; flex-direction: column; gap: 3vh; }
#bigAddress { font-size: clamp(24px, 5vw, 60px); font-weight: 700; overflow-wrap: anywhere; }
#bigCode { font-size: clamp(60px, 17vw, 240px); line-height: 1; color: var(--gold); letter-spacing: .04em; }
.winner { background: var(--gold); color: #1c1500; border-radius: 22px; padding: 28px; width: min(820px, 100%); }
#winner { margin: 14px 0 28px; font-size: clamp(44px, 10vw, 110px); font-weight: 900; line-height: 1.05; overflow-wrap: anywhere; }
#popupJoin { margin: 20px 0 0; font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
#buzzAnswer { margin: -12px 0 28px; font-size: clamp(26px, 4.5vw, 52px); font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.winner button { font-size: 19px; padding: 11px 20px; color: #fff; background: #3a3470; border-color: transparent; }
.winner .yes { background: var(--green); }
.winner .no { background: var(--red); }

#answers { list-style: none; counter-reset: place; margin: 0; padding: 0; }
#answers li { counter-increment: place; display: grid; grid-template-columns: 1.8em minmax(0, 11em) minmax(0, 1fr) auto;
  gap: 4px 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 19px; }
#answers li:first-child { border-top: 0; }
#answers li::before { content: counter(place) "."; text-align: right; color: var(--muted); }
#answers b, #answers span { overflow-wrap: anywhere; }
#answers .marks { display: flex; gap: 8px; }
/* On a narrow screen the answer sits under the name. */
@media (max-width: 640px) {
  #answers li { grid-template-columns: 1.8em minmax(0, 1fr) auto; }
  #answers span { grid-column: 2 / -1; grid-row: 2; }
}
#answers .right[aria-pressed="true"] { background: var(--green); border-color: var(--green); }
#answers .wrong[aria-pressed="true"] { background: var(--red); border-color: var(--red); }
#noAnswers { margin: 0; text-align: center; }

dialog { width: min(420px, 92vw); padding: 22px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgba(8, 6, 24, .8); }
dialog p { margin: 0 0 12px; }
dialog input { width: 100%; font-size: 20px; margin-bottom: 14px; }
dialog .row { margin: 0; }

#googleBox { margin-bottom: 22px; }
#googleOn { margin: 0; }
#driveStatus { margin: 10px 0 0; min-height: 1.4em; }
.home .small { font-size: 13px; color: var(--muted); }

/* The home screen */
.home .title { font-size: clamp(30px, 8vw, 48px); margin: 0; }
.home main { padding: 0; width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.home label { color: var(--muted); }
.home hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 0; }
.button { display: inline-block; background: var(--raised); color: var(--text); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 18px; font-weight: 600; text-decoration: none; }
.join a.brand { text-decoration: none; }

/* The student's page */
.join { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 16px; text-align: center; }
.join .brand { margin: 0; font-size: 17px; }
.join section { width: 100%; max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.join form { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.join form input { width: 260px; font-size: 40px; text-align: center; letter-spacing: 6px; }
.join form button { font-size: 20px; padding: 12px 32px; }
.join p { margin: 0; min-height: 1.4em; color: var(--muted); }
.join #name { font-size: 28px; letter-spacing: normal; width: min(320px, 100%); }
#names { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; width: 100%; }
#names button { padding: 14px 8px; overflow-wrap: anywhere; }
#buzz { width: min(80vw, 55vh, 340px); aspect-ratio: 1; border-radius: 50%; border: 0; font-size: 40px; font-weight: 900;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; background: #55507f; box-shadow: 0 12px 0 #2b2750; }
#buzz.open { background: var(--green); box-shadow: 0 12px 0 #125c32; }
#buzz.won { background: var(--gold); color: #1c1500; box-shadow: 0 12px 0 #9a7414; }
#buzz.beaten { background: var(--red); box-shadow: 0 12px 0 #741d1d; }
#buzz.sent { background: #2f6fd0; box-shadow: 0 12px 0 #1c4585; }
#buzz:active { transform: translateY(8px); box-shadow: none; }

/* With a typed answer the box and button stay near the top, above a phone's keyboard. */
.join.answering { justify-content: flex-start; }
.join #answer { width: min(100%, 420px); font-size: 22px; text-align: center; padding: 12px; }
.join.answering #buzz { width: min(100%, 420px); aspect-ratio: auto; border-radius: 16px; padding: 18px; font-size: 30px; }

@media (max-width: 640px) {
  .pick { margin-left: 0; }
}
