/* Lyondoku stylesheet - extracted verbatim from index.html. */
  :root {
    /* Couleurs officielles NXT - chartées sur les lignes Lyon */
    --nxt-red: #E2001A;       /* Rouge NXT identité (badges modes) */
    --nxt-red-dark: #B8001A;
    --line-a: #E5007D;        /* Métro A - magenta */
    --line-b: #0072BC;        /* Métro B - bleu */
    --line-c: #F18700;        /* Métro C - orange */
    --line-d: #009E60;        /* Métro D - vert */
    --line-tram: #862F8C;     /* Tramway T1–T7 - violet */
    --line-t1: var(--line-tram);
    --line-t2: var(--line-tram);
    --line-t3: var(--line-tram);
    --line-t4: var(--line-tram);
    --line-t5: var(--line-tram);
    --line-t6: var(--line-tram);
    --line-t7: var(--line-tram);

    --ink: #0E0E12;
    --paper: #ffffff;
    --grey-50: #fafafb;
    --grey-100: #f4f4f6;
    --grey-200: #ececef;
    --grey-300: #d8d8de;
    --grey-500: #8b8b95;
    --grey-700: #43434a;
    --muted: #6b6b75;
    --bg: #f2f2f5;
    --bg-soft: #e9e9ee;
    --tile-shadow: 0 1px 3px rgba(14,14,18,.10), 0 4px 14px -6px rgba(14,14,18,.16);
    --tile-shadow-hover: 0 1px 2px rgba(14,14,18,.12), 0 16px 32px -10px rgba(226,0,26,.28);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;

    /* LED departure board */
    --led-bg: #0a0a0a;
    --led-amber: #ffb000;
    --led-green: #4cff4c;
    --led-red: #ff3b3b;
  }

  html.theme-dark {
    color-scheme: dark;
    --ink: #f4f4f7;
    --paper: #1c1c22;
    --grey-50: #15151a;
    --grey-100: #23232a;
    --grey-200: #2c2c34;
    --grey-300: #3a3a44;
    --grey-500: #8b8b95;
    --grey-700: #b0b0b8;
    --muted: #9a9aa3;
    --bg: #0e0e12;
    --bg-soft: #15151a;
    --tile-shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -8px rgba(0,0,0,.5);
    --tile-shadow-hover: 0 1px 2px rgba(0,0,0,.5), 0 16px 32px -10px rgba(226,0,26,.35);
  }
  html.theme-dark body {
    background-image:
      radial-gradient(1200px 600px at 100% -10%, rgba(226,0,26,.12), transparent 60%),
      radial-gradient(900px 500px at -10% 100%, rgba(0,111,185,.08), transparent 60%);
  }
  html.theme-dark header.nxt-bar {
    background: rgba(20,20,26,0.78);
    border-bottom-color: rgba(255,255,255,.06);
  }
  html.theme-dark .placeholder .plus-circle {
    background: var(--grey-200);
    color: var(--grey-700);
  }
  html.theme-dark .play-cell.correct {
    background: linear-gradient(180deg, #14352a 0%, #0e2820 100%);
  }
  html.theme-dark .play-cell.correct .station-name { color: #b8f0d0; }
  html.theme-dark .station-points {
    color: #4cd58a;
    background: rgba(10,139,84,0.18);
  }
  html.theme-dark .station-points::before { background: #4cd58a; }
  @keyframes flashWrongDark {
    0% { background: var(--paper); box-shadow: var(--tile-shadow); }
    20% { background: #3a1318; box-shadow: 0 0 0 3px rgba(226,0,26,0.55), 0 12px 30px -8px rgba(226,0,26,0.6); transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { background: #2a0e12; transform: translateX(2px); }
    100% { background: var(--paper); box-shadow: var(--tile-shadow); transform: translateX(0); }
  }
  html.theme-dark .play-cell.flash-wrong { animation: flashWrongDark 0.6s cubic-bezier(.36,.07,.19,.97); }
  html.theme-dark button.nxt-btn { box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 20px -8px rgba(0,0,0,.6); }
  html.theme-dark button.nxt-btn.ghost { background: var(--paper); color: var(--ink); border-color: var(--grey-300); }
  html.theme-dark button.nxt-btn.ghost:hover { background: var(--grey-100); }
  html.theme-dark .modal { background: var(--paper); }
  html.theme-dark .modal-criteria { background: var(--grey-100); }
  html.theme-dark .search-input { background: transparent; color: var(--ink); border-bottom-color: var(--grey-300); }
  html.theme-dark .suggestion { border-bottom-color: var(--grey-200); }
  html.theme-dark .suggestion:hover { background: var(--grey-100); }
  html.theme-dark .end-stat-card:not(.score-card) { background: var(--grey-100); }
  html.theme-dark .col-header .ico { background: var(--grey-200); }

  * { margin: 0; padding: 0; box-sizing: border-box; }

  html, body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', 'Barlow', system-ui, sans-serif;
    min-height: 100vh;
    background-image:
      radial-gradient(1200px 600px at 100% -10%, rgba(226,0,26,.06), transparent 60%),
      radial-gradient(900px 500px at -10% 100%, rgba(0,111,185,.05), transparent 60%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
  }

  .container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 0 5rem;
  }
  .pad-x { padding-left: 1rem; padding-right: 1rem; }

  /* ============ HEADER STYLE NXT - modernisé 2026 ============ */
  header.nxt-bar {
    background: rgba(255,255,255,0.78);
    backdrop-filter: saturate(140%) blur(14px);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 0.9rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(14,14,18,.06);
  }
  header.nxt-bar::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, var(--nxt-red) 0%, var(--nxt-red) 70%, transparent 100%);
  }
  .nxt-mark {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  .nxt-logo {
    background: var(--nxt-red);
    color: white;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: 0.02em;
    padding: 0.15rem 0.6rem;
    border-radius: 4px;
    line-height: 1.1;
    font-style: italic;
    transform: skewX(-8deg);
  }
  .nxt-logo span { display: inline-block; transform: skewX(8deg); }
  .header-title {
    flex: 1;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--ink);
  }
  .header-title em {
    color: var(--nxt-red);
    font-style: normal;
  }
  /* Logo + wordmark act as a "home" link back to today's grid. */
  .brand-home {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s, transform 0.15s;
  }
  .brand-home:hover { opacity: 0.85; }
  .brand-home:active { transform: scale(0.98); }
  .brand-home:focus-visible { outline: 2px solid var(--nxt-red); outline-offset: 3px; }
  .theme-toggle {
    background: var(--grey-100);
    color: var(--ink);
    border: 1px solid var(--grey-200);
    width: 2.4rem; height: 2.4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
  }
  .theme-toggle:hover { background: var(--grey-200); transform: rotate(15deg); }
  .header-subtitle {
    font-size: 0.7rem;
    color: var(--muted);
    letter-spacing: 0.02em;
    font-weight: 500;
    margin-top: 0.2rem;
  }

  /* ============ LED DEPARTURE BOARD (scoreboard) - modernisé ============ */
  /* Light mode: a recessed pale "LCD" screen with deep, legible segment digits. */
  .led-board {
    background: linear-gradient(180deg, #f7f8fa 0%, #e7e9ef 100%);
    color: #2a2a30;
    padding: 1rem 1.1rem;
    margin: 0.85rem 1rem 0.85rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
    font-family: 'VT323', 'Courier New', monospace;
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(14,14,18,.08);
    box-shadow: inset 0 2px 5px rgba(14,14,18,.06),
                0 1px 2px rgba(14,14,18,.04),
                0 8px 24px -12px rgba(14,14,18,.12);
  }
  /* Dark mode: glowing retro "departure board" device. */
  html.theme-dark .led-board {
    background: linear-gradient(180deg, #15151b 0%, #0a0a0e 100%);
    color: var(--led-amber);
    border: none;
    box-shadow: 0 1px 2px rgba(14,14,18,.12),
                0 18px 40px -16px rgba(14,14,18,.45),
                inset 0 1px 0 rgba(255,255,255,.05);
  }
  .led-board::after {
    content:'';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid rgba(14,14,18,0.04);
    pointer-events: none;
  }
  html.theme-dark .led-board::after { border-color: rgba(255,255,255,0.06); }
  .led-board::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
      0deg,
      rgba(14,14,18,0.025) 0,
      rgba(14,14,18,0.025) 1px,
      transparent 1px,
      transparent 3px
    );
    pointer-events: none;
  }
  html.theme-dark .led-board::before {
    background: repeating-linear-gradient(
      0deg,
      rgba(255,255,255,0.02) 0,
      rgba(255,255,255,0.02) 1px,
      transparent 1px,
      transparent 3px
    );
  }
  .led-stat { position: relative; }
  .led-label {
    font-family: 'Barlow', sans-serif;
    font-size: 0.6rem;
    color: #8a8a95;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    margin-bottom: 0.15rem;
    font-weight: 600;
  }
  html.theme-dark .led-label { color: rgba(255, 176, 0, 0.55); }
  /* Light: deep "LCD off-glass" digit colors. Dark: glowing LED. */
  .led-value {
    font-family: 'VT323', 'Courier New', monospace;
    font-weight: 400;
    font-size: 2.2rem;
    line-height: 1;
    letter-spacing: 0.02em;
    color: #b8860b;
    text-shadow: 0 1px 0 rgba(255,255,255,.45);
  }
  .led-value .green { color: #15803d; }
  html.theme-dark .led-value {
    color: var(--led-amber);
    text-shadow: 0 0 8px rgba(255, 176, 0, 0.55);
  }
  html.theme-dark .led-value .green { color: var(--led-green); text-shadow: 0 0 8px rgba(76, 255, 76, 0.55); }
  .led-stat.center { text-align: center; }
  .led-stat.right { text-align: right; }
  .led-stat.right .led-label { text-align: right; }

  .errors-dots {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
    align-items: center;
    margin-top: 0.45rem;
  }
  .err-dot {
    width: 0.85rem; height: 0.85rem;
    border-radius: 50%;
    background: rgba(255, 59, 59, 0.15);
    border: 1px solid rgba(255, 59, 59, 0.4);
  }
  .err-dot.used {
    background: var(--led-red);
    box-shadow: 0 0 6px var(--led-red);
    border-color: var(--led-red);
  }

  /* ============ MODERN CARD GRID ============ */
  .panel {
    margin: 0 1rem 0.85rem;
  }
  .panel-head {
    background: transparent;
    color: var(--ink);
    padding: 0 0.25rem 0.6rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    text-transform: none;
  }
  .panel-head .right {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    color: var(--muted);
    letter-spacing: 0.02em;
    font-weight: 500;
    text-transform: none;
  }

  /* The 3x3 board, modern card grid */
  .board {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .board-col-headers {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background: transparent;
    border-bottom: none;
    padding: 0;
  }
  .col-header {
    padding: 0.6rem 0.4rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: -0.005em;
    text-align: center;
    color: var(--ink);
    cursor: pointer;
    line-height: 1.2;
    transition: transform 0.15s, box-shadow 0.15s;
    background: var(--paper);
    border-radius: var(--radius-md);
    box-shadow: var(--tile-shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 104px;
    position: relative;
    overflow: hidden;
  }
  .col-header.is-corner {
    background: transparent;
    box-shadow: none;
    cursor: default;
    color: var(--grey-500);
  }
  @media (hover: hover) { .col-header:hover:not(.is-corner) { transform: translateY(-1px); box-shadow: var(--tile-shadow-hover); } }
  .col-header .ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-family: 'VT323', monospace;
    font-size: 0.7rem;
    color: var(--grey-500);
    letter-spacing: 0.05em;
    background: var(--grey-100);
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    border: none;
    text-transform: uppercase;
    font-weight: normal;
    line-height: 1;
  }
  .col-header .label-text { display: block; }
  /* Match the line row-header label ("Sur la ligne") to the column header font */
  .row-header .label-text {
    font-family: 'Inter', sans-serif;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    line-height: 1.2;
  }

  /* Tiny "?" hint shown in the top-right of column/row headers to suggest
     they are tappable for an explanation. */
  .header-help {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--grey-100);
    color: var(--grey-500);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 10px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    letter-spacing: 0;
    text-align: center;
    padding-top: 1px;
  }
  html.theme-dark .header-help { background: var(--grey-200); color: var(--grey-500); }

  .board-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    border-bottom: none;
    min-height: 104px;
  }

  .row-header {
    background: var(--paper);
    padding: 0.6rem 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-right: none;
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
    border-radius: var(--radius-md);
    box-shadow: var(--tile-shadow);
    overflow: hidden;
    min-height: 104px;
    text-align: center;
  }
  @media (hover: hover) { .row-header:hover { transform: translateY(-1px); box-shadow: var(--tile-shadow-hover); } }
  .row-header.is-line { gap: 0.35rem; flex-direction: column; }
  .row-header.is-line .header-label {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.7rem;
    color: var(--ink);
    letter-spacing: -0.005em;
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
    line-height: 1.15;
  }
  .row-header > .header-label,
  .row-header > span,
  .row-header > div:not(.is-line) {
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
    line-height: 1.15;
  }

  /* NXT-style mode + line badge stack: e.g. [M][A] */
  /* Official TCL pictogram (SVG = whole [M][A] badge). Height-driven scaling;
     width auto preserves the 2-square aspect. Rounded silhouette is baked
     into the SVG itself, so no border-radius needed here. */
  .tcl-line-img {
    height: 1.0rem;
    width: auto;
    display: inline-block;
    vertical-align: middle;
  }
  .tcl-line-img.mini { height: 0.85rem; }

  /* Single scaling knob: change --badge-size to resize the whole badge.
     Square side, corner radius and glyph size all derive from it. */
  .line-stack {
    --badge-size: 1.7rem;
    --badge-radius: calc(var(--badge-size) * 0.19);
    --badge-glyph: calc(var(--badge-size) * 0.68);
    display: inline-flex;
    align-items: stretch;
    gap: 0;                 /* squares sit flush, no gap */
    flex-wrap: wrap;
    justify-content: center;
  }
  /* MODE badge (M, T) - NXT style: white letter on red. Square tile with ONLY
     the two left corners rounded; right corners sharp where it meets the line
     tile. Upright (non-italic) condensed type. */
  .mode-pill {
    background: var(--nxt-red);
    color: #fff;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: var(--badge-glyph);
    letter-spacing: 0;
    width: var(--badge-size);
    height: var(--badge-size);
    border-radius: var(--badge-radius) 0 0 var(--badge-radius);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
  }

  /* LINE tile - colored per ligne. Plain square: all four corners sharp. */
  .line-tile {
    color: white;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: var(--badge-glyph);
    width: var(--badge-size);
    height: var(--badge-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border-radius: 0;
    text-transform: uppercase;
  }
  .line-tile.A { background: var(--line-a); }
  .line-tile.B { background: var(--line-b); }
  .line-tile.C { background: var(--line-c); }
  .line-tile.D { background: var(--line-d); }
  .line-tile.tram { background: var(--line-tram); }
  .line-tile.RX { background: #444; font-size: 0.7rem; }

  /* line accent bar at left of row header */
  .row-accent {
    position: absolute;
    top: 12px; bottom: 12px;
    left: 0;
    width: 3px;
    border-radius: 0 3px 3px 0;
  }
  .row-accent.A { background: var(--line-a); }
  .row-accent.B { background: var(--line-b); }
  .row-accent.C { background: var(--line-c); }
  .row-accent.D { background: var(--line-d); }

  .play-cell {
    background: var(--paper);
    border-left: none;
    padding: 0.65rem 0.6rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: transform 0.18s cubic-bezier(.2,.8,.2,1), box-shadow 0.18s, background 0.15s;
    position: relative;
    border-radius: var(--radius-md);
    box-shadow: var(--tile-shadow);
    overflow: hidden;
  }
  @media (hover: hover) {
    .play-cell:hover:not(.locked) {
      transform: translateY(-2px);
      box-shadow: var(--tile-shadow-hover);
    }
  }
  .play-cell:active:not(.locked) { transform: translateY(0); box-shadow: var(--tile-shadow-hover); }
  .play-cell.locked { cursor: default; }

  .placeholder {
    color: var(--grey-300);
    font-size: 1.6rem;
    font-weight: 300;
    line-height: 1;
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
  }
  .placeholder .plus-circle {
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    background: var(--grey-100);
    position: relative;
    color: var(--grey-500);
    font-size: 0; /* hide literal "+" glyph; cross drawn via pseudo-elements */
    transition: background 0.15s, color 0.15s;
  }
  .placeholder .plus-circle::before,
  .placeholder .plus-circle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: currentColor;
  }
  .placeholder .plus-circle::before { width: 0.5rem; height: 1.4px; }
  .placeholder .plus-circle::after { width: 1.4px; height: 0.5rem; }
  @media (hover: hover) {
    .play-cell:hover .plus-circle {
      background: var(--nxt-red);
      color: white;
    }
  }
  .placeholder small {
    display: block;
    font-size: 0.6rem;
    color: var(--muted);
    text-transform: none;
    letter-spacing: 0.01em;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
  }

  .station-name {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.82rem;
    line-height: 1.2;
    color: var(--ink);
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
    letter-spacing: -0.01em;
  }
  .station-points {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.45rem;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.72rem;
    color: #0a8b54;
    background: #e6f7ee;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    letter-spacing: 0;
  }
  .station-points::before {
    content: '';
    width: 0.4rem;
    height: 0.4rem;
    background: #0a8b54;
    border-radius: 50%;
  }
  .play-cell.correct {
    background: linear-gradient(180deg, #e8f8ee 0%, #d6f1e0 100%);
    /* Correct cells: rarity band on top, name, divider, lines pinned bottom. */
    justify-content: flex-start;
    align-items: flex-start;
    text-align: left;
    padding: 0.8rem 0.75rem;
  }
  .play-cell.correct .station-name {
    width: 100%;
    text-align: left;
    /* Scale with the tile so long names (e.g. "Gare Part-Dieu Vivier Merle")
       don't overflow on small screens. */
    font-size: clamp(0.46rem, 2.1vw, 0.6rem);
    line-height: 1.12;
    margin-top: 0.3rem;
  }
  .cell-lines {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: auto;   /* pin line badges to the bottom of the cell */
    align-self: flex-start;
    /* Leave room on the right so badges never run under the undo button. */
    max-width: calc(100% - 1.5rem);
  }
  /* Rarity band: full-width strip at the very top of a correct cell showing
     "<label> - X%" - the share of players who chose this station for this cell.
     Bleeds to the cell edges via negative margins. `.estimated` = frozen prior
     (no live data yet). */
  .cell-rarity-band {
    align-self: stretch;
    margin: -0.8rem -0.75rem 0;
    padding: 0.26rem 0.4rem;
    font-family: 'Inter', sans-serif;
    font-size: clamp(0.44rem, 1.8vw, 0.52rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    color: var(--grey-500);
    background: var(--grey-100);
  }
  .cell-rarity-band.estimated { font-style: italic; font-weight: 600; opacity: 0.85; }
  html.theme-dark .cell-rarity-band { color: var(--grey-400, #9aa); background: var(--grey-200); }
  /* Mini [M][A] / [T][1] badge stacks (used in cells AND in the solutions /
     suggestions lists). Cells get an extra, tile-responsive shrink below. */
  .line-stack.mini { --badge-size: 1.05rem; gap: 0; }
  .cell-lines .line-stack.mini { --badge-size: clamp(0.58rem, 3vw, 0.78rem); }
  .cell-lines .tcl-line-img.mini { height: clamp(0.5rem, 2.6vw, 0.66rem); }
  /* Undo button: bottom-right of a correct cell, frees the station to reuse. */
  .cell-undo {
    position: absolute;
    bottom: 0.55rem;
    right: 0.55rem;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--grey-100);
    color: var(--grey-500);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, transform 0.15s;
    z-index: 2;
  }
  .cell-undo svg { width: 10px; height: 10px; }
  .cell-undo:hover { color: var(--nxt-red); transform: rotate(-25deg); }
  html.theme-dark .cell-undo { background: var(--grey-200); color: var(--grey-500); }
  html.theme-dark .cell-undo:hover { color: var(--nxt-red); }
  .play-cell.wrong .station-name {
    color: var(--nxt-red);
    text-decoration: line-through;
    opacity: 0.55;
  }
  @keyframes flashWrong {
    0% { background: var(--paper); box-shadow: var(--tile-shadow); }
    20% { background: #ffe5e8; box-shadow: 0 0 0 3px rgba(226,0,26,0.4), 0 12px 30px -8px rgba(226,0,26,0.5); transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { background: #ffeef0; transform: translateX(2px); }
    100% { background: var(--paper); box-shadow: var(--tile-shadow); transform: translateX(0); }
  }
  .play-cell.flash-wrong { animation: flashWrong 0.6s cubic-bezier(.36,.07,.19,.97); }

  /* ============ ACTIONS ============ */
  .actions {
    display: flex;
    gap: 0.5rem;
    padding: 0 1rem;
    margin-top: 0.5rem;
  }
  button.nxt-btn {
    flex: 1;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.92rem;
    text-transform: none;
    letter-spacing: -0.005em;
    padding: 0.85rem 1rem;
    border: none;
    background: var(--ink);
    color: white;
    cursor: pointer;
    border-radius: 999px;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
    box-shadow: 0 1px 2px rgba(14,14,18,.08), 0 8px 20px -8px rgba(14,14,18,.25);
  }
  button.nxt-btn:hover { background: var(--grey-700); transform: translateY(-1px); }
  button.nxt-btn.primary {
    background: var(--nxt-red);
    box-shadow: 0 1px 2px rgba(226,0,26,.18), 0 12px 24px -10px rgba(226,0,26,.5);
  }
  button.nxt-btn.primary:hover { background: var(--nxt-red-dark); }
  button.nxt-btn.ghost {
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--grey-300);
    box-shadow: var(--tile-shadow);
  }
  button.nxt-btn.ghost:hover { background: var(--grey-50); }

  /* ============ RULES PANEL ============ */
  .rules {
    margin: 2.25rem 1rem 0;
    padding: 1.1rem 1.2rem;
    background: var(--paper);
    border-left: none;
    border-radius: var(--radius-md);
    box-shadow: var(--tile-shadow);
    position: relative;
    overflow: hidden;
  }
  .rules::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--nxt-red);
  }
  .rules h3 {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: -0.01em;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  .rules h3::before {
    content: 'i';
    width: 1.2rem;
    height: 1.2rem;
    background: var(--nxt-red);
    color: white;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Barlow', serif;
    font-style: italic;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    text-indent: -2px;
    flex-shrink: 0;
    box-sizing: border-box;
    padding-bottom: 2px;
  }
  .rules ul { list-style: none; }
  .rules li {
    padding-left: 1.1rem;
    position: relative;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    line-height: 1.45;
    color: var(--grey-700);
  }
  .rules li::before {
    content: "▸";
    position: absolute;
    left: 0;
    color: var(--nxt-red);
    font-weight: bold;
  }

  /* ============ CONTACT / FEEDBACK PANEL ============ */
  .contact {
    margin: 0.85rem 1rem 0;
    padding: 0.85rem 1rem;
    background: var(--paper);
    border-radius: var(--radius-md);
    box-shadow: var(--tile-shadow);
    position: relative;
    overflow: hidden;
    text-align: center;
  }
  .contact::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--nxt-red);
  }
  .contact h3 {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 0.3rem;
    color: var(--ink);
  }
  .contact p {
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--grey-700);
    margin-bottom: 0.7rem;
  }
  a.contact-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: -0.005em;
    padding: 0.5rem 0.95rem;
    border: 1px solid var(--nxt-red);
    border-radius: 999px;
    background: var(--paper);
    color: var(--nxt-red);
    text-decoration: none;
    box-shadow: var(--tile-shadow);
    transition: background 0.15s, color 0.15s, transform 0.15s;
  }
  a.contact-btn:hover {
    background: var(--nxt-red);
    color: #fff;
    transform: translateY(-1px);
  }
  .contact-mail-ico { color: var(--nxt-red); flex-shrink: 0; }
  a.contact-btn:hover .contact-mail-ico { color: #fff; }

  footer {
    text-align: center;
    margin: 1.5rem 1rem 0;
    font-size: 0.72rem;
    color: var(--muted);
    line-height: 1.5;
    padding-top: 1rem;
    border-top: 1px solid var(--grey-300);
  }
  footer a { color: var(--nxt-red); text-decoration: none; font-weight: 600; }

  /* ============ MODALS ============ */
  .modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 100;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }
  .modal-backdrop.active { display: flex; }

  .modal {
    background: var(--paper);
    width: 100%;
    max-width: 720px;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 12px 12px 0 0;
    animation: slideUp 0.25s cubic-bezier(.2,.8,.2,1);
  }
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  /* Centered card variant (used for the category explanation) */
  .modal-backdrop.modal-center {
    align-items: center;
    justify-content: center;
    padding: 1rem;
  }
  .modal-card {
    width: 100%;
    max-width: 420px;
    max-height: 80vh;
    border-radius: var(--radius-lg);
    animation: popIn 0.2s cubic-bezier(.2,.8,.2,1);
  }
  .modal-card .modal-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  @keyframes popIn {
    from { opacity: 0; transform: scale(.94); }
    to { opacity: 1; transform: scale(1); }
  }

  .modal-header {
    padding: 0.85rem 1rem;
    border-bottom: 3px solid var(--nxt-red);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--ink);
    color: var(--paper);
    border-radius: 12px 12px 0 0;
    /* Stick to the top of the scrolling sheet so the close button stays
       reachable on mobile even when the archive list is long. */
    position: sticky;
    top: 0;
    z-index: 2;
  }
  html.theme-dark .modal-header {
    background: #0a0a0e;
    color: #f4f4f7;
  }
  .modal-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .close-btn {
    background: rgba(255,255,255,0.12);
    color: white;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
  }
  .close-btn:hover { background: rgba(255,255,255,0.25); }
  .modal-body { padding: 1rem; }

  .modal-criteria {
    background: var(--grey-100);
    padding: 0.85rem 0.95rem 0.85rem 1.05rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--nxt-red);
    font-size: 0.95rem;
    position: sticky;
    top: 0;
    z-index: 2;
  }
  /* In the solutions sheet the criteria should scroll away with the answer
     list, not stay pinned (only the header stays sticky). */
  #solutionsCriteria { position: static; }
  .criteria-line {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.3rem 0;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
  }
  .criteria-line .bullet {
    width: 0.55rem;
    height: 0.55rem;
    background: var(--nxt-red);
    border-radius: 50%;
    flex-shrink: 0;
  }
  .modal-criteria strong {
    display: block;
    margin-bottom: 0.5rem;
    font-family: 'Barlow Condensed', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.8rem;
    color: var(--muted);
  }

  /* Two side-by-side criteria pills (line badge or theme label) at the top of
     the station-search modal, mirroring the board headers. */
  .criteria-chips {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
  }
  .criteria-chip {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.65rem 0.6rem;
    background: var(--grey-50);
    border: 1px solid var(--grey-200);
    border-radius: var(--radius-md);
    box-shadow: none;
    text-align: center;
  }
  .criteria-chip-text {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--ink);
    line-height: 1.2;
    word-break: break-word;
  }

  /* ====== Sober centered station-search popup (métrodoku-style) ====== */
  .modal-card.search-card,
  .modal-card.end-card {
    max-width: 480px;
    position: relative;
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px -15px rgba(14,14,18,0.35);
  }
  .search-card .modal-body,
  .end-card .modal-body { padding: 1.4rem 1.3rem 1.2rem; }
  /* Minimal floating close - no heavy dark header bar */
  .close-btn.search-close {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    z-index: 3;
    background: var(--grey-100);
    color: var(--grey-700);
  }
  .close-btn.search-close:hover { background: var(--grey-200); }
  /* Criteria reminder: flat and quiet inside the sober popup */
  #searchModal .modal-criteria {
    background: transparent;
    border-left: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: 1.1rem;
    position: static;
  }
  #searchModal .modal-criteria strong {
    font-family: 'Inter', sans-serif;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.45rem;
  }

  .search-input {
    width: 100%;
    padding: 0.7rem 0.2rem;
    border: none;
    border-bottom: 1px solid var(--grey-200);
    font-size: 1.1rem;
    font-family: 'Inter', sans-serif;
    border-radius: 0;
    margin-bottom: 0.5rem;
    background: transparent;
    color: var(--ink);
  }
  .search-input:focus {
    outline: none;
    border-bottom-color: var(--ink);
  }
  .station-counter {
    font-size: 0.7rem;
    color: var(--muted);
    text-align: right;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
  }

  .suggestions {
    max-height: 50vh;
    overflow-y: auto;
    border: none;
    border-radius: 0;
  }
  .suggestion {
    padding: 0.85rem 0.2rem;
    cursor: pointer;
    border-bottom: 1px solid var(--grey-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    transition: background 0.1s;
  }
  .suggestion:last-child { border-bottom: none; }
  .suggestion:hover { background: var(--grey-50); }
  .suggestion.is-used {
    color: var(--grey-500);
    cursor: default;
  }
  .suggestion.is-used:hover { background: transparent; }
  .used-tag {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--grey-500);
    flex-shrink: 0;
  }
  .suggestion-lines {
    display: flex;
    gap: 0.2rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .mini-tile {
    color: white;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-size: 0.7rem;
    width: 1.15rem;
    height: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    line-height: 1;
    font-style: italic;
  }

  /* End screen */
  .end-screen { text-align: left; }
  .end-headline {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--nxt-red);
    margin: 0.2rem 0 0.25rem;
    padding-right: 2rem;
    line-height: 1;
  }
  .end-screen p.subline {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 1rem;
  }
  .end-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, var(--line-d), #007a4a);
    color: #fff;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 1.05rem;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-sm);
    margin: 0.2rem 0 0.4rem;
    text-align: center;
    line-height: 1.1;
  }
  .end-rank .rank-num { font-size: 1.5rem; }
  .end-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin: 1rem 0;
  }
  .end-stat-card {
    background: var(--grey-100);
    padding: 0.7rem 0.85rem;
    border-left: 4px solid var(--ink);
    border-radius: var(--radius-sm);
    text-align: left;
  }
  /* Hero Score card mirrors the in-game LCD: pale recessed screen (light),
     glowing departure board (dark). */
  .end-stat-card.score-card {
    background: linear-gradient(180deg, #f7f8fa 0%, #e7e9ef 100%);
    border-left: none;
    border: 1px solid rgba(14,14,18,.08);
    padding: 0.9rem 1rem;
    box-shadow: inset 0 2px 5px rgba(14,14,18,.06);
  }
  .end-stat-card.score-card .label { color: #8a8a95; }
  .end-stat-card.score-card .value {
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 2.6rem;
    color: #b8860b;
    text-shadow: 0 1px 0 rgba(255,255,255,.45);
  }
  html.theme-dark .end-stat-card.score-card {
    background: linear-gradient(180deg, #15151b 0%, #0a0a0e 100%);
    border: none;
    box-shadow: 0 1px 2px rgba(14,14,18,.12),
                0 14px 32px -16px rgba(14,14,18,.45),
                inset 0 1px 0 rgba(255,255,255,.05);
  }
  html.theme-dark .end-stat-card.score-card .label { color: rgba(255, 176, 0, 0.55); }
  html.theme-dark .end-stat-card.score-card .value {
    color: var(--led-amber);
    text-shadow: 0 0 8px rgba(255, 176, 0, 0.55);
  }
  .end-stat-card.errors-card { border-left-color: var(--nxt-red); }
  .end-stats .label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.08em;
    font-weight: 700;
  }
  .end-stats .value {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.15rem;
  }

  /* Toast */
  .toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    background: var(--ink);
    color: white;
    padding: 0.75rem 1.1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 200;
    transition: transform 0.3s cubic-bezier(.2,.8,.2,1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 90%;
  }
  .toast.show { transform: translateX(-50%) translateY(0); }
  .toast::before {
    content: '';
    width: 0.5rem;
    height: 0.5rem;
    background: var(--led-amber);
    border-radius: 50%;
    flex-shrink: 0;
  }
  .toast.error::before { background: var(--led-red); box-shadow: 0 0 6px var(--led-red); }
  .toast.success::before { background: var(--led-green); box-shadow: 0 0 6px var(--led-green); }

  /* ============ HEADER ARCHIVE BUTTON ============ */
  .header-archive-btn {
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--grey-200);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(14,14,18,.08), 0 6px 14px -6px rgba(14,14,18,.25);
  }
  .header-archive-btn:hover { background: var(--grey-100); transform: translateY(-1px); }
  .header-archive-btn svg { flex-shrink: 0; }
  html.theme-dark .header-archive-btn { background: var(--paper); color: var(--ink); border: none; }
  html.theme-dark .header-archive-btn:hover { background: var(--grey-100); }

  /* Flat streak chip in the header (left of Archive) */
  .streak-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    padding: 0.42rem 0.7rem;
    border-radius: 999px;
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--grey-200);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.82rem;
    line-height: 1;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    user-select: none;
  }
  .streak-chip .streak-flame { font-size: 0.95em; line-height: 1; }
  html.theme-dark .streak-chip { background: var(--paper); color: var(--ink); border: none; }

  /* ============ CORNER DATE ============ */
  .col-header.is-corner.has-date {
    background: var(--paper);
    box-shadow: var(--tile-shadow);
    cursor: pointer;
    color: var(--ink);
    padding: 0.4rem 0.3rem;
  }
  @media (hover: hover) { .col-header.is-corner.has-date:hover { transform: translateY(-1px); box-shadow: var(--tile-shadow-hover); } }
  .corner-date-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    line-height: 1.1;
    text-align: center;
  }
  .corner-date-value {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--nxt-red);
    letter-spacing: -0.02em;
    margin-top: 0.25rem;
    line-height: 1;
    text-align: center;
  }

  /* ============ ARCHIVE LIST ============ */
  .archive-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--grey-200);
    cursor: pointer;
    transition: background 0.1s;
    border-radius: 4px;
  }
  .archive-item:last-child { border-bottom: none; }
  .archive-item:hover { background: var(--grey-100); }
  .archive-item.is-today {
    background: rgba(226,0,26,0.06);
    border-left: 3px solid var(--nxt-red);
    padding-left: 0.6rem;
  }
  html.theme-dark .archive-item.is-today { background: rgba(226,0,26,0.12); }
  html.theme-dark .archive-item:hover { background: var(--grey-100); }
  .archive-date {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--ink);
  }
  .archive-date small {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--muted);
    margin-top: 0.1rem;
  }
  .archive-status {
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    text-align: right;
    flex-shrink: 0;
  }
  .archive-status.done { color: #0a8b54; }
  .archive-status.failed { color: var(--nxt-red); }
  .archive-status.progress { color: var(--led-amber); }

  .archive-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-top: 0.9rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--grey-200);
  }
  .archive-pager[hidden] { display: none; }
  .archive-nav-btn {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: -0.005em;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--grey-300);
    border-radius: 999px;
    background: var(--paper);
    color: var(--ink);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.12s;
  }
  .archive-nav-btn:hover:not(:disabled) {
    background: var(--nxt-red);
    border-color: var(--nxt-red);
    color: #fff;
    transform: translateY(-1px);
  }
  .archive-nav-btn:disabled {
    opacity: 0.4;
    cursor: default;
  }
  .archive-page-info {
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    flex-shrink: 0;
  }

  /* ============ HIDE-RULES TOGGLE ============ */
  .hide-rules-toggle {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 1rem 0 0;
    font-size: 0.88rem;
    color: var(--grey-700);
    cursor: pointer;
    user-select: none;
  }
  .hide-rules-toggle input[type="checkbox"] {
    width: 1.05rem;
    height: 1.05rem;
    cursor: pointer;
    accent-color: var(--nxt-red);
  }

  @media (max-width: 540px) {
    .header-archive-btn { padding: 0.4rem 0.65rem; font-size: 0.7rem; gap: 0.3rem; }
    .header-archive-btn svg { width: 14px; height: 14px; }
    .corner-date-label { font-size: 0.5rem; letter-spacing: 0.06em; }
    .corner-date-value { font-size: 0.72rem; margin-top: 0.2rem; }
  }

  /* Mobile tweaks */
  @media (max-width: 540px) {
    header.nxt-bar { padding: 0.75rem 0.75rem; gap: 0.5rem; }
    .nxt-logo { font-size: 1.25rem; padding: 0.12rem 0.45rem; }
    .header-title { font-size: 1.35rem; }
    .header-subtitle { font-size: 0.6rem; }
    .led-value { font-size: 1.65rem; }
    .led-label { font-size: 0.55rem; }
    .streak-chip { padding: 0.35rem 0.55rem; font-size: 0.72rem; }
    .board-col-headers { grid-template-columns: 64px repeat(3, 1fr); }
    .board-row { grid-template-columns: 64px repeat(3, 1fr); min-height: 92px; }
    .col-header { font-size: 0.65rem; padding: 0.4rem 0.3rem 0.55rem; min-height: 96px; }
    .row-header { min-height: 96px; }
    .board-col-headers { grid-template-columns: repeat(4, 1fr); gap: 6px; }
    .board-row { grid-template-columns: repeat(4, 1fr); gap: 6px; min-height: 96px; }
    .row-header { padding: 0.5rem 0.3rem; }
    .mode-pill { font-size: 0.95rem; width: 1.4rem; height: 1.4rem; }
    .line-tile { width: 1.4rem; height: 1.4rem; font-size: 0.95rem; }
    .station-name { font-size: 0.72rem; }
    .play-cell { padding: 0.4rem 0.35rem; }
    .placeholder { font-size: 1.3rem; }
    .placeholder small { font-size: 0.5rem; }
    .station-points { font-size: 0.7rem; }
    button.nxt-btn { font-size: 0.85rem; padding: 0.65rem 0.8rem; }
    /* Bottom-sheet modals: cap to the *visible* viewport (dvh excludes the
       browser's floating toolbar) and clear the status bar / notch so the
       sticky header + close button stay on-screen and tappable. */
    .modal { max-height: 85dvh; }
    .modal-header { padding-top: calc(0.85rem + env(safe-area-inset-top)); }

    /* Pin the station-search popup to the top of the screen. On iOS WebKit
       (incl. Chrome iOS), focusing the input inside a vertically-centred modal
       makes the browser scroll the page to pull it above the keyboard - and the
       offset sticks after the modal closes. Anchoring the card near the top
       keeps the input above the keyboard, so no scroll is ever triggered. */
    #searchModal.modal-center { align-items: flex-start; }
    #searchModal .modal-card.search-card {
      margin-top: calc(env(safe-area-inset-top) + 0.5rem);
      max-height: calc(100dvh - env(safe-area-inset-top) - 1rem);
      display: flex;
      flex-direction: column;
    }
    #searchModal .modal-body {
      display: flex;
      flex-direction: column;
      min-height: 0;
      overflow: hidden;
    }
    #searchModal .suggestions {
      flex: 1 1 auto;
      min-height: 0;
      overflow-y: auto;
    }
  }

  /* Narrow phones - keep the header from crowding the title */
  @media (max-width: 400px) {
    header.nxt-bar { padding: 0.65rem 0.6rem; gap: 0.4rem; }
    .nxt-logo { font-size: 1.1rem; padding: 0.1rem 0.4rem; }
    .header-title { font-size: 1.2rem; }
    .header-subtitle { font-size: 0.56rem; }
    .streak-chip { padding: 0.3rem 0.45rem; font-size: 0.68rem; gap: 0.25rem; }
    /* Icon-only archive button to free up horizontal space */
    .header-archive-btn { padding: 0.45rem; }
    .header-archive-btn span { display: none; }
    .theme-toggle { width: 2.1rem; height: 2.1rem; }
  }

/* Accessibility: honour the OS-level "reduce motion" preference - kill the
   wrong-cell shake, modal slide/pop and hover/press transitions. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Personal stats modal: score histogram bars. */
.stat-bar-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; }
.stat-bar-label { width: 2.2rem; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-align: right; flex: none; }
.stat-bar-track { flex: 1; height: 14px; background: var(--grey-200); border-radius: 7px; overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--nxt-red); border-radius: 7px; }
.stat-bar-count { width: 1.6rem; font-size: 0.75rem; font-weight: 700; flex: none; }
