/* Iron Trails, a parchment survey map, iron and steam. Fixed palette (the same in light and dark OS modes). */
:root {
  --bg: #efe9dc;
  --surface: #fbf8f1;
  --surface2: #e5ddcb;
  --line: rgba(60, 48, 30, .14);
  --ink: #2d2a24;
  --muted: #776e5f;
  --accent: #cf4a2c;           /* you */
  --land: #f4ecd6;
  --sea: #c4dbe0;
  --iron: #3b4048;
  /* tutorial kit (tutorial.css) */
  --tut-accent: #f2b33d;
  --tut-accent-ink: #2d2a24;
  --tut-bubble: #fbf8f1;
  --tut-ink: #2d2a24;
  --tut-muted: #776e5f;
  --tut-dim: rgba(40, 30, 16, .55);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; touch-action: manipulation; min-height: 100vh; overflow-x: hidden; }
button { font: inherit; color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { width: 20px; height: 20px; display: inline-block; vertical-align: middle; flex: none; }

.app { position: relative; max-width: 1080px; margin: 0 auto; padding: 0 12px 14px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }

/* ---------- top bar + menu ---------- */
.topbar { display: flex; align-items: center; gap: 4px; height: 48px; }
.back, .iconbtn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: 22px; background: none; border: 0; cursor: pointer; padding: 0; }
.back:hover, .iconbtn:hover, .iconbtn[aria-expanded="true"] { color: var(--ink); background: var(--surface2); }
.brand { flex: 1; text-align: center; font: 800 20px/1 "Rockwell", "Roboto Slab", Georgia, serif; letter-spacing: .06em; text-transform: uppercase; color: var(--iron); }
.menu { position: absolute; right: 12px; top: 44px; z-index: 45; min-width: 190px; padding: 6px; background: var(--surface); border-radius: 14px; box-shadow: 0 14px 36px rgba(60, 48, 30, .25); display: flex; flex-direction: column; animation: pop .14s ease-out; }
.menu button { min-height: 46px; text-align: left; padding: 0 14px; border: 0; background: none; border-radius: 10px; cursor: pointer; font-weight: 600; }
.menu button:hover, .menu button:focus-visible { background: var(--surface2); }
@keyframes pop { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- buttons ---------- */
.btn { min-height: 44px; padding: 8px 16px; border-radius: 12px; border: 0; background: var(--surface2); color: var(--ink); cursor: pointer; font-weight: 650; transition: background .15s, transform .1s, opacity .15s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover:not(:disabled) { background: #d9cfb9; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #b53d22; }
.btn.quiet { background: transparent; }
.btn.small { min-height: 40px; padding: 4px 14px; font-size: 14px; }

/* ---------- player chips ---------- */
.chips { display: flex; gap: 6px; margin: 0 0 2px; }
.pchip { position: relative; flex: 1 1 0; min-width: 0; min-height: 42px; display: flex; align-items: center; gap: 7px; padding: 4px 8px; border: 0; border-radius: 13px; background: var(--surface); cursor: pointer; text-align: left; transition: box-shadow .2s; }
.pchip.cur { box-shadow: inset 0 -3px 0 var(--pc); }
.pchip .av { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--pc); color: #fff; font-weight: 800; font-size: 13px; }
.pchip .ci { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.pchip .nm { font-size: 11.5px; color: var(--muted); white-space: normal; overflow-wrap: anywhere; line-height: 1.15; }
.pchip .ln { display: flex; align-items: baseline; gap: 8px; font-size: 16px; font-weight: 800; white-space: nowrap; }
.pchip .ln small { font-size: 12px; font-weight: 700; color: var(--muted); display: inline-flex; align-items: center; gap: 2px; }
.pchip .ln small svg { width: 14px; height: 14px; color: var(--muted); }
.pchip .bubble { position: absolute; right: 4px; top: -8px; background: var(--iron); color: #fff; border-radius: 9px; font-size: 11px; font-weight: 800; padding: 1px 7px; animation: pop .25s ease-out; white-space: nowrap; }
.chips.n4 .nm, .chips.n3 .nm { display: none; }
.chips.n4 .pchip { gap: 5px; padding: 4px 6px; }
.chips.n4 .ln { gap: 5px; font-size: 15px; }

/* ---------- status ---------- */
.status { min-height: 34px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 2px 4px; font-size: 14.5px; color: var(--muted); text-align: center; }
.status.mine { color: var(--ink); font-weight: 600; }
.status .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.status .final { color: var(--accent); font-weight: 800; }
.thinking::after { content: ''; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- map ---------- */
.mapwrap { position: relative; border-radius: 16px; overflow: hidden; background: var(--land); box-shadow: inset 0 0 0 1.5px rgba(60, 48, 30, .2); }
.mapscroll { overflow: auto; max-height: 60vh; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.map { display: block; width: 100%; height: auto; }
.mapwrap.zoomed .map { width: 190%; }
.mapwrap.zoomed .mapscroll { height: 60vh; }
.zoom { position: absolute; right: 8px; bottom: 8px; width: 40px; height: 40px; border-radius: 12px; border: 0; background: rgba(251, 248, 241, .92); box-shadow: 0 1px 4px rgba(0, 0, 0, .2); font-size: 22px; font-weight: 700; cursor: pointer; color: var(--iron); }
.map .city circle { fill: #fff; stroke: #3b4048; stroke-width: .55; }
.map .city.flag circle { stroke: var(--accent); stroke-width: 1; }
.map .city.done circle { fill: #e8d9b8; }
.map .city.hl circle { fill: #ffe38a; stroke: var(--accent); stroke-width: 1.1; }
.map .lbl { font: 700 3px/1 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; fill: #2d2a24; paint-order: stroke; stroke: rgba(244, 236, 214, .92); stroke-width: .9px; stroke-linejoin: round; pointer-events: none; }
.map .lbl.hl { fill: var(--accent); }
.map .slot { stroke: rgba(40, 32, 20, .55); stroke-width: .28; }
.map .slot.grey { fill: #c9c1b0; }
.map .route.open.dim .slot { opacity: .55; }
.map .route.sel .slot { stroke: #1b1b1b; stroke-width: .5; }
.map .selglow { fill: none; stroke: #ffd24a; stroke-width: 3.6; stroke-linecap: round; opacity: .8; animation: glow 1.1s ease-in-out infinite; }
.map .flashglow { fill: none; stroke: #fff; stroke-width: 3.4; stroke-linecap: round; animation: flashr 1.6s ease-out forwards; }
@keyframes glow { 0%, 100% { opacity: .85; } 50% { opacity: .4; } }
@keyframes flashr { 0% { opacity: 1; stroke-width: 4.4; } 100% { opacity: 0; stroke-width: 2.4; } }
.map .track { stroke-linecap: butt; }
.map .ties { stroke: rgba(25, 18, 10, .5); stroke-width: 2.3; stroke-dasharray: .4 1.5; }
.map .closed .slot { opacity: .25; }

/* ---------- tray ---------- */
.tray { margin-top: 8px; background: var(--surface); border-radius: 16px; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.tray.turn { box-shadow: inset 0 0 0 2px rgba(207, 74, 44, .35); }
.market { display: flex; gap: 6px; align-items: stretch; min-height: 56px; }
.cardbtn { flex: 1 1 0; min-width: 0; min-height: 56px; border: 0; border-radius: 10px; padding: 3px 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; background: var(--cc); color: #fff; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .12); transition: transform .15s, opacity .2s, box-shadow .2s; }
.cardbtn svg { width: 26px; height: 26px; }
.cardbtn span { font-size: 10.5px; font-weight: 750; line-height: 1; }
.cardbtn.light { color: #3b3a36; box-shadow: inset 0 0 0 1.5px #b9b2a2; }
.cardbtn.eng { background: linear-gradient(135deg, #e25b4a 0%, #f0b23a 30%, #69b35a 55%, #4a8fd4 78%, #9a63c4 100%); }
.cardbtn.can { box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .12), 0 0 0 2px var(--accent); }
.cardbtn.can:hover { transform: translateY(-2px); }
.cardbtn:disabled { opacity: .45; cursor: default; }
.cardbtn.fresh { animation: deal .45s ease-out; }
.cardbtn.empty { background: transparent; box-shadow: inset 0 0 0 1.5px dashed rgba(60, 48, 30, .2); }
.deckbtn { background: #3b4048; color: #efe9dc; }
.deckbtn b { font-size: 15px; }
@keyframes deal { from { transform: translateY(-8px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.handrow { display: flex; align-items: center; gap: 6px; min-height: 44px; }
.hand { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.hc { display: inline-flex; align-items: center; gap: 2px; height: 34px; padding: 0 6px 0 3px; border-radius: 9px; background: var(--cc); color: #fff; font-weight: 800; font-size: 14px; box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .14); }
.hc svg { width: 22px; height: 22px; }
.hc.light { color: #3b3a36; box-shadow: inset 0 0 0 1.5px #b9b2a2; }
.hc.eng { background: linear-gradient(135deg, #e25b4a 0%, #f0b23a 30%, #69b35a 55%, #4a8fd4 78%, #9a63c4 100%); }
.hc.fresh { animation: deal .45s ease-out; }
.hand .none { color: var(--muted); font-size: 13px; }
.tickets-btn { flex: none; min-height: 44px; border: 0; border-radius: 12px; background: var(--surface2); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; padding: 0 10px; font-weight: 750; font-size: 13.5px; }
.tickets-btn svg { width: 22px; height: 22px; }
.claimbar { display: flex; flex-direction: column; gap: 6px; min-height: 56px; justify-content: center; }
.claimbar .ct { font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.claimbar .ct b { font-size: 15px; }
.claimbar .pays { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.claimbar .pays .btn[data-pay] { margin-right: auto; }
.claimbar .cmsg { font-size: 13px; color: var(--muted); }
.claimbar .pays .btn { min-height: 44px; padding: 4px 10px; }
.pay { display: inline-flex; align-items: center; gap: 3px; }
.pay i { display: inline-block; width: 12px; height: 16px; border-radius: 3px; background: var(--cc); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2); }
.pay i.eng { background: linear-gradient(135deg, #e25b4a 0%, #f0b23a 30%, #69b35a 55%, #4a8fd4 78%, #9a63c4 100%); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; background: var(--cc); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); vertical-align: -2px; }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(40, 32, 20, .3); }
.sheet-wrap.keep .sheet-backdrop { background: rgba(40, 32, 20, .12); }
.sheet { position: relative; width: 100%; max-width: 520px; max-height: 70vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); animation: up .18s ease-out; box-shadow: 0 -10px 40px rgba(40, 32, 20, .22); }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet h3 { font: 800 17px/1.2 "Rockwell", "Roboto Slab", Georgia, serif; margin-bottom: 6px; color: var(--iron); letter-spacing: .02em; }
.sheet p { margin: 6px 0; }
.sheet .actions { display: flex; gap: 8px; margin-top: 12px; }
.sheet .actions .btn { flex: 1 1 0; }
.sheet .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 12px 0 5px; }
.tlist { display: flex; flex-direction: column; gap: 6px; }
.ticket { display: flex; align-items: center; gap: 10px; min-height: 50px; border: 0; border-radius: 12px; background: #f6efdc; padding: 6px 12px; text-align: left; cursor: pointer; box-shadow: inset 0 0 0 1.5px #d8ccaf; width: 100%; }
.ticket .tn { flex: 1; font-weight: 700; font-size: 14.5px; }
.ticket .tn small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.ticket .tv { font: 800 18px/1 "Rockwell", Georgia, serif; color: var(--iron); min-width: 28px; text-align: right; }
.ticket.on { box-shadow: inset 0 0 0 2.5px var(--accent); background: #fbe9df; }
.ticket.done { background: #e4efdc; box-shadow: inset 0 0 0 1.5px #9cc08a; }
.ticket.done .tv { color: #3f7a2e; }
.ticket .chk { width: 22px; height: 22px; border-radius: 6px; border: 2px solid #b9ad90; display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 14px; flex: none; }
.ticket.on .chk { background: var(--accent); border-color: var(--accent); }
.log { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; font-size: 13px; }
.log li { padding: 5px 2px; border-bottom: 1px solid var(--line); color: var(--muted); }
.log li:first-child, .log li.mine { color: var(--ink); }
.setup-sheet .field { margin: 12px 0; }
.setup-sheet .label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1 1 0; min-width: 0; min-height: 46px; border-radius: 12px; border: 0; background: var(--surface2); cursor: pointer; font-weight: 650; }
.seg button.on { background: var(--surface); box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.results { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.results th, .results td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.results th:first-child, .results td:first-child { text-align: left; }
.results th { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.results tr.me td { font-weight: 700; color: var(--accent); }
.results td.tot { font-weight: 800; }

/* ---------- modals ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(40, 32, 20, .42); display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 620px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(40, 32, 20, .3); }
.over-modal { max-width: 460px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.modal-head h2 { font: 800 19px/1.2 "Rockwell", "Roboto Slab", Georgia, serif; color: var(--iron); letter-spacing: .02em; }
.modal-body { padding: 0 18px 14px; overflow-y: auto; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 16px; }
.modal-foot .btn { flex: 1 1 110px; }
.rules h3 { font-size: 15px; margin: 16px 0 4px; color: var(--iron); font-family: "Rockwell", Georgia, serif; }
.rules p, .rules li { font-size: 14px; }
.rules ol, .rules ul { padding-left: 20px; margin: 4px 0; }
.rules li { margin: 4px 0; }
.result-banner { font: 800 24px/1.2 "Rockwell", Georgia, serif; margin: 0 0 10px; }
.result-banner.win { color: var(--accent); }

/* desktop: map on the left, cards on the right */
@media (min-width: 900px) {
  .game { display: grid; grid-template-columns: auto minmax(300px, 360px); grid-template-areas: "chips chips" "status status" "map tray"; column-gap: 16px; align-items: start; justify-content: center; }
  .chips { grid-area: chips; max-width: 720px; }
  .status { grid-area: status; justify-content: flex-start; }
  .mapwrap { grid-area: map; width: max-content; max-width: 100%; }
  .mapscroll { max-height: none; overflow: visible; }
  .map { height: calc(100vh - 150px); min-height: 520px; width: auto; }
  .zoom { display: none; }
  .tray { grid-area: tray; margin-top: 0; }
  .market { flex-wrap: wrap; }
  .cardbtn { flex: 1 1 28%; min-height: 64px; }
}
@media (max-width: 370px) {
  .cardbtn span { display: none; }
  .hc { padding: 0 5px 0 2px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- online (a table with friends: tables.js) ---------- */
/* a short notice (connection lost, the table was updated, a friend left) floats over the map's top edge, so the
   board never moves */
.net-note { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); z-index: 6; width: max-content; max-width: min(88vw, 360px);
  padding: 5px 12px; border-radius: 12px; background: var(--iron); color: #fff; font-size: 12.5px; font-weight: 700; line-height: 1.3; text-align: center;
  white-space: normal; box-shadow: 0 4px 14px rgba(40, 32, 20, .3); pointer-events: none; animation: pop .25s ease-out; }
/* a friend whose page stopped checking in */
.pchip.away .av { opacity: .5; }
.pchip .aw { font-style: italic; }
.pchip:disabled { cursor: default; }
/* one divider above the online rows */
.menu #menu-online, .menu #menu-leave { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; }
/* the top bar (← and ⋯) stays in reach above a contracts sheet: the first contracts open on arrival, and
   ⋯ → Play friends online must not wait for them */
.topbar { position: relative; z-index: 31; }
