:root {
  color-scheme: light;
  --canvas: #f2f3ef;
  --surface: #fafbf8;
  --ink: #171d24;
  --muted: #505963;
  --line: #c7cec9;
  --strong-line: #838e91;
  --hover: #e9ece7;
  --signal: #234ab9;
  --signal-fill: #234ab9;
  --on-signal: #fff;
  --terminal: #20272d;
  --terminal-ink: #f3f4ed;
  --terminal-muted: #b8c4c9;
  --terminal-line: #53616a;
  --amber: #e6c76e;
  --green: #dbe9dc;
  --green-ink: #2d5d3c;
  --red: #efdfdd;
  --red-ink: #7b3b35;
  --yellow-soft: #f2e8cd;
  --ochre: #644e18;
  --mono: "IBM Plex Mono", Consolas, monospace;
  --shell: 1280px;
  --edge: clamp(16px, 4vw, 56px);
  --columns: minmax(84px, .85fr) minmax(165px, 2.6fr) minmax(64px, .75fr) repeat(3, minmax(56px, .75fr));
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  line-height: 1.45;
  color: var(--ink);
  background: var(--canvas);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --canvas: #151a20;
    --surface: #1c232a;
    --ink: #f0f2ed;
    --muted: #b1bdc6;
    --line: #39444a;
    --strong-line: #75818b;
    --hover: #27323b;
    --signal: #9bb4ff;
    --signal-fill: #a9bcfe;
    --on-signal: #182645;
    --terminal: #252f38;
    --green: #293e34;
    --green-ink: #bbdfc2;
    --red: #472f34;
    --red-ink: #ffc0b8;
    --yellow-soft: #433821;
    --ochre: #f5d98b;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
svg { display: block; }
.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(100%, 420px); padding: clamp(20px, 6vw, 36px); border-top: 3px solid var(--signal); background: var(--surface); }
.login-brand { display: flex; align-items: center; gap: 8px; font: 800 1rem var(--mono); }
.login-panel h1 { margin: 22px 0 8px; font-size: clamp(1.65rem, 6vw, 2rem); line-height: 1.15; letter-spacing: -.035em; }
#loginHeading:focus-visible { outline: none; }
.login-panel p { color: var(--muted); }
.login-panel .account-actions { margin-top: 20px; }
.login-panel .account-message:empty { display: none; }
.money { display: inline-flex; align-items: center; gap: .2em; max-width: 100%; }
.money > span { min-width: 0; }
.coin-icon { flex: none; width: .88em; height: .88em; }
time, .price, .train-chip, #balanceTop, .coupon-total strong { font-variant-numeric: tabular-nums; }

