@font-face { font-family: Barlow; src: url(/fonts/barlow-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Barlow; src: url(/fonts/barlow-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url(/fonts/barlow-condensed-latin-600-normal.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url(/fonts/barlow-condensed-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --ink: #152235;
  --ground: #121d2d;
  --panel: #1d2c43;
  --panel-2: #24365150;
  --rule: #2e4060;
  --text: #e9eef5;
  --muted: #9aaac0;
  --taxi: #e8b64a;
  --bus: #38b09a;
  --underground: #e05468;
  --ferry: #8cc6ee;
  --black: #070b12;
  --d0: #5b9dff; --d1: #c58bff; --d2: #ff8fb7; --d3: #74e0b4; --d4: #ff9f5a;
  --radius: 8px;
  --cond: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--ink); color: var(--text); font: 400 16px/1.45 Barlow, system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--cond); font-weight: 700; line-height: 1.1; margin: 0 0 .5em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; margin-top: 1em; display: flex; align-items: center; gap: .4em; }
a { color: var(--ferry); }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--taxi); outline-offset: 2px; }

/* ---------- controls ---------- */
.btn { font: 500 1rem/1 Barlow, sans-serif; color: var(--text); background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius);
  min-height: 44px; padding: 0 1rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; gap: .4em; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--taxi); color: var(--ink); border-color: var(--taxi); font-weight: 500; }
.btn.primary:disabled { background: var(--panel); color: var(--muted); border-color: var(--rule); cursor: default; }
.btn.ghost { background: transparent; }
.btn.ghost.on { border-color: var(--ferry); color: var(--ferry); }
.btn.small { min-height: 36px; padding: 0 .7rem; font-size: .9rem; }
.btn.big { min-height: 56px; font-size: 1.15rem; padding: 0 2rem; }
input, select { font: inherit; color: var(--text); background: var(--ground); border: 1px solid var(--rule); border-radius: var(--radius); min-height: 44px; padding: 0 .7rem; width: 100%; }
input:disabled, select:disabled { opacity: .75; }
input[type=checkbox] { width: 22px; min-height: 22px; accent-color: var(--taxi); }
input[type=range] { padding: 0; accent-color: var(--taxi); }
label { display: grid; gap: .3rem; }
.form-error { color: #ff9aa8; min-height: 1.2em; margin: .3rem 0; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.check { display: flex; align-items: center; gap: .5rem; }
.chip { display: inline-flex; align-items: center; border-radius: 4px; padding: .15em .5em; font: 600 .9rem/1.2 var(--cond); color: var(--ink); border: 2px solid transparent; }
.chip.taxi { background: var(--taxi); } .chip.bus { background: var(--bus); } .chip.underground { background: var(--underground); }
.chip.ferry { background: var(--ferry); }
.chip.black { background: var(--black); color: var(--text); border-color: var(--muted); }
.chip.double { background: transparent; color: var(--text); border-color: var(--text); }
button.chip { min-height: 44px; padding: 0 1rem; font-size: 1.05rem; cursor: pointer; opacity: .6; }
button.chip.chosen { opacity: 1; outline: 3px solid var(--text); outline-offset: 2px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rule); display: inline-block; flex: none; }
.dot.on { background: var(--bus); }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.swatch.d0 { background: var(--d0); } .swatch.d1 { background: var(--d1); } .swatch.d2 { background: var(--d2); } .swatch.d3 { background: var(--d3); } .swatch.d4 { background: var(--d4); }
.code { font: 700 1.05rem/1 var(--cond); letter-spacing: .08em; }
.code.big { font-size: 2.4rem; color: var(--taxi); }
#toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem); background: var(--text); color: var(--ink); padding: .7rem 1rem; border-radius: var(--radius);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.offline-banner { display: none; position: fixed; top: 0; left: 0; right: 0; background: var(--underground); color: #fff; text-align: center; padding: .4rem; z-index: 40; }
body.offline .offline-banner { display: block; }
.loading { display: grid; place-items: center; min-height: 100dvh; color: var(--muted); }

