/* Iron Lines — clean modern interface around an antique-style board. */
:root {
  --bg: #1c2427;
  --bg-2: #192023;
  --surface: #253035;
  --surface-2: #2e3b40;
  --surface-3: #37464c;
  --line: rgba(232, 240, 236, .09);
  --line-strong: rgba(232, 240, 236, .18);
  --text: #edf1ee;
  --text-dim: #9db0ac;
  --accent: #f2b544;
  --accent-hover: #ffc65e;
  --accent-ink: #2b1e05;
  --danger: #e8604f;
  --good: #5ec393;
  --ink: #3b2a1a;           /* ink on game components (cards, tickets, map) */
  --paper-tex: none;        /* set from JS: generated paper grain for tickets */

  --ui: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --display: 'IM Fell English', 'Iowan Old Style', Georgia, serif;
  --smallcaps: 'IM Fell English SC', 'IM Fell English', Georgia, serif;

  --c-red: #d23a2c; --c-orange: #ef8a1f; --c-yellow: #f2cd27; --c-green: #2f9a4c;
  --c-blue: #2a63c4; --c-pink: #e27cc2; --c-black: #1f1d1c; --c-white: #fffdf6; --c-gray: #b0aca3;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--ui); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin-bottom: .75rem; }
h3 { font-size: .92rem; margin-bottom: .5rem; }
.muted { color: var(--text-dim); font-weight: 500; font-size: .85rem; }
.hint { color: var(--text-dim); font-size: .88rem; margin: .6rem 0 0; }
.eyebrow-less { margin: 0; color: var(--text-dim); font-size: .85rem; font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- surfaces & controls ---------- */
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.card { padding: 22px; }
.btn {
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  padding: .6rem 1.1rem; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: .92rem;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #f27463; }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.small { padding: .38rem .8rem; font-size: .84rem; border-radius: 8px; }
.link-btn { background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }
input:not([type=checkbox]):not([type=radio]), select {
  width: 100%; margin-top: .35rem; padding: .6rem .75rem; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--bg-2); color: var(--text);
}
input:focus, select:focus { border-color: var(--accent); outline: none; }
label { display: block; margin-bottom: .9rem; font-size: .85rem; font-weight: 600; color: var(--text-dim); }

.logo { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; font-size: 2.6rem; letter-spacing: -.035em; }
.logo-mark { width: 1.05em; height: .62em; border-radius: .14em; flex: none; position: relative;
  background: var(--c-red); box-shadow: inset 0 .1em 0 rgba(255,255,255,.3), inset 0 -.1em 0 rgba(0,0,0,.25); }
.logo-mark::after { content: ''; position: absolute; left: 18%; right: 18%; top: 38%; height: 22%; border-radius: 2px; background: rgba(255,248,225,.75); }
.logo.small { font-size: 1.05rem; gap: 8px; }

/* ---------- home ---------- */
.create-bar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 14px; margin: 4px -22px -22px; padding: 14px 22px 18px; background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 var(--r) var(--r); }
.home-wrap { max-width: 1180px; margin: 0 auto; padding: 56px 24px 48px; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.join-card { position: sticky; top: 20px; }
.home-head { grid-column: 1 / -1; margin-bottom: 14px; }
.tagline { margin: 12px 0 0; max-width: 56ch; font-size: 1.06rem; color: var(--text-dim); }
.field-row { display: grid; grid-template-columns: 1fr 140px; gap: 12px; }
.map-pick { border: 0; padding: 0; margin: 0 0 1.1rem; }
.map-pick legend { font-size: .85rem; font-weight: 600; color: var(--text-dim); margin-bottom: .5rem; }
.map-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; }
.map-group { grid-column: 1 / -1; margin: 6px 0 -2px; font-size: .8rem; font-weight: 700; color: var(--text-dim); }
.map-option { margin: 0; cursor: pointer; border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; background: var(--bg-2); color: var(--text); transition: border-color .15s, box-shadow .15s; display: flex; flex-direction: column; }
.map-option:hover { border-color: var(--text-dim); }
.map-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.map-option input { position: absolute; opacity: 0; pointer-events: none; }
.map-option svg { display: block; width: 100%; height: auto; aspect-ratio: 1.414; }
.map-option .map-text { padding: 8px 10px 10px; }
.map-option .map-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; }
.map-option strong { display: block; font-size: .88rem; line-height: 1.25; }
.map-option small { display: block; color: var(--text-dim); font-size: .8rem; line-height: 1.4; margin-top: 2px; }
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 800; }

