/*
  Sections: tokens · base · header · mode tabs · clue card · guesses · guess input · result · practice · footer and content pages · dialogs · picker · toast · responsive.
  Dev toolbar styles live in src/dev/devbar.css.
*/

/* ===== Tokens ===== */

:root {
  /* Brand palette */
  --navy: #153962; /* dark cornflower blue, deep */
  --blue: #1f4898; /* dark cornflower blue */
  --sky: #4696d1; /* celestial blue */
  --orange: #ed882e; /* safety orange */
  --orange-strong: #fc5400; /* safety orange, vivid */
  --white: #ffffff;

  /* Surfaces and text */
  --bg: var(--white);
  --paper: var(--white); /* inputs and dialogs */
  --surface: #f3f8fd; /* celestial tint for cards */
  --text: var(--navy);
  --muted: #5b7290;
  --placeholder: #9db3c9;
  --border: #d8e7f5;
  --error: #c0392b;

  /* Guess and hint feedback */
  --correct: #2e9e5b;
  --present: #d9a520;
  --absent: #8a909c;
  --bad-bg: #eceef3;

  /* Destination mode distance bands (correct uses --correct) */
  --band-hot: var(--orange-strong);
  --band-warm: var(--present);
  --band-mild: var(--sky);
  --band-cold: var(--absent);

  /* Layout */
  --radius: 10px;
  --content-width: 560px;
  /* Side padding that lines full-width bars up with the centred content column. */
  --page-gutter: max(16px, calc((100% - var(--content-width)) / 2 + 16px));

  color-scheme: light;
}

/* Dimmed mode (default): softer, slightly darker light colours so the page isn't glaring. */
:root[data-dim='on'] {
  --bg: #e4eaf1;
  --paper: #f6f8fa;
  --surface: #f6f8fa; /* stays lighter than --bad-bg so wrong-hint chips remain visible */
  --border: #c9d6e4;
  --muted: #536a86;
}

/* ===== Base ===== */

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  transition: background 0.2s;
}

main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 16px;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  background: var(--blue);
  color: var(--white);
  padding: 10px 18px;
  font-weight: 600;
  transition:
    background 0.15s,
    color 0.15s;
}

button:hover {
  background: var(--navy);
}

/* Main calls to action are orange so they stand out from the blues. */
.btn-primary {
  background: var(--orange-strong);
}

.btn-primary:hover {
  background: var(--orange);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

/* Until the data has loaded (see main.js) */
#app[aria-busy='true'] > :not(.mode-tabs) {
  opacity: 0.4;
  pointer-events: none;
}

.error {
  color: var(--error);
  text-align: center;
}

/* ===== Header ===== */

/* Full-width navy bar; the title stays centred between the two side groups. */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 12px var(--page-gutter);
  background: var(--navy);
  border-bottom: 4px solid var(--orange);
}

.topbar > :first-child {
  justify-self: start;
}

.topbar h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
  color: var(--white);
}

.topbar h1 span {
  color: var(--orange);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  background: transparent;
  color: var(--white);
  border: 1px solid rgb(255 255 255 / 0.35);
}

.icon-btn:hover {
  background: rgb(255 255 255 / 0.12);
}

/* A new player's bubble under the help button (see showHelpHint), its tail under the button's centre */
.help-anchor {
  position: relative;
  display: flex;
  --tail-right: calc(19px - 7px);
}

.help-hint {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 10;
  padding: 6px 12px;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 700;
  background: var(--orange-strong);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.25);
  animation: hint-bob 0.8s ease-in-out infinite alternate;
}

.help-hint:hover {
  background: var(--orange-strong);
}

.help-hint::before {
  content: '';
  position: absolute;
  bottom: 100%;
  right: var(--tail-right);
  border: 7px solid transparent;
  border-bottom-color: var(--orange-strong);
}

@keyframes hint-bob {
  to {
    transform: translateY(5px);
  }
}

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

