/* ==========================================================================
   General Knowledge — mobile-first stylesheet
   Designed for iPhone: large type, large targets, safe-area aware, no
   horizontal scroll, and nothing that needs a hover to work.
   ========================================================================== */

:root {
  --bg:        #0B0D12;
  --bg-2:      #10131B;
  --surface:   #171B25;
  --surface-2: #1F2431;
  --border:    #2A3040;
  --text:      #F2F4F8;
  --muted:     #98A1B3;
  --accent:    #6E8BFF;
  --accent-2:  #9B6CFF;
  --accent-ink:#FFFFFF;
  --right:     #35C88F;
  --wrong:     #FF6B6B;
  --gold:      #FFC857;

  --radius:     18px;
  --radius-sm:  12px;
  --gutter:     20px;
  --tap:        56px;

  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] {
  --bg:        #F4F6FB;
  --bg-2:      #EDF0F7;
  --surface:   #FFFFFF;
  --surface-2: #F3F5FA;
  --border:    #DFE4EE;
  --text:      #10131A;
  --muted:     #5B6479;
  --accent:    #4C6BF5;
  --accent-2:  #8250E6;
  --right:     #16A97A;
  --wrong:     #E23F3F;
  --gold:      #C98A05;
  --shadow: 0 8px 28px rgba(16, 19, 26, .10);
}

* { box-sizing: border-box; }

/* The `hidden` attribute is how this app shows and hides panels. A bare
   `display: flex` or `display: grid` rule beats the user-agent
   `[hidden] { display: none }`, so it has to be enforced explicitly — without
   this, hidden panels render on top of each other. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* No pull-to-refresh bounce swallowing taps mid-quiz. */
  overscroll-behavior-y: contain;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  /* Stops iOS waiting 300ms to see whether a tap is a double-tap zoom. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* --------------------------------------------------------------------------
   Screens
   -------------------------------------------------------------------------- */

.app {
  min-height: 100%;
  min-height: 100dvh;
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  padding:
    calc(env(safe-area-inset-top) + 12px)
    calc(env(safe-area-inset-right) + var(--gutter))
    calc(env(safe-area-inset-bottom) + 14px)
    calc(env(safe-area-inset-left) + var(--gutter));
}

