/* Atlas Junction. Colours come from the active theme (content/themes), applied as custom properties;
   the values here are the Transit Atlas defaults so the first paint already looks right. */
:root {
  --bg: #efe9dc; --panel: #fffdf8; --panel-2: #f6f0e3; --ink: #1c2833; --ink-soft: #5d6b78; --line: #d9cfbb;
  --accent: #d2452a; --accent-ink: #fff; --board: #f4eedf; --land: #ece3cf; --water: #a9d3ea; --green: #cfe3b8;
  --label: #1c2833; --label-halo: #fffdf8; --node: #fffdf8; --node-ring: #1c2833; --slot: #fffdf8; --danger: #b3261e; --good: #1b7f4c;
  --pass-coral: #e2553a; --pass-azure: #2a78cf; --pass-amber: #e3a008; --pass-jade: #1f9a66; --pass-violet: #8b55c9; --pass-slate: #566370; --pass-wild: #1c2833; --pass-any: #b3a993;
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-text-size-adjust: 100%; }
body { overflow: hidden; overscroll-behavior: none; }
html[data-large-text] { font-size: 118%; }
.app { height: 100%; }
h1, h2, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.soft { color: var(--ink-soft); font-weight: 500; }
.small { font-size: .82rem; }
.grow { flex: 1 1 auto; min-width: 0; }
.good { color: var(--good); } .bad { color: var(--danger); }
.pts { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pass-icon, .badge, .kind-icon { flex: none; vertical-align: -0.28em; }
.tagline { font-style: italic; color: var(--ink-soft); }
.arrow { color: var(--ink-soft); padding: 0 .1em; }
.who { display: inline-flex; align-items: center; gap: .3em; vertical-align: middle; }
.facedown { display: inline-block; width: .85em; height: 1.1em; border-radius: 3px; background: repeating-linear-gradient(45deg, var(--ink) 0 3px, var(--ink-soft) 3px 6px); vertical-align: -0.2em; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; padding: .1em .5em; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); }
.timer.low { background: var(--danger); color: #fff; border-color: transparent; }
.final { background: var(--accent); color: var(--accent-ink); font-weight: 800; padding: .1em .6em; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; font-size: .8em; }
.tag { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: .15em .5em; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.long { background: var(--ink); color: var(--bg); border-color: transparent; }
.tag.itinerary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ---- the map ---- */
.map-host { position: relative; width: 100%; height: 100%; }
.board { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
.board.interactive { touch-action: none; cursor: grab; }
.b-bg { fill: var(--board); }
.b-water { stroke: var(--water); stroke-linecap: round; stroke-linejoin: round; }
polygon.b-water { fill: var(--water); stroke: none; }
.b-green { fill: var(--green); stroke: var(--green); stroke-linejoin: round; }
.b-land { fill: var(--land); }
.b-seg { stroke: color-mix(in srgb, var(--c) 72%, var(--board)); stroke-width: 7; }
.b-seg-edge { stroke: var(--ink); stroke-width: 12.5; opacity: 0; }
.b-lane.owned .b-seg { stroke: var(--o); stroke-width: 9.5; }
.b-lane.owned .b-seg-edge { opacity: 1; }
.b-link.selected .b-lane:not(.owned) .b-seg-edge { opacity: 1; stroke: var(--accent); stroke-width: 15; }
.b-link.selected .b-lane:not(.owned) .b-seg { stroke: var(--c); }
.b-link.hint .b-lane:not(.owned) .b-seg { animation: hint 1.4s ease-in-out infinite; }
.b-link.fresh .b-lane.owned .b-seg { animation: lay .45s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: calc(var(--i) * 90ms); }
.b-mark-bg { fill: var(--label-halo); stroke: var(--line); stroke-width: 1.5; }
.b-mark.gone { display: none; }
.b-hit { stroke: transparent; stroke-width: 44; stroke-linecap: round; pointer-events: none; outline-offset: 0; }
.board.interactive .b-hit { pointer-events: stroke; cursor: pointer; }
.b-hit:focus-visible { stroke: color-mix(in srgb, var(--accent) 35%, transparent); outline: none; }
.b-dot { fill: var(--node); stroke: var(--node-ring); stroke-width: 3.2; }
.b-ring { fill: none; stroke: var(--accent); stroke-width: 6; opacity: 0; }
.b-node.stop .b-ring { opacity: 1; animation: ring 1.2s ease-in-out infinite; }
.b-label { font-size: 22px; letter-spacing: -.01em; font-weight: 700; fill: var(--label); paint-order: stroke; stroke: var(--label-halo); stroke-width: 6px; stroke-linejoin: round; pointer-events: none; }
.board.has-stops .b-label:not(.stop) { opacity: .4; }
.b-label.stop { font-weight: 900; }
.b-nodes, .b-marks, .b-labels, .b-links { pointer-events: none; }
@keyframes hint { 50% { opacity: .35; } }
@keyframes lay { from { stroke-width: 0; opacity: 0; } }
@keyframes ring { 50% { stroke-width: 10; opacity: .55; } }

/* ---- shared controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45em; min-height: 46px; padding: .55em 1em; border-radius: 12px; border: 2px solid var(--ink); background: var(--panel); font-weight: 750; text-align: center; }
.btn.wide { width: 100%; margin-top: .6rem; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 60%, #000); }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn:disabled { opacity: .45; box-shadow: none; }
.btn:not(:disabled):active { transform: translateY(2px); box-shadow: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.field { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-top: .7rem; font-weight: 650; }
.field select { min-height: 44px; border-radius: 10px; border: 2px solid var(--ink); background: var(--panel); padding: 0 .6em; max-width: 60%; }

/* ---- phone ---- */
.phone { height: 100dvh; display: flex; flex-direction: column; position: relative; max-width: 720px; margin: 0 auto; }
.p-top { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .3rem .6rem; padding: .45rem .7rem; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 50px; }
.p-top .me { display: flex; align-items: center; gap: .55rem; }
.p-top .stat { font-size: .85rem; color: var(--ink-soft); } .p-top .stat b { color: var(--ink); font-size: 1.05rem; }
.p-top .turn { display: flex; align-items: center; gap: .4rem; font-weight: 750; font-size: .92rem; }
.p-top .turn.mine span:not(.timer):not(.final) { background: var(--accent); color: var(--accent-ink); padding: .2em .7em; border-radius: 99px; }
.p-top .net { flex-basis: 100%; font-size: .8rem; color: var(--danger); font-weight: 700; }
.p-map { flex: 0 0 39dvh; min-height: 200px; position: relative; border-bottom: 1px solid var(--line); background: var(--board); }
.map-tools { position: absolute; right: .5rem; bottom: .5rem; display: flex; flex-direction: column; gap: .35rem; }
.map-tools button { width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--ink); background: var(--panel); font-size: 1.3rem; font-weight: 800; line-height: 1; }
.p-tabs { flex: none; display: flex; background: var(--panel); border-bottom: 1px solid var(--line); }
.p-tabs button { flex: 1 1 auto; white-space: nowrap; min-height: 46px; border: 0; background: none; font-weight: 750; font-size: .86rem; border-bottom: 4px solid transparent; padding: 0 .2rem; }
.p-tabs button.on { border-bottom-color: var(--accent); }
.p-panel { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: .7rem .8rem 1.6rem; -webkit-overflow-scrolling: touch; }
.p-panel h2, .card h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; margin: 1rem 0 .45rem; display: flex; align-items: center; gap: .5rem; }
.p-panel h2:first-child { margin-top: 0; }
.p-panel h2 .soft { text-transform: none; letter-spacing: 0; font-size: .82rem; }
.hand { display: grid; grid-template-columns: repeat(7, 1fr); gap: .3rem; }
.chip { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .35rem 0 .25rem; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.chip b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.chip.zero { opacity: .4; }
.market { display: flex; gap: .4rem; }
.pass-card { flex: 1 1 0; min-width: 0; min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; border-radius: 12px; border: 3px solid var(--c); background: color-mix(in srgb, var(--c) 14%, var(--panel)); font-size: .68rem; font-weight: 800; text-transform: capitalize; padding: .2rem 0; }
.pass-card span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pass-card:disabled { opacity: .55; }
.pass-card:not(:disabled):active { transform: scale(.94); }
.card-slot.empty, .pass-card.empty { flex: 1 1 0; min-height: 76px; border-radius: 12px; border: 2px dashed var(--line); }
.rows { display: flex; flex-direction: column; gap: .35rem; }
.row { display: flex; align-items: center; gap: .55rem; width: 100%; min-height: 48px; padding: .45rem .65rem; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); text-align: left; font-weight: 650; }
.rows.plain .row { min-height: 42px; }
.row.on { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.row.done { background: color-mix(in srgb, var(--good) 12%, var(--panel)); }
.row.missed { background: color-mix(in srgb, var(--danger) 10%, var(--panel)); }
.row.away { opacity: .6; }
.row.next { border-style: dashed; background: none; }
.row .check { color: var(--good); font-weight: 900; }
.row .box { flex: none; width: 26px; height: 26px; border-radius: 7px; border: 2px solid var(--ink); display: grid; place-items: center; font-weight: 900; background: var(--panel); }
.row.pick.on .box { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.link-card { background: var(--panel); border: 2px solid var(--ink); border-radius: var(--radius); padding: .7rem .8rem .8rem; margin-bottom: .4rem; }
.link-card h2 { margin: 0 0 .3rem; font-size: 1.05rem; text-transform: none; letter-spacing: 0; }
.link-card p { margin: .25rem 0; }
.note { font-weight: 700; padding: .5rem .7rem; border-radius: 10px; background: var(--panel-2); }
.log { display: flex; flex-direction: column; gap: .35rem; font-size: .88rem; }
.log li { line-height: 1.5; }
.p-cover { position: absolute; inset: 0; z-index: 5; background: var(--bg); overflow-y: auto; padding: 1rem .9rem 1.5rem; display: flex; }
.p-cover[hidden] { display: none; }
main.p-cover { position: fixed; }
.card { margin: auto; width: 100%; max-width: 520px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 1.2rem 1.1rem 1.3rem; display: flex; flex-direction: column; gap: .6rem; box-shadow: 0 10px 30px rgb(0 0 0 / .08); }
.card.center { align-items: center; text-align: center; }
.card h1 { font-size: 1.6rem; letter-spacing: -.01em; }
.rules { display: flex; flex-direction: column; gap: .4rem; counter-reset: r; font-size: .93rem; line-height: 1.4; }
.rules li { counter-increment: r; padding-left: 1.9rem; position: relative; }
.rules li::before { content: counter(r); position: absolute; left: 0; top: .05em; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: .75rem; font-weight: 800; display: grid; place-items: center; }
.who-list { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-weight: 700; }
.who-list .away { opacity: .55; }
.results { display: flex; flex-direction: column; gap: .4rem; }
.results li { display: flex; align-items: center; gap: .55rem; padding: .5rem .6rem; border-radius: 12px; border: 1px solid var(--line); }
.results li.first { border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--panel)); }
.results li.me { box-shadow: inset 4px 0 0 var(--ink); }
.results .grow { display: flex; flex-direction: column; }
.results .place { width: 1.5rem; font-weight: 900; font-size: 1.2rem; text-align: center; }
.results .total { font-weight: 900; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.toast { position: absolute; left: .8rem; right: .8rem; bottom: 1rem; z-index: 9; background: var(--ink); color: var(--bg); padding: .7rem .9rem; border-radius: 12px; font-weight: 700; text-align: center; box-shadow: 0 6px 20px rgb(0 0 0 / .25); }
details summary { cursor: pointer; font-weight: 750; min-height: 44px; display: flex; align-items: center; justify-content: center; }

/* ---- big screen ---- */
.tv { height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) 29vw; font-size: clamp(12px, 1.05vw, 34px); position: relative; }
.tv-main { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; }
.tv-head { display: flex; align-items: center; justify-content: space-between; gap: 2em; padding: .7em 1.4em; }
.tv-title { display: flex; align-items: center; gap: .7em; font-size: 1.15em; }
.tv-title div { display: flex; flex-direction: column; line-height: 1.2; }
.tv-turn { display: flex; align-items: center; gap: .6em; font-size: 1.7em; min-height: 2.1em; }
.tv-turn .turn-name { font-weight: 900; }
.tv-turn .timer { font-size: .9em; }
.tv-map { min-height: 0; }
.tv-log { display: flex; align-items: center; gap: 2em; padding: .5em 1.4em .8em; min-height: 3.2em; font-size: 1.15em; overflow: hidden; white-space: nowrap; }
.tv-log-line.old { opacity: .5; font-size: .85em; overflow: hidden; text-overflow: ellipsis; }
.tv-side { background: var(--panel); border-left: 1px solid var(--line); padding: 1em 1.1em; display: flex; flex-direction: column; gap: 1em; min-height: 0; overflow: hidden; }
.tv-side h2 { font-size: .85em; text-transform: uppercase; letter-spacing: .07em; margin-bottom: .5em; display: flex; justify-content: space-between; align-items: baseline; }
.tv-side h2 .soft { text-transform: none; letter-spacing: 0; }
.tv-players { display: grid; gap: .4em; }
.tv-players.n7, .tv-players.n8, .tv-players.n9, .tv-players.n10 { grid-template-columns: 1fr 1fr; }
.tv-players li { display: flex; align-items: center; gap: .6em; padding: .45em .6em; border-radius: .7em; border: 2px solid var(--line); min-width: 0; }
.tv-players li.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); box-shadow: 0 0 0 .15em var(--accent); }
.tv-players li.away { opacity: .5; }
.tv-players .grow { display: flex; flex-direction: column; line-height: 1.25; }
.tv-players b { font-size: 1.2em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-players .soft { font-size: .78em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-players.n7 .soft, .tv-players.n8 .soft, .tv-players.n9 .soft, .tv-players.n10 .soft { font-size: .7em; }
.score { font-weight: 900; font-size: 1.5em; font-variant-numeric: tabular-nums; }
.tv-demands { display: flex; flex-direction: column; gap: .35em; }
.tv-demands li { display: flex; align-items: center; gap: .6em; padding: .4em .6em; border-radius: .7em; background: var(--panel-2); font-weight: 650; line-height: 1.2; }
.tv-demands li.next { background: none; border: 2px dashed var(--line); color: var(--ink-soft); }
.tv-demands .score { font-size: 1.25em; }
.tv-market { display: flex; gap: .45em; }
.tv-market .pass-card { min-height: 4.2em; border-width: .2em; border-radius: .7em; }
.tv .badge { width: 2.3em; height: 2.3em; }
.tv .tv-turn .badge { width: 1.5em; height: 1.5em; }
.tv .kind-icon { width: 1.5em; height: 1.5em; }
.tv .tv-market .pass-icon { width: 2.4em; height: 2.4em; }
.tv .tv-log .badge, .tv .tv-log .pass-icon { width: 1.3em; height: 1.3em; }
.tv-points { display: flex; gap: .4em; margin-bottom: .5em; }
.tv-points span { flex: 1; display: flex; flex-direction: column; align-items: center; border-radius: .6em; background: var(--panel-2); padding: .25em 0; }
.tv-points i { font-style: normal; font-size: .8em; color: var(--ink-soft); } .tv-points b { font-size: 1.3em; }
.tv-key p { font-size: .82em; line-height: 1.3; }
.tv-cover { position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 93%, transparent); display: grid; place-items: center; padding: 3vh 4vw; z-index: 4; }
.tv-cover[hidden] { display: none; }
.tv-card { background: var(--panel); border: 1px solid var(--line); border-radius: 1.6em; padding: 2em 2.6em; display: flex; flex-direction: column; gap: .9em; max-width: 62vw; box-shadow: 0 1em 3em rgb(0 0 0 / .12); font-size: 1.25em; }
.tv-card.center { align-items: center; text-align: center; }
.tv-card.wide { width: 78vw; max-width: 78vw; }
.tv-card h1 { font-size: 2.4em; letter-spacing: -.02em; }
.tv-lead { font-size: 1.2em; font-weight: 700; }
.tv-who { display: flex; flex-wrap: wrap; gap: .6em 1.4em; font-weight: 800; font-size: 1.15em; }
.tv-who li { display: flex; align-items: center; gap: .4em; } .tv-who .away { opacity: .4; }
.tv-rules { display: flex; flex-direction: column; gap: .45em; counter-reset: r; }
.tv-rules li { counter-increment: r; padding-left: 2em; position: relative; }
.tv-rules li::before { content: counter(r); position: absolute; left: 0; top: .1em; width: 1.4em; height: 1.4em; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: .8em; font-weight: 800; display: grid; place-items: center; }
.tv-results { display: flex; flex-direction: column; gap: .45em; }
.tv-results li { display: grid; grid-template-columns: 1.6em auto minmax(0, 1.3fr) minmax(0, 1fr) 3em; align-items: center; gap: .7em; padding: .4em .8em; border-radius: .8em; border: 2px solid var(--line); animation: rise .5s both; animation-delay: calc(var(--d) * 120ms); }
.tv-results li.first { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.tv-results .place { font-weight: 900; font-size: 1.4em; text-align: center; }
.tv-results .name { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.tv-results .name .soft { font-size: .7em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-results .bar { height: .9em; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.tv-results .bar i { display: block; height: 100%; border-radius: 99px; animation: grow 1.1s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--d) * 120ms + 300ms); }
.tv-results .total { font-weight: 900; font-size: 1.6em; text-align: right; font-variant-numeric: tabular-nums; }
.tv-results.n8, .tv-results.n9, .tv-results.n10 { font-size: .8em; }
@keyframes rise { from { opacity: 0; transform: translateY(.6em); } }
@keyframes grow { from { width: 0; } }

html[data-reduced-motion] *, html[data-reduced-motion] *::before { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
html[data-theme="schematic"] .row, html[data-theme="schematic"] .chip, html[data-theme="schematic"] .tv-players li { border-width: 2px; }