/* ---------- lobby ---------- */
.lobby-wrap { max-width: 760px; margin: 56px auto; }
.lobby-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.lobby-code { font-size: clamp(3rem, 12vw, 4.6rem); font-weight: 800; letter-spacing: .12em; margin: 0; line-height: 1; color: var(--accent); }
.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 28px; }
.lobby-players { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.lobby-players li { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px 8px 12px; animation: rise .35s ease-out both; }
.lobby-players li .grow { flex: 1; }
.lobby-actions { display: flex; gap: 10px; margin-top: 28px; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.chip { width: 24px; height: 13px; border-radius: 4px; flex: none; box-shadow: inset 0 3px 0 rgba(255,255,255,.28), inset 0 -3px 0 rgba(0,0,0,.25); }
.tag { display: inline-block; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--surface-3); color: var(--text-dim); margin-left: 6px; vertical-align: 1px; }
.tag.bot { background: rgba(94,195,147,.16); color: var(--good); }
.tag.off { background: rgba(232,96,79,.16); color: var(--danger); }
.tag.host { background: rgba(242,181,68,.15); color: var(--accent); }

/* ---------- game layout ---------- */
#game { height: 100dvh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 6px 14px; min-height: 48px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.code-tag { color: var(--text-dim); font-size: .85rem; font-weight: 600; margin-right: 4px; }
.turn-banner { padding: 6px 14px; border-radius: 999px; background: var(--surface-2); font-weight: 700; font-size: .9rem; }
.turn-banner.mine { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 4px rgba(242,181,68,.18); }
.turn-banner.final { box-shadow: 0 0 0 2px var(--danger); }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 340px; grid-template-rows: 1fr auto; }
.layout > * { min-width: 0; }
.board-wrap { position: relative; min-height: 0; overflow: hidden; touch-action: none; background: radial-gradient(ellipse at 50% 45%, #2b383c 0%, var(--bg) 70%); }
#board { width: 100%; height: 100%; display: block; cursor: grab; user-select: none; }
#board.dragging { cursor: grabbing; }
.board-shadow { filter: drop-shadow(0 14px 26px rgba(0,0,0,.45)); }
.zoom-controls { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.zoom-controls button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line-strong); background: rgba(37,48,53,.92); color: var(--text); font-size: 1.15rem; cursor: pointer; backdrop-filter: blur(6px); }
.zoom-controls button:hover { background: var(--surface-3); }
.focus-bar { position: absolute; left: 12px; top: 12px; right: 64px; max-width: 460px; z-index: 6; display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 12px; border-radius: 12px; background: rgba(25,32,35,.95); border: 1px solid var(--line-strong); box-shadow: 0 10px 26px rgba(0,0,0,.4); backdrop-filter: blur(6px); animation: rise .25s ease-out; }
.focus-bar .fb-text { flex: 1; min-width: 0; }
.focus-bar strong { display: block; font-size: .95rem; }
.focus-bar .fb-line { display: block; font-size: .84rem; color: var(--text-dim); margin-top: 2px; }
.focus-bar .fb-line.good { color: var(--good); font-weight: 700; }
.focus-bar .fb-line.warn { color: var(--danger); font-weight: 700; }
.focus-bar .fb-key { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; font-size: .76rem; color: var(--text-dim); }
.focus-bar .fb-key i { display: inline-block; width: 18px; height: 6px; border-radius: 3px; vertical-align: 1px; margin-right: 5px; }
.focus-bar .fb-key i.need { background: repeating-linear-gradient(90deg, #f2b544 0 3px, transparent 3px 7px), #fff6d8; }
.focus-bar .fb-key i.have { background: var(--mine, var(--good)); }
.focus-bar .close { flex: none; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 1rem; }
.ticket.focused { outline: 3px solid var(--accent); outline-offset: 2px; transform: translateY(-3px); }
.tickets-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tickets-head h3 { margin-bottom: .4rem; }
.show-all { font-size: .78rem; padding: .25rem .6rem; }
.btn.show-all[aria-pressed="true"], .btn.show-all[aria-pressed="true"]:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tooltip { position: absolute; pointer-events: none; padding: 8px 11px; border-radius: 10px; font-size: .84rem; max-width: 260px; z-index: 5; background: rgba(25,32,35,.96); border: 1px solid var(--line-strong); box-shadow: 0 8px 20px rgba(0,0,0,.35); }
.tooltip .muted { display: block; }

.side { grid-row: 1 / span 2; grid-column: 2; display: flex; flex-direction: column; gap: 10px; padding: 10px; overflow-y: auto; min-height: 0; background: var(--bg-2); border-left: 1px solid var(--line); }
.panel { padding: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.draw-hint { font-size: .8rem; color: var(--accent); font-weight: 700; }

/* player list */
.players { display: grid; gap: 6px; }
.player { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 9px 12px 9px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; transition: border-color .2s, background .2s; }
.player::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--pc); }
.player.turn { border-color: var(--accent); background: var(--surface-2); }
.player .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .score { font-weight: 800; font-size: 1.1rem; min-width: 44px; padding: 4px 8px; text-align: center; border-radius: 9px; background: var(--bg-2); grid-row: 1 / span 2; grid-column: 2; }
.player.turn .score { background: var(--accent); color: var(--accent-ink); }
.player .stats { display: flex; gap: 10px; font-size: .78rem; color: var(--text-dim); flex-wrap: wrap; }
.player .actions { grid-column: 1 / -1; display: flex; gap: 6px; margin-top: 6px; }
.player .chip { display: none; }

/* ---------- train cards (game components keep their illustrated look) ---------- */
.tcard {
  --c: var(--c-gray);
  position: relative; display: inline-block; width: 52px; height: 76px; border-radius: 7px; flex: none; padding: 0;
  background: #f6ecd2; border: 1px solid #6b5236;
  box-shadow: 0 2px 0 rgba(0,0,0,.25), 0 6px 12px rgba(0,0,0,.25);
}
.tcard .face {
  position: absolute; inset: 3px; border-radius: 4px; overflow: hidden;
  background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.35), transparent 60%), var(--c);
  border: 1px solid rgba(30,20,10,.45);
}
.tcard .face::before {
  content: ''; position: absolute; left: 10%; right: 10%; top: 34%; height: 32%;
  background: rgba(20,12,6,.32);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 36'%3E%3Cpath d='M1 31 L9 22 L9 31 Z'/%3E%3Crect x='9' y='12' width='32' height='12' rx='5'/%3E%3Crect x='41' y='5' width='15' height='20' rx='1'/%3E%3Crect x='39' y='2' width='19' height='4' rx='1.5'/%3E%3Cpath d='M13 12 L11 2 L20 2 L18 12 Z'/%3E%3Ccircle cx='28' cy='11' r='3.5'/%3E%3Crect x='6' y='23' width='54' height='4' rx='1'/%3E%3Ccircle cx='17' cy='30' r='5'/%3E%3Ccircle cx='30' cy='30' r='5'/%3E%3Ccircle cx='49' cy='29' r='6.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 36'%3E%3Cpath d='M1 31 L9 22 L9 31 Z'/%3E%3Crect x='9' y='12' width='32' height='12' rx='5'/%3E%3Crect x='41' y='5' width='15' height='20' rx='1'/%3E%3Crect x='39' y='2' width='19' height='4' rx='1.5'/%3E%3Cpath d='M13 12 L11 2 L20 2 L18 12 Z'/%3E%3Ccircle cx='28' cy='11' r='3.5'/%3E%3Crect x='6' y='23' width='54' height='4' rx='1'/%3E%3Ccircle cx='17' cy='30' r='5'/%3E%3Ccircle cx='30' cy='30' r='5'/%3E%3Ccircle cx='49' cy='29' r='6.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.tcard .face::after { content: ''; position: absolute; inset: 3px; border: 1px solid rgba(255,255,255,.4); border-radius: 2px; }
.tcard.c-white .face::before { background: rgba(59,42,26,.38); }
.tcard.c-black .face::before { background: rgba(240,225,190,.35); }
.tcard.loco .face {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.35), transparent 60%),
    linear-gradient(180deg, var(--c-red) 0 17%, var(--c-orange) 17% 33%, var(--c-yellow) 33% 50%, var(--c-green) 50% 67%, var(--c-blue) 67% 83%, var(--c-pink) 83%);
}
.tcard.loco .face::before { background: #f6ecd2; filter: drop-shadow(0 1px 0 rgba(0,0,0,.6)); left: 6%; right: 6%; top: 30%; height: 40%; }
.tcard.back .face {
  background:
    repeating-linear-gradient(0deg, transparent 0 7px, rgba(232,192,106,.35) 7px 8px),
    linear-gradient(90deg, transparent 38%, rgba(232,192,106,.55) 38% 42%, transparent 42% 58%, rgba(232,192,106,.55) 58% 62%, transparent 62%),
    radial-gradient(ellipse, #6e4a2c, #3d2715);
}
.tcard.back .face::before { display: none; }
.tcard .count {
  position: absolute; right: -8px; top: -8px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; z-index: 2;
  background: var(--text); color: var(--bg); font-weight: 800; font-size: .8rem; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--surface);
}
button.tcard { cursor: pointer; transition: transform .14s, box-shadow .14s; }
button.tcard:hover:not(:disabled) { transform: translateY(-5px); box-shadow: 0 2px 0 rgba(0,0,0,.25), 0 12px 20px rgba(0,0,0,.35); }
button.tcard:disabled { cursor: not-allowed; }
.market button.tcard:disabled { filter: saturate(.6) brightness(.8); }
.tcard.empty { background: transparent; border: 2px dashed var(--line-strong); box-shadow: none; }
.tcard.deal { animation: flipIn .5s cubic-bezier(.3,1.3,.5,1) both; }
@keyframes flipIn { from { transform: perspective(400px) rotateY(90deg) translateY(-10px); } to { transform: perspective(400px) rotateY(0); } }
.tcard.mini { width: 22px; height: 32px; border-radius: 4px; box-shadow: none; }
.tcard.mini .face { inset: 2px; }
.tcard.mini .count { display: none; }

.market { display: flex; gap: 8px; justify-content: space-between; padding: 8px 0 12px; }
.market .tcard { width: calc((100% - 32px) / 5); max-width: 58px; aspect-ratio: 52/76; height: auto; }
.draw-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pile-btn {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; text-align: left;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font-weight: 700; font-size: .82rem; line-height: 1.2;
  transition: background .15s, border-color .15s;
}
.pile-btn:hover:not(:disabled) { background: var(--surface-3); }
.pile-btn:disabled { opacity: .45; cursor: not-allowed; }
.your-turn .pile-btn:not(:disabled) { border-color: var(--accent); }
.pile-count { display: block; font-weight: 500; color: var(--text-dim); }
.pile { position: relative; width: 34px; height: 48px; flex: none; }
.pile .tcard { position: absolute; width: 30px; height: 44px; left: 0; top: 0; border-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.pile .tcard .face { inset: 2px; }
.pile > :nth-child(2) { transform: translate(2px, 2px); }
.pile > :nth-child(3) { transform: translate(4px, 4px); }
.pile.riffle > * { animation: riffle .5s ease-in-out 2; }
.pile.riffle > :nth-child(2) { animation-delay: .08s; }
.pile.riffle > :nth-child(3) { animation-delay: .16s; }
@keyframes riffle { 50% { transform: translate(14px, -6px) rotate(14deg); } }
.ticket-back {
  position: absolute; width: 32px; height: 22px; left: 0; top: 13px; border-radius: 3px;
  background: repeating-linear-gradient(45deg, #e7d6a8 0 4px, #dcc797 4px 8px); border: 1px solid #6b5236;
}
.ticket-back::after { content: ''; position: absolute; inset: 4px 9px; border-radius: 50%; background: #8e2c22; opacity: .7; }
.tickets-pile > :nth-child(2) { transform: translate(2px, -3px) rotate(-4deg); }
.tickets-pile > :nth-child(3) { transform: translate(3px, -6px) rotate(3deg); }

/* feed */
.feed { display: flex; flex-direction: column; min-height: 200px; flex: 1; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; padding: 3px; background: var(--bg-2); border-radius: 10px; }
.tab { flex: 1; background: none; border: 0; padding: 5px 10px; cursor: pointer; color: var(--text-dim); font-weight: 700; font-size: .84rem; border-radius: 8px; }
.tab.active { color: var(--text); background: var(--surface-3); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: .7rem; }
.log { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; font-size: .84rem; display: flex; flex-direction: column; gap: 6px; max-height: 300px; }
.log li { color: var(--text-dim); padding-left: 10px; border-left: 2px solid transparent; }
.log li.mine { color: var(--text); }
.log li.fresh { animation: logIn .5s ease-out; border-left-color: var(--accent); }
@keyframes logIn { from { opacity: 0; transform: translateX(-8px); } }
.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat .log li b { font-weight: 800; }
.chat-form { display: flex; gap: 6px; margin-top: 8px; }
.chat-form input { margin: 0 !important; }

/* dock (your hand) */
.dock { grid-column: 1; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; padding: 8px 16px 10px; align-items: start; background: var(--bg-2); border-top: 1px solid var(--line); }
.hand-area, .tickets-area { min-width: 0; }
.hand { display: flex; gap: 9px; padding: 9px 8px 2px 0; min-height: 70px; }
.hand .tcard { width: 41px; height: 60px; }
.hand .tcard.zero { opacity: .25; filter: grayscale(.5); }
.tickets { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px; }
.bot-notice { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 10px; background: rgba(94,195,147,.12); border: 1px solid rgba(94,195,147,.35); font-weight: 600; }

/* ---------- destination tickets ---------- */
.ticket {
  flex: none; width: 176px; border-radius: 8px; padding: 0; position: relative; overflow: hidden;
  background-color: #f8efd6; background-image: var(--paper-tex); color: var(--ink); text-align: left; cursor: pointer;
  border: 1px solid #6b5236; box-shadow: 0 2px 0 rgba(0,0,0,.2), 0 6px 14px rgba(0,0,0,.25);
  font: inherit; display: block; transition: transform .15s;
}
button.ticket:hover { transform: translateY(-3px); }
.ticket .tmap { display: block; width: 100%; height: 46px; border-bottom: 1px dashed #8a6d43; background: #a9c4bc; }
.ticket .tmap .t-land { fill: #efe0b8; stroke: #7d5f37; }
.ticket .tmap .t-line { stroke: #8e2c22; fill: none; stroke-linecap: round; }
.ticket .tmap .t-city { fill: #f6ecd2; stroke: var(--ink); }
.ticket .tbody { display: block; padding: 5px 44px 6px 10px; min-height: 42px; }
.tickets .ticket { width: 168px; }
.ticket .route { font-family: var(--display); font-size: 1.02rem; line-height: 1.12; display: block; }
.ticket .pts {
  position: absolute; right: 8px; bottom: 9px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--display); font-size: 1.15rem; color: #f8efd6; background: radial-gradient(circle at 35% 30%, #b54a3c, #8e2c22 65%, #5e1a13); border: 1px solid #3d0f0a;
}
.ticket .state { display: block; margin-top: 3px; font-family: var(--ui); font-size: .72rem; font-weight: 600; color: #7a6248; }
.ticket.long { background-color: #f3dfa6; }
.ticket.long .pts { background: radial-gradient(circle at 35% 30%, #f3d58c, #c8963e 60%, #8a6526); color: #2a1a06; border-color: #5a3f14; }
.ticket.done .state { color: #2e7a55; }
.ticket.done::after, .ticket.failed::after {
  content: 'Connected'; position: absolute; right: 14px; top: 9px; font-family: var(--smallcaps); font-size: 1.1rem; color: #2e7a55;
  border: 2px solid currentColor; border-radius: 4px; padding: 0 6px; transform: rotate(-12deg); opacity: .9; background: rgba(248,239,214,.6); pointer-events: none;
}
.ticket.failed::after { content: 'Unfinished'; color: #8e2c22; }
.ticket.stamp::after { animation: stamp .45s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes stamp { from { transform: rotate(-12deg) scale(2.4); opacity: 0; } }
.ticket.deal { animation: deal .5s cubic-bezier(.3,1.3,.5,1) both; }
@keyframes deal { from { transform: translateY(26px) rotate(4deg); opacity: 0; } }
.ticket.selectable { width: 100%; outline: 3px solid transparent; outline-offset: 2px; }
.ticket.selectable:not(.selected) { opacity: .55; filter: grayscale(.5); }
.ticket.selected { outline-color: var(--accent); }
.ticket.selected .tbody::before { content: '✓'; position: absolute; left: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: .8rem; z-index: 2; }

/* dialogs */
.dialog { border: 1px solid var(--line-strong); border-radius: 18px; padding: 24px; width: min(540px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 30px 60px rgba(0,0,0,.5); }
.dialog[open] { animation: dialogIn .3s cubic-bezier(.3,1.3,.5,1); }
@keyframes dialogIn { from { transform: translateY(16px) scale(.97); opacity: 0; } }
.dialog.small { width: min(420px, calc(100vw - 32px)); }
.dialog.wide { width: min(800px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(10, 14, 16, .6); backdrop-filter: blur(2px); }
#ticketDialog { margin: auto auto 16px; }
#ticketDialog::backdrop { background: rgba(10, 14, 16, .25); backdrop-filter: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
#ticketLeaveBtn { margin-right: auto; }
.ticket-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 14px; }
.claim-options { display: grid; gap: 8px; margin-top: 12px; }
.pay-option { display: flex; align-items: center; gap: 12px; text-align: left; }
.host-end { margin-top: 14px; padding: 12px; border-radius: 12px; background: var(--bg-2); }
.host-end .btn { margin-top: 10px; }
.rules ol { padding-left: 1.2rem; }
.rules li { margin-bottom: .45rem; }
.rules p { margin: .55rem 0; max-width: 70ch; }

.results-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.results-table th, .results-table td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--line); }
.results-table th:first-child, .results-table td:first-child { text-align: left; }
.results-table th { color: var(--text-dim); font-weight: 600; font-size: .8rem; }
.results-table td.total { font-weight: 800; font-size: 1.25rem; }
.results-table tr { animation: deal .5s ease-out both; }
.results-table tr.winner td { color: var(--accent); }
.results-table tr.winner td:first-child::after { content: ' ★'; }
.results-tickets { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.results-tickets .ticket { width: 150px; cursor: default; }
.results-tickets .ticket .tmap { height: 40px; }
.results-tickets .ticket::after { top: 5px; font-size: .95rem; }
.results-tickets .ticket .state { display: none; }
#results h3 { margin-top: 16px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: .9rem; z-index: 60; max-width: calc(100vw - 32px); box-shadow: 0 12px 28px rgba(0,0,0,.45); animation: toastIn .3s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
.toast.good { background: var(--good); color: #0e2a1d; }
@keyframes toastIn { from { transform: translate(-50%, 16px); opacity: 0; } }

/* ---------- effects layer ---------- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.fly { position: fixed; z-index: 41; will-change: transform; }
.fly > .tcard, .fly > .ticket-back { width: 100% !important; height: 100% !important; position: relative; top: 0; left: 0; }
.float-text { position: fixed; z-index: 42; font-weight: 800; font-size: 1.9rem; color: var(--c, var(--accent)); text-shadow: 0 2px 0 rgba(0,0,0,.6), 0 0 14px rgba(0,0,0,.5); white-space: nowrap; }
.float-text.big { font-size: 2.5rem; }
.confetti { position: fixed; top: -20px; z-index: 43; border-radius: 2px; }
.announce { position: fixed; left: 50%; top: 42%; z-index: 44; text-align: center; padding: 18px 34px; min-width: 280px;
  background: rgba(37,48,53,.96); color: var(--text); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: 0 24px 50px rgba(0,0,0,.5); backdrop-filter: blur(6px); }
.announce strong { display: block; font-size: 2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.announce span { display: block; margin-top: 6px; color: var(--text-dim); font-size: .95rem; }
.announce.final strong { color: var(--danger); }
.bump { animation: bump .6s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { 30% { transform: scale(1.22); } }

/* ---------- board svg (antique map style) ---------- */
.graticule line { stroke: #4f6f6a; stroke-width: 1; stroke-dasharray: 2 6; opacity: .45; }
.sea-label { font-family: var(--display); font-style: italic; fill: #355954; opacity: .8; letter-spacing: .12em; }
.cartouche-title { font-family: var(--display); font-size: 30px; fill: var(--ink); }
.cartouche-sub { font-family: var(--display); font-style: italic; font-size: 13px; fill: #5a4630; }
.compass-n { font-family: var(--display); font-size: 18px; fill: var(--ink); }
.land-label { font-family: var(--smallcaps); fill: #7a5c38; opacity: .62; letter-spacing: .32em; }
.legend-title { font-family: var(--display); font-size: 19px; fill: var(--ink); }
.legend-num { font-family: var(--display); font-size: 16px; fill: var(--ink); }
.legend-note { font-family: var(--display); font-style: italic; font-size: 12.5px; fill: #5a4630; }
.decor { opacity: .92; }
.city-dot { fill: #f6ecd2; stroke: var(--ink); stroke-width: 3.2; }
.city-core { fill: #8e2c22; }
.city-glow { fill: none; stroke: #c8963e; stroke-width: 0; opacity: 0; }
.city-label { font: 19px var(--display); fill: var(--ink); paint-order: stroke; stroke: #f2e6c4; stroke-width: 5px; stroke-linejoin: round; pointer-events: none; }
.city.hl .city-glow, .city.hl-done .city-glow { stroke-width: 4; opacity: 1; animation: glow 1.1s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
.city.hl-done .city-glow { stroke: #2e7a55; }
.city.hl .city-core { fill: #c8963e; }
.city.hl .city-label, .city.hl-done .city-label { fill: #8e2c22; }
@keyframes glow { from { transform: scale(.85); opacity: .5; } to { transform: scale(1.25); opacity: 1; } }
.slot { stroke: #2e2116; stroke-width: 1.4; }
.slot-white { stroke: #2e2116; stroke-width: 1.8; }
.badge-text { font: 800 12px var(--ui); pointer-events: none; }
.owner-badge { pointer-events: none; }
/* destination focus */
.focus-shade { fill: #1a1209; opacity: 0; transition: opacity .3s; }
#board.focusing .focus-shade { opacity: .38; }
#board.focusing .route:not(.f-on) { opacity: .25; }
#board.focusing .cars:not(.f-on) { opacity: .3; }
#board.focusing .city:not(.f-on) { opacity: .5; }
#board.focusing .city.f-on .city-label { font-weight: 700; stroke-width: 6px; }
#board.focusing .city.f-end .city-label { font-size: 22px; fill: #8e2c22; }
.route, .cars, .city { transition: opacity .25s; }
.f-path-glow { fill: none; stroke: #fff6d8; stroke-width: 28; stroke-linecap: round; opacity: .85; }
.f-path-dash { fill: none; stroke: #f2b544; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 2 9; animation: march 1s linear infinite; }
@keyframes march { to { stroke-dashoffset: -22; } }
.f-mine-glow { fill: none; stroke-width: 32; stroke-linecap: round; opacity: .65; }
.f-end-mark .f-ring { fill: none; stroke: #f2b544; stroke-width: 5; animation: pulse 1.3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.f-end-mark .f-ring2 { fill: none; stroke: #8e2c22; stroke-width: 2.5; }
.f-end-mark.done .f-ring { stroke: #5ec393; }
@keyframes pulse { 0%, 100% { transform: scale(.9); opacity: .9; } 50% { transform: scale(1.18); opacity: .55; } }
.route { cursor: pointer; }
.route .hit { stroke: transparent; stroke-width: 24; fill: none; }
.route:hover:not(.claimed) .slot { stroke: #fff8e0; stroke-width: 2.6; }
.route.can .slot { stroke: #fff8e0; stroke-width: 2.4; animation: canPulse 1.6s ease-in-out infinite; }
@keyframes canPulse { 50% { stroke: #f2b544; } }
.route.blocked .slot-g { opacity: .3; }
.route.claimed { cursor: default; }
.route.claimed .slot-g { opacity: 0; }
.cars .car { transform-box: fill-box; transform-origin: center; }
.cars.waiting { opacity: 0; }
.cars.drop .car { animation: carDrop .5s cubic-bezier(.3,1.6,.5,1) both; animation-delay: calc(var(--i) * 120ms); }
@keyframes carDrop { from { transform: translateY(-30px) scale(1.4); opacity: 0; } 60% { opacity: 1; } }
.steam { fill: #fbf6ea; stroke: rgba(80,60,40,.25); stroke-width: .5; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .focus-bar { right: 58px; left: 8px; top: 8px; padding: 8px 10px; }
  .focus-bar .fb-key { display: none; }
  .join-card { position: static; }
  .home-wrap { grid-template-columns: 1fr; padding-top: 32px; }
  .logo { font-size: 2.1rem; }
  .lobby-wrap { margin: 16px; }
  .lobby-grid { grid-template-columns: 1fr; }
  #game { height: auto; min-height: 100dvh; }
  .layout { display: flex; flex-direction: column; }
  .board-wrap { height: 62vh; flex: none; }
  .side { border-left: 0; overflow: visible; }
  .dock { grid-template-columns: 1fr; }
  .hand { flex-wrap: wrap; }
  .topbar { flex-wrap: wrap; }
  .logo-text, .code-tag { display: none; }
  .announce { min-width: 0; width: calc(100vw - 48px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