.screen.is-active {
  display: flex;
  animation: screen-in .22s ease-out both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Home
   -------------------------------------------------------------------------- */

.screen--home { justify-content: center; gap: 30px; }

.home__head { text-align: center; }

.brand__mark {
  display: inline-block;
  line-height: 0;
  filter: drop-shadow(0 6px 18px rgba(110, 139, 255, .35));
}

.home__title {
  margin: 16px 0 6px;
  font-size: clamp(34px, 11vw, 46px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(160deg, var(--text) 30%, var(--accent) 140%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.home__tagline {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.home__stats {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.statchip {
  flex: 1 1 0;
  max-width: 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
}

.statchip__value { display: block; font-size: 20px; font-weight: 700; }
.statchip__label { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.home__actions { display: flex; flex-direction: column; gap: 12px; }

.home__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

/* A link that should be findable but not compete for attention. */
.linkbtn--quiet {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.home__pool { text-align: right; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap);
  padding: 15px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease, background .15s ease;
}

.btn:active { transform: scale(.975); filter: brightness(1.08); }

.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 6px 20px rgba(110, 139, 255, .30);
}

.btn--reveal { font-size: 18px; letter-spacing: .01em; }

/* Home screen: the two play modes get a subtitle, so they need height and a
   column layout rather than the centred single line the other buttons use. */
.btn--tall {
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 15px 20px;
  text-align: left;
}
.btn__title { font-size: 18px; font-weight: 700; }
.btn__sub { font-size: 13.5px; font-weight: 500; opacity: .78; }

.btn--right { background: var(--right); border-color: transparent; color: #04140E; }
.btn--wrong { background: var(--wrong); border-color: transparent; color: #1A0505; }
:root[data-theme="light"] .btn--right,
:root[data-theme="light"] .btn--wrong { color: #fff; }

.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }

/* Outlined rather than filled: this button should be findable without
   competing with the things people came here to press. */
.btn--danger {
  background: transparent;
  border-color: var(--wrong);
  color: var(--wrong);
}

#account-danger { margin-top: 28px; }

.btn[disabled] { opacity: .5; pointer-events: none; }

.linkbtn {
  background: none;
  border: 0;
  padding: 10px 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.linkbtn--skip { display: block; margin: 2px auto 0; }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex: 0 0 auto;
}

.iconbtn:active { filter: brightness(1.15); }
.iconbtn--ghost { background: transparent; pointer-events: none; }

/* --------------------------------------------------------------------------
   Top bar and run bar
   -------------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.topbar__title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  padding: 6px 0 2px;
}

.runbar b { color: var(--text); font-weight: 700; }
.runbar__dot { width: 3px; height: 3px; border-radius: 50%; background: var(--border); }
.runbar__streak.is-hot b { color: var(--gold); }

/* --------------------------------------------------------------------------
   Quiz
   -------------------------------------------------------------------------- */

.quiz {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 0 18px;
  min-height: 0;
}

.quiz__loading, .quiz__empty, .quiz__error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  color: var(--muted);
  flex: 1 1 auto;
}

.quiz__empty .btn, .quiz__error .btn { max-width: 320px; }

.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.quiz__meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

.chip {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .02em;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.chip--difficulty[data-level="easy"]   { color: var(--right); }
.chip--difficulty[data-level="medium"] { color: var(--accent); }
.chip--difficulty[data-level="hard"]   { color: var(--gold); }
.chip--difficulty[data-level="expert"] { color: var(--wrong); }

.quiz__number {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.quiz__question {
  margin: 0;
  font-size: clamp(25px, 6.6vw, 33px);
  line-height: 1.26;
  font-weight: 700;
  letter-spacing: -0.015em;
  /* Long single words (chemical names, German compounds) must not overflow. */
  overflow-wrap: break-word;
  hyphens: auto;
}

/* A quiet standing note about how this mode is scored. Deliberately low
   contrast: it explains, it does not nag. */
.modenote {
  margin: 4px 16px 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2, rgba(127, 127, 127, .10));
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
  text-align: center;
}

.quiz__hint {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 15px;
}

/* --------------------------------------------------------------------------
   Quick Quiz options
   Four targets, each comfortably bigger than a thumb, stacked so no answer is
   easier to hit than another. Correctness is shown with an icon and a change
   of weight as well as colour, so it reads without relying on colour vision.
   -------------------------------------------------------------------------- */

.options {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 62px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, background .18s ease, border-color .18s ease, opacity .18s ease;
}

.option:active:not(:disabled) { transform: scale(.985); }
.option:disabled { cursor: default; }

.option__key {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.option__text { overflow-wrap: break-word; min-width: 0; }

.option.is-chosen { border-color: var(--accent); }

.option.is-correct {
  border-color: var(--right);
  background: color-mix(in srgb, var(--right) 16%, var(--surface));
}
.option.is-correct .option__key {
  background: var(--right);
  border-color: transparent;
  color: #04140E;
}
.option.is-correct .option__key::after { content: '✓'; }
.option.is-correct .option__key { font-size: 0; }
.option.is-correct .option__key::after { font-size: 16px; }

.option.is-wrong {
  border-color: var(--wrong);
  background: color-mix(in srgb, var(--wrong) 14%, var(--surface));
}
.option.is-wrong .option__key {
  background: var(--wrong);
  border-color: transparent;
  color: #1A0505;
  font-size: 0;
}
.option.is-wrong .option__key::after { content: '✗'; font-size: 16px; }

.option.is-muted { opacity: .45; }

/* Older browsers without color-mix still get a clear correct/wrong signal
   from the border and the tick, so no fallback colour is needed. */

/* The answer block appears only once the server has sent an answer. */
.answer {
  margin-top: 26px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: reveal .28s cubic-bezier(.2, .8, .3, 1) both;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.answer__label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
}

.answer__text {
  margin: 0;
  font-size: clamp(24px, 6.4vw, 30px);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
}

.answer__explanation {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.5;
}

.answer__asof {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  opacity: .8;
}

.verdict { margin-top: 16px; text-align: center; min-height: 24px; }

.verdict__points {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  animation: reveal .25s ease-out both;
}

.verdict__points[data-kind="right"] { color: var(--right); }
.verdict__points[data-kind="wrong"] { color: var(--muted); }

/* Getting one wrong should read as learning, not failing. */
.verdict__note {
  margin: 6px 0 0;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   "Save your progress"
   Sits in the flow rather than over it: an offer, not an interruption. The
   Next button stays exactly where it was, so anyone ignoring this can carry
   straight on without reading a word of it.
   -------------------------------------------------------------------------- */

.saveprompt {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  animation: reveal .3s cubic-bezier(.2, .8, .3, 1) both;
}

.saveprompt__text {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}

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

.btn--small {
  width: auto;
  min-height: 46px;
  padding: 11px 20px;
  font-size: 15.5px;
}

/* --------------------------------------------------------------------------
   Account — sign in / create account
   -------------------------------------------------------------------------- */

.home__account { margin-top: 18px; text-align: center; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.segmented__btn {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  cursor: pointer;
}

.segmented__btn.is-selected {
  background: var(--surface-2);
  color: var(--text);
}

/* .list__note has a top margin only, which leaves the blurb sitting on top of
   the first field label. */
#auth-blurb { margin-bottom: 22px; }

.form { display: grid; gap: 16px; }

/* Sign out is deliberately quiet, but it still needs separating from the text
   above it or it reads as part of the paragraph. */
#account-detail .btn--ghost {
  margin-top: 26px;
  border-color: var(--border);
}

.field { display: grid; gap: 6px; }

.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .02em;
}

.field__input {
  width: 100%;
  min-height: var(--tap);
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  /* 16px minimum, or iOS Safari zooms the whole page when the field is
     focused and never zooms back out. */
  font-size: 16px;
}

.field__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.field__hint { font-size: 13px; color: var(--muted); }

/* Show/hide password. The button sits inside the field, and the input gets
   padding on that side so a long passphrase never runs underneath it. */
.field__wrap { position: relative; display: block; }

.field__input--withbtn { padding-right: 76px; }

.field__toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.field__toggle:hover { color: var(--text); }
.field__toggle[aria-pressed="true"] { color: var(--accent); }

/* Belt and braces: if a browser ever does show the plain field but keeps
   masking its characters, say explicitly that this one is not a secret. */
#auth-password-plain { -webkit-text-security: none; }

.linkbtn--centred { display: block; margin: 4px auto 0; }

/* --------------------------------------------------------------------------
   Recovery code
   -------------------------------------------------------------------------- */

/* Typed back from paper or a screenshot, so the characters have to be
   unmistakable: monospaced, widely spaced, and large. */
.field__input--code,
.codebox {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.codebox {
  margin: 18px 0;
  padding: 22px 16px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: clamp(19px, 5.4vw, 25px);
  font-weight: 700;
  text-align: center;
  /* It exists to be copied, so it must be selectable even where the rest of
     the app suppresses selection. */
  user-select: all;
  -webkit-user-select: all;
  overflow-wrap: anywhere;
}

/* Doubled class for specificity: the base .callout is defined further down the
   file and would otherwise win on source order. */
.callout.callout--warn {
  background: color-mix(in srgb, var(--gold) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--gold) 45%, var(--border));
}

.callout__title {
  margin: 0 0 6px;
  font-weight: 700;
  color: var(--text);
}

.callout--warn p:last-child { margin: 0; color: var(--text); }

.formerror {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--wrong) 14%, var(--surface));
  border: 1px solid var(--wrong);
  color: var(--text);
  font-size: 14.5px;
}

.empty__mark { font-size: 46px; line-height: 1; }
.empty__title { margin: 0; font-size: 24px; font-weight: 700; color: var(--text); }
.empty__text  { margin: 0; max-width: 34ch; }

/* --------------------------------------------------------------------------
   Sticky action area
   -------------------------------------------------------------------------- */

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  flex: 0 0 auto;
}

.actions__verdict { display: flex; flex-direction: column; gap: 10px; }

@media (min-width: 420px) {
  .actions__verdict { flex-direction: row; }
  .actions__verdict .btn { flex: 1 1 0; }
}

/* --------------------------------------------------------------------------
   Lists (categories, statistics)
   -------------------------------------------------------------------------- */

.list { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 10px; }
.list--centred { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.list--centred .btn { max-width: 320px; }

.list__heading {
  margin: 22px 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

.list__heading:first-child { margin-top: 4px; }

.list__note { color: var(--muted); font-size: 13.5px; margin: 18px 0 0; }

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

.pill {
  flex: 1 1 auto;
  min-width: 72px;
  min-height: 46px;
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease;
}

.pill:active { transform: scale(.96); }

.pill.is-selected {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: var(--accent-ink);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (min-width: 560px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 84px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform .12s ease;
}

.tile:active { transform: scale(.97); }

.tile.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.tile__emoji { font-size: 22px; line-height: 1; }
.tile__label { font-size: 15px; font-weight: 600; line-height: 1.25; }
.tile__sub   { font-size: 12px; color: var(--muted); }

/* Subjects inside an opened family: visually subordinate, with an accent edge
   so it is obvious they belong to the family above them. */
.tile--child {
  min-height: 68px;
  background: var(--surface-2);
  border-left: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
}

.tile--child .tile__emoji { font-size: 18px; }
.tile--child .tile__label { font-size: 14px; }

.tile--open {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

/* --------------------------------------------------------------------------
   Statistics
   -------------------------------------------------------------------------- */

.statgrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
}

.stat__value { display: block; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.stat__label { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); }

.callout {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  font-size: 14.5px;
  line-height: 1.45;
}

.bars { display: flex; flex-direction: column; gap: 12px; }

.bar__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 14.5px;
}

.bar__label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar__value { color: var(--muted); font-size: 13px; flex: 0 0 auto; }
.bar__value b { color: var(--text); font-size: 14.5px; }

.bar__track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .5s cubic-bezier(.2, .8, .3, 1);
}

.bar__fill[data-tone="low"]  { background: linear-gradient(90deg, var(--wrong), #FF9E6B); }
.bar__fill[data-tone="high"] { background: linear-gradient(90deg, var(--right), #6EE7C4); }

.bank {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 14.5px;
  color: var(--muted);
  line-height: 1.55;
}

.bank b { color: var(--text); }

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 84px);
  transform: translateX(-50%);
  max-width: min(92vw, 420px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14.5px;
  box-shadow: var(--shadow);
  z-index: 50;
  animation: reveal .2s ease-out both;
}

/* --------------------------------------------------------------------------
   Accessibility and larger screens
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* On a tablet or desktop the app stays a centred phone-width column, which is
   what a quiz this simple wants — the question should never be a long line. */
@media (min-width: 720px) {
  body { background: var(--bg-2); }
  .app {
    max-width: 520px;
    margin: 0 auto;
    background: var(--bg);
    min-height: 100dvh;
    /* The column needs an edge. Without one the difference between the page
       and the column is a barely-visible change of shade, which reads as a
       rendering fault rather than a decision — particularly on an iPad, where
       it is the first thing anyone sees. */
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    box-shadow: 0 0 60px rgba(0, 0, 0, .45);
  }
  .screen { padding-left: 32px; padding-right: 32px; }
}

/* Genuinely large screens: let the column breathe a little rather than looking
   like a phone that wandered onto a desk. */
@media (min-width: 1024px) {
  .app { max-width: 600px; }
}

/* --------------------------------------------------------------------------
   Leaderboard
   A row is rank, name, score, and a quiet second line. Your own row is marked
   rather than merely highlighted, so it is findable by more than colour.
   -------------------------------------------------------------------------- */

.board { display: grid; gap: 8px; margin: 18px 0 8px; }

.board__row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: baseline;
  gap: 4px 12px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.board__row.is-you {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.board__rank {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.board__row:nth-child(1) .board__rank { color: var(--gold); }

.board__name {
  font-size: 16px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.board__score {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Sits under the name, in the middle column. */
.board__detail {
  grid-column: 2 / -1;
  font-size: 13px;
  color: var(--muted);
}

/* The "where you stand" row, for anyone outside the top of the board. */
.board__you {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 14px 4px;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
}

.checkline input { width: 20px; height: 20px; accent-color: var(--accent); }

/* --------------------------------------------------------------------------
   Friends
   -------------------------------------------------------------------------- */

.segmented--three { grid-template-columns: repeat(3, 1fr); }
.segmented--three .segmented__btn { font-size: 14.5px; padding: 0 4px; }

.invite { margin: 16px 0 6px; }

/* A link rather than a code: smaller, wrapping, still selectable. */
.codebox--link {
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  padding: 16px 14px;
  text-align: left;
  font-weight: 500;
}

.friends { margin-top: 24px; }

.friend {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: center;
  padding: 14px 15px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.friend__name { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.friend__detail { grid-column: 1; font-size: 13px; color: var(--muted); }
.friend .linkbtn { grid-row: 1 / 3; grid-column: 2; align-self: center; }
