:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --ink: #1f2430;
  --muted: #6b7080;
  --line: #e2ddd2;
  --primary: #b4442b;
  --primary-ink: #ffffff;
  --ok: #2f855a;
  --bad: #c53030;
  --accent: #e0a526;
  --radius: 14px;
  --font: 'Noto Sans Tamil', 'Tamil Sangam MN', 'Tamil MN', 'Latha', 'Nirmala UI',
    system-ui, -apple-system, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --surface: #1f232b;
    --ink: #eceae4;
    --muted: #a0a4ae;
    --line: #333844;
    --primary: #e0674c;
  }
}

* {
  box-sizing: border-box;
}

/* A downward swipe at the top of the page does not reload it, which on a phone would end the
   quiz and go back to the start page. The page still scrolls as before. */
html,
body {
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

/* Header */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 3px solid #b8862b;
  position: relative;
  overflow: hidden;
}

/* The Deepavali banner, faded behind the header so the title and buttons stay readable. */
.topbar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('banner.webp') center / cover no-repeat;
  opacity: 0.22;
  pointer-events: none;
}

.topbar > * {
  position: relative;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.25);
}

body[data-view='play'] .logo,
body[data-view='break'] .logo {
  width: 52px;
  height: 52px;
}

.brand .brand-event {
  color: #8a1c2c;
  font-weight: 700;
}

@media (prefers-color-scheme: dark) {
  .brand .brand-event {
    color: #f2b8a0;
  }
}

.brand {
  margin: 0;
  font-size: 1.35rem;
}

.brand span {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

nav {
  display: flex;
  gap: 8px;
}

.nav-btn.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  /* The bottom space lets the last controls scroll clear of the host's badge, which Netlify's
     free plan places over the lower edge of the page. */
  padding: 24px 16px 110px;
}

/* Status line for changes not yet in questions.js */
.file-status {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  background: #fff4d6;
  color: #5c4500;
  border-bottom: 1px solid #f0d58a;
  font-weight: 600;
}

/* Outside conductor mode the header's Start a quiz button, the question bank and its save bar
   are not offered. Families start from their own start page, and New quiz on the results page
   returns to it. */
body:not(.conductor) nav .nav-btn[data-view='setup'],
body:not(.conductor) .nav-btn[data-view='bank'],
body:not(.conductor) .file-status {
  display: none !important;
}

.file-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* Generic pieces */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}

h2 {
  margin: 0 0 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
}

label small {
  font-weight: 400;
  color: var(--muted);
}

input[type='text'],
input[type='number'],
input[type='search'],
select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
}

input[type='range'] {
  accent-color: var(--primary);
}

/* A required box left empty, such as the name. */
input[aria-invalid='true'],
input[aria-invalid='true']:focus {
  border-color: var(--bad);
  box-shadow: 0 0 0 2px var(--bad);
  outline: none;
}

