:root{color-scheme:dark;--ink:#faf1d9;--muted:#c2b9a4;--gold:#eaca83;--border:#625337;--panel:#211d18}
*{box-sizing:border-box}
body{margin:0;background:radial-gradient(ellipse at 30% 0,#363123,#131210 66%);color:var(--ink);font:1rem/1.45 system-ui,sans-serif;min-height:100dvh}
.play-screen>header{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:8px;padding:4px 12px;border-bottom:1px solid var(--border);background:#15130f}
.play-screen h1{font:700 clamp(1.4rem,4vw,2rem)/1.1 Georgia,serif}
.play-screen>header a{width:fit-content}
.header-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px}
.header-actions button{padding-inline:8px}
.eyebrow,.factions span{font-size:.78rem;font-weight:700;letter-spacing:.12em;color:var(--gold)}
a{color:var(--ink);text-underline-offset:4px}
main{padding-bottom:32px}
h1,h2,p{margin:0}
#field-guide{max-width:1200px;margin-inline:auto;padding-inline:12px}
.campaign{display:grid;grid-template-columns:minmax(0,1fr) minmax(265px,335px);gap:12px;align-items:start;margin-top:12px}
.map-pane{min-width:0}
.command-bar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:4px 12px;padding:4px 8px;background:#201b15;border-bottom:1px solid var(--border)}
.map-toolbar{display:flex;align-items:center;gap:6px;padding:4px 8px;background:#2b2219;border-bottom:1px solid var(--border)}
.map-brief{flex:1;min-width:0}
.map-toolbar button{min-height:36px;padding:4px 9px;font-size:.875rem}
.army-stats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px}
.army-stat-card{padding:3px 6px;background:#181612;border:1px solid var(--border);border-inline-start:3px solid #8bc6c9;border-radius:3px;font-size:.8125rem;line-height:1.25}
.army-stat-card+.army-stat-card{border-inline-start-color:#e68378}
.army-stat-card dl{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px;margin:2px 0 0}
.army-stat-card dt{color:var(--muted);font-size:.75rem}
.army-stat-card dd{margin:0;font-weight:700;font-variant-numeric:tabular-nums}
#status{padding:2px 4px;font-size:.875rem}
.battle{padding:8px 10px;background:#201b15;border:1px solid var(--border);color:var(--ink);font-size:.9rem}
.battle{min-height:52px;color:var(--muted)}
.battle strong{display:block;color:var(--gold)}
.battle-dice{margin-top:6px}
#battle-dice-rows:not([hidden]){display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-top:8px}
#battle-dice-rows span{font-weight:700;font-size:.84rem}
.dice-row{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}
.battle-face{display:grid;place-items:center;min-width:31px;height:31px;border:1px solid #8a7353;border-radius:5px;background:#ead5a1;color:#342719;font-size:.95rem;font-variant-numeric:tabular-nums}
.battle-face.best{outline:2px solid #eaca83;outline-offset:0}
.cell .dice-odds{position:absolute;z-index:3;bottom:1px;right:1px;padding:1px 3px;background:#691f22;color:#fff7df;border-radius:2px;font-size:clamp(.52rem,2.4cqw,.78rem);line-height:1.2;white-space:nowrap}
.cell.attack .stack-count{bottom:calc(clamp(.48rem,1.8cqw,.74rem) * 1.45 + 1px);right:auto;left:1px}
.cell.last-from{border:2px dashed #65533d}
.cell.last-to{border:2px solid #6f3818}
.cell.last-from.selected,.cell.last-to.selected{border-color:#fff6d3}
#board{width:100%;aspect-ratio:12/10;display:grid;grid-template-columns:repeat(12,minmax(0,1fr));grid-template-rows:repeat(10,minmax(0,1fr));container-type:inline-size}
#board::before{content:"";grid-area:2 / 3 / span 8 / span 8;background:#d5b17a url("territory-map.svg") center/100% 100% no-repeat;pointer-events:none}
.map-name{color:var(--gold);font-size:.875rem;font-weight:700}
#last-move{color:var(--muted);font-size:.8125rem;overflow-wrap:anywhere}
#last-move:empty{display:none}
.map-key{display:flex;flex-wrap:wrap;gap:4px 14px;padding:6px 8px;background:#201b15;color:var(--muted);font-size:.875rem}
.map-key span:not(:last-child)::before{content:"";display:inline-block;width:10px;height:10px;margin-right:5px}
.key-selected::before{border:2px solid #fff8e3}.key-move::before{background:#ffe285;border-radius:50%}.key-attack::before{border:2px dashed #ff8d80}
.map-frame{position:relative;isolation:isolate;background:repeating-linear-gradient(166deg,#45625c18 0 1px,transparent 2px 15px),radial-gradient(ellipse at center,#2b4540,#141f1d 78%)}
.map-surface{position:relative;margin-inline:auto}
.map-coastline{display:block;position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.map-coastline path{fill:none;stroke:#81562d;stroke-width:4;stroke-linecap:round;vector-effect:non-scaling-stroke}
button,select{font:inherit;background:#30271d;color:var(--ink);border:1px solid #837050;border-radius:3px;padding:7px 11px;min-height:40px}
button:not(:disabled){cursor:pointer;touch-action:manipulation}
button:disabled:not(.cell),select:disabled{opacity:.48}
:focus-visible{outline:3px solid #fff;outline-offset:-3px}
.cell{min-width:0;min-height:0;position:relative;padding:0;display:grid;place-items:center;border:1px solid #63462545;border-radius:0;background:transparent;color:#15110b;overflow:hidden}
.cell.dark{background:#613b1911}
.cell.ivory{background:#4daaa052;border-color:#224f4d65}.cell.ivory.dark{background:#31898468}
.cell.crimson{background:#bb554c56;border-color:#6d342964}.cell.crimson.dark{background:#a0443c69}
.cell.wing{background-color:#d5b17a;background-image:radial-gradient(ellipse at 45% 40%,#ffe7ab45,transparent)}
.cell.wing.dark{background-color:#c9a16b}
.cell.wing.ivory{background-color:#a3b18b}.cell.wing.ivory.dark{background-color:#92a782}
.cell.wing.crimson{background-color:#c88e6c}.cell.wing.crimson.dark{background-color:#bf8162}
.cell.wing.woods{background-image:radial-gradient(ellipse at 45% 50%,#62794f73,transparent 66%)}
.cell.wing.river{background-image:linear-gradient(171deg,transparent 28%,#785c3b70 29% 34%,#7b9b97 35% 51%,#d7e3c7 52% 55%,#7b9b97 56% 62%,#785c3b70 63% 67%,transparent 68%)}
.cell.wing.ridge{background-image:linear-gradient(135deg,transparent 35%,#6d51376e 36% 42%,#f7ddb17a 43% 60%,transparent 61%)}
.cell.wing.village{background-image:radial-gradient(ellipse,#f4dc9fa8 25%,transparent 72%)}
.cell small{position:absolute;left:2px;bottom:0;font-size:clamp(.48rem,1.8cqw,.74rem);font-weight:700;color:#120f09;background:#f7e4bcaa;padding:0 2px;border-radius:2px}
.unit-role,.stack-count{position:absolute;z-index:1;font-size:clamp(.58rem,2.1cqw,.83rem);font-weight:800;line-height:1.15}
.map-symbol{align-self:start;justify-self:end;z-index:4;display:grid;place-items:center;width:clamp(16px,4.9cqw,28px);height:clamp(16px,4.9cqw,28px);min-height:0;margin:2px;padding:0;border-radius:4px;border:1px solid #654620;background:#f9e2ae;color:#533916;font-size:clamp(.7rem,2.8cqw,1rem);font-weight:800;line-height:1}
.map-symbol.seal{background:#8d3c2d;color:#ffedbb;border-color:#f5d198}
.map-symbol:focus-visible{outline-color:#130d07;outline-offset:1px}
.unit-role{top:2px;left:2px;background:#201e17;color:#fff1cb;padding:0 2px;border-radius:2px}
.stack-count{right:1px;bottom:1px;background:#201e17;color:#fff5db;padding:1px 2px;border-radius:2px}
.piece{width:91%;height:91%;pointer-events:none;filter:drop-shadow(0 1px 1px #fff2cf9c)}
.cell.selected{box-shadow:inset 0 0 0 2px #20170e,inset 0 0 0 5px #fff8e3}
.cell.target{box-shadow:inset 0 0 0 2px #ffe285}
.cell.attack{box-shadow:inset 0 0 0 2px #66211e}
.cell.target::after{content:"";width:max(7px,18%);aspect-ratio:1;background:#fff0a1;border:1px solid #433000;border-radius:50%;position:absolute;left:4px;bottom:28%;pointer-events:none;z-index:2}
.cell.attack::after{content:"";position:absolute;inset:2px;border:2px dashed #ff9386;pointer-events:none;z-index:2}
.map-dialog{width:min(440px,calc(100% - 24px));max-height:calc(100dvh - 24px);padding:16px;border:1px solid #a98c56;border-radius:6px;background:var(--panel);color:var(--ink);box-shadow:0 8px 40px #0009}
.map-dialog::backdrop{background:#0c0906aa}
.map-dialog h2{font:700 1.45rem Georgia,serif}
.map-dialog p,.map-dialog details{margin-top:8px}
.map-dialog p:not(.attack-chance){color:var(--muted)}
.campaign-dialog{width:min(780px,calc(100% - 24px))}
.campaign-heading{display:flex;justify-content:space-between;align-items:center;gap:8px}
.attack-chance{color:var(--gold);font-weight:800}
.dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}
#stack-controls:not([hidden]){display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;background:#2d241a;padding:6px 8px;border:1px solid var(--border)}
#march{width:5rem;font:inherit;color:var(--ink);background:#30271d;border:1px solid #837050;padding:5px}
.stack-presets{display:flex;gap:4px;flex-wrap:wrap}.stack-presets button{min-height:36px;padding:4px 8px}.stack-presets button[aria-pressed="true"]{background:#eaca83;color:#21180c}
#march-preview{min-width:0;color:var(--muted);font-size:.85rem}
.cell.limited{box-shadow:inset 0 0 0 2px #855527}
#multiplayer button{margin-top:6px}
#join-room{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:7px}
#invite-code{width:7.5rem;min-height:40px;padding:5px;background:#30271d;color:var(--ink);border:1px solid #837050;text-transform:uppercase}
#join-room button{margin-top:0}
.terrain-legend{padding-left:18px;margin:5px 0 0;color:var(--muted);font-size:.88rem}
#move-history{max-height:min(460px,65dvh);overflow:auto;overscroll-behavior:contain;margin:6px 0 0;padding:0;list-style:none}
#move-history:empty{display:none}
#move-history li+li{margin-top:4px}
.history-entry{display:block;width:100%;text-align:left}
.history-entry:hover{border-color:var(--gold)}
.history-entry strong{display:block;color:var(--gold);font-size:.85rem}
.history-entry b{display:block;color:var(--ink);font-size:.95rem}
#history-action #history-round{margin:0 0 4px;color:var(--gold)}
#history-map{width:100%;max-height:33dvh;display:block;margin-top:12px;background:#192924;border:1px solid var(--border);border-radius:4px}
#history-tiles{fill:#a08259}
#history-markers line{stroke:#fff3c6;stroke-width:.09;stroke-dasharray:.19 .11}
.history-from{fill:#18312d;stroke:#c9f4e0;stroke-width:.12}
.history-target{fill:#f1c360;stroke:#35271c;stroke-width:.12}
.history-target.enemy{fill:#a02f31;stroke:#ffe1d5}
#undo-status:empty{display:none}
#undo-response:not([hidden]){display:flex;flex-wrap:wrap;gap:6px}
#undo-status{color:var(--muted);font-size:.875rem}
#field-guide{margin-top:26px;scroll-margin-top:12px}
#field-guide>p:not(.eyebrow){margin:5px 0 12px;color:var(--muted)}
.guide-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.guide-grid h3{margin:6px 0;font-size:1rem;color:var(--ink)}
.guide-grid p{color:var(--muted)}
.guide-grid p+p{margin-top:7px}
.guide-art{display:block;width:100%;height:92px;background:#31271b;border:1px solid #625337;border-radius:3px}
.guide-art .paper{fill:#ead5a1}.guide-art .coin,.guide-art .gold{fill:#eaca83;stroke:#553b1e;stroke-width:2}
.guide-art .teal{fill:#407f75;stroke:#9ac9ad}.guide-art .red{fill:#8e4944;stroke:#e29a7c}
.guide-art .pips{stroke:#4c3723;stroke-width:6;stroke-linecap:round}.guide-art .route{stroke:#eaca83;stroke-width:3;fill:none}
.guide-art text{fill:#fff8e2;stroke:#211a15;stroke-width:2px;paint-order:stroke;text-anchor:middle;font:700 18px Georgia,serif}
@media(max-width:530px){.guide-grid{grid-template-columns:1fr}}
aside{display:grid;gap:9px}.panel,.factions>div{padding:10px;background:var(--panel);border:1px solid var(--border);border-radius:4px}
.factions{display:grid;grid-template-columns:1fr 1fr;gap:6px}.factions strong{display:block;font-size:.87rem;margin-top:3px}.factions>div:first-child{border-top:3px solid #8bc6c9}.factions>div:last-child{border-top:3px solid #e68378}
.turn,.supply-control,.roll,.turn-actions{display:flex;align-items:center;gap:6px}
.turn{flex-wrap:wrap}
.roll{color:var(--muted);font-size:.85rem}
#die{display:grid;place-items:center;flex:none;width:34px;height:34px;border-radius:6px;background:var(--ink);color:#20160f;font-size:1.2rem}
.primary{background:var(--gold);border-color:var(--gold);color:#23180a;font-weight:800}.recruit{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px}
summary{cursor:pointer;font-weight:700;color:var(--gold)}details.panel p{margin-top:8px;color:var(--muted)}#forts{padding:0;margin:6px 0 0;list-style:none}#forts li{padding:5px 0;border-top:1px solid #62533766}#forts span{display:block;font-size:.86rem;color:var(--muted)}
@media(orientation:landscape){
  .play-screen{display:flex;flex-direction:column;height:100vh;height:100dvh;min-height:360px}
  .play-screen>header{flex:none}
  .map-pane{flex:1;min-height:0;display:flex;flex-direction:column}
  .command-bar,.map-toolbar,#stack-controls{flex:none}
  .map-frame{flex:1;min-height:0;container-type:size}
  .map-surface{width:min(100%,190cqh);height:100%}
  #board{height:100%;aspect-ratio:auto}
}
@media(orientation:landscape) and (max-height:500px){
  .map-surface{width:min(100%,220cqh)}
  .command-bar button,.command-bar select{min-height:36px}
}
@media(orientation:portrait) and (max-width:650px){
  .play-screen{display:flex;flex-direction:column;height:100vh;height:100dvh}
  .play-screen>header,.command-bar,.map-toolbar,#stack-controls{flex:none}
  .map-pane{flex:1;min-height:0;display:flex;flex-direction:column}
  .map-frame{flex:1;min-height:min(83.333vw,32dvh)}
  .map-surface{width:100%;height:100%}
  #board{height:100%;aspect-ratio:auto}
}
@media(max-width:820px){.campaign{grid-template-columns:minmax(0,1fr);gap:8px}.battle{min-height:0}}
@media(max-width:620px){.map-toolbar{display:grid;grid-template-columns:minmax(0,1fr) auto auto}.army-stats{grid-column:1/-1;grid-row:2}}
@media(max-width:530px){
  .play-screen>header{padding-inline:6px;font-size:.875rem}
  .header-actions{gap:6px}
  .turn button,.turn select{padding-inline:7px;font-size:.875rem}
  .command-bar,.map-toolbar{padding-inline:5px}
  .map-coastline path{stroke-width:3}
}