/* Segmented language toggle */
.lang-toggle {
  display: flex;
  padding: 2px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.1);
  border: 1px solid rgb(255 255 255 / 0.35);
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  background: transparent;
  color: var(--white);
  font-size: 0.8rem;
}

.lang-btn:hover {
  background: rgb(255 255 255 / 0.15);
}

.lang-btn[aria-pressed='true'] {
  background: var(--white);
  color: var(--navy);
}

.flag {
  width: 18px;
  height: 12px;
  border-radius: 2px;
}

.flag-id {
  /* the white half needs an edge on the white active pill */
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.15);
}

/* ===== Mode tabs ===== */

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0; /* three to a row: let long names wrap instead of widening the grid */
  padding: 12px;
  text-align: left;
  background: var(--paper);
  color: var(--navy);
  border: 2px solid var(--border);
  box-shadow: 0 2px 6px rgb(21 57 98 / 0.08);
}

.mode-btn:hover {
  background: var(--surface);
  border-color: var(--sky);
}

.mode-btn[aria-pressed='true'] {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
  box-shadow: inset 0 -4px 0 var(--orange);
}

.mode-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.mode-name {
  max-width: 100%;
  font-size: 1rem;
  line-height: 1.2;
  hyphens: auto; /* "Destination" barely fits a third of a small phone */
  overflow-wrap: break-word;
}

/* The daily puzzle's sections, grouped only so they can be hidden together */
.daily {
  display: contents;
}

/* ===== Clue card ===== */

.clue {
  background: linear-gradient(120deg, var(--blue), var(--sky));
  color: var(--white);
  border-left: 6px solid var(--orange-strong);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 6px 18px rgb(31 72 152 / 0.2);
}

.clue-meta {
  margin: 0 0 10px;
  color: rgb(255 255 255 / 0.8);
  font-size: 0.85rem;
}

.clue-route {
  display: flex;
  align-items: center;
  gap: 12px;
}

.halte {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.halte:last-child {
  text-align: right;
}

.halte-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgb(255 255 255 / 0.75);
}

.halte strong {
  font-size: 1.1rem;
}

.arrow {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--orange);
  color: var(--white);
  font-size: 1.1rem;
  font-weight: 700;
}

/* Destination mode: the route code is the clue */
.clue-dest {
  display: flex;
  align-items: center;
  gap: 14px;
}

.clue-dest > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.route-badge {
  display: grid;
  place-items: center;
  min-width: 64px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--white);
  color: var(--navy);
  font-size: 1.8rem;
  font-weight: 800;
  box-shadow: inset 0 -4px 0 var(--orange);
}

.clue-question {
  font-size: 1.05rem;
}

/* ===== Guesses ===== */