.field-error {
  margin: -14px 0 0;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

legend {
  font-weight: 600;
  margin-bottom: 8px;
}

.btn {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  flex-direction: row;
}

.btn:hover:not(:disabled) {
  filter: brightness(0.96);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}

.btn.ok {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.btn.bad {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  padding: 6px 12px;
  font-size: 0.9rem;
}

.btn.big {
  padding: 14px 28px;
  font-size: 1.15rem;
}

.btn.selected {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions.end {
  justify-content: flex-end;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.center {
  text-align: center;
}

.error {
  color: var(--bad);
  font-weight: 600;
}

kbd {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
}

/* Setup */
.setup-card {
  max-width: 640px;
  margin: 0 auto;
}

#setup-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.check {
  flex-direction: row;
  align-items: center;
  font-weight: 500;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font: inherit;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}

.chip[aria-pressed='true'] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}

/* Start page for families */
.start-card h2 span {
  display: block;
  font-size: 1.1rem;
  color: var(--muted);
}

#start-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

#start-form input[type='text'] {
  font-size: 1.3rem;
  padding: 14px 16px;
}

.big-chips .chip {
  font-size: 1.15rem;
  padding: 12px 22px;
}

.start-rounds .start-note {
  list-style: none;
  margin: 8px 0 0 -18px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-weight: 600;
  line-height: 1.5;
}

.start-rounds {
  margin: 0;
  padding: 14px 18px 14px 36px;
  border-radius: 12px;
  background: var(--bg);
  line-height: 1.8;
}

.notice {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Play */
.play-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.play-head .btn {
  margin-left: auto;
}

.pill {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 600;
}

.pill:empty {
  display: none;
}

.pill.score {
  color: var(--ok);
}

.stage {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
}

.picture-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  height: min(62vh, 620px);
  overflow: hidden;
}

.picture-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.timer {
  position: relative;
  width: 160px;
  height: 160px;
}

.timer svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer circle {
  fill: none;
  stroke-width: 10;
}

.timer .track {
  stroke: var(--line);
}

.timer .ring {
  stroke: var(--ok);
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.1s linear, stroke 0.3s;
}

.timer.warn .ring {
  stroke: var(--accent);
}

.timer.done .ring {
  stroke: var(--bad);
}

.timer.paused span {
  opacity: 0.4;
}

.timer span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.question {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.question-en {
  margin: -10px 0 0;
  font-size: 1.1rem;
  color: var(--muted);
}

.answer {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 2px solid var(--accent);
  animation: pop 0.25s ease-out;
}

.answer small {
  display: block;
  color: var(--muted);
}

.answer strong {
  font-size: 2rem;
}

.mark-label {
  font-size: 1.2rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 999px;
  color: #fff;
}

.mark-label.ok {
  background: var(--ok);
}

.mark-label.bad {
  background: var(--bad);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.controls .btn {
  min-width: 130px;
  padding: 12px 20px;
  font-size: 1.05rem;
}

@keyframes pop {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.btn.clue {
  background: var(--accent);
  border-color: var(--accent);
  color: #3a2a00;
}

/* Round 3 */
.picture-wrap.sheet-mode {
  /* The window less the header, status pills and buttons, so the sheet and its buttons fit
     without scrolling. */
  height: max(420px, calc(100vh - 270px));
}

.answer.words strong {
  font-size: 1.3rem;
}

.timer.long span {
  font-size: 2.2rem;
}

.score-entry {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 2px solid var(--ok);
  border-radius: 12px;
  background: var(--surface);
  font-weight: 700;
}

.score-entry .btn {
  min-width: 0;
  width: 44px;
  padding: 8px 0;
  font-size: 1.3rem;
}

.score-entry input {
  font: inherit;
  font-size: 1.4rem;
  width: 72px;
  padding: 6px 8px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}

textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  resize: vertical;
}

/* Between rounds */
.break-card {
  max-width: 640px;
  margin: 48px auto;
  text-align: center;
}

.break-card h2 {
  font-size: 2rem;
}

/* Results */
.cheer {
  text-align: center;
  padding: 8px 0 24px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.cheer-lamps {
  margin: 0;
  font-size: 2.2rem;
  letter-spacing: 0.2em;
  animation: glow 1.6s ease-in-out infinite alternate;
}

.cheer-title {
  margin: 8px 0 0;
  font-size: 2.4rem;
  color: var(--primary);
}

.cheer-title-en {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.cheer-message {
  margin: 16px 0 0;
  font-size: 1.3rem;
  font-weight: 600;
}

.cheer-message-en {
  margin: 4px 0 0;
  color: var(--muted);
}

@keyframes glow {
  from {
    transform: scale(1);
    opacity: 0.85;
  }
  to {
    transform: scale(1.06);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cheer-lamps {
    animation: none;
  }
}

.big-score {
  font-size: 2.4rem;
  font-weight: 700;
  margin: 0 0 16px;
}

.results-list {
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  margin: 0 0 24px;
}

#results-rounds {
  margin-bottom: 16px;
}

.results-list li.results-heading {
  display: block;
  border: 0;
  padding: 12px 0 0;
  font-weight: 700;
  font-size: 1.1rem;
}

.results-list li {
  display: grid;
  grid-template-columns: 32px 64px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.results-list img {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
}

.result-mark {
  font-weight: 700;
}

.result-mark.ok {
  color: var(--ok);
}

.result-mark.bad {
  color: var(--bad);
}

.result-mark.none {
  color: var(--muted);
}

/* Bank */
.bank-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.bank-head h2 {
  margin: 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.filters input[type='search'] {
  flex: 1;
  min-width: 200px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.q-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.q-card img {
  width: 100%;
  height: 140px;
  object-fit: contain;
  background: var(--bg);
}

.q-card .body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.q-card .ans {
  font-size: 1.15rem;
  font-weight: 700;
}

.q-card .q {
  color: var(--muted);
  font-size: 0.9rem;
}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.q-card .actions {
  margin-top: auto;
  padding-top: 6px;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}

/* Editor */
dialog {
  width: min(760px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 24px;
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.5);
}

.editor-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.editor-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.image-drop {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  padding: 8px;
  color: var(--muted);
  background: var(--bg);
}

.image-drop.over {
  border-color: var(--primary);
}

.image-drop img {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
}

/* Round 2: the word as letter tiles */
.picture-wrap.word-mode {
  flex-direction: column;
  gap: 24px;
  padding: 24px;
}

.picture-wrap.word-mode img {
  max-height: 45%;
}

.word-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.tile {
  font: inherit;
  min-width: 96px;
  height: 112px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  font-weight: 700;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}

.tile.blank {
  border: 3px dashed var(--accent);
  background: transparent;
  color: var(--accent);
}

.tile.filled {
  border: 3px solid var(--accent);
  background: var(--accent);
  color: #fff;
  animation: pop 0.25s ease-out;
}

.word-tiles.small {
  justify-content: flex-start;
  gap: 6px;
  margin-top: 6px;
}

.word-tiles.small .tile {
  min-width: 48px;
  height: 52px;
  padding: 0 8px;
  font-size: 1.5rem;
  cursor: pointer;
}

.word-tiles.card-word {
  padding: 16px 8px;
  gap: 4px;
  min-height: 140px;
  align-content: center;
  background: var(--bg);
}

.word-tiles.card-word.with-picture {
  min-height: 0;
  padding: 8px;
  border-top: 1px solid var(--line);
}

.word-tiles.card-word .tile {
  min-width: 34px;
  height: 40px;
  padding: 0 6px;
  font-size: 1.15rem;
}

.field-label {
  font-weight: 600;
}

.results-list .result-word {
  width: 64px;
  font-size: 0.8rem;
  text-align: center;
  color: var(--muted);
}

/* English sounds */
.sound {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.answer .sound {
  font-size: 1.1rem;
  margin-top: 4px;
}

/* English meaning of the answer */
.meaning {
  display: block;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--ink);
}

.meaning:empty {
  display: none;
}

.answer .meaning {
  font-size: 1.2rem;
  margin-top: 4px;
}

.tile-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.tile-sound {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* The word during a quiz: one row, with each tile and its sound sized to fit the row's width.
   --letters is set to the word's number of letters when the word is drawn. */
#play-word {
  --gap: clamp(6px, 2cqw, 12px);
  container-type: inline-size;
  width: 100%;
  flex-wrap: nowrap;
  gap: var(--gap);
}

#play-word > * {
  flex: 0 1 calc((100cqw - (var(--letters) - 1) * var(--gap)) / var(--letters));
  max-width: 110px;
  min-width: 0;
}

#play-word .tile {
  width: 100%;
  min-width: 0;
  height: auto;
  aspect-ratio: 6 / 7;
  padding: 0;
  font-size: min(3rem, calc(42cqw / var(--letters)));
}

#play-word .tile-sound {
  font-size: min(1.3rem, calc(22cqw / var(--letters)));
  white-space: nowrap;
}

/* Narrow screens */
@media (max-width: 600px) {
  /* The rounds line is left out on phones, so the header stays short. */
  .brand span:last-child {
    display: none;
  }

  .logo {
    width: 52px;
    height: 52px;
  }

  .topbar {
    padding: 10px 14px;
  }
}

@media (max-width: 800px) {
  .stage,
  .editor-body,
  .row {
    grid-template-columns: 1fr;
  }

  .picture-wrap {
    height: 45vh;
  }

  .tile {
    min-width: 64px;
    height: 76px;
    font-size: 2.2rem;
  }

  .timer {
    width: 120px;
    height: 120px;
  }

  .results-list li {
    grid-template-columns: 28px 56px 1fr;
  }

  .results-list li .result-mark {
    grid-column: 3;
  }
}

/* The families' start page on a phone: each row of choices on one line, and the form closer
   together. */
@media (max-width: 600px) {
  #start-form {
    gap: 10px;
  }

  #start-form input[type='text'] {
    padding: 10px 14px;
  }

  .big-chips {
    flex-wrap: nowrap;
  }

  .big-chips .chip {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 6px;
    font-size: 1.05rem;
    white-space: nowrap;
    text-align: center;
  }

  /* The round list is left out, as the questions row above gives the number of questions. The
     note on other correct words stays, as a line of its own. */
  .start-rounds {
    padding: 0;
    background: none;
    font-size: 0.9rem;
    line-height: 1.4;
  }

  .start-rounds li:not(.start-note) {
    display: none;
  }

  .start-rounds .start-note {
    margin: 0;
    padding: 0;
    border-top: 0;
  }

  /* A shorter header on the families' start page: a smaller logo and the title lines closer
     together. */
  body:not(.conductor)[data-view='start'] .topbar {
    padding-block: 6px;
  }

  body:not(.conductor)[data-view='start'] .logo {
    width: 42px;
    height: 42px;
  }

  body:not(.conductor)[data-view='start'] .brand {
    line-height: 1.25;
  }

  body:not(.conductor)[data-view='start'] .brand .brand-event {
    font-size: 0.75rem;
  }

  /* Less space above and inside the start card. */
  body[data-view='start'] main {
    padding-top: 12px;
  }

  .start-card {
    padding: 16px;
  }

  .start-card h2 {
    margin-bottom: 10px;
  }
}

/* The families' question pages do not list the keyboard keys. The keys still work. */
body:not(.conductor) .play-keys {
  display: none;
}

/* The families' quiz on a phone: the question, its timer, the answer and the buttons fit on one
   screen. The header is left out while a question is shown. */
@media (max-width: 600px) {
  body:not(.conductor)[data-view='play'] .topbar {
    display: none;
  }

  body:not(.conductor)[data-view='play'] main {
    padding-top: 10px;
  }

  /* The player's own name is left out, so the progress, score and End quiz fit on one line. */
  body:not(.conductor) .play-head {
    gap: 6px;
    margin-bottom: 8px;
    font-size: 0.8rem;
  }

  body:not(.conductor) #play-name {
    display: none;
  }

  body:not(.conductor) .play-head .pill {
    padding: 2px 8px;
    white-space: nowrap;
  }

  body:not(.conductor) .play-head .btn {
    padding: 4px 10px;
  }

  body:not(.conductor) .stage {
    gap: 10px;
  }

  body:not(.conductor) .picture-wrap {
    height: 32vh;
  }

  body:not(.conductor) .picture-wrap.word-mode {
    height: auto;
    min-height: 0;
    gap: 12px;
    padding: 16px 12px;
  }

  body:not(.conductor) .picture-wrap.word-mode img {
    max-height: 22vh;
  }

  body:not(.conductor) .picture-wrap.sheet-mode {
    height: auto;
  }

  /* The timer sits beside the question, and the answer and mark run across under both. */
  body:not(.conductor) .side {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px 14px;
    text-align: left;
  }

  body:not(.conductor) .timer {
    grid-row: span 2;
    width: 76px;
    height: 76px;
  }

  body:not(.conductor) .timer span {
    font-size: 1.9rem;
  }

  body:not(.conductor) .timer.long {
    width: 88px;
    height: 88px;
  }

  body:not(.conductor) .timer.long span {
    font-size: 1.25rem;
  }

  body:not(.conductor) .question {
    font-size: 1.2rem;
    align-self: end;
  }

  body:not(.conductor) .question-en {
    margin: 0;
    font-size: 0.95rem;
    align-self: start;
  }

  body:not(.conductor) .answer,
  body:not(.conductor) .mark-label {
    grid-column: 1 / -1;
    justify-self: stretch;
    text-align: center;
  }

  body:not(.conductor) .answer {
    padding: 8px 12px;
  }

  body:not(.conductor) .answer strong {
    font-size: 1.6rem;
  }

  /* The sounds and the English meaning share one line, so the meaning adds no height. */
  .answer strong {
    display: block;
  }

  .answer .sound,
  .answer .meaning {
    display: inline;
    font-size: 1rem;
  }

  .answer .sound:not(:empty) + .meaning:not(:empty)::before {
    content: ' · ';
    font-style: normal;
  }

  body:not(.conductor) .mark-label {
    font-size: 1rem;
    padding: 4px 12px;
  }

  /* Three rows of buttons: Pause, Show answer and the picture clue; Correct and Wrong; then Next.
     Without the clue button, Pause and Show answer share their row. The words-found box takes
     the second row in Round 3. */
  body:not(.conductor) .controls {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-top: 12px;
  }

  body:not(.conductor) .controls .btn {
    grid-column: span 2;
    min-width: 0;
    padding: 10px 6px;
    font-size: 0.95rem;
  }

  body:not(.conductor) .controls:has(#btn-clue[hidden]) #btn-pause,
  body:not(.conductor) .controls:has(#btn-clue[hidden]) #btn-reveal,
  body:not(.conductor) .controls #btn-correct,
  body:not(.conductor) .controls #btn-wrong {
    grid-column: span 3;
  }

  body:not(.conductor) .controls #btn-clue {
    order: 1;
  }

  body:not(.conductor) .controls #btn-correct,
  body:not(.conductor) .controls #btn-wrong {
    order: 2;
    font-size: 1.05rem;
  }

  body:not(.conductor) .controls .score-entry {
    order: 2;
    grid-column: 1 / -1;
    justify-content: center;
  }

  body:not(.conductor) .controls #btn-next {
    order: 3;
    grid-column: 1 / -1;
    font-size: 1.05rem;
  }

  body:not(.conductor) .controls .score-entry .btn {
    grid-column: auto;
    width: 44px;
  }
}