.topbar { border-bottom: 1px solid var(--strong-line); }
.topbar-inner, .content-grid, .legend {
  width: min(calc(100% - 2 * var(--edge)), var(--shell));
  margin-inline: auto;
}
.topbar-inner {
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 20px;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-size: 1.35rem; font-weight: 800; letter-spacing: -.065em; }
.brand-mark { width: 22px; height: 22px; color: var(--signal); }
#testModeBanner { color: var(--ochre); background: var(--yellow-soft); border-left: 2px solid var(--amber); padding: 3px 6px; font: 700 .65rem var(--mono); letter-spacing: .045em; white-space: nowrap; }
.mainnav { display: flex; align-self: stretch; gap: 22px; }
.navbtn, .saldo-btn { display: flex; align-items: center; gap: 6px; color: var(--muted); background: none; border: 0; white-space: nowrap; font-size: .88rem; font-weight: 650; }
.navbtn { padding-inline: 8px; border-bottom: 3px solid transparent; }
.navbtn.active { border-color: var(--signal); color: var(--signal); }
.navbtn:hover, .saldo-btn:hover { color: var(--ink); background: var(--hover); }
.navbtn svg, .saldo-btn > svg { width: 15px; height: 15px; flex: none; }
.topbar-tools { display: flex; align-items: center; justify-self: end; }
.saldo-btn { min-height: 44px; padding-inline: 8px; }
.saldo-btn strong { margin-left: 4px; color: var(--ink); font-family: var(--mono); }
.theme-toggle { display: grid; place-items: center; width: 44px; height: 44px; border: 0; color: var(--muted); background: transparent; }
.theme-toggle:hover, .theme-toggle[aria-pressed="true"] { color: var(--signal); background: var(--hover); }
.theme-toggle svg { width: 17px; height: 17px; }

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(248px, 296px);
  gap: clamp(22px, 3.2vw, 48px);
  align-items: start;
  padding-top: clamp(22px, 3.1vw, 44px);
}
.content-grid.history-mode { display: block; }
.history-mode .coupon-col { display: none; }
.board { min-width: 0; }
.board-top { display: flex; align-items: end; justify-content: space-between; gap: 12px; padding-bottom: 15px; }
.board-top h1 { font-size: clamp(2.05rem, 3.5vw, 3.2rem); font-weight: 760; letter-spacing: -.065em; line-height: 1; }
.board-day { display: grid; justify-items: end; align-self: end; gap: 1px; color: var(--muted); font-size: .86rem; line-height: 1.2; }
.board-day span { text-transform: capitalize; }
.board-day time { font: 700 1.13rem var(--mono); color: var(--ink); }
.market-shifts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 2px solid var(--ink); border-bottom: 1px solid var(--strong-line); }
.shift-tab { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; min-height: 49px; padding: 11px 12px 9px; text-align: left; color: var(--muted); background: transparent; border: 0; border-bottom: 3px solid transparent; }
.shift-tab + .shift-tab { border-left: 1px solid var(--line); }
.shift-tab:hover { background: var(--hover); }
.shift-tab.active { border-bottom-color: var(--signal); color: var(--ink); background: var(--surface); }
.shift-tab.active strong { color: var(--signal); }
.shift-tab strong { font-size: .91rem; }
.shift-tab small { display: flex; flex-wrap: wrap; column-gap: .8ch; min-width: 0; font: .75rem var(--mono); white-space: nowrap; }
.market-table { border-bottom: 1px solid var(--strong-line); }
.market-head, .market-row { display: grid; grid-template-columns: var(--columns); align-items: stretch; }
.market-head { min-height: 34px; align-items: center; background: var(--terminal); color: var(--terminal-ink); font-size: .72rem; }
.market-head > span { padding-inline: 8px; }
.market-head > span:first-child { padding-inline-start: 12px; }
.market-head > span:nth-child(n + 4) { display: flex; justify-content: center; gap: 5px; white-space: nowrap; }
.market-head b { color: var(--amber); font-family: var(--mono); }
.market-head > span:nth-child(4) b { color: #b8d7bf; }
.market-head > span:nth-child(6) b { color: #f4c3bd; }
.market-row { min-height: 72px; align-items: center; background: var(--surface); }
.market-row + .market-row { border-top: 1px solid var(--line); }
.market-row:has(.odd-btn.active) { box-shadow: inset 3px 0 var(--signal); }
.departure { min-width: 0; padding: 0 12px; }
.departure time { font: 700 clamp(1.2rem, 2vw, 1.75rem)/1 var(--mono); letter-spacing: -.09em; white-space: nowrap; }
.departure-label { position: absolute; clip-path: inset(50%); }
.route { min-width: 0; padding: 8px; }
.route-title { font-size: 1rem; line-height: 1.22; overflow-wrap: anywhere; display: block; font-weight: 720; }
.route-join { padding-inline: .28em; color: var(--muted); }
.route-meta { margin-top: 3px; color: var(--muted); font-size: .78rem; }
.train-details { display: grid; gap: 1px; padding: 4px 8px; color: var(--muted); font-size: .68rem; }
.train-chip { font: 700 .8rem var(--mono); color: var(--ink); white-space: nowrap; }
.odd-btn { position: relative; align-self: stretch; display: grid; place-items: center; min-width: 0; min-height: 45px; padding: 6px 5px; color: var(--ink); background: transparent; border: 1px solid transparent; border-left-color: var(--line); }
.odd-btn:hover:not(:disabled) { background: var(--hover); }
.odd-btn:focus-visible { outline-offset: -3px; }
.odd-btn.active, .odd-btn.active:hover:not(:disabled) { color: var(--on-signal); background: var(--signal-fill); border-color: var(--signal-fill); }
.odd-btn.active:focus-visible { outline-color: var(--on-signal); }
.odd-btn:disabled { color: var(--muted); }
.odd-btn .mark { display: none; }
.price { font: 700 clamp(.93rem, 1.5vw, 1.24rem) var(--mono); }
.mark, .ticket-pick-choice b { display: inline-grid; place-items: center; min-width: 20px; min-height: 20px; padding: 2px 4px; font: 700 .75rem var(--mono); }
.choice-1 { background: var(--green); color: var(--green-ink); }
.choice-x { background: var(--yellow-soft); color: var(--ochre); }
.choice-2 { background: var(--red); color: var(--red-ink); }

.coupon-col { position: sticky; top: 16px; }
.coupon { background: var(--terminal); color: var(--terminal-ink); }
.coupon-inner { padding: 17px 17px 16px; }
.coupon-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--terminal-line); padding-bottom: 10px; }
.coupon-title { font-size: 1.22rem; font-weight: 750; letter-spacing: -.035em; }
.coupon-top svg { width: 21px; height: 21px; color: var(--amber); }
.coupon-meta { display: flex; justify-content: space-between; gap: 6px; margin-block: 9px; color: var(--terminal-muted); font-size: .79rem; }
.meta-card { display: flex; gap: 4px; }
.meta-card strong { color: var(--terminal-ink); font-family: var(--mono); }
.coupon-table { border-bottom: 1px solid var(--terminal-line); margin-bottom: 13px; }
.coupon-head, .coupon-row { display: grid; grid-template-columns: minmax(0,1fr) 45px 50px 30px; align-items: center; gap: 3px; }
.coupon-head { padding-block: 4px; color: var(--terminal-muted); font-size: .71rem; }
.coupon-row { min-height: 36px; font: .82rem var(--mono); }
.coupon-row + .coupon-row { border-top: 1px solid var(--terminal-line); }
.coupon-empty { grid-column: 1 / -1; padding-block: 2px 9px; color: var(--terminal-muted); font: .84rem/1.4 "Segoe UI", sans-serif; }
.coupon-remove { min-height: 32px; border: 0; background: transparent; color: #f3c3bb; font-size: 1.1rem; }
.coupon-remove:hover { background: #414a50; }
.coupon-field { display: grid; gap: 4px; margin-bottom: 10px; font-size: .81rem; font-weight: 650; }
.coupon-field input { width: 100%; min-width: 0; min-height: 43px; padding: 6px 8px; border: 1px solid var(--terminal-line); color: var(--terminal-ink); background: #171d22; font-family: var(--mono); }
.coupon-total { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; color: var(--terminal-muted); font-size: .82rem; }
.coupon-total strong { color: var(--terminal-ink); font-family: var(--mono); overflow-wrap: anywhere; text-align: right; }
.coupon-total.big { align-items: baseline; margin-block: 9px 11px; padding-top: 8px; border-top: 1px solid var(--terminal-line); color: var(--terminal-ink); font-weight: 700; }
.coupon-highlight { font-size: 1.32rem; }
.play-btn { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; min-height: 45px; padding: 7px; border: 0; background: var(--amber); color: #222315; font-weight: 800; }
.play-btn svg { width: 18px; height: 18px; }
.play-btn:hover:not(:disabled) { background: #f6d98f; }
.play-btn:active:not(:disabled) { transform: translateY(1px); }
.play-btn:disabled { background: #3a454e; color: #c0c9ce; }
.coupon :focus-visible, .mobile-sheet :focus-visible, .ticket-process :focus-visible { outline-color: var(--amber); }
.mobile-sheet { display: none; }

.legend { display: flex; align-items: start; flex-wrap: wrap; gap: 12px 24px; margin-top: 22px; padding-block: 0 24px; }
.legend-item { display: flex; align-items: start; gap: 6px; }
.legend-item div { display: grid; font-size: .77rem; line-height: 1.35; }
.legend-item div span, .closing-note { color: var(--muted); }
.closing-note { margin-inline-start: auto; font-size: .78rem; }

.history-toolbar { display: flex; align-items: end; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding-block: 11px; margin-bottom: 18px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); }
.history-intro h3 { font-size: .96rem; }
.history-intro span { color: var(--muted); font-size: .82rem; }
.history-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 7px; }
.history-filter { display: grid; gap: 2px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.history-filter select, .history-refresh, .history-go-play, .ticket-actions button, .modal-close, .tab-btn { min-height: 40px; padding: 6px 10px; border: 1px solid var(--strong-line); color: var(--ink); background: var(--surface); font-size: .84rem; font-weight: 650; }
.history-filter select { max-width: 100%; }
.history-refresh:hover, .history-go-play:hover, .ticket-actions button:hover, .modal-close:hover, .tab-btn:hover { background: var(--hover); }
.history-receipts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 350px), 1fr)); gap: 16px; align-items: start; }
.history-receipt { min-width: 0; background: var(--surface); border-top: 3px solid var(--signal); border-bottom: 1px solid var(--strong-line); }
.ticket-inner { padding: 13px; }
.ticket-headline { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.ticket-brand { font-weight: 750; font-size: .78rem; color: var(--signal); }
.ticket-title { font-size: 1.35rem; font-weight: 780; letter-spacing: -.04em; }
.ticket-headline > strong { background: var(--yellow-soft); color: var(--ochre); padding: 4px; font: 700 .68rem var(--mono); }
.ticket-qr-holder { width: 68px; height: 68px; flex: none; }
.ticket-qr-link, .ticket-qr-placeholder { width: 100%; height: 100%; border: 0; color: var(--ink); background: transparent; font-weight: 750; }
.ticket-qr-link img { width: 100%; height: 100%; }
:root[data-theme="dark"] .ticket-qr-link img { filter: invert(1); }
.ticket-reference { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 5px; padding: 8px 0; margin-top: 7px; border-block: 1px solid var(--line); color: var(--muted); font: .7rem var(--mono); }
.ticket-trust { font-size: .75rem; color: var(--muted); margin-top: 5px; }
.ticket-top-status { margin: 8px 0 4px; }
.ticket-status { display: inline-block; padding: 4px 6px; font: 700 .7rem var(--mono); }
.ticket-status.pending { display: inline-flex; flex-wrap: wrap; column-gap: .5em; background: var(--yellow-soft); color: var(--ochre); }
.ticket-status.win, .ticket-pick-result.right, .ticket-pick-settlement.is-correct { background: var(--green); color: var(--green-ink); }
.ticket-status.lose, .ticket-pick-result.wrong, .ticket-pick-settlement.is-incorrect { background: var(--red); color: var(--red-ink); }
.ticket-data-row { display: flex; gap: 20px; margin-bottom: 8px; }
.ticket-data-row > div { display: flex; align-items: baseline; gap: 5px; }
.ticket-data-row small { color: var(--muted); font-size: .68rem; }
.ticket-data-row strong { font: 700 .82rem var(--mono); overflow-wrap: anywhere; }
.ticket-picks-heading, .ticket-pick { display: grid; grid-template-columns: 17px minmax(0, 1fr) 52px 37px; align-items: center; gap: 4px; }
.ticket-picks-heading { padding: 6px 0; color: var(--muted); font-size: .63rem; font-weight: 750; border-top: 1px solid var(--strong-line); }
.ticket-pick { border-top: 1px solid var(--line); padding: 7px 0; font-size: .82rem; }
.ticket-pick-number, .ticket-pick-odd, .ticket-pick-result { font-family: var(--mono); }
.ticket-pick-description { display: grid; gap: 3px; overflow-wrap: anywhere; }
.train-details-button { min-height: 26px; padding: 1px 2px; border: 0; color: var(--signal); background: transparent; font-weight: 750; text-decoration: underline; text-underline-offset: .18em; }
.train-details-button:hover { background: var(--hover); }
.ticket-route, .ticket-pick-choice { color: var(--muted); font-size: .75rem; }
.ticket-pick-result { display: grid; place-items: center; width: 27px; height: 27px; background: var(--hover); font-weight: 700; }
.ticket-pick-live, .ticket-pick-settlement { justify-self: start; border-left: 2px solid var(--strong-line); padding: 1px 5px; color: var(--muted); font-size: .7rem; font-weight: 650; }
.ticket-pick-live.live-band-1 { border-color: var(--green-ink); color: var(--green-ink); }
.ticket-pick-live.live-band-x { border-color: var(--ochre); color: var(--ochre); }
.ticket-pick-live.live-band-2 { border-color: var(--red-ink); color: var(--red-ink); }
.ticket-perforation { border-top: 1px dashed var(--strong-line); margin: 7px 0; }
.ticket-totals { display: grid; gap: 4px; font-size: .84rem; }
.ticket-totals > div { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.ticket-totals strong { font-family: var(--mono); text-align: right; overflow-wrap: anywhere; }
.ticket-payout { border-top: 1px solid var(--line); padding-block: 5px; font-weight: 750; }
.ticket-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ticket-actions button { flex: 1; }
.print-menu { position: relative; }
.print-menu summary { padding: 9px 10px; color: var(--muted); cursor: pointer; font-size: .84rem; font-weight: 650; }
.print-menu summary:hover, .print-menu[open] summary { color: var(--ink); background: var(--hover); }
.print-menu > button { position: absolute; z-index: 2; top: 100%; inset-inline-end: 0; white-space: nowrap; box-shadow: 0 3px 8px #0002; }
.ticket-actions-print-only { justify-content: flex-end; }
.history-empty, .market-closed { padding: 20px 10px; border-top: 1px solid var(--line); color: var(--ink); }
.history-empty h3, .market-closed h3 { font-size: 1.2rem; }
.history-empty p, .market-closed p { margin: 5px 0 10px; color: var(--muted); }
.market-closed-kicker { color: var(--muted); font: 700 .75rem var(--mono); }

.modal-backdrop, .ticket-process { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 15px; background: #101820e0; visibility: hidden; opacity: 0; transition: opacity .18s, visibility .18s; }
.modal-backdrop { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; border: 0; }
.modal-backdrop:not([open]) { display: none; }
.modal-backdrop::backdrop { background: transparent; }
.modal-backdrop[open], .ticket-process.is-open { opacity: 1; visibility: visible; }
body.ticket-process-locked { overflow: hidden; }
.modal-card { width: min(100%, 475px); max-height: 90dvh; overflow: auto; padding: 19px; border-top: 3px solid var(--signal); color: var(--ink); background: var(--surface); }
.modal-card h3 { font-size: 1.55rem; letter-spacing: -.04em; }
.modal-card p, .modal-card li { margin: 6px 0; }
.account-description { color: var(--muted); }
.account-message:not(:empty) { padding: 8px 10px; color: var(--red-ink); background: var(--red); }
.account-message:empty { display: none; }
.account-summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-block: 1px solid var(--line); }
.account-summary small { display: block; color: var(--muted); }
.account-summary > strong { font-family: var(--mono); }
.account-actions { display: grid; gap: 7px; margin-block: 13px; }
.account-actions button { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; border: 1px solid var(--strong-line); color: var(--ink); background: var(--surface); text-align: left; font-weight: 650; }
.account-actions button:hover:not(:disabled) { background: var(--hover); }
.account-actions button:disabled { opacity: .6; }
.account-provider-mark { display: inline-grid; place-items: center; width: 25px; height: 25px; color: var(--signal); background: var(--hover); font-weight: 800; }
.account-hint { color: var(--muted); font-size: .8rem; }
.nickname-form { margin-top: 16px; }
.nickname-form label { font-weight: 700; }
.nickname-form p { color: var(--muted); font-size: .84rem; }
.nickname-controls { grid-template-columns: minmax(0, 1fr) auto; margin-block: 8px 5px; }
.nickname-controls input { min-width: 0; padding: 6px 10px; border: 1px solid var(--strong-line); color: var(--ink); background: var(--canvas); }
.nickname-controls input::placeholder { color: var(--muted); opacity: 1; }
.train-detail-route, .train-detail-meta, .train-detail-section li span { color: var(--muted); }
.train-detail-status { font-weight: 750; }
.train-detail-times { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px 12px; margin: 12px 0 16px; padding-block: 10px; border-block: 1px solid var(--line); }
.train-detail-times dt { color: var(--muted); font-size: .8rem; }
.train-detail-times dd { margin: 2px 0 0; font: 700 .85rem var(--mono); }
.train-detail-section { margin: 12px 0; }
.train-detail-section h4 { margin: 0 0 4px; }
.train-detail-section ul { margin: 0; padding-inline-start: 20px; }
.train-detail-probability > strong { color: var(--signal); font: 750 1.35rem var(--mono); }
.train-detail-meta { font-size: .8rem; }
.train-detail-meta a { color: var(--signal); }
.modal-close { margin-top: 8px; }
.qr-large { display: block; max-width: min(100%, 270px); height: auto; margin: 8px auto; }
.ticket-process { z-index: 40; }
.tp-panel {
  --tp-active: var(--amber);
  --tp-position: 16.6667%;
  width: min(100%, 460px);
  max-height: 93dvh;
  overflow: auto;
  padding: clamp(18px, 5vw, 28px);
  border-top: 3px solid var(--tp-active);
  background: var(--terminal);
  color: var(--terminal-ink);
}
.ticket-process[data-step="save"] .tp-panel { --tp-position: 50%; }
.ticket-process[data-step="done"] .tp-panel { --tp-position: 83.3333%; }
.ticket-process[data-mode="success"] .tp-panel { --tp-active: #b9e5c7; }
.ticket-process[data-mode="error"] .tp-panel { --tp-active: #ffbcb1; }
.tp-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-bottom: 11px; border-bottom: 1px solid var(--terminal-line); }
.tp-brand { font-weight: 800; color: var(--tp-active); }
.tp-top-meta { color: var(--terminal-muted); font: 700 .74rem var(--mono); letter-spacing: .05em; }
.tp-title { margin-top: 14px; font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -.04em; }
.tp-detail { min-height: 2.9em; margin-top: 3px; color: var(--terminal-muted); }
.tp-route { position: relative; margin-top: 13px; padding-top: 24px; }
.tp-rails { position: absolute; top: 27px; inset-inline: 16.6667%; height: 5px; border-block: 1px solid var(--terminal-line); }
.tp-rails::after { content: ""; position: absolute; inset: -1px auto -1px -1px; width: max(0px, calc((var(--tp-position) - 16.6667%) * 1.5)); border-block: 1px solid var(--tp-active); transition: width .34s ease-out; }
.tp-train { position: absolute; top: 3px; left: var(--tp-position); width: 34px; color: var(--tp-active); transform: translateX(-50%); transition: left .34s cubic-bezier(.25,.8,.25,1); }
.tp-train svg { width: 100%; height: auto; }
.tp-stops { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; padding: 0; list-style: none; color: var(--terminal-muted); font: .76rem var(--mono); text-align: center; }
.tp-stops li { position: relative; }
.tp-stops li::before { content: ""; display: block; width: 11px; height: 11px; margin: 0 auto 8px; border: 1px solid var(--terminal-line); background: var(--terminal); }
.ticket-process[data-step="check"] [data-stop="check"],
.ticket-process[data-step="save"] [data-stop="save"],
.ticket-process[data-step="done"] [data-stop="done"] { color: var(--tp-active); font-weight: 700; }
.ticket-process[data-step="check"] [data-stop="check"]::before,
.ticket-process[data-step="save"] [data-stop="save"]::before,
.ticket-process[data-step="done"] [data-stop="done"]::before { border-color: var(--tp-active); background: var(--tp-active); }
.ticket-process:not([data-step="check"]) [data-stop="check"]::before,
.ticket-process[data-step="done"] [data-stop="save"]::before { border-color: var(--tp-active); }
.tp-status-line { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.tp-action { margin-top: 20px; min-height: 44px; width: 100%; padding: 6px 12px; border: 0; background: var(--tp-active); color: #222315; font-weight: 750; }
#printSheet { display: none; }

@media (max-width: 1080px) {
  :root { --columns: minmax(67px, .85fr) minmax(140px, 2.6fr) minmax(57px, .75fr) repeat(3, minmax(54px, .75fr)); }
  .mainnav { gap: 6px; }
  .market-head > span { padding-inline: 4px; font-size: .65rem; }
  .market-head > span:nth-child(n + 4) { flex-direction: column; align-items: center; gap: 0; }
  .departure time { font-size: 1.28rem; }
  .shift-tab { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 1px; }
}

@media (max-width: 800px) {
  .print-menu, .ticket-actions-print-only { display: none; }
  .topbar-inner { grid-template: "brand balance" auto "nav nav" auto / minmax(0,1fr) auto; min-height: 0; gap: 0 8px; }
  .brand-lockup { grid-area: brand; gap: 8px; }
  .topbar-tools { grid-area: balance; }
  .saldo-btn { padding-inline: 2px; }
  .saldo-btn > svg { display: none; }
  .saldo-label { position: absolute; clip-path: inset(50%); }
  .mainnav { grid-area: nav; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 0; border-top: 1px solid var(--line); }
  .navbtn { min-height: 44px; justify-content: center; gap: 4px; padding: 2px; font-size: .78rem; }
  .navbtn svg { width: 14px; height: 14px; }
  .content-grid { display: block; padding-top: 20px; }
  .coupon-col { display: none; }
  .page { padding-bottom: calc(65px + env(safe-area-inset-bottom)); }
  .page:has(.history-mode) { padding-bottom: 0; }
  .mobile-sheet { display: block; position: fixed; inset: auto 0 0; z-index: 10; padding-bottom: env(safe-area-inset-bottom); color: var(--terminal-ink); background: var(--terminal); border-top: 2px solid var(--signal); box-shadow: 0 -3px 12px #10171d30; }
  .mobile-sheet.is-history { display: none; }
  .mobile-sheet-head { display: flex; width: 100%; justify-content: space-between; gap: 8px; min-height: 54px; padding: 7px var(--edge); color: inherit; background: transparent; border: 0; text-align: left; }
  .mobile-sheet-title, .mobile-sheet-summary { display: flex; align-items: center; gap: 7px; font-size: .88rem; font-weight: 750; }
  .mobile-sheet-title .mobile-pill { color: var(--terminal-muted); font-size: .73rem; font-weight: 500; }
  .mobile-sheet-summary .mobile-pill { color: var(--terminal-ink); font: 700 .99rem var(--mono); text-align: right; }
  .mobile-sheet-body { max-height: 0; overflow: hidden; transition: max-height .19s ease; }
  .mobile-sheet.open .mobile-sheet-body { max-height: min(58dvh, 445px); overflow: auto; overscroll-behavior: contain; }
  .mobile-rows { padding-inline: var(--edge); }
  .mobile-row { display: grid; grid-template-columns: minmax(0,1fr) auto 44px; align-items: center; min-height: 40px; gap: 10px; border-top: 1px solid var(--terminal-line); font: .82rem var(--mono); }
  .mobile-row .coupon-remove { min-width: 44px; min-height: 44px; }
  .mobile-controls { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); align-items: end; gap: 8px; padding: 7px var(--edge) 11px; }
  .mobile-controls .coupon-field { margin: 0; }
  .mobile-payout-label { font-size: .73rem; color: var(--terminal-muted); }
  #mobileBottomPayout { font: 700 1.05rem var(--mono); color: var(--terminal-ink); padding-block: 8px; }
  #playBtnMobile { grid-column: 1 / -1; min-height: 46px; }
}

@media (max-width: 560px) {
  .board-top { padding-bottom: 9px; }
  .board-top h1 { font-size: 2rem; }
  .board-day { font-size: .74rem; }
  .board-day time { font-size: .94rem; }
  .shift-tab { min-height: 49px; padding: 6px 7px 5px; }
  .shift-tab strong { font-size: .82rem; }
  .shift-tab small { font-size: .7rem; }
  .market-head { display: none; }
  .market-row { grid-template-columns: 64px repeat(3,minmax(0,1fr)); grid-template-rows: auto auto auto; align-items: stretch; padding-block: 8px 7px; }
  .departure { grid-area: 1 / 1 / 4 / 2; padding: 7px 5px; border-right: 1px solid var(--line); }
  .departure time { font-size: 1.13rem; }
  .departure-label { position: static; clip-path: none; display: block; color: var(--muted); margin-bottom: 3px; font-size: .68rem; }
  .route { grid-area: 1 / 2 / 2 / 5; padding: 0 7px; }
  .route-title { font-size: .91rem; }
  .route-meta { font-size: .72rem; margin-top: 2px; }
  .train-details { grid-area: 2 / 2 / 3 / 5; display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px; padding: 3px 7px 5px; }
  .train-chip { font-size: .74rem; }
  .odd-btn { grid-row: 3; display: flex; justify-content: center; gap: 5px; min-height: 44px; border-block-color: var(--line); }
  .odd-btn:first-of-type { grid-column: 2; border-left-color: transparent; }
  .odd-btn:nth-of-type(2) { grid-column: 3; }
  .odd-btn:nth-of-type(3) { grid-column: 4; }
  .odd-btn .mark { display: inline-grid; min-width: 17px; }
  .odd-btn.active .mark { background: transparent; color: inherit; }
  .price { font-size: .94rem; }
  .legend { display: grid; gap: 8px; margin-top: 15px; }
  .closing-note { margin: 3px 0 0; }
  .history-actions { display: grid; width: 100%; }
  .history-refresh, .history-go-play, .ticket-actions button, .modal-close, .history-filter select { min-height: 44px; }
}

@media (max-width: 355px) {
  .navbtn svg { display: none; }
  .brand { font-size: 1.15rem; }
  .brand-mark { width: 19px; height: 19px; }
  .saldo-btn { font-size: .76rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
