:root {
    --sand: #f4ecdc;
    --sand-2: #eadfc8;
    --ink: #2b2418;
    --muted: #7a6d58;
    --bush: #3f6b3a;
    --bush-dark: #2c4d29;
    --ochre: #c8782a;
    --red: #b8432f;
    --water: #2f7fb5;
    --card: #fffaf0;
    --line: #d8c9a8;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--sand);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
}

button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
input, select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
a { color: var(--bush-dark); }

.primary { background: var(--bush); color: #fff; border: 0; border-radius: 10px; padding: 9px 16px; }
.primary:hover:not(:disabled) { background: var(--bush-dark); }
.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; }
.big { font-size: 1.05rem; padding: 12px 22px; width: 100%; margin: 6px 0; }
.link { background: none; border: 0; color: var(--bush-dark); text-decoration: underline; padding: 4px 0; }
.icon { background: none; border: 0; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gap { gap: 10px; }

.dot {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: .75rem; font-weight: 700;
    flex: none; vertical-align: middle;
}

/* ---------- boot + setup ---------- */
.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.boot-title { font-size: 2rem; font-weight: 800; color: var(--bush-dark); }
.boot-sub { color: var(--muted); margin-top: 8px; }

.setup { max-width: 560px; margin: 0 auto; padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.setup h1 { color: var(--bush-dark); margin: 8px 0 0; font-size: 2rem; }
.tagline { color: var(--muted); margin: -10px 0 0; }
.setup-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 14px 0; }
.setup-card h2 { margin: 0 0 10px; font-size: 1.1rem; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; }
.chip.on { background: var(--bush); color: #fff; border-color: var(--bush); }

/* Setup controls: icon radios, segments, stepper, switches, bottom sheets */
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 16px; height: 16px; }
.ic.book { color: var(--ochre); }
.ss-sec { display: flex; flex-direction: column; gap: 10px; }
.ss-sec h2, .ss-sheet h3 { margin: 0; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ss-sheet h3 { margin-top: 6px; }
.ss-q { font-weight: 600; font-size: .9rem; }
.seg { display: flex; background: var(--sand-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px 4px; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--ink); }
.seg.tall button { flex-direction: column; gap: 1px; }
.seg small { font-size: .72rem; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--card); box-shadow: 0 1px 3px rgba(43,36,24,.2); font-weight: 700; color: var(--bush-dark); }
.tiles { display: grid; gap: 8px; }
.tiles.c2 { grid-template-columns: 1fr 1fr; }
.tiles.c3 { grid-template-columns: repeat(3, 1fr); }
.tile { position: relative; border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 6px 10px; min-height: 44px;
    display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; color: var(--ink); }
.tile > .ic { width: 30px; height: 30px; color: var(--muted); }
.tile b { font-size: .92rem; }
.tile small { font-size: .74rem; color: var(--muted); line-height: 1.25; }
.tile .pair { display: flex; gap: 2px; color: var(--muted); }
.tile .ic.book { position: absolute; top: 6px; right: 6px; width: 14px; height: 14px; color: var(--ochre); }
.tile[aria-checked="true"] { border-color: var(--bush); background: #e6eedd; box-shadow: inset 0 0 0 1px var(--bush); }
.tile[aria-checked="true"] > .ic:not(.book), .tile[aria-checked="true"] .pair { color: var(--bush); }
.tiles.list { grid-template-columns: 1fr; gap: 6px; }
.tiles.list .tile { flex-direction: row; text-align: left; padding: 9px 12px; gap: 12px; }
.tiles.list .tile > .ic { width: 24px; height: 24px; color: var(--ochre); }
.tiles.list .tile span { display: flex; flex-direction: column; }
.stepper { display: flex; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button { width: 54px; height: 48px; border: 0; background: transparent; font-size: 1.4rem; color: var(--bush-dark); }
.stepper output { flex: 1; text-align: center; font-weight: 700; font-size: 1.05rem; }
.stepper output small { display: block; font-weight: 400; font-size: .76rem; color: var(--muted); }
.sw { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 4px 0; background: none; border: 0; text-align: left; color: var(--ink); }
.sw > .ic { color: var(--muted); }
.sw span { flex: 1; display: flex; flex-direction: column; }
.sw small { color: var(--muted); font-size: .78rem; }
.sw i { width: 44px; height: 26px; border-radius: 13px; background: #c9bea6; position: relative; flex: none; transition: background .15s; }
.sw i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.sw[aria-checked="true"] i { background: var(--bush); }
.sw[aria-checked="true"] i::after { transform: translateX(18px); }
.plist { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.plist > button { display: flex; align-items: center; gap: 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 10px 12px; min-height: 60px; text-align: left; color: var(--ink); }
.plist > button:last-child { border-bottom: 0; }
.plist span:not(.veh-dot) { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.plist small { color: var(--muted); font-size: .8rem; }
.plist .veh-dot, .prow .veh-dot { width: 40px; height: 40px; }
.chev { color: var(--muted); }
.addp { border: 1.5px dashed var(--line); background: transparent; border-radius: 12px; padding: 10px; min-height: 44px; color: var(--bush-dark); font-weight: 600; }
.rulesrow { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-height: 60px; text-align: left; color: var(--ink); }
.rulesrow > .ic:first-child { color: var(--ochre); }
.rulesrow span { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rulesrow small { color: var(--muted); font-size: .8rem; }
.rulesrow.changed { border-color: var(--ochre); box-shadow: inset 0 0 0 1px var(--ochre); }

/* Saved game card on the setup screen */
.resume { background: var(--card); border: 2px solid var(--bush); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.resume-head { display: flex; flex-direction: column; }
.resume-head b { font-size: 1.1rem; color: var(--bush-dark); }
.resume-head small, .resume-drivers small { color: var(--muted); font-size: .8rem; }
.resume-drivers { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.resume-drivers > span { display: inline-flex; align-items: center; gap: 6px; }
.resume-drivers .veh-dot { width: 28px; height: 28px; }
.resume-drivers small { margin-left: 2px; }
.resume-actions { display: flex; align-items: center; gap: 16px; }
.resume-actions .primary { flex: 1; }
.resume-error { color: #a33; margin: 0; }
.startbar { position: sticky; bottom: 0; padding: 10px 0 calc(8px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(transparent, var(--sand) 35%); margin-top: -8px; }
.startbar .big { margin: 0; border-radius: 14px; font-weight: 700; }
.prow { display: flex; align-items: center; gap: 10px; }
.prow input { flex: 1; min-width: 0; font-size: 1rem; font-weight: 600; }

/* Phone-to-phone play: lobby and in-game connection notes */
.net-top { display: flex; align-items: baseline; gap: 12px; }
.net-top h1 { font-size: 1.6rem; }
.net .tiles.c2 .tile { padding: 16px 8px 14px; }
.net-seat { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding: 10px 12px; min-height: 56px; }
.net-seat:last-child { border-bottom: 0; }
.net-seat span:not(.veh-dot) { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.net-seat small { color: var(--muted); font-size: .8rem; }
.net-seat .veh-dot { width: 36px; height: 36px; }
.net-qr { display: flex; gap: 14px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.net-qr img { width: 160px; height: 160px; image-rendering: pixelated; flex: none; background: #fff; }
.net-qr p { margin: 0 0 8px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .02em; }
.net-addr { flex: 1; min-width: 0; font-size: 1.05rem; }
.net-bar { background: #fff4d6; border: 1px solid var(--ochre); border-radius: 10px; padding: 8px 10px; font-size: .88rem; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.net-bar.bad { background: #fde3dc; border-color: var(--red); }
.net-bar button { padding: 4px 10px; }
@media (max-width: 380px) { .net-qr { flex-direction: column; align-items: center; } }

/* Online play: join code, chat */
.online-code { font-size: 2.2rem; font-weight: 700; letter-spacing: .3em; color: var(--bush-dark); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; text-align: center; }
.tiles.c1 { grid-template-columns: 1fr; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; }
.ochat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin: 8px 0; overflow: hidden; }
.panel .ochat { margin: 8px 14px; }
.ochat-head { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; padding: 8px 12px; min-height: 44px; color: var(--ink); text-align: left; }
.ochat-head .chev { margin-left: auto; transition: transform .15s; }
.ochat.open .ochat-head .chev { transform: rotate(90deg); }
.ochat-peek { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: .88rem; }
.ochat-badge { background: var(--red); color: #fff; border-radius: 999px; font-size: .75rem; padding: 1px 7px; font-weight: 700; }
.ochat-lines { max-height: 180px; overflow-y: auto; padding: 0 12px 6px; display: flex; flex-direction: column; gap: 4px; }
.ochat-line { font-size: .92rem; }
.ochat-line.mine { color: var(--bush-dark); }
.ochat-line .linkish { text-align: left; text-decoration: none; padding: 0; color: var(--ink); }
.ochat-act { display: flex; gap: 6px; margin: 4px 0 2px; }
.ochat-act button { padding: 4px 10px; font-size: .85rem; }
.ochat-note { margin: 0 12px 6px; background: #fff4d6; border: 1px solid var(--ochre); border-radius: 8px; padding: 6px 8px; }
.ochat-quick { display: flex; gap: 6px; overflow-x: auto; padding: 6px 12px; scrollbar-width: none; }
.ochat-quick .chip { flex: none; padding: 4px 12px; font-size: .88rem; min-height: 34px; white-space: nowrap; }
.ochat-type { display: flex; gap: 8px; padding: 4px 12px; }
.ochat-type input { flex: 1; min-width: 0; }
.ochat > .muted { margin: 2px 12px 8px; }
.hai { display: flex; gap: 2px; background: var(--sand-2); border-radius: 999px; padding: 3px; }
.hai button { border: 0; background: transparent; border-radius: 999px; padding: 5px 10px; min-height: 36px; display: flex; align-items: center; gap: 4px; font-size: .82rem; color: var(--muted); }
.hai button[aria-checked="true"] { background: var(--card); color: var(--bush-dark); font-weight: 700; box-shadow: 0 1px 2px rgba(43,36,24,.2); }
.vgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.vtile { border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); padding: 8px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .74rem; line-height: 1.2; color: var(--ink); min-height: 44px; }
.vtile svg { width: 56px; height: 34px; }
.vtile[aria-checked="true"] { border-color: var(--pc, var(--bush)); box-shadow: inset 0 0 0 1px var(--pc, var(--bush)); background: #fff; font-weight: 700; }
.link.danger { color: var(--red); align-self: flex-start; margin-top: 4px; }
.ss-scrim { position: fixed; inset: 0; background: rgba(30,25,15,.4); z-index: 50; animation: ss-fade .2s ease; }
.ss-sheet { position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; max-height: 88%; z-index: 51; background: var(--sand);
    border-radius: 22px 22px 0 0; display: flex; flex-direction: column; box-shadow: 0 -8px 30px rgba(0,0,0,.2); animation: ss-up .25s ease; }
.ss-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; flex: none; }
.ss-sheet header { display: flex; justify-content: space-between; align-items: center; padding: 6px 16px 8px; flex: none; }
.ss-sheet header b { font-size: 1.1rem; }
.ss-sheet header button { border: 0; background: none; color: var(--bush-dark); font-weight: 700; padding: 8px 0 8px 12px; }
.ss-body { overflow-y: auto; padding: 0 16px calc(20px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 10px; }
.ss-body p { margin: 0; }
@keyframes ss-up { from { transform: translateY(100%); } }
@keyframes ss-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ss-sheet, .ss-scrim { animation: none; } .sw i, .sw i::after { transition: none; } }
button:focus-visible { outline: 2px solid var(--ochre); outline-offset: 2px; }
.fine { color: var(--muted); font-size: .8rem; text-align: center; }

/* ---------- game layout ---------- */
#app { height: 100%; }
.game { display: flex; height: 100%; overflow: hidden; }
.map-wrap { position: relative; flex: 1; min-width: 0; background: #e9dfc6; }
#board { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; }
.panel { width: 400px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--sand); overflow-y: auto; }

.sheet-grab, .sheet-mini { display: none; }

@media (max-width: 820px) {
    .grid2 { grid-template-columns: 1fr; }
    .legend { display: none !important; }
}

/* ---------- map ---------- */
.map-bg { fill: #efe6cf; }
.road { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.road.tar { stroke: #8f8a80; stroke-width: 4.5; }
.road.gravel { stroke: #c4a46e; stroke-width: 3; stroke-dasharray: 9 5; }
.sp { stroke: #fff; stroke-width: 1.5; }
.sp.sighting { fill: #4c9a45; }
.sp.ingozi { fill: #e0782b; }
.sp.dam { fill: var(--water); }
.sp.road { fill: #bdb39f; }
.sp.junction { fill: #9a917f; stroke: none; }
.sp.picnic { fill: #8a55a8; }
.sp.camp { fill: #7a4b22; stroke-width: 2.5; }
.sp.gate { fill: #2b2418; }
.lbl { paint-order: stroke; stroke: #f4ecdc; stroke-width: 4px; stroke-linejoin: round; fill: var(--ink); pointer-events: none; }
.lbl-camp { font-size: 17px; font-weight: 700; }
.lbl-gate { font-size: 13px; font-style: italic; }
.lbl-picnic { font-size: 11px; fill: #5e3a74; }
.hint { fill: none; stroke: var(--bush); stroke-width: 5; stroke-dasharray: 2 9; stroke-linecap: round; opacity: .6; pointer-events: none; }
.route { fill: none; stroke: #e4572e; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; opacity: .8; pointer-events: none; }
.dest-ring { fill: none; stroke: var(--bush); stroke-width: 4; stroke-dasharray: 6 4; pointer-events: none; }
.dest-label { font-size: 13px; font-weight: 700; fill: var(--bush-dark); text-anchor: middle; paint-order: stroke; stroke: #f4ecdc; stroke-width: 4px; pointer-events: none; }
.option { fill: rgba(255, 210, 63, .55); stroke: #d99a00; stroke-width: 3; cursor: pointer; animation: pulse 1.2s ease-in-out infinite; }
.option.fuelstop { fill: rgba(80, 170, 255, .5); stroke: #1f6fb5; }
.fuelstop-icon { font-size: 13px; }
.option.place { stroke-width: 4; }
.option.selected { fill: rgba(228, 87, 46, .6); stroke: #b8432f; animation: none; }
@keyframes pulse { 0%, 100% { stroke-width: 3; } 50% { stroke-width: 6; } }
.token circle { stroke: #fff; stroke-width: 3; }
.token text { fill: #fff; font-size: 12px; font-weight: 800; text-anchor: middle; pointer-events: none; }
.token.current circle { stroke: #ffd23f; stroke-width: 4; }
.owned { stroke: #fff; stroke-width: 1; }

.map-tools { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 6px; }
.map-tools button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 1.1rem; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.attribution { position: absolute; right: 0; bottom: 0; background: rgba(255, 250, 240, .9); font-size: 11px; padding: 2px 6px; border-top-left-radius: 6px; }
.legend { position: absolute; left: 10px; bottom: 10px; display: flex; flex-wrap: wrap; gap: 4px 10px; max-width: 330px; background: rgba(255, 250, 240, .9); padding: 6px 8px; border-radius: 8px; font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.lg.sighting { background: #4c9a45; } .lg.ingozi { background: #e0782b; } .lg.dam { background: var(--water); }
.lg.picnic { background: #8a55a8; } .lg.camp { background: #7a4b22; border-radius: 2px; }
.lg.tar { background: #8f8a80; border-radius: 0; height: 4px; width: 16px; }
.lg.gravel { background: repeating-linear-gradient(90deg, #c4a46e 0 5px, transparent 5px 8px); border-radius: 0; height: 3px; width: 16px; }

/* ---------- panel ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: .9rem; gap: 8px; }
.players { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; }
.pchip { display: flex; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 10px; }
.pchip.cur { background: var(--card); box-shadow: inset 0 0 0 2px #ffd23f; }
.pchip.in { opacity: .7; }
.pname { font-weight: 600; font-size: .9rem; }
.pstats { font-size: .8rem; color: var(--muted); }

.status { padding: 8px 14px; border-top: 1px solid var(--line); }
.who { display: flex; gap: 6px; align-items: center; }
.dice { font-weight: 700; }
.meter { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.mlabel { width: 42px; font-size: .8rem; color: var(--muted); }
.mval { width: 64px; text-align: right; font-size: .85rem; font-variant-numeric: tabular-nums; }
.fuel { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.q { height: 12px; background: #fff; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.qfill { height: 100%; background: var(--bush); }
.qfill.low { background: var(--red); }
.clock { flex: 1; height: 12px; background: linear-gradient(90deg, #fde7b0, #fff6dd 40%, #f6c27a 85%, #c8782a); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.cfill { height: 100%; background: rgba(43, 36, 24, .35); }
.cfill.late { background: rgba(184, 67, 47, .6); }
.dest { font-size: .9rem; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.hintbox { font-size: .8rem; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; margin-left: auto; }
.where { font-size: .85rem; margin-top: 4px; }

.action { padding: 10px 14px; border-top: 1px solid var(--line); min-height: 110px; }
.preview { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: .88rem; margin: 6px 0; }
.warn { color: var(--red); font-weight: 600; }
.good { color: var(--bush); font-weight: 600; }
.handover { text-align: center; }
.prompt { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.ptitle { font-weight: 700; font-size: 1.05rem; margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.picon { font-size: 1.3rem; }
.ptext { white-space: pre-line; margin: 6px 0 10px; font-size: .92rem; }
.choices { display: flex; flex-direction: column; gap: 6px; }
.choices button { text-align: left; white-space: normal; line-height: 1.3; }
.choices:has(.track-choice) { flex-direction: row; flex-wrap: wrap; }
.choices:has(.track-choice) > :not(.track-choice) { flex-basis: 100%; }
.choices .track-choice { flex: 1 1 0; min-width: 80px; padding: 4px; display: flex; justify-content: center; }
.track-choice .track { width: 100%; max-width: 110px; height: auto; aspect-ratio: 120 / 140; }

.tabs { display: flex; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; padding: 9px 4px; font-size: .88rem; color: var(--muted); border-bottom: 3px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--ochre); font-weight: 600; }
.panel > * { flex: none; }
.tabbody { padding: 10px 14px 24px; flex: 1 0 auto !important; }
.log div { font-size: .85rem; margin: 3px 0; }
.setline { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.setline.done b { color: var(--bush); }
.setline.done b::after { content: " ✓"; }
.scoreblock { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin: 6px 0; }
.scoreblock summary { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.scoreblock summary b { margin-left: auto; }
.scoreline { display: flex; justify-content: space-between; font-size: .88rem; padding: 2px 0; gap: 8px; }
.propline { font-size: .85rem; margin: 3px 0; }
.rules p { font-size: .88rem; line-height: 1.45; }

/* ---------- cards ---------- */
.card { background: #fff; border: 1px solid var(--line); border-left: 6px solid #9a917f; border-radius: 10px; padding: 8px 10px; margin: 6px 0; }
.card.compact { padding: 5px 8px; }
.card-head { display: flex; gap: 6px; align-items: center; }
.card-name { font-weight: 700; flex: 1; }
.card-pts { font-weight: 800; color: var(--bush-dark); font-size: 1.05rem; }
.card-sci { font-style: italic; color: var(--muted); font-size: .85rem; }
.card-meta { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.card-note { font-size: .8rem; color: var(--ochre); margin-top: 2px; }
.tag { background: var(--sand-2); border-radius: 999px; padding: 0 7px; font-size: .72rem; color: var(--ink); }
.tier-very-common, .tier-common { border-left-color: #9a917f; }
.tier-uncommon, .tier-summer-migrant { border-left-color: var(--water); }
.tier-scarce { border-left-color: var(--bush); }
.tier-rare { border-left-color: var(--ochre); }
.tier-very-rare { border-left-color: var(--red); }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(43, 36, 24, .45); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.modal { background: var(--sand); border-radius: 16px; padding: 18px 20px; width: min(480px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal h2 { margin-top: 0; color: var(--bush-dark); }

#blazor-error-ui { background: #ffe9a8; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* ---------- card packs (3D flip) ---------- */
.pack { position: relative; perspective: 1000px; margin: 6px 4px 10px; cursor: pointer; }
.pack.flipped, .pack.locked { cursor: default; }
.pack-deck { position: absolute; inset: 6px -4px -6px 4px; border-radius: 14px; background: var(--bush-dark);
    box-shadow: 3px 3px 0 #1f3a1d, 6px 6px 0 #18301a; }
.pack-inner { display: grid; transition: transform .75s cubic-bezier(.3,.7,.3,1.15); transform-style: preserve-3d; }
.pack.flipped .pack-inner { transform: rotateY(180deg); }
.pack:not(.flipped):not(.locked):hover .pack-inner { transform: translateY(-4px) rotateZ(-1deg); }
.pack-face { grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 14px; }
.pack-front { transform: rotateY(180deg); background: var(--card); }
.pack-front > .card, .pack-front > .campcard { margin: 0; height: 100%; }
.pack-back { min-height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    color: #f4ecdc; border: 3px solid #e7c873;
    background: repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 10px, transparent 10px 20px),
                radial-gradient(circle at 50% 40%, #4f8a48, var(--bush-dark)); }
.back-logo { font-weight: 900; font-size: 1.5rem; line-height: 1.05; text-align: center; letter-spacing: .04em; color: #e7c873; }
.back-kind { text-transform: uppercase; font-size: .75rem; letter-spacing: .15em; }
.back-tap { font-size: .8rem; opacity: .85; animation: pulse 1.4s ease-in-out infinite; }

/* Popup pinned next to a tapped circle (positioned by ktMap.pins) */
.map-pop { position: absolute; z-index: 3; visibility: hidden; max-width: min(280px, calc(100% - 8px)); background: var(--card);
    border: 1px solid var(--line); border-radius: 12px; padding: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.25);
    display: flex; flex-direction: column; gap: 6px; font-size: .85rem; }
.pop-where { font-weight: 600; line-height: 1.3; }
.pop-drive { padding: 8px 14px; font-weight: 700; }
.pop-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pop-x { border: 0; background: none; font-size: 1rem; padding: 0 4px; color: var(--muted); }
.pop-pick { text-align: left; background: var(--sand); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; line-height: 1.25; }
.pop-pick:hover { border-color: var(--ochre); }
.pick-badge { display: inline-block; min-width: 20px; height: 20px; line-height: 20px; border-radius: 999px; background: var(--ink); color: #fff;
    text-align: center; font-size: .75rem; font-weight: 700; margin-right: 8px; }
.pick-num { fill: #2b2418; stroke: #fff; stroke-width: 1.5; }
.pick-num-label { fill: #fff; font-size: 11px; font-weight: 700; }

/* ---------- photos, camp cards, detail ---------- */
.photo { height: 160px; margin: -2px -2px 8px; border-radius: 10px; overflow: hidden; background: var(--sand-2);
    display: flex; align-items: center; justify-content: center; }
/* Show the whole photo (no cropping off heads and tails); a blurred copy fills the spare space. */
.photo img { display: block; }
.photo img.bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(14px) brightness(.8); transform: scale(1.15); }
.photo img.fg { position: relative; width: 100%; height: 100%; object-fit: contain; }
.photo.large { height: auto; min-height: 120px; }
.photo.large img.fg { height: auto; max-height: min(60vh, 440px); }
.photo-none { font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.photo-icon { font-size: 2.4rem; opacity: .6; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--ochre); }
.card-more { font-size: .78rem; color: var(--bush-dark); margin-top: 4px; font-weight: 600; }
.campcard { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.camp-head { display: flex; align-items: center; gap: 8px; }
.camp-icon { font-size: 1.4rem; }
.camp-name { font-weight: 800; font-size: 1.1rem; flex: 1; }
.camp-type { color: var(--muted); font-size: .85rem; margin: 2px 0 6px; }
.camp-line { font-size: .88rem; margin: 3px 0; }
.camp-fac { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.fac { background: var(--sand-2); border-radius: 999px; padding: 2px 8px; font-size: .78rem; }
.camp-units { font-size: .8rem; color: var(--muted); }
.dest b.link { cursor: pointer; text-decoration: underline dotted; }
.modal.detail { max-width: 520px; width: calc(100vw - 32px); max-height: calc(100vh - 40px); overflow-y: auto; position: relative; text-align: left; }
.detail h3 { margin: 4px 0 0; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.detail h4 { margin: 14px 0 6px; color: var(--bush-dark); }
.detail-x { position: absolute; top: 8px; right: 8px; z-index: 2; border: 0; border-radius: 999px; width: 30px; height: 30px; background: rgba(0,0,0,.55); color: #fff; }
.wiki { font-size: .9rem; line-height: 1.45; }
.trackrow, .treerow { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; }
.treerow .photo { height: 90px; margin: 0; }
.track { width: 120px; height: 140px; background: #e9dcc0; border-radius: 10px; }
.track .pad { fill: #6b5432; }
.track .claw { stroke: #6b5432; stroke-width: 3; stroke-linecap: round; }
.track .crack { stroke: #e9dcc0; stroke-width: 2; fill: none; }
.track .scale { stroke: var(--ink); stroke-width: 1.5; }
.track .scale-label { font-size: 9px; fill: var(--ink); }
.track-none { font-size: .9rem; color: var(--muted); }
.credit { font-size: .72rem; color: var(--muted); margin-top: 12px; }
.small { font-size: .85rem; }

/* ---------- end-of-game routes ---------- */
.trail { fill: none; stroke-width: 5; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; opacity: .75; pointer-events: none; }
.trail.jump { stroke-width: 3; stroke-dasharray: 6 6; }
.night { stroke: #fff; stroke-width: 2; }
.night-label { font-size: 11px; font-weight: 800; fill: #fff; text-anchor: middle; pointer-events: none; }
.routes { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.rdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.route-info { font-size: .85rem; }

/* ---------- vehicles ---------- */
.veh-dot { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; flex: none; vertical-align: middle;
    box-shadow: 0 0 0 2px #fff inset; }
.veh-dot svg { width: 100%; height: 100%; }
.veh-body { fill: #fff; }
.veh-wheel { fill: #2b2418; stroke: #fff; stroke-width: 1.2; }
.veh-disc { stroke: #fff; stroke-width: 3; }
.token.current .veh-disc { stroke: #ffd23f; stroke-width: 4; }
.seat .veh-dot, .players .veh-dot, .who .veh-dot { width: 34px; height: 34px; }
.fieldnotes { background: var(--card); border-left: 4px solid var(--bush); border-radius: 8px; padding: 6px 10px; margin: 10px 0; font-size: .9rem; }
.fieldnotes p { margin: 4px 0; }

/* Photo credits */
.photo { position: relative; }
.photo-credit { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 8px; font-size: .66rem; color: #fff;
    background: linear-gradient(transparent, rgba(0,0,0,.65)); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.credits input { width: 100%; margin: 6px 0 10px; }
.credits-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; }
.credits-row { display: flex; gap: 8px; align-items: center; font-size: .78rem; }
.credits-row img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; flex: none; }
.credits-row a { color: inherit; }
.linkish { background: none; border: none; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }

/* ---------- phone layouts (last, so they override the rules above) ---------- */
/* Phone held upright: the map fills the screen and the panel is a sheet over its bottom edge.
   Peek shows the turn and the next action; half adds the gauges and players; full adds everything. */
@media (max-width: 820px) and (orientation: portrait), (max-width: 820px) and (min-height: 521px) {
    .game { position: relative; height: 100%; height: 100dvh; }
    .map-wrap { position: absolute; inset: 0; }
    .map-tools { top: calc(10px + env(safe-area-inset-top, 0px)); }
    .attribution { top: env(safe-area-inset-top, 0px); bottom: auto; border-radius: 0 0 0 6px; font-size: 10px; }
    .panel { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; width: auto; max-height: 80%; border: 0;
        border-radius: 18px 18px 0 0; box-shadow: 0 -4px 18px rgba(43, 36, 24, .22); overscroll-behavior: contain;
        padding-bottom: env(safe-area-inset-bottom, 0px); }
    .panel.sheet-half { min-height: 55%; max-height: 88%; }
    .panel.sheet-full { height: calc(100% - 44px - env(safe-area-inset-top, 0px)); max-height: none; }

    .sheet-grab { display: flex; justify-content: center; align-items: center; height: 26px; flex: none; position: sticky; top: 0;
        z-index: 1; background: var(--sand); cursor: grab; touch-action: none; order: 0; }
    .sheet-grab span { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
    .sheet-mini { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: .85rem; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
    .sheet-mini b { color: var(--ink); font-weight: 600; }
    .sheet-mini .warn b { color: var(--red); }

    /* Turn first, then the action, then the rest. */
    .status { order: 1; border-top: 0; padding-top: 0; touch-action: none; }   /* drags the sheet, see ktSheet */
    .action { order: 2; min-height: 0; }
    .players { order: 3; flex-direction: row; overflow-x: auto; }
    .players .pchip { flex: none; background: var(--card); border: 1px solid var(--line); }
    .topbar { order: 4; border-top: 1px solid var(--line); border-bottom: 0; }
    .tabs { order: 5; }
    .tabbody { order: 6; }

    .action .long { display: none; }
    .panel.sheet-peek .players, .panel.sheet-peek .topbar, .panel.sheet-peek .tabs, .panel.sheet-peek .tabbody,
    .panel.sheet-peek .meter, .panel.sheet-peek .dest, .panel.sheet-peek .where,
    .panel.sheet-half .topbar, .panel.sheet-half .tabs, .panel.sheet-half .tabbody { display: none; }
    .panel:not(.sheet-peek) .sheet-mini { display: none; }
}

/* Phone turned sideways: map on the left, a slim panel on the right with the action pinned to its foot. */
@media (orientation: landscape) and (max-height: 520px) {
    .game { height: 100%; height: 100dvh; }
    .panel { width: min(46vw, 380px); padding-right: env(safe-area-inset-right, 0px); }
    .map-tools { left: calc(10px + env(safe-area-inset-left, 0px)); }
    .legend { display: none !important; }
    .topbar { padding: 6px 12px; font-size: .82rem; }
    .players { flex-direction: row; overflow-x: auto; padding: 6px 8px; }
    .players .pchip { flex: none; }
    .status { padding: 6px 12px; }
    .meter { margin: 4px 0; }
    .action { order: 10; position: sticky; bottom: 0; z-index: 1; background: var(--sand); min-height: 0; max-height: 75%;
        overflow-y: auto; box-shadow: 0 -3px 10px rgba(43, 36, 24, .12); padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
    .action .long { display: none; }
}

/* ---------- free version and Safari Pass (2026-11-08) ---------- */
.pass-banner { display: flex; align-items: center; gap: 10px; text-align: left; width: 100%; border: 1.5px solid var(--ochre); background: #fbf3e0;
    border-radius: 14px; padding: 10px 12px; color: inherit; font: inherit; cursor: pointer; }
.pass-banner > .ic { width: 30px; height: 30px; flex: none; color: var(--ochre); }
.pass-banner span { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.pass-banner small { color: var(--muted); font-size: .8rem; line-height: 1.3; }
.pass-banner .pass-price { flex: none; font-weight: 700; color: var(--bush-dark); background: #fff; border-radius: 999px; padding: 4px 10px; }
.pass-have { margin: 0; color: var(--bush-dark); font-size: .85rem; font-weight: 600; display: flex; align-items: center; gap: 6px; justify-content: center; }
.pass-have .ic { width: 16px; height: 16px; }
.pass-why { display: flex; gap: 8px; align-items: flex-start; background: #fbf3e0; border-radius: 10px; padding: 8px 10px; }
.pass-why .ic { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--ochre); }
.pass-owned { display: flex; gap: 8px; align-items: flex-start; }
.pass-owned .ic { flex: none; width: 24px; height: 24px; color: var(--bush); }
.pass-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pass-list li { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 8px 34px; position: relative; }
.pass-list li::before { content: "✓"; position: absolute; left: 12px; top: 8px; color: var(--bush); font-weight: 700; }
.pass-list small { color: var(--muted); font-size: .8rem; line-height: 1.3; }
.pass-msg { font-weight: 600; color: var(--bush-dark); }
.locked { opacity: .7; }
.vtile { position: relative; }
.vtile .vlock { position: absolute; top: 6px; right: 6px; width: 14px; height: 14px; color: var(--ochre); }
.map-locked { fill: rgba(60,50,35,.28); pointer-events: none; }
.map-locked-edge { stroke: var(--ochre); stroke-width: 3; stroke-dasharray: 14 10; pointer-events: none; }
.map-locked-label { font-size: 34px; font-weight: 700; fill: #5a4a2e; text-anchor: middle; paint-order: stroke; stroke: #f4ecdc; stroke-width: 6px; pointer-events: none; }

/* About / Legal disclaimer (top of the Credits screen) */
.legal { margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.legal h3 { margin-top: 0; }
.legal p { font-size: .85rem; line-height: 1.45; margin: 0 0 8px; }
.legal a { color: inherit; }