/* The title's parts and the Sangam's name sit in line, in the heading's own style. The rule above
   for the heading's spans is for the lines under the title. */
.brand .brand-title,
.brand .brand-event span {
  display: inline;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

/* The families' header: the Tamil and English titles on lines of their own, and the Sangam's name
   without the celebration. The rounds line is left out. */
body:not(.conductor) .brand .brand-ta,
body:not(.conductor) .brand .brand-en {
  display: block;
}

/* The header lines are centred, with the logo at the left. On wider screens the space after the
   lines matches the logo and its gap, so the lines sit in the middle of the header. On a phone
   they are centred in the space beside the logo, which keeps the Tamil title on one line. */
body:not(.conductor) .brand-wrap {
  flex: 1;
}

body:not(.conductor) .brand {
  flex: 1;
  text-align: center;
  margin-right: 86px;
}

@media (max-width: 600px) {
  body:not(.conductor) .brand {
    margin-right: 0;
  }
}

/* A plain sandalwood header in place of the Deepavali banner. */
body:not(.conductor) .topbar {
  background: #f3e2c4;
}

body:not(.conductor) .topbar::before {
  display: none;
}

@media (prefers-color-scheme: dark) {
  body:not(.conductor) .topbar {
    background: #3a2f22;
  }
}

body:not(.conductor) .brand-sep,
body:not(.conductor) .brand-celebration,
body:not(.conductor) .brand-rounds {
  display: none !important;
}

@media (max-width: 600px) {
  /* The titles shrink with the screen, so the Tamil title fits on one line on a phone. Phones
     with a wider Tamil font wrap it rather than cut it off. */
  body:not(.conductor) .brand .brand-ta,
  body:not(.conductor) .brand .brand-en {
    font-size: min(1.2rem, 4.4vw);
  }
}

/* Printing the results: the header, without its buttons, and the results card, in light colours. */
@media print {
  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --ink: #000000;
    --muted: #444444;
    --line: #cccccc;
  }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    background: #ffffff;
  }

  .file-status,
  #results-sync,
  #results-actions,
  .topbar nav {
    display: none !important;
  }

  main {
    padding: 8px 0 0;
    max-width: none;
  }

  #view-results .card {
    border: 0;
    padding: 0;
  }

  .cheer-lamps {
    animation: none;
  }

  .results-list {
    gap: 4px;
  }

  /* A4 is narrower than the narrow-screen width, so the one-line row layout is set again. */
  .results-list li {
    grid-template-columns: 28px 56px 1fr auto;
    padding: 4px 8px;
    break-inside: avoid;
  }

  .results-list li .result-mark {
    grid-column: auto;
  }

  .results-list img {
    width: 56px;
    height: 40px;
  }

  .cheer {
    padding: 4px 0 12px;
    margin-bottom: 8px;
  }

  .cheer-lamps {
    font-size: 1.6rem;
  }

  .cheer-title {
    font-size: 2rem;
  }

  .big-score {
    font-size: 2rem;
    margin-bottom: 8px;
  }
}

/* Short phone screens, such as the iPhone SE: the start page's choices are a little smaller, so
   the Start button stays on screen with the round choice added. */
@media (max-width: 720px) and (max-height: 760px) {
  body:not(.conductor)[data-view='start'] .big-chips .chip {
    padding-block: 5px;
    font-size: 1rem;
  }

  .start-card h2 {
    font-size: 1.3rem;
    margin-bottom: 6px;
  }

  body:not(.conductor) #start-form {
    gap: 7px;
  }

  body:not(.conductor) #start-form legend {
    margin-bottom: 4px;
  }

  body:not(.conductor) #start-form input[type='text'] {
    padding-block: 7px;
  }
}
