:root {
    --wood: #241a13;
    --wood-2: #33261c;
    --wood-3: #4a3727;
    --parch: #f2e6c8;
    --parch-2: #e7d6ae;
    --parch-3: #d8c393;
    --ink: #2b2118;
    --ink-soft: #6a5641;
    --gold: #d7a53a;
    --gold-deep: #a87a1c;
    --red: #a33a2c;
    --red-soft: #f2d0c6;
    --blue: #2d5d86;
    --green: #3f7a3a;
    --green-soft: #d5e8c8;
    --radius: 10px;
    --shadow: 0 6px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: radial-gradient(circle at 50% 0%, var(--wood-3), var(--wood) 70%) fixed;
    background-color: var(--wood);
    color: var(--parch);
    font-family: Inter, system-ui, sans-serif;
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .serif { font-family: Cinzel, Georgia, serif; letter-spacing: .02em; }

button {
    font: inherit;
    cursor: pointer;
    border: 1px solid var(--gold-deep);
    background: linear-gradient(#e9c46a, #c9952c);
    color: #2b1c08;
    font-weight: 600;
    border-radius: 7px;
    padding: 7px 12px;
    box-shadow: 0 2px 0 #7a5512;
    transition: transform .05s, filter .1s;
}
button:hover:not(:disabled) { filter: brightness(1.07); }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 #7a5512; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: transparent; color: inherit; border-color: currentColor; box-shadow: none; opacity: .85; }
button.danger { background: linear-gradient(#d0634f, #a33a2c); color: #fff; border-color: #7a2418; box-shadow: 0 2px 0 #5d1a10; }
button.small { padding: 4px 8px; font-size: 13px; }
button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------------------------------------------------------- title & create */

.title-scene { position: fixed; left: 0; right: 0; bottom: 0; height: 36vh; min-height: 200px; z-index: 0; pointer-events: none; }

.title-scene::before { content: ""; position: absolute; inset: -60vh 0 100% 0; background: linear-gradient(#070b1c, #0f1630); }
body:has(.title-scene) { background: #0f1630; }
.title-screen {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
}
.title-card {
    width: min(560px, 100%);
    text-align: center;
    margin-bottom: 30vh;
}
.title-card .home { color: var(--parch-3); font-size: 13px; text-decoration: none; opacity: .8; }
.title-top { display: flex; justify-content: center; align-items: center; gap: 12px; color: var(--parch-3); }
.logo {
    font-family: Cinzel, serif;
    font-weight: 800;
    font-size: clamp(48px, 12vw, 88px);
    margin: 18px 0 0;
    color: var(--gold);
    text-shadow: 0 3px 0 #6b4a10, 0 8px 30px rgba(215, 165, 58, .25);
    letter-spacing: .08em;
}
.tagline { color: var(--parch-2); margin: 6px 0 26px; font-size: 16px; }
.title-buttons { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.title-buttons button { min-width: 220px; padding: 11px 18px; font-size: 16px; }
.howto {
    margin-top: 28px;
    text-align: left;
    background: rgba(0, 0, 0, .22);
    border: 1px solid rgba(215, 165, 58, .25);
    border-radius: var(--radius);
    padding: 14px 18px;
    font-size: 14px;
    color: var(--parch-2);
    line-height: 1.55;
}
.howto h3 { margin: 0 0 6px; color: var(--gold); font-size: 15px; }
.howto ul { margin: 0; padding-left: 18px; }

.parchment {
    background: var(--parch);
    color: var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow), inset 0 0 40px rgba(140, 100, 40, .18);
    border: 1px solid var(--parch-3);
}

.create { width: min(560px, 100%); padding: 22px; text-align: left; }
.create h2 { margin: 0 0 4px; }
.create .muted { color: var(--ink-soft); margin: 0 0 16px; font-size: 14px; }
.create label.name { display: block; font-weight: 600; margin-bottom: 14px; }
.create input[type=text] {
    display: block; width: 100%; margin-top: 6px; font: inherit; padding: 9px 11px;
    border: 1px solid var(--parch-3); border-radius: 7px; background: #fffaf0; color: var(--ink);
}
.skill-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--parch-3);
}
.skill-row .desc { grid-column: 1; font-size: 13px; color: var(--ink-soft); }
.skill-row .name { font-weight: 700; }
.stepper { grid-row: 1 / span 2; grid-column: 2; display: flex; align-items: center; gap: 8px; }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 14px; height: 14px; border: 1.5px solid var(--ink); border-radius: 2px; background: #fffaf0; }
.pips i.on { background: #a33a2c; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2); }
.create-head { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: start; }
.creator-figure { display: grid; justify-items: center; gap: 4px; }
@media (max-width: 460px) { .create-head { grid-template-columns: 1fr; } .creator-figure { grid-row: 1; } }
.creator-figure .portrait { width: 84px; height: 90px; border-radius: 10px; }
.stepper button { width: 34px; height: 34px; padding: 0; }
.points-left { font-weight: 700; margin: 6px 0 14px; }
.create-actions { display: flex; justify-content: space-between; gap: 10px; }

/* ---------------------------------------------------------- game layout */

.game { max-width: 1280px; margin: 0 auto; padding: 10px 12px 24px; }

.topbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 16px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, .28);
    border: 1px solid rgba(215, 165, 58, .25);
    border-radius: var(--radius);
    margin-bottom: 10px;
}
.topbar .brand { font-family: Cinzel, serif; font-weight: 800; color: var(--gold); font-size: 18px; letter-spacing: .08em; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; }
.stat b { color: #fff; }
.xpbar { width: 70px; height: 6px; background: rgba(255, 255, 255, .15); border-radius: 3px; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: var(--gold); }
.topbar .spacer { flex: 1; }
.topbar .points { background: var(--gold); color: #2b1c08; border-radius: 999px; padding: 2px 9px; font-weight: 700; font-size: 13px; }

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    grid-template-areas: "map panel" "log panel";
    grid-template-rows: auto 1fr;
    gap: 12px;
    align-items: start;
}
.mapwrap { position: relative; grid-area: map; min-width: 0; }
.panel { grid-area: panel; }
.logbox { grid-area: log; }
.mapscroll { border-radius: var(--radius); box-shadow: var(--shadow); }
.mapbox {
    container-type: size;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    background: #a9c7c6;
    aspect-ratio: 1080 / 728;
}
.map-img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.mapbox .map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: manipulation;
    user-select: none;
}
/* Cloud shadows drift over the map on their own composited layer. */
.map-clouds {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    pointer-events: none;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 700'%3E%3Cdefs%3E%3Cfilter id='b'%3E%3CfeGaussianBlur stdDeviation='14'/%3E%3C/filter%3E%3C/defs%3E%3Cg filter='url(%23b)' fill='%23fff' opacity='.5'%3E%3Cellipse cx='180' cy='150' rx='90' ry='22'/%3E%3Cellipse cx='230' cy='138' rx='50' ry='18'/%3E%3Cellipse cx='640' cy='480' rx='100' ry='24'/%3E%3Cellipse cx='590' cy='470' rx='55' ry='18'/%3E%3Cellipse cx='860' cy='250' rx='70' ry='16'/%3E%3C/g%3E%3Cg filter='url(%23b)' fill='%233a2410' opacity='.10'%3E%3Cellipse cx='190' cy='190' rx='90' ry='20'/%3E%3Cellipse cx='650' cy='520' rx='100' ry='22'/%3E%3C/g%3E%3C/svg%3E") repeat-x;
    background-size: 50% 100%;
    animation: clouds 150s linear infinite;
    will-change: transform;
}
@keyframes clouds { to { transform: translateX(-50%); } }
.map .city { cursor: pointer; outline: none; }
.map .city .label {
    font-family: Cinzel, serif;
    font-weight: 800;
    font-size: 13.5px;
    fill: #3a2a1b;
    paint-order: stroke;
    stroke: rgba(241, 228, 195, .92);
    stroke-width: 4px;
    stroke-linejoin: round;
    pointer-events: none;
}
.map .region {
    font-family: Cinzel, serif;
    font-style: italic;
    font-weight: 600;
    letter-spacing: .25em;
    fill: rgba(74, 56, 38, .42);
    text-transform: uppercase;
    pointer-events: none;
}
.map .city .ring { fill: none; stroke: transparent; stroke-width: 2.5; }
.map .city .glow { opacity: 0; transition: opacity .3s; pointer-events: none; }
.map .city.here .glow { opacity: 1; }
.map .city.here .ring { stroke: #a87a1c; }
.map .city.dest .ring { stroke: var(--blue); stroke-width: 3; }
.map .city.target .ring { stroke: #a87a1c; stroke-dasharray: 4 3; }
.map .city:hover .ring { stroke: rgba(74, 56, 38, .6); }
.map .city:focus-visible .ring { stroke: var(--ink); stroke-dasharray: 2 2; }
@keyframes pulse { 50% { opacity: .45; } }
.map .road { fill: none; stroke: none; stroke-linecap: round; }
.map .road.route { stroke: #2d5d86; stroke-width: 3.4; stroke-dasharray: 9 5; }


.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 12px;
    color: var(--parch-2);
    margin: 8px 2px 0;
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--ink); display: inline-block; }

.panel { padding: 0; overflow: hidden; }
.panel-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--parch-3); }
.panel-head h2 { margin: 0; font-size: 22px; }
.panel-head .sub { font-size: 13px; color: var(--ink-soft); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid; }
.badge.free { color: var(--green); border-color: var(--green); }
.badge.buccaneers { color: var(--red); border-color: var(--red); }
.badge.player { color: var(--gold-deep); border-color: var(--gold-deep); }
.badge.hq { color: var(--blue); border-color: var(--blue); }

.tabs { display: flex; border-bottom: 1px solid var(--parch-3); background: var(--parch-2); overflow-x: auto; }
.tabs button {
    flex: 1;
    background: none;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    color: var(--ink-soft);
    padding: 10px 6px;
    font-size: 13px;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
}
.tabs button.on { color: var(--ink); border-bottom-color: var(--gold-deep); background: var(--parch); }
.tab-body { padding: 12px 14px 16px; max-height: 620px; overflow-y: auto; }

.route {
    margin: 12px 14px 0;
    padding: 10px 12px;
    background: #fffaf0;
    border: 1px solid var(--parch-3);
    border-left: 4px solid var(--blue);
    border-radius: 8px;
    font-size: 14px;
}
.route .row { display: flex; gap: 8px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.route .facts { color: var(--ink-soft); font-size: 13px; margin: 4px 0 8px; }
.route .actions { display: flex; gap: 8px; }
.risk-low { color: var(--green); font-weight: 600; }
.risk-med { color: var(--gold-deep); font-weight: 600; }
.risk-high { color: var(--red); font-weight: 600; }

.hint { font-size: 13px; color: var(--ink-soft); margin: 0 0 10px; }

/* market */
.market { width: 100%; border-collapse: collapse; font-size: 14px; }
.market th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); padding: 0 4px 6px; font-weight: 600; }
.market td { padding: 7px 4px; border-top: 1px solid var(--parch-3); vertical-align: middle; }
.market .good { white-space: nowrap; font-weight: 600; }
.market .held { color: var(--ink-soft); font-size: 12px; font-weight: 400; display: block; }
.market .num { text-align: right; font-variant-numeric: tabular-nums; }
.market .cheap { color: var(--green); }
.market .dear { color: var(--red); }
.market .btns { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.market .btns button { padding: 3px 7px; font-size: 12px; min-width: 34px; }
.market .tip { display: block; font-size: 11px; color: var(--ink-soft); font-weight: 400; }
.cargo-line { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }
.qty-pick { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; font-size: 13px; color: var(--ink-soft); }
.qty-pick button { padding: 3px 9px; font-size: 12px; background: #fffaf0; color: var(--ink); border-color: var(--parch-3); box-shadow: none; }
.qty-pick button.on { background: var(--gold); border-color: var(--gold-deep); }

/* shop cards */
.cards { display: grid; gap: 8px; }
.card {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: #fffaf0;
    border: 1px solid var(--parch-3);
    border-radius: 8px;
}
.card .icon { font-size: 24px; width: 32px; text-align: center; }
.card .body { flex: 1; min-width: 0; }
.card .body b { display: block; }
.card .body small { color: var(--ink-soft); display: block; font-size: 12.5px; line-height: 1.4; }
.card.done { opacity: .7; }
.section-title { font-family: Cinzel, serif; font-size: 14px; margin: 14px 0 8px; color: var(--ink); }
.section-title:first-child { margin-top: 0; }

/* party */
.party { display: grid; gap: 6px; }
.unit {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 2px 8px;
    align-items: center;
    padding: 6px 8px;
    background: #fffaf0;
    border: 1px solid var(--parch-3);
    border-radius: 8px;
    font-size: 13px;
}
.unit .icon { font-size: 20px; grid-row: 1 / span 2; text-align: center; }
.unit .stats { color: var(--ink-soft); font-size: 12px; }
.hpbar { grid-column: 2 / span 2; height: 6px; background: #e3d2ab; border-radius: 3px; overflow: hidden; }
.hpbar i { display: block; height: 100%; background: var(--green); transition: width .25s; }
.hpbar i.low { background: var(--red); }
.unit.dead { opacity: .4; }

.log { margin-top: 12px; }
.log p { margin: 0 0 4px; font-size: 13px; color: var(--parch-2); }
.log p span { color: var(--gold); margin-right: 6px; font-variant-numeric: tabular-nums; }
.logbox {
    background: rgba(0, 0, 0, .25);
    border: 1px solid rgba(215, 165, 58, .2);
    border-radius: var(--radius);
    padding: 10px 12px;
    max-height: 170px;
    overflow-y: auto;
}
.logbox h3 { margin: 0 0 6px; font-size: 13px; color: var(--gold); }

.travel-box { padding: 16px; text-align: center; }
.travel-box .big { font-family: Cinzel, serif; font-size: 20px; margin: 0 0 4px; }
.progress { height: 10px; background: var(--parch-3); border-radius: 5px; overflow: hidden; margin: 10px 0; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), #4f8bbd); transition: width .35s linear; }

/* ---------------------------------------------------------- stage */

.stage {
    position: relative;
    height: 250px;
    margin-bottom: 12px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow), inset 0 0 0 1px rgba(215, 165, 58, .35);
    background: #8fc6e8;
}
.stage-art { position: absolute; inset: 0; }
.stage-caption {
    position: absolute;
    left: 12px;
    top: 10px;
    padding: 6px 12px 7px;
    background: rgba(36, 26, 19, .78);
    border: 1px solid rgba(215, 165, 58, .5);
    border-radius: 8px;
    color: var(--parch);
    font-size: 13px;
    line-height: 1.3;
    backdrop-filter: blur(2px);
    max-width: calc(100% - 24px);
}
.stage-caption b { display: block; font-family: Cinzel, serif; font-size: 16px; color: var(--gold); }


/* Every walk cycle, wheel and flag ticks on one shared 140 ms clock, like a
   sprite animation: the caravan layer repaints ~7 times a second, not 60. */
.walking .leg.front { animation: swing .56s steps(4, jump-none) infinite alternate; animation-delay: var(--delay, 0s); }
.walking .leg.back { animation: swing .56s steps(4, jump-none) infinite alternate-reverse; animation-delay: var(--delay, 0s); }
.walking .arm.back { animation: swing-arm .56s steps(4, jump-none) infinite alternate; animation-delay: var(--delay, 0s); }
.horse.walking .leg.front, .horse.walking .leg.back { animation-duration: .56s; }
@keyframes swing { from { transform: rotate(-24deg); } to { transform: rotate(24deg); } }
@keyframes swing-arm { from { transform: rotate(18deg); } to { transform: rotate(-18deg); } }
.rolling .wheel { animation: spin 1.12s steps(8) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stage .banner, .title-scene .banner { animation: wave 1.12s steps(8, jump-none) infinite alternate; transform-box: fill-box; transform-origin: left center; }
@keyframes wave { to { transform: skewY(6deg) scaleX(.92); } }
.stage .sails { animation: spin 6.72s steps(48) infinite; }
.stage .sail, .title-scene .sail { animation: wave 2.24s steps(16, jump-none) infinite alternate; transform-box: fill-box; transform-origin: left center; }

.battle-stage {
    position: relative;
    height: 210px;
    margin: 0 -20px 12px;
    overflow: hidden;
    border-top: 1px solid var(--parch-3);
    border-bottom: 1px solid var(--parch-3);
}
.battle-stage svg { width: 100%; height: 100%; display: block; }
@keyframes lunge-r { 40% { transform: translateX(26px); } }
@keyframes lunge-l { 40% { transform: translateX(-26px); } }
.unit-fig.down { animation: none; }
.unit-fig.down .topple { transform: rotate(-84deg) translateY(6px); opacity: .55; filter: grayscale(.8); }
.unit-fig[data-side=foe].down .topple { transform: rotate(84deg) translateY(6px); }
.unit-fig.dying .topple { animation: topple .55s ease-in .3s both; }
.unit-fig[data-side=foe].dying .topple { animation-name: topple-r; }
@keyframes topple { from { transform: none; opacity: 1; filter: none; } }
@keyframes topple-r { from { transform: none; opacity: 1; filter: none; } }
.unit-fig .slash { fill: none; stroke: #fff; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; opacity: 0; animation: slash .42s ease-out .3s both; filter: drop-shadow(0 0 3px rgba(255, 255, 255, .9)); }
.unit-fig .slash.foe-hit { stroke: #fff6c8; }
@keyframes slash { 10% { opacity: 1; } 60% { stroke-dashoffset: 0; opacity: 1; } to { stroke-dashoffset: 0; opacity: 0; } }
.battle-svg .arrow { animation: arrow .32s ease-in .05s both; }
@keyframes arrow { from { transform: none; opacity: 1; } 95% { opacity: 1; } to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }
.unit-fig.hit .fig { animation: flash .45s ease-out .35s; }
@keyframes flash { 30% { filter: brightness(2.4) saturate(.4); } }
.unit-fig .dmg {
    font-family: Cinzel, serif;
    font-weight: 800;
    font-size: 26px;
    fill: #c0392b;
    stroke: #fff;
    stroke-width: 3px;
    paint-order: stroke;
    text-anchor: middle;
    animation: float-up 1.1s ease-out .35s both;
}
@keyframes float-up { from { opacity: 0; transform: translateY(10px); } 20% { opacity: 1; } to { opacity: 0; transform: translateY(-28px); } }

.portrait { width: 34px; height: 36px; display: block; border-radius: 6px; border: 1px solid var(--parch-3); }
.unit { grid-template-columns: 38px 1fr auto; }
.unit .icon { font-size: 0; }
.card .icon .portrait { width: 40px; height: 44px; }

/* ---------------------------------------------------------- modals */

.modal-back {
    position: fixed;
    inset: 0;
    background: rgba(15, 10, 6, .72);
    display: grid;
    place-items: center;
    padding: 16px;
    z-index: 20;
    animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 20px; }
.modal.wide { width: min(780px, 100%); }
.modal h2 { margin: 0 0 8px; }
.modal p { line-height: 1.55; margin: 0 0 12px; }
.modal .choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.modal .loot { background: #fffaf0; border: 1px solid var(--parch-3); border-radius: 8px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }

.battle { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.battle h3 { margin: 0 0 6px; font-size: 14px; }
.battle-log {
    margin-top: 12px;
    background: #fffaf0;
    border: 1px solid var(--parch-3);
    border-radius: 8px;
    padding: 8px 10px;
    height: 130px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.45;
}
.battle-log div { color: var(--ink-soft); }
.battle-log div.latest { color: var(--ink); }
.battle-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.battle-actions .note { font-size: 12.5px; color: var(--ink-soft); margin-left: auto; }

.victory h2 { color: var(--gold-deep); font-size: 28px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.ach { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--parch-3); background: #fffaf0; font-size: 13px; }
.ach b { display: block; }
.ach.locked { opacity: .45; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 30; max-width: calc(100vw - 32px); }
.toast {
    background: var(--parch);
    color: var(--ink);
    border-left: 4px solid var(--gold-deep);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: var(--shadow);
    font-size: 14px;
    animation: slide .25s ease-out;
}
.toast b { display: block; }
.toast.bad { border-left-color: var(--red); }
@keyframes slide { from { transform: translateY(12px); opacity: 0; } }

@media (max-width: 960px) {
    .stage { height: 190px; }
    .layout { grid-template-columns: 1fr; grid-template-areas: "map" "panel" "log"; grid-template-rows: auto; }
    .tab-body { max-height: none; }
}

@media (max-width: 700px) {
    .mapscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .mapscroll .mapbox { width: 760px; max-width: none; }
}

@media (max-width: 560px) {
    .stage { height: 124px; }
    .st-town { width: calc(var(--tile) * .4); }
    .stage-caption { top: 6px; left: auto; right: 8px; padding: 3px 8px; }
    .stage-caption span { display: none; }
    .battle-stage { height: 150px; margin: 0 -16px 10px; }
    .stage-caption { font-size: 12px; padding: 5px 9px; }
    .stage-caption b { font-size: 14px; }
    body { font-size: 14px; }
    .game { padding: 8px 8px 20px; }
    .topbar { gap: 4px 12px; padding: 8px 10px; }
    .topbar .brand { display: none; }
    .battle { grid-template-columns: 1fr; }
    .market .hide-sm { display: none; }
    .modal { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

.ico { display: inline-block; vertical-align: -3px; flex: none; }
.card .icon .ico { display: block; margin: 0 auto; }
button .ico { vertical-align: -3px; }
.topbar .ico { filter: drop-shadow(0 0 .8px #f2e6c8) drop-shadow(0 0 .8px #f2e6c8); width: 20px; height: 20px; vertical-align: -5px; }

/* ---------------------------------------------------------- stage layers */

.stage { container-type: size; --tile: 454.545cqh; isolation: isolate; }
.stage-art { overflow: hidden; }
.stage-art > * { position: absolute; pointer-events: none; }
.st-sky, .st-tint, .st-stars { inset: 0; }
.st-sky { transition: opacity 1.4s ease; }
.st-sky.dawn { background: linear-gradient(#f2a77f, #fde2bb); opacity: 0; }
.st-sky.dusk { background: linear-gradient(#5c4778, #f2a46a); opacity: 0; }
.st-sky.night { background: linear-gradient(#0d1430, #2e3a64); opacity: 0; }
.time-dawn .st-sky.dawn, .time-dusk .st-sky.dusk, .time-night .st-sky.night { opacity: 1; }
.st-stars { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 160' width='400' height='160'%3E%3Ccircle cx='205' cy='10' r='1.4' fill='white' opacity='0.87'/%3E%3Ccircle cx='389' cy='17' r='0.7' fill='white' opacity='0.42'/%3E%3Ccircle cx='312' cy='43' r='0.6' fill='white' opacity='0.65'/%3E%3Ccircle cx='365' cy='131' r='0.7' fill='white' opacity='0.49'/%3E%3Ccircle cx='368' cy='91' r='1.1' fill='white' opacity='0.45'/%3E%3Ccircle cx='23' cy='110' r='0.9' fill='white' opacity='0.44'/%3E%3Ccircle cx='375' cy='102' r='1.2' fill='white' opacity='0.45'/%3E%3Ccircle cx='342' cy='11' r='1.3' fill='white' opacity='0.67'/%3E%3Ccircle cx='136' cy='88' r='1.3' fill='white' opacity='0.56'/%3E%3Ccircle cx='52' cy='84' r='0.7' fill='white' opacity='0.47'/%3E%3Ccircle cx='65' cy='8' r='0.7' fill='white' opacity='0.59'/%3E%3Ccircle cx='122' cy='122' r='0.8' fill='white' opacity='0.70'/%3E%3Ccircle cx='71' cy='56' r='0.5' fill='white' opacity='0.55'/%3E%3Ccircle cx='6' cy='117' r='1.0' fill='white' opacity='0.51'/%3E%3Ccircle cx='190' cy='150' r='0.6' fill='white' opacity='0.89'/%3E%3Ccircle cx='173' cy='79' r='1.3' fill='white' opacity='0.64'/%3E%3Ccircle cx='203' cy='110' r='1.4' fill='white' opacity='0.61'/%3E%3Ccircle cx='333' cy='113' r='1.1' fill='white' opacity='0.64'/%3E%3Ccircle cx='139' cy='9' r='0.6' fill='white' opacity='0.44'/%3E%3Ccircle cx='296' cy='41' r='0.6' fill='white' opacity='0.45'/%3E%3Ccircle cx='337' cy='139' r='1.1' fill='white' opacity='0.57'/%3E%3Ccircle cx='97' cy='47' r='0.9' fill='white' opacity='0.49'/%3E%3Ccircle cx='178' cy='42' r='1.4' fill='white' opacity='0.98'/%3E%3Ccircle cx='219' cy='39' r='1.4' fill='white' opacity='0.59'/%3E%3Ccircle cx='143' cy='0' r='0.8' fill='white' opacity='0.68'/%3E%3Ccircle cx='201' cy='32' r='1.0' fill='white' opacity='0.40'/%3E%3Ccircle cx='106' cy='14' r='0.9' fill='white' opacity='0.43'/%3E%3Ccircle cx='9' cy='49' r='0.7' fill='white' opacity='0.75'/%3E%3Ccircle cx='212' cy='120' r='1.1' fill='white' opacity='0.83'/%3E%3Ccircle cx='352' cy='62' r='0.8' fill='white' opacity='0.99'/%3E%3Ccircle cx='60' cy='116' r='1.1' fill='white' opacity='0.43'/%3E%3Ccircle cx='334' cy='143' r='1.1' fill='white' opacity='0.84'/%3E%3Ccircle cx='325' cy='22' r='1.0' fill='white' opacity='0.70'/%3E%3Ccircle cx='334' cy='129' r='1.2' fill='white' opacity='0.75'/%3E%3Ccircle cx='357' cy='109' r='1.1' fill='white' opacity='0.54'/%3E%3Ccircle cx='12' cy='21' r='0.8' fill='white' opacity='0.46'/%3E%3Ccircle cx='334' cy='89' r='1.1' fill='white' opacity='0.78'/%3E%3Ccircle cx='272' cy='78' r='0.5' fill='white' opacity='0.88'/%3E%3Ccircle cx='299' cy='80' r='1.0' fill='white' opacity='0.80'/%3E%3Ccircle cx='26' cy='118' r='0.7' fill='white' opacity='0.44'/%3E%3Ccircle cx='106' cy='117' r='0.7' fill='white' opacity='0.84'/%3E%3Ccircle cx='390' cy='79' r='0.8' fill='white' opacity='0.69'/%3E%3Ccircle cx='273' cy='123' r='1.1' fill='white' opacity='0.79'/%3E%3Ccircle cx='31' cy='24' r='0.7' fill='white' opacity='0.85'/%3E%3Ccircle cx='122' cy='91' r='0.5' fill='white' opacity='0.44'/%3E%3Ccircle cx='108' cy='108' r='1.1' fill='white' opacity='0.81'/%3E%3Ccircle cx='116' cy='83' r='0.9' fill='white' opacity='0.68'/%3E%3Ccircle cx='47' cy='143' r='0.7' fill='white' opacity='0.99'/%3E%3Ccircle cx='375' cy='3' r='0.9' fill='white' opacity='0.89'/%3E%3Ccircle cx='387' cy='72' r='0.7' fill='white' opacity='0.53'/%3E%3Ccircle cx='378' cy='34' r='1.0' fill='white' opacity='0.49'/%3E%3Ccircle cx='210' cy='152' r='0.6' fill='white' opacity='0.89'/%3E%3Ccircle cx='203' cy='142' r='1.1' fill='white' opacity='0.54'/%3E%3Ccircle cx='359' cy='78' r='0.5' fill='white' opacity='0.40'/%3E%3Ccircle cx='197' cy='72' r='0.8' fill='white' opacity='0.48'/%3E%3Ccircle cx='138' cy='51' r='1.3' fill='white' opacity='0.40'/%3E%3Ccircle cx='300' cy='134' r='0.6' fill='white' opacity='0.96'/%3E%3Ccircle cx='285' cy='144' r='0.8' fill='white' opacity='0.62'/%3E%3Ccircle cx='157' cy='160' r='1.0' fill='white' opacity='0.62'/%3E%3Ccircle cx='171' cy='44' r='0.5' fill='white' opacity='0.46'/%3E%3C/svg%3E") repeat; background-size: 400px 160px; opacity: 0; transition: opacity 1.4s; height: 70%; }
.time-night .st-stars { opacity: 1; }
.time-dusk .st-stars { opacity: .35; }
.st-sun, .st-moon { width: 13cqh; height: 13cqh; border-radius: 50%; top: 8cqh; right: 12%; transition: transform 1.4s ease, opacity 1.4s; }
.st-sun { background: radial-gradient(circle, #fff8d8 55%, rgba(255, 246, 200, 0) 72%); box-shadow: 0 0 40px 10px rgba(255, 236, 160, .35); }
.st-sun.red { background: radial-gradient(circle, #f6a05a 55%, rgba(240, 138, 74, 0) 72%); }
.st-moon { background: radial-gradient(circle at 38% 40%, #f4efd8 50%, #d8d2b8 64%, rgba(0, 0, 0, 0) 66%); opacity: 0; transform: translateY(30cqh); }
.time-dawn .st-sun { transform: translate(-60cqw, 34cqh); }
.time-dusk .st-sun { transform: translate(8cqw, 36cqh); background: radial-gradient(circle, #ffb070 55%, rgba(255, 150, 90, 0) 72%); }
.time-night .st-sun { transform: translateY(70cqh); opacity: 0; }
.time-night .st-moon { opacity: 1; transform: none; }
.st-layer {
    top: 0; left: 0; height: 100%;
    width: calc(100% + var(--tile));
    background-repeat: repeat-x;
    background-size: var(--tile) 100%;
    will-change: transform;
}
.scrolling .st-layer { animation: st-scroll var(--dur) linear infinite; }
@keyframes st-scroll { to { transform: translateX(calc(-1 * var(--tile))); } }
.st-layer.clouds { opacity: .9; }
.time-night .st-layer.clouds { opacity: .25; }
.st-party, .st-town, .st-others { bottom: 0; height: 100%; }
.st-party { left: 0; width: calc(var(--tile) * .76); will-change: transform; }
.st-town { right: 0; width: calc(var(--tile) * .52); }
.st-others { right: 0; width: calc(var(--tile) * .36); }
.st-party svg, .st-town svg, .st-others svg { width: 100%; height: 100%; display: block; overflow: visible; }
.st-party .lantern { opacity: 0; transition: opacity 1.4s; }
.time-night .st-party .lantern, .time-dusk .st-party .lantern { opacity: 1; }
.st-tint { background: #101a44; opacity: 0; transition: opacity 1.4s; mix-blend-mode: multiply; }
.time-night .st-tint { opacity: .5; }
.time-dusk .st-tint { opacity: .18; background: #6a3a5a; }
.time-dawn .st-tint { opacity: .12; background: #a0603a; }
.st-weather {
    top: -200px; left: -200px; width: calc(100% + 400px); height: calc(100% + 400px);
    background-size: 200px 200px; opacity: 0; transition: opacity 1s; will-change: transform;
}
.wx-snow .st-weather { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200' width='200' height='200'%3E%3Ccircle cx='65' cy='30' r='2.5' fill='white' opacity='0.63'/%3E%3Ccircle cx='107' cy='73' r='1.3' fill='white' opacity='0.78'/%3E%3Ccircle cx='7' cy='87' r='1.3' fill='white' opacity='0.63'/%3E%3Ccircle cx='85' cy='165' r='1.4' fill='white' opacity='0.68'/%3E%3Ccircle cx='125' cy='190' r='2.4' fill='white' opacity='0.74'/%3E%3Ccircle cx='195' cy='9' r='2.9' fill='white' opacity='0.70'/%3E%3Ccircle cx='29' cy='24' r='1.8' fill='white' opacity='0.89'/%3E%3Ccircle cx='36' cy='116' r='2.5' fill='white' opacity='0.73'/%3E%3Ccircle cx='110' cy='13' r='1.3' fill='white' opacity='0.67'/%3E%3Ccircle cx='136' cy='86' r='1.8' fill='white' opacity='0.80'/%3E%3Ccircle cx='91' cy='60' r='2.8' fill='white' opacity='0.84'/%3E%3Ccircle cx='49' cy='115' r='2.3' fill='white' opacity='0.91'/%3E%3Ccircle cx='146' cy='58' r='3.2' fill='white' opacity='0.64'/%3E%3Ccircle cx='84' cy='151' r='1.5' fill='white' opacity='0.77'/%3E%3Ccircle cx='8' cy='134' r='2.7' fill='white' opacity='0.80'/%3E%3Ccircle cx='175' cy='63' r='2.6' fill='white' opacity='0.81'/%3E%3Ccircle cx='116' cy='91' r='2.9' fill='white' opacity='0.93'/%3E%3Ccircle cx='95' cy='133' r='1.3' fill='white' opacity='0.85'/%3E%3Ccircle cx='129' cy='199' r='2.8' fill='white' opacity='0.70'/%3E%3Ccircle cx='77' cy='134' r='1.2' fill='white' opacity='0.76'/%3E%3Ccircle cx='34' cy='23' r='1.3' fill='white' opacity='0.87'/%3E%3Ccircle cx='26' cy='50' r='2.0' fill='white' opacity='0.90'/%3E%3Ccircle cx='16' cy='90' r='2.3' fill='white' opacity='0.91'/%3E%3Ccircle cx='164' cy='173' r='1.8' fill='white' opacity='0.75'/%3E%3Ccircle cx='72' cy='177' r='3.1' fill='white' opacity='0.65'/%3E%3Ccircle cx='35' cy='46' r='1.7' fill='white' opacity='0.77'/%3E%3C/svg%3E"); opacity: 1; animation: wx-snow 9s linear infinite; }
.wx-rain .st-weather { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200' width='200' height='200'%3E%3Cpath d='M118 53l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M1 84l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M74 113l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M191 138l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M103 124l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M135 11l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M180 156l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M175 160l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M78 80l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M21 127l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M12 13l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M42 32l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M68 11l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M0 30l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M20 73l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M5 175l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M123 30l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M50 69l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M73 25l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M170 199l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M93 97l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M17 20l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M69 53l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M166 32l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M5 190l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M106 29l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M109 5l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M106 196l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M173 139l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3Cpath d='M52 73l-6 16' stroke='#cfe2f0' stroke-width='1.4' opacity='.7'/%3E%3C/svg%3E"); opacity: 1; animation: wx-rain .7s linear infinite; }
.wx-sand .st-weather { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200' width='200' height='200'%3E%3Cpath d='M33 154h26' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M156 66h17' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M162 197h36' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M161 164h32' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M45 104h21' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M6 6h18' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M52 139h39' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M89 187h40' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M191 73h17' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M45 39h16' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M125 180h35' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M96 131h34' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M17 132h37' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M156 150h24' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M36 158h20' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M160 194h22' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M80 189h32' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M34 25h15' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M181 161h14' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M165 196h30' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M70 110h14' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3Cpath d='M3 194h29' stroke='#e9cf98' stroke-width='1.6' opacity='.55' stroke-linecap='round'/%3E%3C/svg%3E"); opacity: 1; animation: wx-sand 1.6s linear infinite; }
.wx-embers .st-weather { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200' width='200' height='200'%3E%3Ccircle cx='105' cy='187' r='1.6' fill='#ff9a3c'/%3E%3Ccircle cx='165' cy='42' r='1.4' fill='#ffcf5a'/%3E%3Ccircle cx='100' cy='153' r='1.5' fill='#e0602c'/%3E%3Ccircle cx='84' cy='26' r='2.3' fill='#ffcf5a'/%3E%3Ccircle cx='180' cy='132' r='2.1' fill='#e0602c'/%3E%3Ccircle cx='84' cy='184' r='1.7' fill='#e0602c'/%3E%3Ccircle cx='30' cy='102' r='2.2' fill='#ff9a3c'/%3E%3Ccircle cx='122' cy='155' r='1.2' fill='#ff9a3c'/%3E%3Ccircle cx='95' cy='145' r='1.8' fill='#ffcf5a'/%3E%3Ccircle cx='136' cy='106' r='1.7' fill='#ff9a3c'/%3E%3Ccircle cx='177' cy='11' r='1.3' fill='#ff9a3c'/%3E%3Ccircle cx='154' cy='102' r='1.8' fill='#ff9a3c'/%3E%3Ccircle cx='89' cy='123' r='1.7' fill='#e0602c'/%3E%3Ccircle cx='40' cy='55' r='1.7' fill='#ffcf5a'/%3E%3Ccircle cx='102' cy='50' r='1.7' fill='#ffcf5a'/%3E%3Ccircle cx='185' cy='179' r='1.3' fill='#ffcf5a'/%3E%3C/svg%3E"); opacity: 1; animation: wx-embers 7s linear infinite; }
.wx-leaves .st-weather { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200' width='200' height='200'%3E%3Cellipse cx='27' cy='24' rx='4' ry='2' fill='#c9852c' transform='rotate(80 27 24)'/%3E%3Cellipse cx='134' cy='86' rx='4' ry='2' fill='#d8a93a' transform='rotate(38 134 86)'/%3E%3Cellipse cx='157' cy='179' rx='4' ry='2' fill='#d8a93a' transform='rotate(28 157 179)'/%3E%3Cellipse cx='29' cy='177' rx='4' ry='2' fill='#a8582a' transform='rotate(174 29 177)'/%3E%3Cellipse cx='149' cy='19' rx='4' ry='2' fill='#a8582a' transform='rotate(159 149 19)'/%3E%3Cellipse cx='198' cy='166' rx='4' ry='2' fill='#7a9a3a' transform='rotate(29 198 166)'/%3E%3Cellipse cx='199' cy='81' rx='4' ry='2' fill='#d8a93a' transform='rotate(76 199 81)'/%3E%3Cellipse cx='64' cy='144' rx='4' ry='2' fill='#7a9a3a' transform='rotate(4 64 144)'/%3E%3Cellipse cx='88' cy='4' rx='4' ry='2' fill='#d8a93a' transform='rotate(60 88 4)'/%3E%3C/svg%3E"); opacity: 1; animation: wx-leaves 8s linear infinite; }
@keyframes wx-snow { to { transform: translate(-60px, 200px); } }
@keyframes wx-rain { to { transform: translate(-75px, 200px); } }
@keyframes wx-sand { to { transform: translate(-200px, 20px); } }
@keyframes wx-embers { to { transform: translate(40px, -200px); } }
@keyframes wx-leaves { to { transform: translate(-200px, 200px); } }
.title-scene .stage-art { position: absolute; inset: 0; }
.title-scene { container-type: size; --tile: 454.545cqh; }

/* The map wagon: an HTML layer, so its glide along the road is composited. */
.map-caravan {
    position: absolute;
    left: 0;
    top: 0;
    width: 3.7cqw;
    aspect-ratio: 70 / 46;
    pointer-events: none;
    transform: translate(calc(var(--x, .5) * 100cqw - 50%), calc(var(--y, .5) * 100cqh - 66%));
    transition: transform .52s linear;
    will-change: transform;
}
.map-caravan svg { width: 100%; height: 100%; display: block; overflow: visible; }
.map-caravan.east svg { transform: scaleX(-1); }

/* Town windows glow through the night tint: a second copy of the town with
   everything but the windows hidden, shown only after dark. */
.st-lights { opacity: 0; transition: opacity 1.4s; }
.st-lights svg * { visibility: hidden; }
.st-lights svg .win { visibility: visible; fill: #ffd86a; filter: drop-shadow(0 0 3px #ffb43a); }
.time-night .st-lights { opacity: 1; }
.time-dusk .st-lights { opacity: .7; }

/* Town life: strollers and chimney smoke, all composited transforms. */
.st-town .npc { position: absolute; height: 34%; aspect-ratio: 40 / 86; animation: npc-walk var(--dur) linear infinite; animation-delay: var(--delay); will-change: transform; }
.st-town .npc svg { width: 100%; height: 100%; display: block; overflow: visible; animation: npc-face var(--dur) steps(1) infinite; animation-delay: var(--delay); }
@keyframes npc-walk { 50% { transform: translateX(var(--range)); } }
@keyframes npc-face { 50% { transform: scaleX(-1); } }
.st-town .smoke {
    position: absolute; width: 5cqh; height: 5cqh; margin: -2.5cqh 0 0 -2.5cqh; border-radius: 50%;
    background: radial-gradient(circle, rgba(236, 232, 226, .8), rgba(236, 232, 226, 0) 70%);
    animation: puff 3.3s ease-out infinite; will-change: transform, opacity;
}
@keyframes puff { from { transform: translate(0, 0) scale(.6); opacity: .85; } to { transform: translate(3cqh, -16cqh) scale(2.4); opacity: 0; } }
.st-lights .npc, .st-lights .smoke { display: none; }

/* Tavern: local information card */
.local-info { display: grid; grid-template-columns: 150px 1fr; gap: 10px 12px; margin-bottom: 6px; }
.local-picture { border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; height: 104px; box-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.local-picture svg { width: 100%; height: 100%; display: block; }
.local-facts b { display: block; font-size: 15px; margin-bottom: 6px; }
.local-facts dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 13.5px; }
.local-facts dt { color: var(--ink-soft); }
.local-facts dd { margin: 0; font-weight: 600; }
.local-blurb { grid-column: 1 / -1; margin: 0; font-size: 13.5px; color: var(--ink-soft); }

/* ---------------------------------------------------------- panel chrome */

/* Wood-grain top bar with a brass edge. */
.topbar {
    background:
        repeating-linear-gradient(92deg, rgba(255, 255, 255, .025) 0 2px, rgba(0, 0, 0, .03) 2px 7px),
        linear-gradient(#4a3524, #2c2017);
    border: 1px solid #a8803a;
    box-shadow: inset 0 1px 0 rgba(255, 220, 150, .25), inset 0 -2px 0 rgba(0, 0, 0, .3), var(--shadow);
}
/* The parchment panel gets an inked double frame, like the map. */
.panel { position: relative; }
.panel::after {
    content: "";
    position: absolute;
    inset: 5px;
    border: 1px solid rgba(74, 56, 38, .45);
    outline: 1px solid rgba(74, 56, 38, .25);
    outline-offset: 3px;
    border-radius: 6px;
    pointer-events: none;
}
.panel-head { background: linear-gradient(rgba(255, 250, 235, .5), rgba(255, 250, 235, 0)); }
/* Raised parchment tabs, after the original's Buy / Sell / Arms row. */
.tabs { background: linear-gradient(#cdb889, #dcc89a); gap: 3px; padding: 6px 8px 0; border-bottom: 2px solid #b39a63; }
.tabs button {
    background: linear-gradient(#e7d6ae, #d9c494);
    border: 1px solid #b39a63;
    border-bottom: none;
    border-radius: 7px 7px 0 0;
    padding: 7px 8px 6px;
    color: #5a4632;
    font-weight: 600;
    transform: translateY(2px);
}
.tabs button:hover:not(.on) { background: linear-gradient(#efe2c0, #e0cc9c); }
.tabs button.on {
    background: var(--parch);
    color: var(--ink);
    border-color: #a8803a;
    border-bottom: 2px solid var(--parch);
    transform: translateY(2px);
    box-shadow: 0 -2px 6px rgba(0, 0, 0, .08);
}
.card, .unit, .route { background: #fbf3df; border-color: #d4bf8e; }
.card { box-shadow: 0 1px 0 rgba(120, 90, 40, .15); }
.section-title { display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(74, 56, 38, .4), transparent); }
.stage { border: 2px solid #3a2a1c; box-shadow: var(--shadow), inset 0 0 0 1px rgba(215, 165, 58, .4); }
.stage-caption { border-color: #a8803a; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); }

.look-row { display: grid; grid-template-columns: 26px 96px 26px; align-items: center; text-align: center; font-size: 12px; color: var(--ink-soft); }
.look-row button { padding: 1px 0; font-size: 10px; color: var(--ink); }

/* The title's night sky continues the page background without a seam. */
.title-scene .st-sky.night { background: linear-gradient(#0f1630, #2e3a64); }

/* Hirelings */
.recruit .lvl, .card .lvl { font-weight: 500; font-size: 12px; color: var(--ink-soft); margin-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 2px; }
.chip { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 999px; border: 1px solid; }
.chip.trade { color: #7a5a14; border-color: #c99a2c; background: #fbefd0; }
.chip.travel { color: #2d5d86; border-color: #6f9ac0; background: #e4eef6; }
.chip.heal { color: #3f7a3a; border-color: #7aa86f; background: #e3f0dc; }
.chips .wage { font-size: 12px; color: var(--ink-soft); }
.tier { font-weight: 700; margin-top: -4px; }
.tier-weak { color: var(--green); }
.tier-even { color: var(--gold-deep); }
.tier-dangerous { color: var(--red); }

/* ---------------------------------------------------------- feedback */

#fx { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.fx { position: fixed; will-change: transform, opacity; line-height: 0; }
.fx.fly svg { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)); }
.fx.crate svg { width: 22px; height: 22px; }
.fx.float {
    line-height: 1;
    font-family: Cinzel, serif;
    font-weight: 800;
    font-size: 18px;
    white-space: nowrap;
    color: #fff3c4;
    text-shadow: 0 1px 0 #2b1c08, 0 0 6px rgba(0, 0, 0, .6);
}
.fx.float.gain { color: #9be38a; }
.fx.float.loss { color: #ff8f7a; }
.fx.float.big { font-size: 28px; color: #ffd76a; }
.fx.float.sleep { font-size: 22px; color: #d8e4ff; }
.fx.ring { width: 40px; height: 40px; border: 3px solid var(--c); border-radius: 50%; }
.fx.spark { width: 7px; height: 7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }

/* Top bar numbers react when they change. */
.topbar [data-stat] { display: inline-block; transition: color .3s; }
.bump-up { animation: bump-up .5s ease-out; }
.bump-down { animation: bump-down .5s ease-out; }
.bump { animation: bump .45s ease-out; }
.flip { animation: flip .5s ease-out; }
@keyframes bump-up { 30% { transform: scale(1.25); color: #9be38a; } }
@keyframes bump-down { 30% { transform: scale(1.18); color: #ff8f7a; } }
@keyframes bump { 30% { transform: scale(1.22); color: #fff3c4; } }
@keyframes flip { 0% { transform: rotateX(90deg); } 100% { transform: none; } }

/* Market: the row you just traded flashes, with the price move. */
.market tr.traded td { animation: row-flash 1.2s ease-out; }
@keyframes row-flash { 0% { background: rgba(215, 165, 58, .45); } 100% { background: transparent; } }
.market .delta { display: inline-block; margin-left: 3px; font-size: 10px; font-weight: 800; animation: delta 1.6s ease-out both; }
.market .delta.up { color: var(--green); }
.market .delta.down { color: var(--red); }
@keyframes delta { 0% { opacity: 0; transform: translateY(6px); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }

/* Tabs slide their content in; cards arrive one after another. */
.tab-body.enter { animation: tab-in .28s ease-out; }
.tab-body.enter .card, .tab-body.enter .market tbody tr { animation: card-in .35s ease-out both; }
.tab-body.enter .card:nth-child(2), .tab-body.enter tbody tr:nth-child(2) { animation-delay: .03s; }
.tab-body.enter .card:nth-child(3), .tab-body.enter tbody tr:nth-child(3) { animation-delay: .06s; }
.tab-body.enter .card:nth-child(4), .tab-body.enter tbody tr:nth-child(4) { animation-delay: .09s; }
.tab-body.enter .card:nth-child(5), .tab-body.enter tbody tr:nth-child(5) { animation-delay: .12s; }
.tab-body.enter .card:nth-child(n+6), .tab-body.enter tbody tr:nth-child(n+6) { animation-delay: .15s; }
@keyframes tab-in { from { opacity: 0; transform: translateX(10px); } }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } }

/* Stage: scenes slide or fade into each other, recruits walk in, upgrades
   flash, a night passes when you rest. */
.stage-art.leaving { z-index: 1; animation: stage-fade .8s ease-in forwards; }
.stage-art.leaving.depart { animation-name: stage-depart; }
@keyframes stage-fade { to { opacity: 0; } }
@keyframes stage-depart { to { opacity: 0; transform: translateX(-30%); } }
.st-party .joining { animation: join 1.3s cubic-bezier(.2, .7, .3, 1); }
@keyframes join { from { translate: 420px 0; } }
.st-party.upgraded { animation: upgraded .7s ease-out; }
@keyframes upgraded { 0% { filter: brightness(2.2); transform: translateY(-4%) scale(1.03); } 100% { filter: none; transform: none; } }
.stage.resting .st-tint { animation: rest-night 1.8s ease-in-out; }
@keyframes rest-night { 0%, 100% { opacity: inherit; } 45%, 60% { opacity: .65; background: #0b1230; } }

/* Map: unexplored towns stay faint until visited; routes draw themselves. */
.map .city.unvisited .label { fill: rgba(58, 42, 27, .45); font-style: italic; }
.map .city.unvisited:hover .label { fill: #3a2a1b; }
.map .city.revealed .label { animation: reveal 1.2s ease-out; }
@keyframes reveal { 0% { fill: #d7a53a; font-size: 18px; } 100% { font-size: 13.5px; } }
.map .road.route.draw { stroke-dasharray: 100; animation: draw .7s ease-out both; }
@keyframes draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
.stage-caption { z-index: 3; }

/* =============================================================
   Frontier layout: title, player creation, town tabs, field screen
   ============================================================= */

:root {
    --olive: #74895a;
    --olive-dark: #4f6239;
    --olive-light: #9fb07c;
    --sheet: #e8ddc0;
    --sheet-line: rgba(74, 56, 38, .22);
    --pill: linear-gradient(#d9cf9f, #b3a670);
}

/* ---------- shared pieces */
.pill {
    font: inherit; font-weight: 600; color: #2b2118;
    background: var(--pill);
    border: 2px solid #4a3b1e; border-radius: 999px;
    padding: 6px 18px; box-shadow: 0 2px 0 rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.pill.big { font-size: 18px; padding: 8px 26px; }
.pill.ghost { background: transparent; }
.pill.danger { background: linear-gradient(#e08b74, #b2513b); color: #fff; }
.pill:disabled { opacity: .45; }
.boxes { display: inline-flex; gap: 5px; }
.boxes i { width: 22px; height: 22px; border: 2.5px solid #2b2118; border-radius: 2px; background: rgba(255, 252, 240, .5); }
.boxes i.on { background: #9a4a3a; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .2); }
.boxes.small i { width: 12px; height: 12px; border-width: 1.5px; }
.round { width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid #2b2118; background: transparent; color: #2b2118; box-shadow: none; font-weight: 800; }
.mini-portrait .portrait { width: 26px; height: 28px; border-radius: 4px; }
.gain { color: #3f7a3a; }
.loss { color: #a33a2c; }

/* ---------- title */
body:has(.title-hero) { background: #2a1d1a; overflow: hidden; }
.title-hero { position: fixed; inset: 0; container-type: size; --tile: 300cqh; }
.title-hero .stage-art { position: absolute; inset: 0; }
.title-logo { position: fixed; right: 4vw; top: 6vh; z-index: 2; text-align: right; }
.title-logo .wheel { position: absolute; right: 52%; top: -30%; width: min(30vh, 260px); opacity: .85; animation: spin 40s linear infinite; }
.title-logo .logo { position: relative; font-size: clamp(56px, 10vw, 128px); margin: 0; background: linear-gradient(#f3c48a, #d9824c 55%, #9a4a3a); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; filter: drop-shadow(0 4px 0 #2b1c10) drop-shadow(0 0 20px rgba(0, 0, 0, .4)); }
.title-logo .version { position: relative; color: #f2e6c8; font-size: 18px; margin-top: -6px; text-shadow: 0 1px 3px #000; }
.title-menu {
    position: fixed; right: 0; bottom: 14vh; z-index: 2; width: min(460px, 92vw);
    background: rgba(48, 34, 30, .92); padding: 18px 26px 14px; border-left: 6px solid #5a3a2e;
    display: grid; gap: 4px;
}
.menu-item { all: unset; cursor: pointer; display: block; color: #f6efe2; font-size: clamp(20px, 2.6vw, 30px); padding: 8px 4px; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.menu-item:hover, .menu-item:focus-visible { color: #ffd98a; }
.menu-item .curl { color: #d8c8b0; margin-right: 10px; font-size: .8em; }
.menu-foot { padding-top: 8px; }
.menu-foot .small { color: #f6efe2; border-color: rgba(255, 255, 255, .4); }
.title-credits { position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 6px 28px; justify-content: space-between; padding: 12px 24px; background: rgba(40, 28, 24, .92); color: #f2e6c8; font-size: 14px; }

/* ---------- black title cards */
.title-card-black { position: fixed; inset: 0; z-index: 60; background: #000; display: grid; place-items: center; color: #fff; font-size: 28px; animation: card-in .35s ease-out both; }
.title-card-black.out { animation: card-out .7s ease-in both; }
@keyframes card-out { to { opacity: 0; } }

/* ---------- player creation */
.create-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px 12px; }
.sheet {
    background:
        radial-gradient(ellipse at 30% 20%, rgba(255, 250, 230, .55), transparent 60%),
        radial-gradient(ellipse at 80% 90%, rgba(120, 90, 40, .18), transparent 55%),
        var(--sheet);
    color: var(--ink);
    border-radius: 8px;
    box-shadow: var(--shadow), inset 0 0 60px rgba(120, 90, 40, .25);
}
.create.sheet { width: min(980px, 100%); padding: 22px 28px; }
.sheet-title { font-family: Inter, sans-serif; font-weight: 500; font-size: 34px; margin: 0 0 14px; padding-bottom: 6px; border-bottom: 2px solid var(--sheet-line); }
.create-grid { display: grid; grid-template-columns: 280px 200px 1fr; gap: 20px; align-items: start; }
.namebox { display: block; text-align: center; font-size: 13px; font-style: italic; }
.namebox input { display: block; width: 100%; font: inherit; font-style: normal; font-size: 26px; text-align: center; padding: 6px; background: rgba(200, 186, 150, .6); border: 2px solid #4a3b1e; color: var(--ink); }
.create-portrait { margin-top: 8px; border: 2px solid #2b2118; background: linear-gradient(#0d1430, #2e3a64 60%, #8a5a4a 60%, #7a4a40); aspect-ratio: 1; display: grid; place-items: end center; overflow: hidden; }
.create-portrait .portrait { width: 80%; height: auto; border: 0; background: transparent; }
.create-portrait .portrait rect:first-of-type { fill: transparent; }
.create-portrait.small { width: 84px; margin: 0; }
.look-picker { text-align: center; }
.look-picker h3 { font-family: Inter, sans-serif; font-weight: 500; font-size: 19px; margin: 34px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--sheet-line); }
.look-row { display: grid; grid-template-columns: 32px 1fr 32px; align-items: center; margin-bottom: 12px; }
.look-row .look-title { grid-column: 1 / -1; font-size: 17px; }
.look-row em { font-size: 14px; }
.look-row .arrow { all: unset; cursor: pointer; color: #6b4a2c; font-size: 24px; text-align: center; }
.look-row .arrow:hover { color: #a87a1c; }
.create-skills .points { font-family: Inter, sans-serif; font-weight: 600; font-size: 30px; text-align: right; margin: 0 0 8px; }
.create-skills .skill-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 2px 8px; align-items: center; border: 0; padding: 6px 0; }
.create-skills .skill-row .name { font-size: 22px; text-align: right; font-weight: 500; }
.create-skills .skill-row .desc { grid-column: 1 / -1; text-align: right; font-style: italic; font-size: 13px; color: var(--ink-soft); }
.create-skills.inline .skill-row { grid-template-columns: 90px auto auto auto; justify-content: start; }
.create-skills.inline .skill-row .name { text-align: left; font-size: 17px; }
.create-skills.inline .skill-row .desc { text-align: left; }
.crewplus { font-size: 12px; color: var(--green); font-weight: 700; }
.create-actions { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--sheet-line); }

/* ---------- town screen */
.screen { max-width: 1280px; margin: 0 auto; padding: 0 12px 24px; }
.head {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 26px;
    background: linear-gradient(#0c0a08, #23201c); color: #f6f1e6;
    margin: 0 -12px; padding: 10px 24px 8px;
}
.head .place { font-family: Inter, sans-serif; font-weight: 600; font-size: clamp(22px, 3.2vw, 36px); margin: 0; letter-spacing: -.01em; }
.head .stat { font-size: 20px; color: #f6f1e6; }
.head .stat b { color: #f6f1e6; }
.head .ico { filter: none !important; }
.head .meta { margin-left: auto; display: flex; gap: 18px; }
.head .link { all: unset; cursor: pointer; color: #d8d2c4; font-size: 14px; }
.head .link:hover { color: #fff; }
.head .who { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.head .who > b { font-size: 22px; }
.head .xpbar { width: 70px; }
.screen-town .stage { height: 190px; margin: 0 -12px; border-radius: 0; border: 0; border-bottom: 3px solid #3a0d0a; }
.screen-town .tabs {
    display: flex; gap: 4px; padding: 10px 6px 0; margin: 0 -2px; background: none; border: 0; overflow-x: auto; scrollbar-width: none;
}
.screen-town .tabs button {
    flex: 1 0 auto; transform: none; font-size: 18px; font-weight: 500; color: #2b2118; padding: 6px 16px 4px;
    background: linear-gradient(#e9dfc6, #d4c7a2); border: 1px solid #9a8a62; border-bottom: 0; border-radius: 9px 9px 0 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5);
}
.screen-town .tabs button.on { background: var(--sheet); position: relative; top: 2px; box-shadow: 0 -3px 8px rgba(0, 0, 0, .2); }
.screen-town .tabs button.travel { margin-left: 18px; }
.screen-town .sheet { border-radius: 0 0 10px 10px; padding: 14px 22px 22px; border: 2px solid #9a8a62; min-height: 420px; position: relative; }
.page-title { font-family: Inter, sans-serif; font-weight: 500; font-size: clamp(26px, 3.4vw, 40px); margin: 0 0 10px; letter-spacing: -.01em; }
.page.enter { animation: tab-in .28s ease-out; }
.page .card { background: rgba(255, 252, 240, .55); border-color: var(--sheet-line); }
.screen-town .logbox { margin-top: 12px; }

/* order sheets */
table.trade { width: 100%; border-collapse: collapse; font-size: 17px; }
table.trade th { font-weight: 500; font-size: 15px; color: #2b2118; text-align: left; padding: 4px 8px; border-bottom: 2px solid var(--sheet-line); }
table.trade th.num, table.trade td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.trade td { padding: 5px 8px; border-bottom: 1px solid var(--sheet-line); vertical-align: middle; }
table.trade tbody tr:nth-child(odd) td { background: rgba(160, 130, 80, .1); }
table.trade td.good { font-size: 19px; white-space: nowrap; }
table.trade td.good .tip { display: block; font-size: 12px; color: var(--ink-soft); }
table.trade tr.none td { color: rgba(43, 33, 24, .45); }
table.trade tr.contraband td.good { color: #5a2a4a; }
table.trade .cost { font-weight: 600; }
table.trade .paid { display: block; font-size: 11px; color: var(--ink-soft); }
table.trade tr.traded td { animation: row-flash 1.2s ease-out; }
table.trade .cheap { color: var(--green); }
table.trade .dear { color: var(--red); }
.stepper-cell { display: flex; align-items: center; gap: 4px; }
.ord-in { width: 58px; font: inherit; font-size: 16px; text-align: center; padding: 2px; border: 1px solid #9a8a62; background: #f8f2e2; color: var(--ink); }
.ord-in::-webkit-inner-spin-button { -webkit-appearance: none; }
.updown, .maxnone { display: grid; gap: 1px; }
.tiny { all: unset; cursor: pointer; display: block; font-size: 9px; line-height: 1; padding: 2px 4px; background: #3b2d1c; color: #f2e6c8; text-align: center; }
.tiny.wide { font-size: 11px; padding: 2px 8px; background: #5a4428; }
.tiny:disabled { opacity: .35; cursor: default; }
.footnote { font-size: 13px; color: var(--ink-soft); margin: 6px 0 0; }
.order-foot { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-top: 14px; padding-top: 10px; border-top: 2px solid var(--sheet-line); }
.order-foot .carry { display: grid; font-size: 17px; color: var(--ink-soft); }
.order-foot .carry b { color: var(--ink); }
.order-foot .total { text-align: right; display: grid; }
.order-foot .total > b { font-size: 22px; font-weight: 600; }
.order-foot .total span { color: var(--ink-soft); }

/* arms, armour, vessels */
.gear { display: grid; grid-template-columns: 260px 1fr; gap: 24px; }
.gear h3 { font-weight: 500; font-size: 20px; margin: 0 0 8px; }
.kit-icon { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 18px; }
.kit-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--sheet-line); }
.owned { font-size: 13px; color: var(--green); font-weight: 700; border: 2px solid var(--green); border-radius: 999px; padding: 2px 12px; }
tr.owned-row td { background: rgba(120, 160, 90, .15) !important; }
.vessels tbody tr { cursor: pointer; }
.vessels tr.viewing td { background: rgba(215, 165, 58, .25) !important; }
.vessel-show { display: grid; grid-template-columns: minmax(0, 1.2fr) 1fr; gap: 16px; align-items: center; margin-top: 14px; }
.vessel-picture { border: 2px solid #2b2118; height: 200px; overflow: hidden; background: #8fc6e8; }
.vessel-picture svg { width: 100%; height: 100%; display: block; }
.vessel-show p { font-size: 18px; line-height: 1.5; }

/* tavern */
.hire-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.recruit { align-items: flex-start; flex-wrap: wrap; }
.recruit .body > button { float: right; margin: 0 0 4px 8px; font-size: 14px; padding: 5px 10px; }
.stat-boxes { display: grid; grid-template-columns: auto auto; gap: 2px 8px; align-items: center; margin-top: 4px; font-size: 13px; justify-content: start; }
.stat-boxes > span { text-align: right; }

/* party */
.party-sheet { display: grid; gap: 10px; }
.party-me { display: flex; gap: 12px; align-items: center; }

/* travel page */
.travel-page .mapscroll { position: relative; }
.citycard {
    position: absolute; right: 12px; bottom: 12px; width: min(560px, 62%);
    background: var(--sheet); border: 3px solid #4a3b1e; border-radius: 10px; padding: 10px 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35); font-size: 14px; pointer-events: none;
    animation: card-in .18s ease-out;
}
.cc-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.cc-head b { font-size: 24px; font-weight: 600; }
.cc-body { display: grid; grid-template-columns: 1fr 170px; gap: 12px; }
.cc-body table { border-collapse: collapse; width: 100%; }
.cc-body th { text-align: left; font-size: 13px; border-bottom: 1px solid var(--sheet-line); }
.cc-body td { padding: 0 4px; border-bottom: 1px solid var(--sheet-line); white-space: nowrap; }
.cc-body .num { text-align: right; }
.cc-side dl { margin: 0 0 6px; display: grid; gap: 0; }
.cc-side dt { font-weight: 700; }
.cc-side dd { margin: 0 0 4px; }
.cc-picture { height: 92px; border: 2px solid #2b2118; overflow: hidden; }
.cc-picture svg { width: 100%; height: 100%; display: block; }
.legend .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; border: 1.5px solid #2b2118; }
.legend .dot.here { background: #d0702c; }
.legend .dot.near { background: #9cc06a; }
.travel-page .legend { color: var(--ink-soft); }
.route.idle { border-left-color: var(--parch-3); }
.map .city.near .ring { stroke: #6f9a3a; stroke-width: 3; }
.map .city.here .ring { stroke: #d0702c; stroke-width: 3.5; }

/* ---------- field screen */
.screen-field .field-stage { height: min(46vh, 430px); margin: 0 -12px; border-radius: 0; border: 0; border-top: 5px solid #3a0d0a; border-bottom: 5px solid #3a0d0a; }
.stage .battle-stage { position: absolute; inset: 0; margin: 0; height: 100%; border: 0; }
.hud {
    display: grid; grid-template-columns: minmax(240px, 34%) 1fr; grid-template-areas: "a b" "a c"; gap: 14px;
    padding: 14px; margin: 0 -12px; min-height: 300px;
    background: repeating-linear-gradient(115deg, rgba(255, 255, 255, .03) 0 3px, transparent 3px 14px), #3f362c;
}
.hud.fighting { grid-template-columns: minmax(200px, 24%) 1fr minmax(200px, 24%); grid-template-areas: "a b c"; }
.hud-a { grid-area: a; min-height: 0; }
.hud-b { grid-area: b; display: grid; grid-template-rows: auto 1fr; background: var(--olive); border: 3px solid var(--olive-dark); border-radius: 4px; min-height: 0; }
.hud-c { grid-area: c; }
.controls { display: flex; align-items: center; gap: 14px; padding: 8px 12px; flex-wrap: wrap; }
.controls .acts { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; }
.speed { display: grid; grid-template-columns: auto; color: #f4efe0; font-size: 13px; line-height: 1.1; }
.speed .bars { display: flex; align-items: flex-end; gap: 4px; height: 38px; }
.speed .bar { all: unset; cursor: pointer; width: 12px; height: var(--h); background: #2f4a28; border: 1.5px solid #1a2416; }
.speed .bar.on { background: #4f7a40; }
.speed .bar:last-child.on { background: #111; }
.speed .ends { display: flex; justify-content: space-between; font-size: 11px; }
.speed .ends i { font-style: normal; }
.flog { background: #ddd2a6; border: 2px solid #c8bc8c; margin: 0 8px 8px; padding: 6px 12px; overflow-y: auto; max-height: 210px; min-height: 140px; font-size: 17px; line-height: 1.55; color: #24331e; }
.flog p { margin: 0; }
.flog .day { color: #4a5a3a; }
.flog .event { color: #1d2a3a; font-weight: 500; }
.flog .us { color: #3a7a2a; }
.flog .them { color: #a32a1c; }
.flog .gain { color: #2f6a24; font-weight: 600; }
.flog .loss { color: #a32a1c; font-weight: 600; }
.trip-box, .party-box { background: var(--olive); border: 3px solid var(--olive-dark); border-radius: 4px; padding: 10px 14px; color: #1c2414; height: 100%; }
.trip-box h3, .party-box h3 { font-family: Inter, sans-serif; font-weight: 800; font-size: clamp(18px, 2vw, 24px); margin: 0 0 6px; }
.trip-box dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 16px; }
.trip-box dt { text-align: right; }
.trip-box dd { margin: 0; font-weight: 600; }
.trip-foot { display: flex; gap: 40px; margin-top: 8px; font-size: 18px; font-weight: 600; }
.mini-hp { display: inline-block; height: 8px; width: 60px; background: #3a1a14; border: 1px solid #1a1410; vertical-align: middle; overflow: hidden; }
.mini-hp.wide { width: 120px; }
.mini-hp i { display: block; height: 100%; background: #5a8a3a; }
.party-box { background: linear-gradient(var(--olive-light), var(--olive)); }
.party-box h3 { text-align: center; }
.big-hp { height: 16px; background: #9a2a1c; border: 2px solid #3a2a20; overflow: hidden; }
.big-hp i { display: block; height: 100%; background: linear-gradient(#5a5a5a, #3a3a3a); transition: width .4s ease-out; }
.hp-num { text-align: right; font-size: 22px; margin: 2px 0 8px; }
.members { display: grid; gap: 4px; }
.member { display: grid; grid-template-columns: 28px 1fr 60px; gap: 6px; align-items: center; font-size: 13px; }
.member.down { opacity: .45; }
.mname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.minimap { position: relative; height: 100%; min-height: 260px; overflow: hidden; border: 3px solid #2a2016; background: #a9c7c6; container-type: size; }
.minimap .mapbox {
    position: absolute; left: 0; top: 0; width: 250cqw; max-width: none; border-radius: 0;
    transform: translate(calc(50cqw - var(--x, .5) * 250cqw), calc(50cqh - var(--y, .5) * 168.5cqw));
    transition: transform .5s linear; will-change: transform;
}
.minimap .mapbox .map { pointer-events: none; }
.minimap .mm-arrow { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px; border: 2px dashed rgba(208, 112, 44, .8); border-radius: 50%; pointer-events: none; }

/* ---------- newcomer tips */
.newcomer {
    position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 50; width: min(640px, 92vw);
    background: var(--sheet); border: 6px solid #6b4520; border-radius: 16px; padding: 14px 22px 18px; color: #1c140c;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .5); animation: card-in .25s ease-out;
}
.newcomer h3 { margin: 0 0 6px; text-align: right; color: #7a7262; font-family: Inter, sans-serif; font-weight: 700; font-size: 24px; }
.newcomer p { font-weight: 700; font-size: 18px; line-height: 1.4; margin: 0 0 12px; }
.newcomer .choices { display: flex; justify-content: space-around; }

/* ---------- small screens */
@media (max-width: 900px) {
    .create-grid { grid-template-columns: 1fr 1fr; }
    .create-skills { grid-column: 1 / -1; }
    .gear { grid-template-columns: 1fr; }
    .vessel-show { grid-template-columns: 1fr; }
    .hud, .hud.fighting { grid-template-columns: 1fr; grid-template-areas: "b" "c" "a"; }
    .hud.fighting { grid-template-areas: "b" "a" "c"; }
    .minimap { min-height: 200px; }
    .citycard { position: static; width: auto; margin-top: 8px; pointer-events: auto; }
}
.only-sm { display: none; }
@media (max-width: 600px) {
    .head { gap: 2px 14px; padding: 8px 12px; }
    .head .meta { margin-left: 0; width: 100%; order: 9; }
    .head .stat { font-size: 16px; }
    .screen-town .stage { height: 120px; }
    .screen-field .field-stage { height: 170px; }
    .screen-town .tabs button { font-size: 15px; padding: 6px 10px 4px; }
    .screen-town .sheet { padding: 10px 10px 16px; }
    table.trade { font-size: 14px; }
    table.trade td, table.trade th { padding: 4px 3px; }
    table.trade td.good { font-size: 14px; white-space: normal; }
    table.trade .locked { white-space: normal; display: inline-block; max-width: 60px; font-size: 11px; overflow-wrap: anywhere; text-align: right; line-height: 1.25; }
    table.trade .pill { padding: 3px 9px; font-size: 13.5px; }
    .hide-sm { display: none; }
    .only-sm { display: inline; }
    .order-foot { grid-template-columns: 1fr; text-align: center; }
    .order-foot .total { text-align: center; }
    .create-grid { grid-template-columns: 1fr; }
    .cc-body { grid-template-columns: 1fr; }
    .title-logo { left: 4vw; right: 4vw; text-align: center; }
    .title-menu { bottom: 72px; }
    .flog { font-size: 15px; }
}

.look-row { grid-template-columns: 32px 1fr 32px; }
.look-row > em { grid-column: 2; }
.create .namebox input { font-size: 26px; padding: 6px; margin: 0; background: rgba(200, 186, 150, .6); border: 2px solid #4a3b1e; border-radius: 0; }

/* ---------- guild page */
.guild-page {
    display: grid; grid-template-columns: 300px 1fr; grid-template-areas: "seal main" "says says";
    gap: 0; margin: -6px 0 18px; border-bottom: 2px solid var(--sheet-line);
}
.guild-seal { grid-area: seal; display: grid; justify-items: center; align-content: start; gap: 18px; padding: 10px 20px 20px; border-right: 2px solid var(--sheet-line); }
.guild-seal .emblem { filter: drop-shadow(0 0 10px rgba(110, 70, 30, .6)); width: min(220px, 60vw); height: auto; }
.guild-main { grid-area: main; padding: 0 0 18px 26px; }
.guild-name { font-family: Inter, sans-serif; font-weight: 800; font-size: clamp(32px, 5vw, 60px); text-align: right; margin: 0; border-bottom: 2px solid var(--sheet-line); line-height: 1.1; }
.guild-level { text-align: right; font-weight: 800; font-size: 24px; color: #3a2e22; }
.merit-bar { height: 8px; margin: 6px 0 16px auto; width: 50%; background: rgba(74, 56, 38, .2); border-radius: 4px; overflow: hidden; }
.merit-bar i { display: block; height: 100%; background: #9a4a3a; }
.guild-main h3, .guild-says h3 { font-family: Inter, sans-serif; font-weight: 800; font-size: 24px; margin: 0 0 4px; color: #2b2118; }
.quest-text, .guild-says p { font-weight: 700; font-size: 18px; line-height: 1.5; margin: 0; color: #2b2118; }
.quest-progress { margin: 10px 0 0; font-weight: 700; color: #9a4a3a; }
.guild-says { padding: 16px 20px; border-top: 2px solid var(--sheet-line); }
.guild-says + .guild-says { border-left: 2px solid var(--sheet-line); }
.guild-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.guild-choice { display: flex; gap: 14px; align-items: flex-start; padding: 12px; border: 1px solid var(--sheet-line); border-radius: 10px; background: rgba(255, 252, 240, .45); }
.guild-choice h3 { margin: 0 0 4px; font-family: Inter, sans-serif; font-weight: 800; font-size: 22px; }
.guild-choice .emblem { flex: none; }
.section-subtitle { font-weight: 700; font-size: 13px; color: var(--ink-soft); margin: 10px 0 6px; text-transform: uppercase; letter-spacing: .06em; }
.place-kind { display: block; font-size: 15px; font-weight: 400; letter-spacing: 1.1em; color: rgba(246, 241, 230, .35); margin-bottom: -6px; white-space: nowrap; }

/* ---------- travel reach and search */
.map .reach { fill: rgba(255, 255, 255, .06); stroke: #6a6a6a; stroke-width: 3.5; pointer-events: none; }
.map .spokes line { stroke: rgba(90, 60, 30, .55); stroke-width: 1.2; pointer-events: none; }
.map .city.inreach .ring { stroke: #7aa04a; stroke-width: 2.5; }
.map .city.found .ring { stroke: #111; stroke-width: 3.5; stroke-dasharray: none; }
.bubble {
    position: absolute; transform: translate(-50%, calc(-100% - 26px)); z-index: 3; pointer-events: none;
    background: #fff; border: 3px solid #111; border-radius: 22px; padding: 4px 22px; font-weight: 800; font-size: 18px; color: #111; white-space: nowrap;
    animation: card-in .2s ease-out;
}
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -16px; border: 9px solid transparent; border-top: 14px solid #111; transform: translateX(-30%); }
.search { display: flex; align-items: center; gap: 12px; margin: 10px 4px; font-size: 20px; }
.search input { flex: 0 1 380px; font: inherit; font-size: 17px; padding: 5px 14px; border-radius: 999px; border: 2px solid #8a8a7a; background: rgba(255, 255, 255, .55); color: var(--ink); }
.minimap .reach, .minimap .spokes { display: none; }
@media (max-width: 900px) {
    .guild-page { grid-template-columns: 1fr; grid-template-areas: "seal" "main" "gm" "tm"; }
    .guild-seal { border-right: 0; }
    .guild-main { padding: 0; }
    .guild-says + .guild-says { border-left: 0; }
    .guild-choices { grid-template-columns: 1fr; }
}
.guild-says-row { grid-area: says; display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .guild-page { grid-template-areas: "seal" "main" "says"; } .guild-says-row { grid-template-columns: 1fr; } }

/* ---------- combat, blow by blow */
.battle-svg .unit-fig[data-act] { cursor: crosshair; }
.battle-svg .unit-fig[data-act]:hover .lunge { filter: drop-shadow(0 0 6px rgba(255, 80, 60, .9)); }
.battle-svg .focus-ring { fill: rgba(200, 40, 30, .25); stroke: #c0281c; stroke-width: 3; stroke-dasharray: 8 5; animation: ring-spin 3s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ring-spin { to { stroke-dashoffset: -26; } }
.battle-svg .lunge { transform-box: fill-box; transform-origin: bottom center; }
.lunge-r { animation: blow-r .32s ease-out; }
.lunge-l { animation: blow-l .32s ease-out; }
@keyframes blow-r { 35% { transform: translateX(42px) rotate(6deg); } }
@keyframes blow-l { 35% { transform: translateX(-42px) rotate(-6deg); } }
.hurt { animation: hurt .35s ease-out; }
@keyframes hurt { 0% { filter: brightness(3) saturate(0); } 40% { transform: translateX(var(--kb, 8px)); } 100% { filter: none; } }
.dodge { animation: dodge .3s ease-out; }
@keyframes dodge { 40% { transform: translateY(-14px) skewX(-6deg); } }
.stumble { animation: stumble .4s ease-out; }
@keyframes stumble { 30% { transform: rotate(-12deg) translateX(-10px); } }
.glow { animation: glow .6s ease-out; }
@keyframes glow { 30% { filter: drop-shadow(0 0 10px #8ef08a) brightness(1.3); } }
.battle-svg .unit-fig.fleeing { transition: transform 1.2s ease-in, opacity 1.2s; transform: translateX(400px); opacity: 0; }
.battle-svg .unit-fig.fled { opacity: 0; }
.bnum { font-family: Inter, sans-serif; font-weight: 900; font-size: 30px; text-anchor: middle; paint-order: stroke; stroke: #1a0f08; stroke-width: 5px; animation: bnum 1.1s ease-out both; pointer-events: none; }
.bnum.dealt { fill: #ffe9a8; }
.bnum.taken { fill: #ff7a64; }
.bnum.crit { fill: #ffd23a; font-size: 44px; }
.bnum.power { fill: #ffb03a; font-size: 40px; }
.bnum.miss { fill: #e8eef4; font-size: 24px; font-style: italic; }
.bnum.heal { fill: #8ef08a; }
@keyframes bnum { 0% { opacity: 0; transform: translateY(16px) scale(.6); } 15% { opacity: 1; transform: translateY(0) scale(1.15); } 30% { transform: scale(1); } 100% { opacity: 0; transform: translateY(-46px); } }
.bnum { transform-box: fill-box; transform-origin: center; }
.bslash { fill: none; stroke: #fff; stroke-width: 7; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; filter: drop-shadow(0 0 4px #fff); animation: bslash .3s ease-out forwards; }
.bslash.big { stroke: #ffd23a; stroke-width: 11; filter: drop-shadow(0 0 8px #ff9a2a); }
@keyframes bslash { 60% { stroke-dashoffset: 0; opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 0; } }
.barrow { stroke: #6b4a2c; stroke-width: 3; fill: #c4c9cf; }
.stage.shake .stage-art { animation: shake .28s linear; }
@keyframes shake { 20% { transform: translate(-6px, 3px); } 40% { transform: translate(5px, -4px); } 60% { transform: translate(-4px, 2px); } 80% { transform: translate(3px, -1px); } }
.pill.skill { background: linear-gradient(#e9c46a, #c9952c); }
.pill.skill.cooling { background: var(--pill); }
.pill.skill i { font-style: normal; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #2b2118; color: #f2e6c8; font-size: 12px; margin-left: 4px; }
.focus-hint { width: 100%; font-size: 13px; color: #f4efe0; opacity: .85; }
.member[data-act] { cursor: crosshair; border-radius: 4px; }
.member[data-act]:hover { background: rgba(255, 255, 255, .15); }
.member.focused { background: rgba(200, 40, 30, .25); outline: 2px dashed #c0281c; }
.stage-art > .battle-stage { pointer-events: auto; }
.stage-art.leaving { pointer-events: none; }

/* ---------------------------------------------------------------- stories & endings */

.story-card {
    position: absolute; z-index: 4; left: 14px; right: 14px; bottom: 12px; max-width: 720px; margin: 0 auto;
    display: flex; gap: 12px; align-items: flex-start;
    background: linear-gradient(#f6ecd2, #ead9b0); color: var(--ink);
    border: 2px solid #8a6a3a; border-radius: 6px; padding: 10px 14px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, .45);
    max-height: calc(100% - 24px); overflow-y: auto;
}
.story-card.enter { animation: story-in .45s cubic-bezier(.2, .8, .3, 1); }
@keyframes story-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.story-card .sc-who { flex: 0 0 64px; width: 64px; height: 68px; border: 2px solid #8a6a3a; border-radius: 4px; overflow: hidden; background: #e9dcb8; }
.story-card .sc-who svg { width: 100%; height: 100%; display: block; }
.story-card h3 { margin: 0 0 4px; font-size: 17px; color: #6a3a14; }
.story-card p { margin: 0; font-size: 14.5px; line-height: 1.5; }
@media (max-width: 640px) {
    .story-card { left: 6px; right: 6px; bottom: 6px; padding: 8px 10px; gap: 8px; }
    .story-card .sc-who { flex-basis: 44px; width: 44px; height: 48px; }
    .story-card p { font-size: 13px; }
}

.flog .story { color: #6a3a14; font-family: Cinzel, Georgia, serif; font-weight: 600; }
.pill .why { display: block; font-size: 10.5px; font-weight: 500; opacity: .85; max-width: 220px; white-space: normal; line-height: 1.25; }

.victory .ending-mark { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--gold-deep); font-family: Cinzel, serif; letter-spacing: .2em; text-transform: uppercase; font-size: 12px; }
.victory .ending-mark .ico { animation: trophy-in .8s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes trophy-in { from { transform: scale(.2) rotate(-30deg); opacity: 0; } }
.victory h2 { text-align: center; }
.victory .ending-text { font-size: 16px; line-height: 1.6; font-style: italic; }

.menu-item .menu-count { font-size: .55em; color: #d8c8b0; margin-left: 8px; font-family: Inter, sans-serif; }
.endings-page { max-width: 860px; margin: 0 auto; color: var(--ink); }
.ending-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 14px 0; }
.ending { padding: 10px 12px; border-radius: 8px; border: 1px dashed var(--parch-3); background: rgba(255, 250, 240, .5); font-size: 13px; color: var(--ink-soft); }
.ending b { display: block; font-family: Cinzel, serif; color: var(--ink-soft); margin-bottom: 3px; }
.ending.found { border-style: solid; border-color: var(--gold-deep); background: #fffaf0; color: var(--ink); animation: card-in .3s both; }
.ending.found b { color: #6a3a14; }

.talk { display: grid; gap: 6px; margin-bottom: 10px; }
.talk-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; background: #fffaf0; border: 1px solid var(--parch-3); color: var(--ink); font-size: 13.5px; animation: card-in .3s both; }
.talk-row > span:nth-child(2) { flex: 1; }
.talk-row button { flex: none; }
.talk-tag { flex: none; font-family: Cinzel, serif; font-size: 11px; font-weight: 700; letter-spacing: .05em; padding: 2px 7px; border-radius: 4px; background: #6a3a14; color: #f6ecd2; }
.talk-row.rumour { font-style: italic; color: var(--ink-soft); }
.talk-row.rumour .talk-tag { background: var(--ink-soft); font-style: normal; }
.talk-row.shortage .talk-tag { background: var(--green); }
.talk-row.glut .talk-tag { background: var(--blue); }

.trait { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 9px; font-size: 10.5px; font-weight: 700; line-height: 17px; vertical-align: 1px; background: #e8dcc0; color: #4a3826; border: 1px solid #c8b48a; cursor: help; }
.trait-lucky { background: #f4e3a0; }
.trait-fierce, .trait-greedy { background: #f2d0c6; }
.trait-tough, .trait-steady { background: #d8e3ea; }
.trait-loyal, .trait-family { background: #d5e8c8; }

.ev-badge { display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 4px; font-size: 10.5px; font-weight: 700; color: #fff; vertical-align: 1px; }
.ev-badge.shortage { background: var(--green); }
.ev-badge.glut { background: var(--blue); }

.cc-note { margin: 4px 8px; font-size: 12.5px; color: var(--ink); }
.cc-note.lead b { color: #a33a2c; }
.cc-note.shortage b { color: var(--green); }
.cc-note.glut b { color: var(--blue); }

.map .city .lead-mark, .map .city .ev-mark, .map .city .ev-up, .map .city .ev-down { display: none; }
/* Static on purpose: animating an SVG group repaints the whole map overlay every frame. */
.map .city.lead .lead-mark { display: inline; }
.map .city.shortage .ev-mark, .map .city.glut .ev-mark { display: inline; }
.map .city.shortage .ev-mark circle { fill: var(--green); }
.map .city.glut .ev-mark circle { fill: var(--blue); }
.map .city.shortage .ev-up, .map .city.glut .ev-down { display: inline; }

.flog .story-text { display: none; font-style: italic; }
@media (max-width: 640px) {
    .story-card p { display: none; }
    .story-card { align-items: center; }
    .flog .story-text { display: block; }
}
.endings-page { padding: 20px 24px; margin: 16px auto; }
@media (max-width: 640px) { .endings-page { padding: 14px 16px; margin: 8px; } }
.talk-row.seek { border-color: var(--gold-deep); background: #fff4d6; }
.talk-row.seek .talk-tag { background: var(--gold-deep); }

/* ---------------------------------------------------------------- touch and phones */

.head .place.long { font-size: clamp(20px, 2.4vw, 30px); }

/* Order steppers big enough for a thumb: ▼ [qty] ▲ over Max | None. */
@media (pointer: coarse) {
    .stepper-cell { display: grid; grid-template-columns: 38px 52px 38px; grid-template-areas: "dn in up" "mx mx mx"; gap: 3px; }
    .stepper-cell .updown, .stepper-cell .maxnone { display: contents; }
    .stepper-cell .ord-in { grid-area: in; width: 100%; height: 38px; }
    .stepper-cell .updown .tiny { font-size: 15px; min-height: 38px; display: grid; place-items: center; padding: 0; border-radius: 3px; }
    .stepper-cell .updown .tiny:first-child { grid-area: up; }
    .stepper-cell .updown .tiny:last-child { grid-area: dn; }
    .stepper-cell .maxnone .tiny { font-size: 12px; min-height: 30px; height: auto; display: grid; place-items: center; padding: 0 4px; border-radius: 3px; }
    .stepper-cell .maxnone .tiny:first-child { grid-area: mx; }
    .speed .bar { width: 18px; }
    .speed .bars { gap: 6px; }
}

/* A fight on a phone: a bigger stage, both sides' boxes side by side under
   it, then the controls and the log. */
@media (max-width: 600px) {
    .screen-field.fighting .field-stage { height: min(25vh, 200px); }
    .hud.fighting { grid-template-columns: 1fr 1fr; grid-template-areas: "a c" "b b"; gap: 8px; padding: 8px; }
    .hud.fighting .party-box { padding: 6px 8px; }
    .hud.fighting .party-box h3 { font-size: 15px; margin-bottom: 4px; }
    .hud.fighting .hp-num { font-size: 15px; margin: 0 0 4px; }
    .hud.fighting .big-hp { height: 10px; }
    .hud.fighting .member { grid-template-columns: 22px 1fr 36px; font-size: 12px; min-height: 30px; }
    .hud.fighting .mini-hp { width: 36px; }
    .hud.fighting .flog { min-height: 96px; max-height: 150px; }
}
.pill.pressed, button.pressed { animation: pressed .18s ease-out; }
@keyframes pressed { 40% { transform: scale(.94); filter: brightness(1.15); } }
.volume { display: grid; grid-template-columns: auto 1fr 44px; align-items: center; gap: 10px; margin: 8px 0 14px; font-size: 14px; }
.volume input { accent-color: var(--gold-deep); width: 100%; }
.volume b { text-align: right; }
table.trade .resale { display: block; font-size: 11.5px; color: var(--ink-soft); font-weight: 500; line-height: 1.2; }
table.trade .resale b { color: var(--green); }
@media (max-width: 600px) {
    .controls { flex-direction: column; align-items: stretch; gap: 8px; }
    .controls .speed { display: flex; align-items: center; gap: 10px; }
    .controls .speed .ends { display: none; }
    .controls .speed .bars { height: 28px; }
    .controls .acts { justify-content: center; gap: 8px; }
    .controls .acts .pill { padding: 6px 14px; }
}

/* ---------------------------------------------------------------- less clutter */

.stage-caption[hidden] { display: none; }
.head .link.icon { font-size: 18px; line-height: 1; }
.stepper-cell .updown { display: flex; flex-direction: row-reverse; gap: 2px; }
.stepper-cell .updown .tiny { font-size: 14px; width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border-radius: 3px; }
.stepper-cell .maxnone .tiny { height: 22px; display: grid; place-items: center; border-radius: 3px; }
@media (pointer: coarse) { .stepper-cell .updown { display: contents; } .stepper-cell .updown .tiny { width: auto; height: auto; } }
.foot-acts { display: flex; gap: 8px; justify-content: center; align-items: center; }
table.trade td.empty { text-align: center; color: var(--ink-soft); padding: 18px 8px; font-style: italic; }
.other-prices { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 0; font-size: 13px; color: var(--ink-soft); }
.other-prices > span:first-child { font-weight: 600; }
.other-prices b { color: var(--ink); font-weight: 600; }
.recruit .rstats { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; color: var(--ink); font-size: 13px; margin-top: 2px; }
.perk { display: inline-block; padding: 0 6px; border-radius: 9px; background: #e2ecd6; color: #2f5a24; font-size: 11px; font-weight: 700; line-height: 17px; }
.skill-row.compact { grid-template-rows: auto; padding: 4px 0; cursor: help; }
.skill-row.compact .desc { display: none; }
/* Max is a secondary action: outlined, so a column of them doesn't shout. */
.stepper-cell .maxnone .tiny.wide { background: transparent; color: #5a4428; box-shadow: inset 0 0 0 1.5px #8a6a44; font-weight: 700; }
.stepper-cell .maxnone .tiny.wide:not(:disabled):hover { background: rgba(90, 68, 40, .1); }

/* The road clock, after the original's hour lines. */
.flog .hour { display: flex; align-items: center; gap: 8px; color: #6a7a52; font-size: .85em; }
.flog .hour::after { content: ""; flex: 1; border-bottom: 2px dashed rgba(74, 90, 58, .45); margin-right: 6px; }
.flog p:first-child { animation: log-in .25s ease-out; }
@keyframes log-in { from { opacity: 0; transform: translateY(-4px); } }
/* In a fight the side panels are the original's: party name, health bar, total. */
.hud.fighting .party-box .members { display: none; }
.hud.fighting .party-box { display: flex; flex-direction: column; }
.flog .us, .flog .them { color: #24331e; }
.flog .us .dmg { color: #2f7a24; font-weight: 600; }
.flog .them .dmg { color: #a32a1c; font-weight: 600; }

/* ---------------------------------------------------------------- quality of life */

.needs { display: grid; gap: 6px; margin: 0 0 12px; }
.need { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; background: #fff4d6; border: 1px solid var(--gold-deep); color: var(--ink); font-size: 13.5px; }
.need > span { flex: 1; }
.tabs button { position: relative; }
.tab-dot { position: absolute; top: 5px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: #c0392b; box-shadow: 0 0 0 2px var(--parch); }
.route-warn { margin: 6px 0 8px; padding: 0 0 0 18px; color: #8a3a1c; font-size: 13px; }
.route-warn li { margin: 2px 0; }
.cc-note.cargo b { color: var(--ink); }
.cc-note .gain { color: var(--green); font-weight: 600; }
.cc-note .loss { color: var(--red); font-weight: 600; }
.title-card-black { cursor: pointer; }

/* ---------------------------------------------------------------- encounter transitions */

/* Halted for an encounter: the land and the caravan stop where they are. */
.stage.halted .st-layer, .stage.halted .st-party * { animation-play-state: paused !important; }

/* Folk on the road walk in from the right, and off again afterwards. */
.st-others { z-index: 1; }
.st-others.arriving { animation: folk-in .75s cubic-bezier(.2, .7, .3, 1) both; }
.st-others.walking-off { animation: folk-out .85s ease-in forwards; }
@keyframes folk-in { from { transform: translateX(110%); } }
@keyframes folk-out { to { transform: translateX(115%); } }

/* An ambush: letterbox bars close in and the edges glow red. */
.stage::before, .stage::after {
    content: ""; position: absolute; left: 0; right: 0; height: 0; z-index: 2; background: #0c0806;
    transition: height .35s cubic-bezier(.3, .7, .3, 1); pointer-events: none;
}
.stage::before { top: 0; }
.stage::after { bottom: 0; }
.stage.ambush::before, .stage.ambush::after { height: 8%; }
.stage.ambush .stage-art:not(.leaving)::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    box-shadow: inset 0 0 90px rgba(170, 24, 12, .55); animation: alarm-glow 1.4s ease-in-out infinite;
}
@keyframes alarm-glow { 50% { box-shadow: inset 0 0 50px rgba(170, 24, 12, .3); } }
.fx.float.alarm-mark { font: 900 58px/1 Cinzel, Georgia, serif; color: #d0281c; -webkit-text-stroke: 2px #2b1008; text-shadow: 0 3px 0 #2b1008; }

/* Into a fight: the road flashes out, the battle flashes in, and both sides march up. */
.stage-art.leaving.battle-in { animation: battle-in-old .4s ease-in forwards; }
@keyframes battle-in-old { 40% { filter: brightness(2.4) contrast(1.2); transform: scale(1.05); } to { opacity: 0; filter: brightness(3); transform: scale(1.12); } }
.battle-stage.entering { animation: battle-flash .5s ease-out; }
@keyframes battle-flash { from { filter: brightness(2.6) saturate(.5); } }
.battle-stage.entering .unit-fig[data-side=party] { animation: march-l .7s cubic-bezier(.2, .8, .3, 1) both; animation-delay: calc(var(--i) * 70ms); }
.battle-stage.entering .unit-fig[data-side=foe] { animation: march-r .7s cubic-bezier(.2, .8, .3, 1) both; animation-delay: calc(var(--i) * 70ms + 120ms); }
@keyframes march-l { from { transform: translateX(-320px); opacity: 0; } 60% { opacity: 1; } }
@keyframes march-r { from { transform: translateX(320px); opacity: 0; } 60% { opacity: 1; } }

/* Out of a fight: the winners cheer, the beaten run for it. */
.battle-stage.over-won .unit-fig[data-side=party]:not(.down) .lunge { animation: cheer .42s ease-out 3; animation-delay: calc(var(--i) * 90ms); }
@keyframes cheer { 45% { transform: translateY(-16px); } }
.battle-stage.over-fled .unit-fig[data-side=party] { animation: run-off .9s ease-in forwards; animation-delay: calc(var(--i) * 50ms); }
@keyframes run-off { 15% { transform: translateX(16px); } to { transform: translateX(-900px); } }
.battle-stage.over-lost, .battle-stage.over-surrendered { animation: beaten 1.2s ease-out forwards; }
@keyframes beaten { to { filter: grayscale(.7) brightness(.7); } }
.stage-art.leaving.battle-out { animation: battle-out-old .7s ease-in forwards; }
@keyframes battle-out-old { to { opacity: 0; transform: scale(.94); } }

@media (prefers-reduced-motion: reduce) {
    .stage::before, .stage::after { transition: none; }
}

/* ---------------------------------------------------------------- declutter, round two */

/* On a mouse, a row's − + Max appear when you point at it or have ordered some. */
@media (pointer: fine) {
    table.trade tbody tr:not(:hover):not(:focus-within):not(.ordering) .updown,
    table.trade tbody tr:not(:hover):not(:focus-within):not(.ordering) .maxnone { visibility: hidden; }
}
table.trade .own { margin-left: 6px; font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.order-foot .carry { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.room { display: inline-block; width: 90px; height: 8px; border-radius: 4px; background: #e2d4b0; box-shadow: inset 0 0 0 1px #c8b48a; overflow: hidden; }
.room i { display: block; height: 100%; background: linear-gradient(#b58654, #8a5a34); }
.order-foot .total:empty { visibility: hidden; }
.cc-seen { margin: 0 0 6px; font-size: 12px; color: var(--ink-soft); }
.trip-box dl { margin-top: 2px; }
.flog .day { color: #6a7a52; font-size: .78em; letter-spacing: .12em; text-transform: uppercase; border-top: 1px solid rgba(74, 90, 58, .25); margin-top: 4px; padding-top: 2px; }

/* Snappier: pages and scenes change faster, and buttons answer on press. */
.page.enter, .tab-body.enter { animation-duration: .16s; }
.stage-art.leaving { animation-duration: .5s; }
.title-card-black { animation-duration: .2s; }
.title-card-black.out { animation-duration: .35s; }
button:not(:disabled):active, .pill:not(:disabled):active { transform: translateY(1px) scale(.97); transition: transform .04s; }
/* Depth: haze between the far hills and the near land, and a soft vignette. */
.st-haze { inset: 0; pointer-events: none; }
.st-vignette { inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 55%, transparent 58%, rgba(20, 12, 6, .22) 100%); }
.time-night .st-haze { opacity: .35; }
.local-line { margin: 0 0 10px; font-size: 14px; color: var(--ink-soft); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.local-line b { color: var(--ink); font-size: 16px; }
.unit .dismiss { margin-left: 6px; padding: 0 7px; line-height: 18px; font-size: 14px; }
.unit .lvl { font-size: 12px; color: var(--ink-soft); }

/* ---------------------------------------------------------------- permits, routes, fittings, tiers */

.link-btn { all: unset; cursor: pointer; font-size: 12.5px; color: var(--gold-deep); text-decoration: underline; margin: 6px 2px 0; display: inline-block; }
.locked { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.fittings { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.fitting { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; padding: 8px 10px; border-radius: 6px; background: #fffaf0; border: 1px solid var(--parch-3); color: var(--ink); }
.fitting small { grid-column: 1; color: var(--ink-soft); font-size: 12px; line-height: 1.35; }
.fitting button, .fitting .owned { grid-row: 1 / span 2; grid-column: 2; }
.fitting.have { opacity: .75; }
.permit { padding: 8px 12px; margin-bottom: 8px; border-radius: 6px; background: #fffaf0; border: 1px solid var(--parch-3); color: var(--ink); }
.permit-head { display: flex; align-items: center; gap: 10px; }
.permit-head span { color: var(--ink-soft); font-size: 12.5px; flex: 1; }
.permit .tasks { list-style: none; margin: 6px 0 4px; padding: 0; font-size: 13.5px; display: grid; gap: 3px; }
.permit .tasks li.done { color: var(--green); }
.permit small { color: var(--ink-soft); font-size: 12px; }
.permit.closed { background: transparent; }
.permit-list summary { cursor: pointer; font-size: 13.5px; color: var(--ink-soft); margin: 4px 0 8px; }
.permit-held { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.badge-permit { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: #d5e8c8; color: #2f5a24; }
.route-row { display: flex; align-items: center; gap: 12px; padding: 7px 10px; margin-bottom: 6px; border-radius: 6px; background: #fffaf0; border: 1px solid var(--parch-3); color: var(--ink); font-size: 13.5px; }
.route-row span { flex: 1; color: var(--ink-soft); }
.route-row.offer { background: transparent; border-style: dashed; }
.perk.talent { background: #f4e3c0; color: #6a3a14; cursor: help; }
.route-row .raid { color: var(--red); font-style: normal; }
.unit .train { margin-left: 6px; padding: 0 8px; line-height: 18px; font-size: 11.5px; }

/* ---------- flow: a lone Go fills up and presses itself at ×5 and up */
.pill.auto-go { position: relative; overflow: hidden; isolation: isolate; }
.pill.auto-go::after {
    content: ""; position: absolute; inset: 0; z-index: -1; transform-origin: left;
    background: linear-gradient(#f0cf78, #d3a23a);
    animation: auto-fill var(--auto-ms, 1500ms) linear var(--auto-at, 0ms) both;
}
@keyframes auto-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .pill.auto-go::after { animation: none; } }
.pill.queued { outline: 3px solid #e9c46a; outline-offset: 2px; }
.pill[data-act=auto].on { background: linear-gradient(#e9c46a, #c9952c); }
.route .load { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 2px 0 10px; font-size: 13px; color: var(--ink-soft); }
.route .load .pill { display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; padding: 4px 14px; }
.route .load.none { font-style: italic; }
.resale a { color: inherit; text-decoration: underline dotted; text-underline-offset: 2px; }

/* ---------------------------------------------------------------- declutter, round three */

/* The Cost column only once something is on order. */
table.trade.no-cost .cost { display: none; }
table.trade td.num, table.trade .own, table.trade .good { white-space: nowrap; }
table.trade .good sup[title] { cursor: help; }

/* On a touchscreen a row shows [qty][+] until you order some; then − and Max. */
@media (pointer: coarse) {
    table.trade tbody tr:not(.ordering):not(:focus-within) .stepper-cell { grid-template-areas: "in up"; grid-template-columns: 52px 38px; }
    table.trade tbody tr:not(.ordering):not(:focus-within) .stepper-cell .updown .tiny:last-child,
    table.trade tbody tr:not(.ordering):not(:focus-within) .stepper-cell .maxnone .tiny { display: none; }
}

/* Journal: the latest three lines; the rest fold away. */
.log details summary { cursor: pointer; font-size: 12px; color: var(--gold); margin: 2px 0 4px; list-style: none; }
.log details summary::before { content: "▸ "; }
.log details[open] summary::before { content: "▾ "; }

/* Phone header: two rows. Place and day with the menu; then the purse,
   the hold, standing and your level. Your name is on the Party page. */
@media (max-width: 600px) {
    .head { display: grid; grid-template-columns: auto auto auto 1fr; grid-template-areas: "place place place meta" "gold cargo rep who"; gap: 2px 12px; align-items: center; }
    .head .place { grid-area: place; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
    .head .place.long { font-size: 16px; }
    .head > .stat:nth-of-type(1) { grid-area: gold; }
    .head > .stat:nth-of-type(2) { grid-area: cargo; }
    .head > .stat:nth-of-type(3) { grid-area: rep; }
    .head .stat { font-size: 15px; white-space: nowrap; }
    .head .meta { grid-area: meta; width: auto; order: 0; gap: 12px; justify-self: end; }
    .head .who { grid-area: who; justify-self: end; gap: 6px; font-size: 13px; }
    .head .who > b:first-child { display: none; }
    .head .who { white-space: nowrap; }
    .head .who .xpbar { display: none; }
    .head .who .small { padding: 2px 8px; font-size: 12px; white-space: nowrap; }
}

/* Fittings and town works: name and price on one line, what it does under
   it across the card, so every card lines up. */
.fittings { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.fitting { grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; align-items: start; gap: 4px 10px; padding: 9px 12px; }
.fitting b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: center; }
.fitting button, .fitting .owned { grid-row: 1; grid-column: 2; }
.fitting small { grid-column: 1 / -1; }

/* Guilds you have not joined: one line each. */
.guild-choices.compact { gap: 8px; margin-bottom: 8px; }
.guild-choices.compact .guild-choice { align-items: center; gap: 12px; padding: 8px 12px; }
.guild-choices.compact .guild-choice > div { flex: 1; min-width: 0; }
.guild-choices.compact .guild-choice b { display: block; font-size: 15px; }
.guild-choices.compact .guild-choice small { display: block; font-size: 12.5px; color: var(--ink-soft); line-height: 1.35; }
.guild-choices.compact .guild-choice .hint { margin-top: 2px; font-style: italic; }
.standing { display: flex; gap: 22px; margin: 4px 2px 10px; font-size: 14px; color: var(--ink-soft); }
.standing span { display: inline-flex; align-items: center; gap: 6px; cursor: help; }
.standing b { color: var(--ink); }
.guild-level small { font-size: 12.5px; color: var(--ink-soft); font-weight: 500; }
.toast { cursor: pointer; }

/* Deed-made kit: its knack under the name, and the lock that says how to earn it. */
.kit-note { display: block; font-size: 11.5px; color: var(--ink-soft); font-weight: 400; line-height: 1.3; margin-top: 1px; white-space: normal; }
.kit-perk { margin: -2px 0 8px; font-size: 12.5px; color: var(--ink-soft); }
.locked.deed { color: #7a5a1a; }
.locked small { font-variant-numeric: tabular-nums; opacity: .85; }
.fitting .locked { grid-row: 1; grid-column: 2; }
.fitting.is-locked { background: #f6efe0; }
.fitting.is-locked b { opacity: .7; }
.ach .ach-opens { display: block; margin-top: 3px; font-size: 11px; color: #7a5a1a; }
.barrow.bolt { stroke: #3a2618; stroke-width: 4; fill: #9aa0a8; }
.barrow.bomb { stroke: #3a2618; stroke-width: 2; fill: #7ad05a; }
.bnum.fire { fill: #ff9a3a; }
/* Faces: a little bigger in the tavern, where you're choosing who to hire. */
.card.recruit .icon { width: 54px; flex: none; }
.card.recruit .icon .portrait.face { width: 54px; height: 58px; }
.hunts .fitting small i { color: #8a5a2a; font-style: normal; }
/* The Compass, the secret lodge: dark and quiet, gold mark. */
.lodge { background: #2b2620; color: #e8dcc0; border-radius: 8px; padding: 12px 14px; border: 1px solid #4a4034; }
.lodge-head { display: flex; gap: 12px; align-items: center; }
.lodge-head b { font-size: 18px; color: #f0d890; display: block; }
.lodge-head small { color: #c8bca4; font-size: 12.5px; }
.lodge-perks { list-style: none; margin: 10px 0 6px; padding: 0; display: block; font-size: 13px; color: #d8ccb4; }
.lodge-perks li { display: block; white-space: normal; margin: 2px 0; }
.lodge-perks li.locked { opacity: .62; }
.lodge-perks b { color: #f0e2bc; }
.lodge-work { margin: 6px 0 0; font-size: 13.5px; color: #f0e2bc; }
.lodge .ghost { color: #f0e2bc; border-color: #6a5a44; }

/* Shipyard: the craft line, materials against what you carry, built refits. */
.craft-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 13.5px; margin-bottom: 8px; }
.craft-line span { flex: 1; min-width: 200px; color: var(--ink-soft); }
.craft-line i { color: #8a5a2a; font-style: normal; }
.mat { white-space: nowrap; font-variant-numeric: tabular-nums; }
.mat.short { color: #8a3a2a; }
.fitting small.mats { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; }
.have-line { font-size: 13px; color: var(--ink-soft); margin: 0 0 8px; }
.have-line span { white-space: nowrap; margin-right: 8px; color: #4a6a3a; cursor: help; }
.recruit .rstats > span:not(.perk) { white-space: nowrap; }
.recruit .rstats .wage { color: var(--ink-soft); }
.recruit .rstats .wage::before { content: "· "; }
@media (max-width: 600px) { .fittings.town-works { grid-template-columns: 1fr 1fr; } .town-works .fitting b { white-space: normal; } }