.guesses {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guess {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  align-items: center;
}

.tiles {
  display: flex;
  gap: 4px;
}

.tile {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 38px;
  border-radius: 6px;
  color: var(--white);
  font-weight: 700;
  font-size: 1.15rem;
}

.tile-correct {
  background: var(--correct);
}

.tile-present {
  background: var(--present);
}

.tile-absent {
  background: var(--absent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.chip {
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.chip-label {
  opacity: 0.75;
  margin-right: 4px;
}

.chip-good {
  background: var(--correct);
  color: var(--white);
}

.chip-bad {
  background: var(--bad-bg);
  color: var(--text);
}

.guess-path {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* Destination mode guess row: one cell per guessed station */
.dest-guess {
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

.dest-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  min-width: 0;
}

.dest-station {
  font-weight: 600;
}

.dest-note {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.75rem;
}

.band {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--white);
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.band-correct {
  background: var(--correct);
}

.dest-arrow {
  display: inline-block;
  min-width: 1em;
  text-align: center;
}

.band-hot {
  background: var(--band-hot);
}

.band-warm {
  background: var(--band-warm);
}

.band-mild {
  background: var(--band-mild);
}

.band-cold {
  background: var(--band-cold);
}

/* ===== Guess input ===== */

.guesses-left {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.guesses-left p {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.guesses-left strong {
  font-size: 1.6rem;
  color: var(--blue);
}

.pips {
  display: flex;
  gap: 6px;
}

.pip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--sky);
}

.pip-used {
  background: var(--border);
}

/* Final guess: switch to orange as a warning. */
.last-guess strong,
.last-guess span {
  color: var(--orange-strong);
}

.last-guess .pip:not(.pip-used) {
  background: var(--orange-strong);
}

.guess-form {
  display: flex;
  gap: 8px;
}

/* A guess field: a button that opens the picker, styled as a text field */
.pick-field {
  flex: 1;
  min-width: 0;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border: 2px solid var(--sky);
  background: var(--paper);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pick-field:hover {
  background: var(--surface);
}

.pick-placeholder {
  color: var(--placeholder);
  font-weight: 400;
}

.pick-field.filled .pick-placeholder {
  display: none;
}

/* Destination mode: two station fields above the Guess button */
.destination-form {
  flex-direction: column;
}

.station-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.station-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.station-field .pick-field {
  font-size: 1rem;
}

.station-field.locked .pick-field {
  border-color: var(--correct);
  background: var(--surface);
  color: var(--correct);
  font-weight: 700;
  cursor: default;
}

/* ===== Result ===== */

.result {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--sky);
  border-radius: var(--radius);
  padding: 16px;
}

.result h2 {
  margin-top: 0;
  color: var(--blue);
}

.result p {
  margin: 4px 0;
}

.result .result-detail {
  color: var(--muted);
  margin-bottom: 14px;
}

.result-answer {
  display: inline-block;
  min-width: 80px;
  padding: 4px 16px;
  border-radius: var(--radius);
  background: var(--navy);
  color: var(--white);
  font-size: 2.4rem;
  font-weight: 800;
}

/* Short line between the share button and the countdown */
.result-divider {
  width: 40px;
  margin: 20px auto 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.result .next {
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Needs .result to beat `.result p`, which would leave it 4px under the countdown */
.result .other-mode {
  margin-top: 16px;
}

/* Link to a daily mode: the other one under the countdown, an unfinished one under Practice's summary */
.other-mode {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.other-mode button {
  padding: 0;
  background: transparent;
  color: var(--orange-strong);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.other-mode button:hover {
  background: transparent;
  color: var(--orange);
}

#countdown {
  color: var(--orange-strong);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Two station names instead of a short code */
.result-answer.result-answer-long {
  font-size: 1.5rem;
  padding: 8px 16px;
}

/* ===== Practice ===== */

.practice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--sky);
  border-radius: var(--radius);
  padding: 16px;
}

.practice-card h2 {
  margin: 0 0 4px;
  color: var(--blue);
}

.practice-intro {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Setup: each choice is a radio styled as a button */
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  border: none;
}

.choices-3 {
  grid-template-columns: repeat(3, 1fr);
}

.choices legend {
  margin-bottom: 6px;
  padding: 0;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice > span {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  height: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.choice > span:hover {
  border-color: var(--sky);
}

.choice small {
  color: var(--muted);
  font-size: 0.75rem;
}

.choice input:checked + span {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
  box-shadow: inset 0 -4px 0 var(--orange);
}

.choice input:checked + span small {
  color: rgb(255 255 255 / 0.8);
}

.choice input:focus-visible + span {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

.practice-card > .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 1.05rem;
}

/* Playing */
.practice-progress {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.practice-bar {
  height: 6px;
  margin: 6px 0 12px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.practice-bar span {
  display: block;
  height: 100%;
  background: var(--orange);
  transition: width 0.3s;
}

#practice-play .clue {
  margin-bottom: 16px;
}

.practice-reveal {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.practice-reveal p {
  margin: 4px 0;
}

.practice-verdict {
  font-size: 1.3rem;
  font-weight: 800;
}

.is-right {
  color: var(--correct);
}

.is-wrong {
  color: var(--error);
}

.practice-label,
.practice-detail,
.practice-meta {
  color: var(--muted);
}

.practice-codes {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.practice-codes .route-badge {
  background: var(--navy);
  color: var(--white);
}

.practice-ends {
  font-size: 1.3rem;
  font-weight: 800;
}

.practice-yours {
  margin-top: 12px !important;
  font-size: 0.9rem;
}

.practice-yours-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  font-size: 0.9rem;
}

.practice-reveal .btn-primary {
  margin-top: 14px;
  min-width: 160px;
}

/* Summary */
#practice-summary {
  text-align: center;
}

.practice-score {
  margin: 4px 0 0;
  font-size: 1.4rem;
  color: var(--muted);
}

.practice-score strong {
  font-size: 3rem;
  color: var(--navy);
}

.practice-percent {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.practice-verdict-title {
  margin: 8px 0 14px !important;
}

#practice-summary h3 {
  margin: 14px 0 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.practice-types {
  justify-content: center;
}

.practice-review {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: left;
}

.practice-review-row {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.practice-review-row.is-wrong {
  background: var(--bad-bg);
}

.practice-review-mark {
  font-weight: 800;
}

.practice-review-row.is-right .practice-review-mark {
  color: var(--correct);
}

.practice-review-row.is-wrong .practice-review-mark {
  color: var(--error);
}

.practice-review-row > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.practice-review-clue {
  font-weight: 700;
}

.practice-review-detail {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Share stands alone, centred above the other actions */
.practice-share {
  display: block;
  min-width: 160px;
  margin: 16px auto 0;
}

.practice-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

/* Secondary actions: outlined, so the main ones stand out */
.btn-secondary {
  background: transparent;
  color: var(--blue);
  border: 2px solid var(--border);
}

.btn-secondary:hover {
  background: var(--paper);
  border-color: var(--sky);
}

.disclaimer {
  color: var(--muted);
  font-size: 0.75rem;
}

/* ===== Footer and content pages (About, Privacy, Donate) ===== */

.site-footer {
  display: flex;
  justify-content: center;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 20px;
  max-width: var(--content-width);
  margin: 8px auto 0;
  padding: 16px 16px 28px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}

.footer-version {
  font-weight: 700;
}

/* Small text buttons */
.site-footer a,
.back-link,
.page-card a {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.site-footer a:hover,
.back-link:hover,
.page-card a:hover {
  color: var(--orange-strong);
  text-decoration: underline;
}

.home-link {
  color: inherit;
  text-decoration: none;
}

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

.back-link {
  align-self: flex-start;
  font-size: 0.9rem;
}

.page-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--sky);
  border-radius: var(--radius);
  padding: 18px;
  line-height: 1.55;
}

.page-card h2 {
  margin: 0 0 8px;
  color: var(--blue);
}

.page-card h3 {
  margin: 18px 0 4px;
  color: var(--navy);
  font-size: 1rem;
}

.page-card ul {
  padding-left: 20px;
}

.donate {
  text-align: center;
}

.qris {
  display: block;
  width: min(100%, 320px);
  height: auto;
  margin: 16px auto;
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgb(21 57 98 / 0.18);
}

/* ===== Dialogs ===== */

dialog {
  max-width: min(440px, calc(100vw - 32px));
  border: none;
  border-top: 6px solid var(--orange);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--text);
  padding: 20px;
  box-shadow: 0 12px 40px rgb(21 57 98 / 0.3);
}

dialog::backdrop {
  background: rgb(21 57 98 / 0.55);
}

dialog h2 {
  margin-top: 0;
  color: var(--blue);
}

dialog h3 {
  color: var(--blue);
}

dialog ul {
  padding-left: 18px;
  line-height: 1.6;
}

dialog .tile {
  width: 24px;
  height: 26px;
  font-size: 0.85rem;
}

dialog > button {
  margin-top: 16px;
  width: 100%;
}

.stats-mode {
  margin: -8px 0 12px;
  color: var(--muted);
  font-weight: 600;
}

dialog .band {
  font-size: 0.75rem;
  padding: 1px 7px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  text-align: center;
}

.stats strong {
  display: block;
  font-size: 1.6rem;
  color: var(--blue);
}

.stats span {
  font-size: 0.75rem;
  color: var(--muted);
}

.dist-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 4px 0;
}

.dist-bar {
  background: var(--sky);
  color: var(--white);
  text-align: right;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
}

/* ===== Picker ===== */

/*
  The list a guess field opens: a panel over the bottom half of the screen, so the clue and the
  latest guesses stay visible above it. picker.js sets --keyboard-inset and --visible-height from
  the visible viewport, so the panel sits above a phone's keyboard instead of behind it.
*/
dialog.picker {
  inset: auto 0 var(--keyboard-inset, 0) 0;
  margin: 0 auto;
  width: min(var(--content-width), 100vw);
  max-width: 100vw;
  height: min(55dvh, var(--visible-height, 100dvh));
  min-height: min(320px, var(--visible-height, 100dvh));
  max-height: 100dvh;
  padding: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  flex-direction: column;
}

/* Lighter than other dialogs: the puzzle behind it is meant to be read */
dialog.picker::backdrop {
  background: rgb(21 57 98 / 0.25);
}

/* Room under the page while the panel is open, so the guess field can scroll up above it */
body.picker-open main {
  padding-bottom: var(--picker-height, 0);
}

dialog.picker[open] {
  display: flex;
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 8px 16px;
}

.picker-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.picker-close {
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
}

.picker-close:hover {
  background: var(--surface);
  color: var(--text);
}

.picker-search {
  margin: 0 12px 8px;
  font: inherit;
  font-size: 1rem; /* 16px or more, so iPhones don't zoom in on focus */
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 2px solid var(--sky);
  background: var(--paper);
  color: var(--text);
}

.picker-search::placeholder {
  color: var(--placeholder);
}

.picker-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  margin: 0;
  padding: 0 0 12px;
  border-top: 1px solid var(--border);
}

.picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}

.picker-row:hover,
.picker-row[aria-selected='true'] {
  background: var(--surface);
  box-shadow: inset 4px 0 0 var(--sky);
}

.picker-row mark {
  background: none;
  color: var(--orange-strong);
}

.picker-row.is-guessed,
.picker-row.is-guessed mark {
  color: var(--absent);
}

.picker-guessed {
  font-size: 0.8rem;
  font-weight: 400;
  white-space: nowrap;
}

/* Fills the space, so a tap there isn't read as a tap outside the dialog (which closes it) */
.picker-empty {
  flex: 1;
  padding: 16px;
  text-align: center;
  color: var(--muted);
}

.picker-empty p {
  margin: 4px 0;
}

/* ===== Toast ===== */

.toast {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: var(--white);
  border-left: 4px solid var(--orange);
  padding: 10px 16px;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.toast.visible {
  opacity: 1;
}

/* ===== Responsive ===== */

/* Not enough room beside the centred title for the language names: flags only. */
@media (max-width: 540px) {
  .lang-name {
    display: none;
  }

  .topbar h1 {
    font-size: 1.4rem;
  }

  .topbar-actions {
    gap: 6px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  .help-anchor {
    --tail-right: calc(17px - 7px);
  }
}

@media (max-width: 420px) {
  .guess,
  .station-fields {
    grid-template-columns: 1fr;
  }

  .mode-btn {
    padding: 10px;
  }

  .mode-name {
    font-size: clamp(0.8rem, 3.6vw, 1rem); /* scales so "Destination" fits whole from 360px up */
  }

  .choice small:not(.choice-count) {
    display: none;
  }

  .practice-actions {
    grid-template-columns: 1fr;
  }

  .chips {
    justify-content: flex-start;
  }
}
