:root {
  color-scheme: dark;
  --ink:#131a17; --surface:#1d2722; --surface2:#25312a; --muted:#adbaad;
  --paper:#f5ecd7; --gold:#e9bd71; --gold2:#f3d49c; --rim:#3e4a3d; --danger:#f3a491;
  --sans:system-ui,-apple-system,sans-serif; --serif:Georgia,'Times New Roman',serif;
}
* { box-sizing:border-box; }
body { margin:0; min-width:320px; min-height:100vh; background:radial-gradient(ellipse at 30% 0%,#27352c 0%,transparent 53%),var(--ink); color:var(--paper); font:1rem/1.45 var(--sans); }
button,input,select { font:inherit; }
button,select { cursor:pointer; }
button:disabled { cursor:default; opacity:.47; }
button:focus-visible,select:focus-visible,input:focus-visible { outline:2px solid #ffda89; outline-offset:3px; }
h1,h2,h3,p { margin:0; }
h1,h2,h3 { font-family:var(--serif); font-weight:600; }
h1 { font-size:clamp(2rem,4.5vw,4rem); line-height:1.04; letter-spacing:-.035em; }
h2 { font-size:clamp(1.35rem,2vw,1.9rem); line-height:1.13; }
h3 { font-size:1.06rem; }
small { font-size:.8rem; }
.masthead { display:flex; align-items:center; justify-content:space-between; padding:.75rem clamp(1rem,4vw,4rem); min-height:72px; background:#111814eb; border-bottom:1px solid var(--rim); }
.brand { display:flex; align-items:center; gap:.72rem; padding:0; color:var(--paper); border:none; background:none; text-align:left; font:600 clamp(.96rem,2vw,1.28rem)/1.1 var(--serif); }
.brand small { display:block; margin-top:.28rem; color:var(--muted); font:500 .75rem var(--sans); letter-spacing:.025em; }
.insignia { display:grid; place-items:center; width:39px; height:42px; border:1px solid #947641; border-radius:4px 4px 10px 10px; background:#372d20; color:var(--gold2); font-size:1.65rem; }
.header-actions { display:flex; align-items:center; justify-content:flex-end; flex-shrink:0; gap:.65rem; }
#language { width:auto; min-width:92px; font-size:.85rem; }
.connection { color:var(--muted); font-size:.85rem; }
#main { max-width:1510px; margin:0 auto; padding:clamp(.8rem,2vw,1.75rem) clamp(.8rem,3.6vw,3.4rem) 2rem; }
.eyebrow { color:var(--gold); text-transform:uppercase; font-size:.75rem; font-weight:750; letter-spacing:.16em; }
.muted { color:var(--muted); }
.stack { display:grid; gap:.85rem; }
.stack-sm { display:grid; gap:.5rem; }
.row { display:flex; align-items:center; gap:.55rem; flex-wrap:wrap; }
.between { justify-content:space-between; }
.quiet,.secondary,.primary,.option,.danger { padding:.57rem .86rem; border:1px solid var(--rim); border-radius:6px; color:var(--paper); font-size:.9rem; font-weight:650; background:#1b2520; min-height:40px; }
.quiet { color:var(--muted); background:transparent; }
.secondary { background:#28352d; }
.primary { color:#1d1b13; background:linear-gradient(#f3d193,#deb16b); border-color:#efc887; }
.danger { color:var(--danger); background:#342420; border-color:#654135; }
.quiet:hover,.secondary:hover,.option:hover,.danger:hover { border-color:#b39864; color:var(--paper); }
.primary:hover { background:var(--gold2); }
.wide { width:100%; }
.setup-grid,.game-grid { display:grid; grid-template-columns:minmax(0,1fr) minmax(280px,350px); gap:1.15rem; align-items:start; }
.intro { display:grid; align-content:start; gap:1rem; }
.intro h1 { max-width:16ch; }
.intro-copy { color:#d4d8c7; max-width:58ch; }
.card { background:var(--surface); border:1px solid var(--rim); border-radius:9px; padding:1rem; min-width:0; box-shadow:0 12px 28px #090c0933; }
.card-head { padding-bottom:.8rem; border-bottom:1px solid var(--rim); }
.setup-card { display:grid; gap:.9rem; }
.mode,.segments { display:grid; grid-auto-flow:column; grid-auto-columns:1fr; gap:4px; background:#121b16; border:1px solid var(--rim); border-radius:8px; padding:4px; }
.mode button,.segments button { background:none; border:1px solid transparent; border-radius:5px; padding:.5rem .35rem; color:var(--muted); font-size:.86rem; min-height:37px; }
.mode button[aria-pressed=true],.segments button[aria-pressed=true] { background:#334237; color:var(--paper); border-color:#65775e; }
.scenario-choice,.tactic { width:100%; display:grid; gap:.12rem; text-align:left; }
.option[aria-pressed=true] { background:#423722; border-color:#bf9a56; color:#ffe4ac; }
.option small,.tactic small { display:block; color:var(--muted); font-weight:450; }
.field { display:grid; gap:.3rem; color:var(--muted); font-size:.86rem; }
input,select { width:100%; background:#141e18; border:1px solid #465647; color:var(--paper); min-height:39px; padding:.42rem .52rem; border-radius:5px; }
select { appearance:none; padding-right:1.55rem; background-image:linear-gradient(45deg,transparent 50%,#c5d2bf 50%),linear-gradient(135deg,#c5d2bf 50%,transparent 50%); background-position:calc(100% - 12px) 53%,calc(100% - 7px) 53%; background-size:5px 5px; background-repeat:no-repeat; }
.seat-row { display:grid; grid-template-columns:minmax(0,1fr) minmax(96px,45%); align-items:center; gap:.55rem; }
.house { display:inline-flex; align-items:center; min-width:0; gap:.43rem; color:var(--paper); font-size:.9rem; }
.house b { display:inline-grid; place-items:center; flex:0 0 1.65rem; min-height:1.65rem; border-radius:4px; background:var(--house-color); color:#fff7e1; font-size:.89rem; }
.house span { text-overflow:ellipsis; overflow:hidden; white-space:nowrap; }
.atlas { background:#172b28; border:1px solid #6f7253; border-radius:10px; overflow:hidden; box-shadow:0 20px 38px #090f0b55; }
.map-shell { position:relative; aspect-ratio:1000/650; isolation:isolate; }
.map-shell canvas { display:block; width:100%; height:100%; }
.map-actions { position:absolute; inset:0; pointer-events:none; }
.map-node { position:absolute; left:calc(var(--x)*1%); top:calc(var(--y)*1%); transform:translate(-50%,-47%); pointer-events:auto; min-width:40px; min-height:40px; width:clamp(40px,5.45vw,86px); border:0; border-radius:10px; display:grid; justify-items:center; align-content:center; gap:2px; background:transparent; color:#fff4d0; text-shadow:0 1px 3px #131611, 0 0 6px #131611; line-height:1; padding:2px; }
.map-node:disabled { opacity:1; cursor:default; }
.map-node:not(:disabled):hover .marker,.map-node.selected .marker { box-shadow:0 0 0 2px #ffdd94, 0 0 0 6px #281d15b3; }
.map-node.target .marker { box-shadow:0 0 0 2px #fff1a2,0 0 0 6px #c78b3bb5; animation:targetpulse 1.7s ease-in-out infinite alternate; }
@keyframes targetpulse { to { box-shadow:0 0 0 3px #fff1a2,0 0 0 9px #c78b3b51; } }
.marker { display:inline-flex; align-items:center; justify-content:center; gap:.22rem; font-size:clamp(.72rem,1.3vw,1rem); min-width:32px; min-height:25px; padding:.18rem .3rem; border:1px solid #e4d9a789; border-radius:16px; background:var(--map-color,#333a2d); color:#fff4d0; box-shadow:0 2px 5px #181b0fbf; }
.map-name { display:block; width:max-content; max-width:115px; padding:.11rem .22rem; border-radius:3px; background:#17221bb0; font:700 clamp(.61rem,1.05vw,.8rem)/1 var(--sans); white-space:nowrap; }
.place-mini { display:none; }
.map-node.cut .marker { border-color:#fed18c; border-style:dashed; }
.map-node.crown .marker { border-color:#f9c77c; }
.map-caption { padding:.55rem .8rem; background:#19251f; border-top:1px solid #6f7253; display:flex; justify-content:space-between; gap:.4rem 1rem; align-items:center; flex-wrap:wrap; color:var(--muted); font-size:.85rem; }
.legend-key { color:var(--gold2); font-weight:650; }
.statusbar { padding:.65rem .8rem; background:var(--surface); border:1px solid var(--rim); border-radius:7px; display:flex; gap:.5rem 1.05rem; flex-wrap:wrap; align-items:center; margin-bottom:.9rem; }
.statusbar strong { color:var(--gold2); }
.turn-time { color:#e7dec4; margin-left:auto; font-variant-numeric:tabular-nums; }
.turn-time.urgent { color:var(--danger); }
.houses-strip { display:flex; gap:.4rem; flex-wrap:wrap; }
.house-chip { display:flex; gap:.37rem; align-items:center; padding:.33rem .55rem; border-radius:5px; border:1px solid var(--rim); background:#17201b; font-size:.85rem; }
.house-chip[data-ready=true] { border-color:#738661; }
.house-chip[data-eliminated=true] { opacity:.55; }
.house-chip .mark { font-size:1em; color:var(--house-light); }
.house-chip small { color:var(--muted); }
.sidebar { display:grid; gap:.8rem; }
.province-stats { display:flex; align-items:center; flex-wrap:wrap; gap:.35rem; }
.unit-pill { padding:.22rem .43rem; border:1px solid var(--rim); border-radius:4px; color:#e8e1cb; background:#171e19; font-size:.84rem; }
.unit-pill b { color:var(--gold2); }
.unit-slider { display:grid; grid-template-columns:7rem minmax(40px,1fr) 1.4rem; align-items:center; font-size:.84rem; gap:.35rem; }
.unit-slider input { min-height:32px; padding:0; accent-color:var(--gold); }
.order-row { display:flex; align-items:center; justify-content:space-between; gap:.45rem; padding:.45rem .5rem; background:#141e18; border:1px solid #39483b; border-radius:5px; font-size:.87rem; }
.order-row button { padding:.18rem .48rem; min-height:29px; }
.panel-title { display:flex; align-items:center; justify-content:space-between; gap:.5rem; }
.tag { font-size:.74rem; font-weight:700; color:#c8d6c3; border:1px solid #566950; border-radius:4px; padding:.17rem .33rem; white-space:nowrap; }
.tag.cut { color:#ffcd9f; border-color:#87643e; }
.tag.gold { color:var(--gold2); border-color:#8b754a; }
.detail { font-size:.87rem; color:var(--muted); }
.feed { padding:.8rem 1rem; }
.feed summary { cursor:pointer; font:600 1.05rem var(--serif); }
.feed ol { margin:.45rem 0 0; padding-left:1.15rem; color:#c5cfc1; font-size:.85rem; max-height:12rem; overflow:auto; }
.feed li { padding:.27rem 0; }
.field-note { padding:.55rem .62rem; color:#e8d8b5; background:#352f22; border-left:2px solid #b59150; border-radius:2px; font-size:.86rem; }
.blank,.lobby { max-width:720px; margin:clamp(.5rem,3vw,2.5rem) auto 0; }
.lobby h1 { font-size:clamp(2rem,4vw,3.1rem); }
.lobby .card { padding:clamp(1rem,3vw,1.75rem); }
.lobby-seat { padding:.55rem 0; border-bottom:1px solid var(--rim); }
.code { font-family:ui-monospace,monospace; color:var(--gold2); padding:.38rem .65rem; border:1px solid #736344; border-radius:5px; background:#242118; letter-spacing:.14em; font-size:1.25rem; }
.join-form { display:grid; gap:.7rem; }
.battle-layout .atlas { opacity:.9; }
.battlefield { display:grid; gap:.66rem; padding:clamp(.75rem,2vw,1.4rem); background:radial-gradient(ellipse at 50% 36%,#4a493360 0%,transparent 75%),var(--surface); }
.duel { display:grid; grid-template-columns:1fr auto 1fr; gap:.5rem; align-items:center; text-align:center; }
.duel .row { justify-content:center; }
.duel strong { font-size:1.32rem; color:var(--gold2); }
.field-lanes { display:grid; grid-template-columns:repeat(3,1fr); gap:.4rem; min-height:clamp(100px,17vw,188px); background:repeating-linear-gradient(168deg,#343f2f 0px,#343f2f 2px,#2c362a 3px,#2c362a 9px); padding:.5rem; border:1px solid #6a6a45; border-radius:6px; }
.field-lanes button { display:flex; flex-direction:column; justify-content:space-between; align-items:center; gap:.28rem; min-width:0; background:linear-gradient(40deg,#60704b25,#15231a66); color:#f3e9cb; border-color:#69785a; padding:.45rem .12rem; font-size:clamp(.74rem,2vw,.93rem); }
.field-lanes button[aria-pressed=true] { background:#a17d396e; }
.lane-symbol { font-size:clamp(1.5rem,4vw,3rem); color:#e9c989; line-height:1.1; }
.battle-result { animation:flash .32s ease-out; }
@keyframes flash { from { background:#665333; } to { background:var(--surface); } }
.toast { position:fixed; right:1rem; bottom:1rem; max-width:min(440px,calc(100% - 2rem)); padding:.75rem 1rem; border:1px solid #a68a53; background:#2e2b21; color:var(--paper); border-radius:7px; box-shadow:0 8px 24px #0008; z-index:5; }
dialog { background:var(--surface); color:var(--paper); border:1px solid #86754e; border-radius:9px; width:min(650px,calc(100% - 1.75rem)); max-height:calc(100dvh - 2rem); padding:1.3rem; }
dialog::backdrop { background:#090d0bbb; }
dialog .close { float:right; font-size:1.15rem; }
.manual { padding-left:1.35rem; color:#d8ddcd; }
.manual li { padding:.3rem .2rem; }
.manual strong { color:var(--gold2); }
[hidden] { display:none !important; }
@media (max-width:900px) {
  .setup-grid,.game-grid { grid-template-columns:minmax(0,1fr) minmax(245px,285px); gap:.7rem; }
  .card { padding:.75rem; }
  .map-name { display:none; }
}
@media (max-width:680px) {
  .setup-grid,.game-grid { grid-template-columns:minmax(0,1fr); }
  .intro { gap:.6rem; }
  .intro h1 { font-size:2.2rem; max-width:none; }
  .map-node { width:40px; }
  .map-node .marker { min-width:25px; min-height:21px; }
  .statusbar { margin-bottom:.6rem; }
  .lobby { margin-top:.3rem; }
  .connection { display:none; }
}
@media (max-width:420px) {
  .brand { gap:.38rem; }
  .brand small { font-size:.63rem; }
  .header-actions { gap:.3rem; }
  .header-actions .quiet { max-width:75px; padding:.27rem .38rem; font-size:.76rem; line-height:1.15; }
  #language { min-width:79px; padding-left:.32rem; font-size:.76rem; }
  .masthead { padding:.58rem .7rem; min-height:59px; }
  .insignia { width:30px; height:32px; font-size:1.3rem; }
  .map-shell { aspect-ratio:1000/740; }
  .map-node .marker { padding:.11rem .19rem; }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none !important; scroll-behavior:auto !important; } }