/* ---------- front page ---------- */
.front { min-height: 100dvh; display: grid; grid-template-columns: 1fr; gap: 2rem; padding: 2rem 16px; align-content: center; max-width: 1100px; margin: 0 auto; }
.front-title h1 { font-size: clamp(4.5rem, 19vw, 11rem); line-height: .82; letter-spacing: -.01em; margin-bottom: .2em;
}
.front-title h1::after { content: ''; display: block; height: 10px; margin-top: .25em; width: min(100%, 520px);
  background: linear-gradient(90deg, var(--taxi) 0 40%, var(--bus) 40% 70%, var(--underground) 70% 100%); border-radius: 2px; }
.front-title p { font-size: 1.25rem; max-width: 30ch; color: var(--muted); }
.front-form { background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 1.5rem; max-width: 420px; width: 100%; }
.auth-form { display: grid; gap: 1rem; }
@media (min-width: 860px) { .front { grid-template-columns: 1.3fr 1fr; align-items: end; } }

/* ---------- home and lobby ---------- */
.home, .lobby { max-width: 1100px; margin: 0 auto; padding: 1rem 16px 3rem; }
.home section { margin-top: 2rem; max-width: 640px; }
.home-head, .lobby-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1.5rem; border-bottom: 1px solid var(--rule); padding-bottom: 1rem; }
.home-head h1 { font-size: 2.6rem; margin: 0; }
.who { display: flex; gap: 1rem; align-items: center; margin-left: auto; color: var(--muted); flex-wrap: wrap; }
.inline-form { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.inline-form label { flex: 1 1 200px; }
.room-list { list-style: none; padding: 0; margin: 0; }
.room-list a { display: flex; flex-wrap: wrap; gap: .3rem 1rem; align-items: baseline; padding: .9rem 0; border-bottom: 1px solid var(--rule); color: var(--text); text-decoration: none; }
.room-list a:hover strong { color: var(--taxi); }
.room-list .muted { margin-left: auto; }
.lobby-head h1 { font-size: 2.4rem; margin: 0; flex: 1 1 auto; }
.back { color: var(--muted); text-decoration: none; }
.join-code { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.note { background: var(--panel); border-left: 4px solid var(--taxi); padding: .8rem 1rem; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.lobby-grid { display: grid; gap: 1rem; margin-top: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 1.1rem; }
.members, .seats { list-style: none; padding: 0; margin: 0 0 1rem; }
.members li { display: flex; align-items: center; gap: .6rem; min-height: 44px; border-bottom: 1px solid var(--rule); }
.members li .btn { margin-left: auto; }
.seats li { display: grid; grid-template-columns: auto 6.5rem 1fr; gap: .6rem; align-items: center; margin-bottom: .5rem; }
.field { display: grid; grid-template-columns: 1fr; gap: .35rem; margin-bottom: .9rem; }
.field > span:first-child { color: var(--muted); }
.panel .field:has(button) { grid-template-columns: 1fr auto; }
.panel .field:has(button) > span:first-child { grid-column: 1 / -1; }
.start-row { margin-top: 1.5rem; }

/* ---------- game layout ---------- */
.game { height: 100dvh; display: grid; grid-template-rows: auto 1fr auto auto; grid-template-columns: 100%; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: .5rem .8rem; padding: .4rem 12px; border-bottom: 1px solid var(--rule); background: var(--ink); flex-wrap: wrap; min-height: 56px; }
.topbar .back { font-size: 2rem; line-height: 1; padding: 0 .4rem; min-width: 32px; }
.round { display: flex; align-items: baseline; gap: .3rem; }
.round-n { font: 700 2rem/1 var(--cond); }
.turn { font-weight: 500; padding: .35rem .6rem; border-radius: 6px; flex: 1 1 12rem; }
.turn.mine { background: var(--taxi); color: var(--ink); }
.timer { font: 700 1.4rem/1 var(--cond); font-variant-numeric: tabular-nums; }
.timer.low { color: var(--underground); }
.top-tools { display: flex; gap: .4rem; flex-wrap: wrap; }
.map-box { position: relative; min-height: 0; background: var(--ground); overflow: hidden; touch-action: none; }
body.my-turn .map-box::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px var(--taxi); pointer-events: none; }
.actionbar { background: var(--panel); border-top: 1px solid var(--rule); padding: .7rem 12px; display: grid; gap: .6rem; }
.actionbar:empty { display: none; }
.actionbar p { margin: 0; }
.actionbar .row:last-child { justify-content: flex-end; }
.pick { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; font: 600 1.2rem/1 var(--cond); }
.ticket-choice { display: flex; gap: .5rem; flex-wrap: wrap; }
.result h2 { font-size: 1.8rem; margin: 0; }
.result p { margin: .2rem 0 0; color: var(--muted); }
.replay { display: grid; grid-template-columns: auto 1fr; gap: .4rem .8rem; align-items: center; }
.replay .muted { grid-column: 1 / -1; }

.side { background: var(--panel); border-top: 1px solid var(--rule); display: flex; flex-direction: column; min-height: 0; max-height: 46dvh; }
.side.closed { max-height: none; }
.side.closed .tab-body { display: none; }
.tabs { display: flex; border-bottom: 1px solid var(--rule); flex: none; }
.tab { flex: 1; background: none; border: 0; color: var(--muted); font: 600 1rem/1 var(--cond); min-height: 46px; cursor: pointer; border-bottom: 3px solid transparent; }
.tab[aria-selected=true] { color: var(--text); border-bottom-color: var(--taxi); }
.tab-body { overflow: auto; padding: .5rem 12px 1rem; min-height: 0; flex: 1; }
.desk-log { display: none; }

@media (min-width: 900px) {
  .game { grid-template-columns: 1fr 380px; grid-template-rows: auto 1fr auto; }
  .topbar { grid-column: 1 / -1; }
  .side { grid-column: 2; grid-row: 2 / 4; max-height: none; border-top: 0; border-left: 1px solid var(--rule); }
  .side.closed .tab-body { display: block; }
  .desk-log { display: block; padding: .8rem 12px; border-bottom: 1px solid var(--rule); flex: none; }
  .t-log { display: none; }
  .side.tab-log .tab-body { display: none; }
}

/* ---------- panels ---------- */
.counts { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem .8rem; }
.counts li { display: flex; align-items: center; gap: .3rem; font-variant-numeric: tabular-nums; }
.move-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .4rem; }
.move-btn { width: 100%; min-height: 44px; display: flex; justify-content: space-between; align-items: center; background: var(--ground); color: var(--text); border: 1px solid var(--rule); border-radius: var(--radius); font: inherit; padding: 0 .6rem; cursor: pointer; }
.move-btn:hover { border-color: var(--muted); }
.turn-order { list-style: none; padding: 0; margin: 0; }
.turn-order li { padding: .6rem .6rem .7rem; border-left: 4px solid var(--rule); margin-bottom: .4rem; background: var(--ground); border-radius: 0 6px 6px 0; }
.turn-order li.current { background: #2a3d5a; }
.turn-order .fug { border-left-color: var(--text); }
.turn-order .d0 { border-left-color: var(--d0); } .turn-order .d1 { border-left-color: var(--d1); } .turn-order .d2 { border-left-color: var(--d2); }
.turn-order .d3 { border-left-color: var(--d3); } .turn-order .d4 { border-left-color: var(--d4); }
.p-head { display: flex; gap: .5rem; align-items: center; margin-bottom: .4rem; flex-wrap: wrap; }
.p-name { font: 700 1.1rem/1 var(--cond); }
.p-at { margin-left: auto; color: var(--muted); }
.chan { display: flex; gap: .4rem; margin-bottom: .5rem; }
.messages { list-style: none; padding: 0; margin: 0 0 .5rem; max-height: 30dvh; overflow: auto; }
.messages li { padding: .3rem 0; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
.messages li.me strong { color: var(--taxi); }
.chat-form { display: flex; gap: .5rem; }

/* the travel log: a strip of ticket slots, reveal rounds punched */
.strip { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.slot { position: relative; aspect-ratio: 1 / 1.05; background: var(--ground); border: 1px solid var(--rule); border-radius: 5px; padding: 3px 5px; display: flex; flex-direction: column; overflow: hidden; }
.slot-n { font: 600 .8rem/1 var(--cond); color: var(--muted); }
.slot-t { font: 700 .85rem/1.1 var(--cond); margin-top: auto; }
.slot-t.empty { color: var(--muted); font-weight: 600; font-size: .75rem; }
.slot-x { position: absolute; top: 3px; right: 5px; font: 600 .7rem/1 var(--cond); }
.slot-at { font: 700 1.05rem/1 var(--cond); }
.slot-at.private { opacity: .8; font-style: italic; }
.slot.reveal::after { content: ''; position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--ink); box-shadow: inset 0 0 0 1px var(--muted); }
.slot.reveal.used::after { background: var(--ink); box-shadow: none; }
.slot.used { border-color: transparent; color: var(--ink); }
.slot.used .slot-n { color: inherit; opacity: .7; }
.slot.used.taxi { background: var(--taxi); } .slot.used.bus { background: var(--bus); } .slot.used.underground { background: var(--underground); }
.slot.used.black { background: var(--black); color: var(--text); border-color: var(--muted); }
.slot.next { border-color: var(--text); border-style: dashed; }
.slot.reveal .slot-x { right: 16px; }

/* ---------- map ---------- */
.map { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; cursor: grab; }
.map .ground { fill: var(--ground); }
.map .river { fill: none; stroke: #1c3553; stroke-width: 40; stroke-linecap: round; stroke-linejoin: round; }
.map .line { fill: none; stroke-linecap: round; }
.map .taxi { stroke: var(--taxi); stroke-width: 2.4; opacity: .75; }
.map .bus { stroke: var(--bus); stroke-width: 4.5; opacity: .85; }
.map .underground { stroke: var(--underground); stroke-width: 6; opacity: .85; }
.map .ferry { stroke: var(--ferry); stroke-width: 3; stroke-dasharray: 8 6; }
.map .station circle { fill: #0d1726; stroke-width: 3; }
.map .station.taxi circle { stroke: var(--taxi); }
.map .station.bus circle { stroke: var(--bus); }
.map .station.underground circle { stroke: var(--underground); }
.map .station.ferry circle { stroke: var(--ferry); }
.map .station text { fill: var(--text); font: 700 13px var(--cond); pointer-events: none; }
.map .possible { fill: rgba(233, 238, 245, .12); stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 3 3; }
.map .revealed { fill: none; stroke: var(--text); stroke-width: 2.5; stroke-dasharray: 6 4; }
.map .revealed-label { fill: var(--text); font: 600 13px var(--cond); paint-order: stroke; stroke: var(--ground); stroke-width: 4px; }
.map .route { fill: none; stroke: var(--text); stroke-width: 3.5; stroke-dasharray: 2 7; stroke-linecap: round; opacity: .9; }
.map .legal .ring { fill: none; stroke-width: 4.5; }
.map .legal .ring.taxi { stroke: var(--taxi); } .map .legal .ring.bus { stroke: var(--bus); }
.map .legal .ring.underground { stroke: var(--underground); } .map .legal .ring.black { stroke: var(--text); stroke-dasharray: 5 3; }
.map .legal { animation: pulse 1.4s ease-in-out infinite; }
.map .legal.selected { animation: none; }
.map .legal.selected .ring:first-child { fill: rgba(255, 255, 255, .22); stroke-width: 6; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .map .legal { animation: none; } #toast { transition: none; } }
.map .piece path { stroke: var(--ink); stroke-width: 2.5; }
.map .piece text { font: 700 13px var(--cond); fill: var(--ink); pointer-events: none; }
.map .piece.d0 path { fill: var(--d0); } .map .piece.d1 path { fill: var(--d1); } .map .piece.d2 path { fill: var(--d2); }
.map .piece.d3 path { fill: var(--d3); } .map .piece.d4 path { fill: var(--d4); }
.map .piece.fug path { fill: var(--text); stroke: var(--underground); stroke-width: 3; }
.map .piece.current path { stroke: var(--text); stroke-width: 3.5; }
.map .piece.fug.current path { stroke: var(--underground); }

/* ---------- help ---------- */
.help { max-width: 68ch; margin: 0 auto; padding: 1.5rem 16px 4rem; }
.help h1 { font-size: 3rem; margin-top: 1rem; }
.help h2 { margin-top: 2rem; }
.help .lede { font-size: 1.2rem; }
.help ul { padding-left: 1.2rem; }
.help .legend { list-style: none; padding: 0; }
.help .legend li, .help ul li { margin-bottom: .5rem; }
.help pre { background: var(--ground); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem; overflow: auto; font-size: .85rem; }
.help code { color: var(--taxi); }

.map .pin { transform: scale(var(--pin, 1)); }
.map.far .station text { display: none; }
.map.far .station circle { r: 9px; }
