:root{color-scheme:dark;--ink:#101e20;--paper:#fff4d8;--dim:#c5c9b6;--gold:#f3ce83;--mint:#99dfc3;--brass:#c899596e;--ribbon:linear-gradient(90deg,#071c1a30,#10292646 48%,#071b1a30),url("../assets/hud-banner.png") center 48%/cover;font-family:"Malgun Gothic",system-ui,sans-serif}
*{box-sizing:border-box}
html,body{width:100%;height:100%;margin:0;overflow:hidden;overscroll-behavior:none}
body{background:#101e20;color:var(--paper)}
main{width:100vw;height:100vh;height:100dvh;display:grid;place-items:center;background:#0b171b}
button{font:inherit;color:var(--paper);background:transparent;border:0;border-bottom:1px solid #a995624d;border-radius:0;padding:8px 12px;cursor:pointer;min-height:38px}
button:hover:enabled,button:focus-visible{background:#edc48126;border-color:var(--gold);outline:1px solid #f3ce8380;outline-offset:2px}
button:disabled{opacity:.45;cursor:default}
button.primary{background:linear-gradient(110deg,#e8bb6a,#ffe1a4 55%,#e4ae60);border-color:var(--gold);color:#222a24;font-weight:800}
button.primary:hover:enabled{background:#ffe1a3}
#stage{--touch:44px;--edge:clamp(7px,1.6vmin,16px);--left:max(var(--edge),env(safe-area-inset-left));--right:max(var(--edge),env(safe-area-inset-right));--top:max(var(--edge),env(safe-area-inset-top));--bottom:max(var(--edge),env(safe-area-inset-bottom));position:relative;width:100%;height:100%;isolation:isolate;overflow:hidden;user-select:none;background:#263d3a}
canvas{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;touch-action:none}
#stage:is([data-scene="field"],[data-scene="battle"]) canvas{transform:scale(1.2)}
#hud{position:absolute;inset:0;pointer-events:none}
#hud button,#hud .overlay,#hud .command-ribbon{pointer-events:auto}
button{touch-action:manipulation}
.stage-header{position:absolute;z-index:3;inset:0 0 auto;height:clamp(42px,9%,61px);padding:var(--top) var(--right) 0 var(--left);display:flex;justify-content:center;align-items:flex-start;background:linear-gradient(#071b1bd9,#0c282421,transparent);pointer-events:none}
.header-controls{position:absolute;right:var(--right);top:var(--top);display:flex;align-items:center;gap:5px;pointer-events:auto}
.header-controls button{min-width:var(--touch);min-height:var(--touch);padding:3px 6px;border:1px solid #c4a26d8c;border-radius:6px;background:#0e2422e6;color:var(--gold)}
#sound[aria-pressed="false"]>span:first-child{text-decoration:line-through;color:var(--dim)}
#stage:not([data-scene="field"]) #compass{display:none}
.controls-hint{position:absolute;inset:auto var(--right) max(4px,env(safe-area-inset-bottom)) var(--left);display:flex;justify-content:space-between;color:var(--dim);font-size:10px;letter-spacing:.07em;text-shadow:0 1px 4px black;pointer-events:none}
.build-label{display:none}
#stage[data-scene="title"] .build-label{display:block;position:absolute;right:var(--right);bottom:var(--bottom);color:#fff0ce;font:600 11px/1.2 system-ui,sans-serif;text-shadow:0 1px 4px #10201b;pointer-events:none}
.title{position:absolute;left:var(--left);top:50%;transform:translateY(-50%);max-width:min(540px,calc(100% - var(--left) - var(--right)));padding:12px clamp(4px,3vw,40px);text-shadow:0 3px 18px #10201b}
.title h1{font-family:Georgia,"Batang",serif;font-size:clamp(45px,7vw,100px);letter-spacing:-.075em;line-height:.99;margin:12px 0 20px}
.title p{line-height:1.7}.title .primary{padding:12px 24px;margin-top:10px}
#stage[data-scene="title"] .stage-header{background:none}
#stage[data-scene="title"] .controls-hint span:last-child{display:none}
#stage[data-scene="title"] .controls-hint{inset:auto var(--right) var(--bottom) max(var(--left),5vw);color:#efce8db3}
#stage[data-scene="title"] .header-controls button{background:#102927aa}
.title-home{left:max(var(--left),5vw);max-width:49%;padding:0;text-shadow:0 3px 18px #081b19}
.title-emblem{display:inline-flex;align-items:center;gap:.52em;color:var(--gold);font-size:clamp(14px,4vmin,32px);line-height:1}
.title-emblem::after{content:"";width:2.8em;height:1px;background:linear-gradient(90deg,var(--gold),transparent)}
.title-home h1{margin:.12em 0 .2em;color:#fff2cf;font-size:clamp(27px,11vmin,104px);font-weight:700;letter-spacing:-.07em;line-height:1.04}
.title-logo .eyebrow{font:700 clamp(8px,1.8vmin,14px)/1.2 Georgia,serif;letter-spacing:.24em}
.title-actions{display:grid;gap:4px;width:min(100%,clamp(136px,24vw,274px));margin-top:clamp(7px,3vmin,26px)}
.title-actions button,.title-actions .primary{display:flex;align-items:center;justify-content:space-between;margin:0;min-height:var(--touch);padding:4px 12px;text-align:left;font-size:clamp(12px,2.7vmin,18px);border-bottom-color:#e8bd785e;background-color:#0d211d8a}
.title-actions button::after{content:"›";font-size:1.2em;line-height:1;opacity:.8}
.eyebrow{color:var(--gold);letter-spacing:.22em;font-size:11px;font-weight:800}
.top,.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.top{position:absolute;inset:var(--top) var(--right) auto var(--left);justify-content:space-between;align-items:flex-start;gap:6px;pointer-events:none}
.plate{padding:5px 9px;font-size:clamp(11px,1.9vmin,14px);background:var(--ribbon);border-block:1px solid var(--brass);box-shadow:0 9px 20px #03161440}
.plate strong{display:block;margin:2px 0 4px;font-family:Georgia,"Batang",serif;font-size:1.25em;color:var(--paper)}
.plate small,.card small,.muted{color:var(--dim)}
.location{border-left:2px solid #f1bd71;min-width:min(160px,31%);max-width:36%;background:linear-gradient(100deg,#102825ec,#102825bd);border-radius:4px}
.supplies{margin-top:calc(var(--touch) + 5px);border-right:2px solid #f1bd71;color:var(--gold);font-variant-numeric:tabular-nums;border-radius:4px}
.supplies:has(button){padding-block:0}.supplies button{border-bottom:0}
.command-ribbon{position:absolute;inset:auto var(--right) max(20px,var(--bottom)) var(--left);display:grid;grid-template-columns:minmax(0,1.16fr) minmax(0,1fr);gap:clamp(7px,1.5vmin,18px);align-items:end;pointer-events:none}
#hud .command-ribbon{pointer-events:none}
.panel{grid-column:1;grid-row:1;width:100%;max-width:610px;min-width:0;padding:clamp(4px,.8vmin,9px);background:var(--ribbon);border:1px solid #dab371ab;border-radius:7px;box-shadow:0 7px 23px #05100dbb;pointer-events:auto}
.top:has(.party){display:grid;grid-template-columns:auto minmax(0,364px) minmax(0,1fr);grid-template-areas:"location party supplies"}
.top:has(.party) .location{grid-area:location;justify-self:start;max-width:min(23vw,240px)}
.top:has(.party) .field-location{min-width:0}
.field-location strong{margin:0}
.top:has(.party) .supplies{grid-area:supplies;justify-self:end;max-width:100%;text-align:right}
.party{grid-area:party;width:100%;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:clamp(3px,.65vmin,7px)}
.party .card{grid-template-columns:clamp(15px,3.2vmin,24px) minmax(0,1fr)}
.party .member-name small{display:none}
.card{display:grid;grid-template-columns:clamp(21px,4.9vmin,38px) minmax(0,1fr);align-items:center;gap:clamp(3px,.7vmin,6px);padding:clamp(3px,.65vmin,7px);min-width:0;background:linear-gradient(135deg,#2c4f70eb,#101f3bf5);border:1px solid #d2aa68c2;border-radius:6px;box-shadow:inset 0 0 0 2px #0e2036aa,0 6px 16px #06151ca3;font-size:clamp(10px,1.9vmin,15px)}
.card.ready{border-color:#ffde91;box-shadow:inset 0 0 0 1px #ffde9170,0 0 10px #f8c2616b}
.card.down{opacity:.57}
.portrait{aspect-ratio:1;border-radius:50%;border:1px solid #e2ba7a;background-image:url("../assets/characters.png"),radial-gradient(#425772,#102239);background-repeat:no-repeat;background-size:910% auto,100% 100%;background-position:var(--face),center;box-shadow:0 2px 7px #050f1d99}
.portrait-ivo{--face:12% 3%}.portrait-nari{--face:50% 3%}.portrait-moru{--face:89% 3%}.portrait-lia{--face:13% 64%}
.member-choice,.skill-person,.field-leader{display:inline-flex;align-items:center;gap:8px;text-align:left}
.member-choice .portrait,.skill-person .portrait,.field-leader .portrait{display:block;width:clamp(28px,7vmin,54px);flex-shrink:0}
.member-label{display:grid;line-height:1.18;gap:3px}
.member-label small{font-size:.73em}
.skill-person{display:flex;border-bottom:1px solid var(--brass);padding:6px 0}
.skill-person p{margin:0 0 0 5px}
.field-leader .portrait{width:29px}
.actor-picker .member-choice .portrait,.battle-panel .submenu .member-choice .portrait{width:26px}
.battle-panel .member-label small{display:none}
.member-details{min-width:0}
.member-name{display:flex;align-items:baseline;gap:4px;line-height:1.12;overflow:hidden;white-space:nowrap;margin-bottom:3px}
.member-name small{min-width:0;overflow:hidden;text-overflow:ellipsis}
.meter{display:grid;grid-template-columns:2em minmax(0,1fr) auto;gap:3px;align-items:center;font:clamp(8px,1.45vmin,11px)/1.3 system-ui,sans-serif;font-variant-numeric:tabular-nums}
.atb-meter progress{grid-column:2 / -1}
.submenu{margin-top:6px;padding-top:6px;border-top:1px solid var(--brass)}
progress{display:block;width:100%;height:6px;appearance:none;border:0;border-radius:1px;overflow:hidden;background:#334643}
progress::-webkit-progress-bar{background:#334643}progress::-webkit-progress-value{background:var(--mint)}progress.atb::-webkit-progress-value{background:var(--gold)}
progress::-moz-progress-bar{background:var(--mint)}progress.atb::-moz-progress-bar{background:var(--gold)}
.mp::-webkit-progress-value{background:#7abbf3}.mp::-moz-progress-bar{background:#7abbf3}
.statbar{margin:5px 0}.log{font-size:13px;color:var(--dim);display:block;margin-bottom:8px}.logline{display:block}
.battle-buttons,.battle-panel .submenu{border-top:1px solid var(--brass);margin-top:3px;padding-top:3px}
.quick-actions{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:clamp(3px,.8vmin,9px)}
.quick-card{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:0;min-height:var(--touch);padding:3px 2px;color:var(--paper);border:1px solid #b69d6a8f;border-radius:5px;background:linear-gradient(#2b4e4ac9,#101f22eb);text-align:center;font-size:clamp(10px,1.8vmin,14px)}
.quick-icon{font-size:clamp(12px,2.4vmin,18px);line-height:1;color:var(--gold)}
.quick-card small{max-width:100%;font-size:clamp(8px,1.35vmin,10px);color:var(--dim);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.field-utility{display:flex;justify-content:space-between;gap:4px;margin-top:3px}
.move{flex-wrap:nowrap;flex-shrink:0;gap:4px}
.move button,.context-actions button{min-height:var(--touch);padding:3px 7px;font-size:clamp(10px,1.8vmin,14px)}
.move button{min-width:var(--touch)}
.action-buttons{justify-content:flex-end}
.action-buttons button{border:1px solid #c5a87699;border-radius:50%;min-width:var(--touch);background-color:#173b40}
#field-stick{display:none;position:absolute;z-index:2;left:var(--left);bottom:clamp(105px,28%,180px);width:clamp(54px,11vmin,83px);aspect-ratio:1;border-radius:50%;border:2px solid #f7dba495;background:#253b4190;touch-action:none;place-items:center}
#stage[data-action-field="true"] #field-stick{display:grid}
#field-stick span{width:40%;aspect-ratio:1;border-radius:50%;background:#f6ce8cb9;transform:translate(var(--stick-x,0),var(--stick-y,0));pointer-events:none}
.field-panel .log{margin:4px 0 0;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}
.overlay{position:absolute;inset:0;z-index:4;display:grid;place-items:center;background:#091616aa;padding:max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left))}
.dialog,.story-strip{width:min(540px,100%);max-height:min(76vh,100%);max-height:min(76dvh,100%);overflow:auto}
.dialog{padding:clamp(9px,2.2vmin,16px);background:var(--ribbon);border-block:2px solid #c6a56c;box-shadow:0 12px 45px #0009;font-size:clamp(12px,2.6vmin,15px)}
.dialog h2{font-size:clamp(17px,4vmin,23px)}
.dialog h2{margin:0 0 8px;color:var(--gold);font-family:Georgia,"Batang",serif}.dialog p{line-height:1.55;margin:8px 0}.dialog hr{border:0;border-top:1px solid #48635c;margin:12px 0}
.story-veil{place-items:end center;background:linear-gradient(transparent 40%,#08181386)}
#hud:has(.story-veil) .command-ribbon,#hud:has(.story-veil)>.top{visibility:hidden}
.story-strip{display:grid;grid-template-columns:clamp(42px,12vmin,78px) minmax(0,1fr);gap:clamp(8px,2vmin,15px);align-items:center;margin-bottom:var(--bottom);padding:clamp(8px,2vmin,14px);background:var(--ribbon);border:1px solid #d1aa70;border-radius:8px;box-shadow:0 8px 30px #051510ad}
.story-face .portrait{display:block;width:100%;border-width:2px}
.npc-face{background-image:url("../assets/dialogue-portraits.png");background-size:200% 200%}
.npc-yeon{--face:0% 0%}.npc-choi{--face:100% 0%}.npc-toa{--face:0% 100%}.npc-guardian{--face:100% 100%}
.story-speaker{display:flex;align-items:center;justify-content:space-between;gap:10px;color:var(--gold)}
.story-speaker strong{font-size:clamp(15px,3.1vmin,25px)}
.story-speaker small{font-size:clamp(10px,1.9vmin,14px);color:var(--dim);font-variant-numeric:tabular-nums}
.story-content{min-width:0}
.story-content p{margin:5px 0;line-height:1.42;font-size:clamp(12px,2.7vmin,16px);overflow-wrap:anywhere}
.story-controls{justify-content:flex-end}
.story-controls button{min-height:44px}
.gear{display:grid;gap:8px;margin:12px 0}.gear button{text-align:left}.gear .equipped{border-color:var(--gold);color:var(--gold)}
.dialog:has(.inv-body),.dialog:has(.region-map){background:#261d17;border:2px solid #b58d52;border-radius:8px}
.region-map{position:relative;height:clamp(108px,43dvh,235px);isolation:isolate;background:#34291e center/cover;border:1px solid #b38b55;border-radius:5px}
.map-route{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.map-route polyline{fill:none;stroke:#ffe4a4;stroke-width:2;stroke-dasharray:4 4;filter:drop-shadow(0 1px 1px #29170c)}
.dialog .map-pin{position:absolute;left:var(--x);top:var(--y);display:grid;place-items:center;width:var(--touch);min-height:var(--touch);transform:translate(-50%,-50%);padding:0;border:0;background:none;outline-offset:0}
.map-pin>span:first-child{display:grid;place-items:center;width:clamp(20px,6vmin,30px);aspect-ratio:1;border:1px solid #f3cb84;border-radius:50%;background:#30372b;color:#ffe0a2;box-shadow:0 2px 5px #21180d;font-size:14px}
.map-pin.current>span:first-child,.map-pin:is(:hover,:focus-visible)>span:first-child{background:#fff0bd;color:#48301c}
.map-pin:is(:hover,:focus-visible){z-index:2}
.map-tip{visibility:hidden;position:absolute;bottom:90%;left:50%;width:max-content;max-width:145px;transform:translateX(-50%);padding:4px 7px;border:1px solid #c4a06d;border-radius:4px;background:#291e17;color:#fff1ce;pointer-events:none;text-align:center}
.map-pin:first-of-type .map-tip{left:0;transform:none}
.map-pin:last-of-type .map-tip{left:auto;right:0;transform:none}
.map-tip :is(strong,small){display:block}
.map-pin:is(:hover,:focus-visible) .map-tip{visibility:visible}
.region-map:has(.map-pin:hover) .map-pin:not(:hover) .map-tip{visibility:hidden}
.map-here{position:absolute;z-index:1;left:var(--x);top:calc(var(--y) + 15px);width:9px;aspect-ratio:1;transform:translate(-50%,-50%);border:1px solid #fff8e1;border-radius:50%;background:#7ce2b8;box-shadow:0 0 0 2px #173a33;pointer-events:none}
.map-footer{gap:4px;justify-content:flex-end}
.map-footer small{margin-right:auto;color:var(--dim)}
.map-footer small span{color:#7ce2b8}
.map-footer button{padding-inline:6px}
.inv-tabs{gap:5px;margin-bottom:9px}
.inv-tabs button{flex:1;padding:4px 6px;border:1px solid #8b6a46;border-radius:5px;white-space:nowrap}
.inv-body{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);gap:8px;align-items:start}
.inv-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:5px;max-height:min(58dvh,330px);overflow:auto;padding:2px}
.inv-slot{position:relative;display:grid;place-items:center;aspect-ratio:1;min-height:var(--touch);padding:1px;background:#1b1410;border:1px solid #8b6a46;border-radius:5px;font-size:clamp(16px,4vmin,26px)}
.inv-slot.selected{border-color:#ffd17a;background:#3c2c20;box-shadow:inset 0 0 0 1px #ffd17a}
.inv-slot .qty,.inv-slot .eq-badge{position:absolute;font-size:10px;line-height:1.2}
.inv-slot .qty{right:3px;bottom:2px;color:var(--gold)}
.inv-slot .eq-badge{top:2px;left:2px;padding:1px 3px;border-radius:2px;background:#345a3d;color:#f7efd8}
.inv-detail{min-width:0;padding:8px;background:#1b1410;border:1px solid #8b6a46;border-radius:5px}
.inv-detail p{font-size:clamp(12px,2.7vmin,15px)}
.inv-detail [role="status"]:empty{display:none}
.detail-actions{gap:4px;margin-top:6px}
.detail-actions button{padding:3px 5px;border:1px solid #946e46;border-radius:4px;font-size:12px}
.detail-actions .portrait{width:clamp(18px,4.6vmin,34px)}
.formation-line{display:grid;grid-template-columns:58px 1fr;align-items:baseline;gap:10px;padding:10px 0;border-top:1px solid var(--brass)}
.formation-line h3{color:var(--gold);font-size:1em;margin:0}
.region-trail{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:12px 0 16px}
.region-trail div{border-block:1px solid var(--brass);padding:7px 5px;display:grid;gap:3px}
.region-trail small{color:var(--gold)}
.region-trail strong{font-size:clamp(12px,2.7vmin,17px)}
.command-ribbon .row button,.dialog button,.story-controls button{min-height:var(--touch)}
#stage:is([data-scene="field"],[data-scene="battle"],[data-scene="airship"]){
  --hud-wood:repeating-linear-gradient(2deg,#eac1910a 0 1px,transparent 1px 5px),linear-gradient(168deg,#634631,#35261f 70%,#473023);
  --hud-brass:#ae8457;
  --hud-frame:inset 0 0 0 1px #311f18,inset 0 0 0 2px #dfad7752,0 3px 8px #21160db3;
}
#stage[data-scene] :is(.panel,.supplies,.card){
  background:var(--hud-wood,var(--ribbon));
  border:1px solid var(--hud-brass,var(--brass));
  box-shadow:var(--hud-frame);
}
#stage[data-scene] .card.ready{
  border-color:#ffe096;
  box-shadow:var(--hud-frame),0 0 9px #ffd4769e;
}
#stage[data-scene] .location{
  background:radial-gradient(ellipse at 40% 20%,#e4cf9e,#b59a70);
  border:1px solid #785b3e;
  border-radius:8px 4px;
  box-shadow:inset 0 0 0 1px #fae3aa,inset 0 0 0 3px #815c3f71,0 3px 8px #32211680;
}
#stage[data-scene] .location :is(strong,small){color:#332318}
#stage:is([data-scene="field"],[data-scene="battle"],[data-scene="airship"]) .header-controls button{
  background:linear-gradient(#344d4f,#172c32);
  border-color:var(--hud-brass);
  box-shadow:var(--hud-frame);
}
#stage[data-scene] .quick-card{
  background:linear-gradient(#765237,#493021);
  border-color:#bd925f;
  box-shadow:inset 0 0 0 1px #372419,inset 0 0 0 2px #e6bb825c;
}
#stage[data-scene] :is(.quick-card,.header-controls button):is(:hover,:focus-visible){filter:brightness(1.23)}
#stage[data-scene] :is(.card,.supplies) progress{
  border-radius:8px;
  background:#271b16;
  box-shadow:0 0 0 1px #bf9d6c88;
}
#stage[data-scene] :is(.card,.supplies) progress::-webkit-progress-bar{background:#271b16}
#stage[data-scene] :is(.card,.supplies) progress::-webkit-progress-value{background:linear-gradient(#a6d77a,#4e9c54)}
#stage[data-scene] .card .mp::-webkit-progress-value{background:linear-gradient(#9ad8f7,#377eae)}
#stage[data-scene] .card .atb::-webkit-progress-value{background:linear-gradient(#ffe09b,#ba7b36)}
#stage[data-scene] :is(.card,.supplies) progress::-moz-progress-bar{background:linear-gradient(#a6d77a,#4e9c54)}
#stage[data-scene] .card .mp::-moz-progress-bar{background:linear-gradient(#9ad8f7,#377eae)}
#stage[data-scene] .card .atb::-moz-progress-bar{background:linear-gradient(#ffe09b,#ba7b36)}
#stage:not([data-scene="title"]){--hud-scale:.9;--touch:49px}
#stage:not([data-scene="title"]) :is(.header-controls,.top .plate,.command-ribbon .panel,.party,.dialog,.story-strip,#field-stick,.controls-hint){
  transform:scale(var(--hud-scale));
}
.header-controls,.top .supplies{transform-origin:top right}
.top .location{transform-origin:top left}
.command-ribbon .panel,#field-stick{transform-origin:bottom left}
.party{transform-origin:top left}
#stage[data-scene="field"] .field-panel{--hud-scale:.81}
@media(pointer:coarse){
  #stage[data-scene="field"] .field-panel{--touch:55px}
}
.story-strip,.controls-hint{transform-origin:bottom center}
@media(pointer:fine){#stage{--touch:34px}}
@media(pointer:fine){#stage:not([data-scene="title"]){--touch:34px}}
@media(max-height:520px),(orientation:portrait){
  .command-ribbon{bottom:var(--bottom)}
  .controls-hint,.sound-label,.row-order{display:none}
  .plate{padding:5px 8px;font-size:12px}
  .log{font-size:11px;margin-bottom:4px}
  .panel .row{gap:3px}
  .panel .row button{padding-inline:6px;font-size:12px}
  .battle-log .logline:nth-last-child(n+2){display:none}
  .title:not(.title-home) h1{font-size:clamp(28px,6.7vmin,54px);margin:6px 0}
  .title p{font-size:13px;margin:7px 0}
  .card progress{height:4px}
}
@media(orientation:portrait){
  .title-home h1{font-size:clamp(20px,7vmin,54px)}
  .title-actions{gap:1px;margin-top:5px}
  .title-actions button,.title-actions .primary{min-height:clamp(24px,8vmin,44px);padding-block:1px}
  #stage[data-scene="title"] .controls-hint{display:none}
}
@media(max-width:970px){
  .top:has(.party){grid-template-columns:auto minmax(0,min(364px,46vw)) minmax(0,1fr)}
}
@media(orientation:portrait){
  #stage{height:min(100%,56.25vw)}
  .location{min-width:0;max-width:33%}
  .quick-card small,.field-panel .log{display:none}
  .card .member-name small{display:none}
}
@media(max-width:540px) and (orientation:portrait){
  .top:has(.party){grid-template-columns:auto minmax(0,42vw) minmax(0,1fr)}
  .location>small:first-child,.location>small:last-child,.card .meter>span:last-child,.field-leader small{display:none}
  .header-controls{gap:2px}
  .header-controls button{min-width:32px}
  .supplies{font-size:10px;max-width:42%;padding-inline:4px}
  .command-ribbon{gap:4px}
  .party{gap:2px}
  .party .card{grid-template-columns:16px minmax(0,1fr);padding:2px;gap:2px;font-size:10px}
  .meter{grid-template-columns:13px minmax(8px,1fr);gap:2px;font-size:7px}
  .quick-actions{gap:2px}
  .quick-card{font-size:9px}
  .quick-icon{font-size:11px}
  .panel .row button{font-size:10px;padding-inline:3px}
  .move button{min-width:31px}
}
/* Build 006: bookbinder title. Text remains live HTML; no image labels. */
#stage[data-scene="title"]{--paper:#fff2d7;--gold:#d7b982;--dim:#becfca}
#stage[data-scene="title"] .title-home{left:6%;top:50%;width:39%;max-width:560px;padding:clamp(20px,3.2vw,48px);background:linear-gradient(135deg,#183638f2,#0c202bea);border:1px solid #b89c67aa;border-radius:3px 22px 3px 3px;box-shadow:inset 0 0 0 5px #10282b,inset 0 0 0 6px #b89c673b,0 18px 70px #07151a80;text-shadow:none}
#stage[data-scene="title"] .title-home::before{content:"";position:absolute;left:clamp(20px,3.2vw,48px);top:0;width:48px;height:4px;background:#d7b982}
#stage[data-scene="title"] .title-emblem{font-size:21px;color:#dbc291}
#stage[data-scene="title"] .title-home h1{font-family:"Malgun Gothic",system-ui,sans-serif;font-size:clamp(32px,4.9vw,76px);font-weight:800;letter-spacing:-.055em;line-height:1.13;margin:.28em 0 .3em;color:#fff2d7;overflow-wrap:normal;word-break:keep-all}
#stage[data-scene="title"] .title-logo .eyebrow{font:600 clamp(9px,.9vw,13px)/1.6 system-ui,sans-serif;letter-spacing:.21em;color:#d0b783}
#stage[data-scene="title"] .title-actions{width:100%;gap:9px;margin-top:clamp(20px,3.3vh,36px)}
#stage[data-scene="title"] .title-actions button{min-height:48px;padding:11px 17px;font-size:clamp(13px,1.15vw,17px);font-weight:600;background:#183b40;border:1px solid #63848288;border-radius:3px;line-height:1.35;white-space:normal;text-align:left}
#stage[data-scene="title"] .title-actions button.primary{background:linear-gradient(110deg,#e6cf9f,#c5a570);border-color:#e8d7b3;color:#152d32;box-shadow:0 4px 16px #06161955}
#stage[data-scene="title"] .title-actions button:is(:hover,:focus-visible){outline:2px solid #f3d9a4;outline-offset:3px;filter:brightness(1.09)}
#stage[data-scene="title"] .title-actions button::after{margin-left:14px;font-size:21px;flex-shrink:0}
#stage[data-scene="title"] .header-controls button{background:#102b32e8;border-color:#b99c68;color:#e9d7b3;border-radius:3px}
@media(max-height:540px) and (orientation:landscape){
 #stage[data-scene="title"] .title-home{padding:18px 24px;width:42%;left:4%}
 #stage[data-scene="title"] .title-home h1{font-size:clamp(25px,5vw,45px)}
 #stage[data-scene="title"] .title-emblem{font-size:14px}
 #stage[data-scene="title"] .title-actions{margin-top:14px;gap:6px}
 #stage[data-scene="title"] .title-actions button{min-height:44px;padding:8px 12px;font-size:13px}
}
@media(orientation:portrait){
 #stage[data-scene="title"]{height:100%;}
 #stage[data-scene="title"] canvas{object-position:67% center;opacity:.83}
 #stage[data-scene="title"] .title-home{left:6%;top:auto;bottom:7%;transform:none;width:88%;max-width:none;padding:24px;background:linear-gradient(135deg,#17363af5,#0d222cf5)}
 #stage[data-scene="title"] .title-home h1{font-size:clamp(32px,9vw,52px);line-height:1.08}
 #stage[data-scene="title"] .title-home h1 br{display:none}
 #stage[data-scene="title"] .title-actions{margin-top:22px;gap:9px}
 #stage[data-scene="title"] .title-actions button{min-height:48px;font-size:15px;padding:11px 16px}
 #stage[data-scene="title"] .title-logo .eyebrow{font-size:10px}
}
/* In-game bookbinder system: shared material, live meters and unchanged DOM. */
#stage:is([data-scene="field"],[data-scene="battle"],[data-scene="airship"]){--hud-wood:linear-gradient(135deg,#1b3942f5,#112630f5);--hud-brass:#a88f64;--hud-frame:inset 0 0 0 2px #10252b,inset 0 0 0 3px #c1aa7938,0 5px 18px #07161c70;--dim:#bfd0cb;--paper:#f4eddc;--gold:#ddc396;--mint:#83c6aa}
#stage:not([data-scene="title"]) :is(.panel,.card,.supplies){border-radius:3px 9px 3px 3px}
#stage:not([data-scene="title"]) .party .card{padding:8px 7px;border-top:2px solid #91b7b0;gap:6px}
#stage:not([data-scene="title"]) .party .portrait{border-radius:4px;border-color:#c3ab7e;box-shadow:0 2px 5px #07151b80}
#stage:not([data-scene="title"]) .member-name{color:#f5e8c8;margin-bottom:5px}
#stage:not([data-scene="title"]) .meter{row-gap:3px;line-height:1.55}
#stage:not([data-scene="title"]) .card.ready{border-top-color:#ffe2a2;box-shadow:inset 0 0 0 1px #dec38e,0 0 12px #d6b36c50}
#stage:not([data-scene="title"]) .card.down{filter:saturate(.2);opacity:.65}
#stage:not([data-scene="title"]) .location{background:linear-gradient(110deg,#e7d7b5,#cfbd98);border:1px solid #b09a72;border-radius:3px 9px 3px 3px;box-shadow:inset 0 0 0 3px #f9edce55,0 4px 12px #0b1b2860}
#stage:not([data-scene="title"]) .location :is(strong,small){color:#20373e}
#stage:not([data-scene="title"]) .quick-card{background:linear-gradient(#284e56,#1b363f);border:1px solid #6c8e8d;box-shadow:inset 0 1px #9fb6a72e;border-radius:3px;gap:4px;padding:7px 4px}
#stage:not([data-scene="title"]) .quick-icon{color:#d9c18d}
#stage:not([data-scene="title"]) .panel{padding:10px;border-top:2px solid #bdab80}
#stage:not([data-scene="title"]) .panel button.primary{background:linear-gradient(110deg,#ddc99d,#c3aa78);border:1px solid #e3cfa3;color:#183038}
#stage:not([data-scene="title"]) .panel .row button{border-radius:3px}
#stage:not([data-scene="title"]) .panel .row button:not(.primary){background:#1e3b44;border:1px solid #6b87835e}
#stage:not([data-scene="title"]) :is(.dialog,.story-strip){background:linear-gradient(120deg,#1a3942fa,#112830fa);border:1px solid #ad966e;box-shadow:inset 0 0 0 4px #112a31,inset 0 0 0 5px #ad966e40,0 12px 40px #0008;border-radius:3px 12px 3px 3px}
#stage:not([data-scene="title"]) :is(.card,.supplies) progress::-webkit-progress-bar{background:#0a2029}
#stage:not([data-scene="title"]) :is(.card,.supplies) progress::-webkit-progress-value{background:linear-gradient(90deg,#62a88e,#a6dac0)}
#stage:not([data-scene="title"]) .card .mp::-webkit-progress-value{background:linear-gradient(90deg,#548cac,#a0c9df)}
#stage:not([data-scene="title"]) .card .atb::-webkit-progress-value{background:linear-gradient(90deg,#bfa16a,#f0d79e)}
#stage:not([data-scene="title"]) :is(.card,.supplies) progress::-moz-progress-bar{background:#87c4a8}
#stage:not([data-scene="title"]) .card .mp::-moz-progress-bar{background:#86bad2}
#stage:not([data-scene="title"]) .card .atb::-moz-progress-bar{background:#e6ca8d}
#stage:not([data-scene="title"]) button:focus-visible{outline:2px solid #ffe4ad;outline-offset:3px}
@media(max-height:520px),(orientation:portrait){
 #stage:not([data-scene="title"]) .party .card{padding:4px;gap:3px}
 #stage:not([data-scene="title"]) .panel{padding:6px}
 #stage:not([data-scene="title"]) .quick-card{padding:4px 2px;gap:2px}
 #stage:not([data-scene="title"]) .member-name{margin-bottom:2px}
}
/* Final artwork composition: heroes left, readable negative space right. */
#stage[data-scene="title"]{background:#102b31 url("../assets/title-hero.png") center/cover no-repeat}
#stage[data-scene="title"] canvas{opacity:0;pointer-events:none}
#stage[data-scene="title"] .title-home{left:auto;right:5%;width:39%;background:linear-gradient(135deg,#15343bd9,#0c242de8)}
@media(max-height:540px) and (orientation:landscape){#stage[data-scene="title"] .title-home{left:auto;right:4%;width:42%}}
@media(orientation:portrait){
 #stage[data-scene="title"]{background-position:30% center}
 #stage[data-scene="title"] .title-home{left:6%;right:auto;width:88%;background:linear-gradient(135deg,#17363af5,#0d222cf5)}
}
/* Give four live HP/MP cards actual room instead of shrinking their numbers. */
@media(min-width:971px){
 #stage:not([data-scene="title"]) .top:has(.party){grid-template-columns:auto minmax(480px,560px) minmax(0,1fr)}
 #stage:not([data-scene="title"]) .party{transform:none}
 #stage:not([data-scene="title"]) .party .card{grid-template-columns:25px minmax(0,1fr);font-size:13px}
 #stage:not([data-scene="title"]) .meter{font-size:10px;grid-template-columns:19px minmax(12px,1fr) auto}
}
/* Portrait art is contained above the controls: both companions remain visible. */
@media(orientation:portrait){
 #stage[data-scene="title"]{background-color:#102d34;background-image:linear-gradient(to bottom,transparent 47%,#102d34 64%),url("../assets/title-hero.png");background-size:100% 100%,auto 63%;background-position:center,33% top;background-repeat:no-repeat}
 #stage[data-scene="title"] .title-home{bottom:3%;padding:20px 24px}
 #stage[data-scene="title"] .title-actions{margin-top:16px}
}
.title-locale{display:flex;align-items:center;gap:7px;margin-top:14px;color:#d4c7a9;font-size:11px}
.title-locale select{font:inherit;font-size:12px;min-height:36px;color:#f4ecd9;background:#173940;border:1px solid #a48f68;border-radius:3px;padding:5px 8px;max-width:100%}
.title-locale select:focus-visible{outline:2px solid #ffe4ad;outline-offset:3px}
@media(orientation:portrait){.title-locale{margin-top:10px}.title-locale select{min-height:36px}}

/* 007: main page is landscape-only. No gameplay/HUD rules changed. */
#stage[data-scene="title"] .title-rotate-hint{display:none}
@media(orientation:landscape) and (max-height:540px){
 #stage[data-scene="title"] .title-home{top:50%;bottom:auto;right:4%;left:auto;transform:translateY(-50%);width:42%;max-height:calc(100% - 28px);padding:14px 20px;overflow:auto}
 #stage[data-scene="title"] .title-home h1{font-size:clamp(25px,3.8vw,36px);line-height:1.06;margin:7px 0 7px}
 #stage[data-scene="title"] .title-emblem{font-size:12px}
 #stage[data-scene="title"] .title-logo .eyebrow{font-size:9px;line-height:1.2}
 #stage[data-scene="title"] .title-actions{margin-top:12px;gap:5px}
 #stage[data-scene="title"] .title-actions button{min-height:44px;padding:7px 12px;font-size:13px}
 #stage[data-scene="title"] .title-locale{margin-top:8px;gap:6px;font-size:10px}
 #stage[data-scene="title"] .title-locale select{min-height:30px;padding:3px 6px;font-size:11px}
 #stage[data-scene="title"] .title-language-note{margin-top:5px!important;font-size:9px!important}
}
@media(orientation:portrait){
 #stage[data-scene="title"]{height:100%;background:#102d34}
 #stage[data-scene="title"] .title-home{display:none}
 #stage[data-scene="title"] .title-rotate-hint{display:grid;place-content:center;gap:18px;position:absolute;inset:70px 24px;color:#f4e5c5;text-align:center;padding:24px}
 #stage[data-scene="title"] .title-rotate-hint::before{content:"↻";font-size:56px;color:#d9bd88}
 #stage[data-scene="title"] .title-rotate-hint p{margin:0;font-size:16px;line-height:1.6}
}

/* 008: one centered 16:9 stage on every display. Existing 1200x620
   canvas/cover transform and its inverse pointer mapping remain unchanged. */
main{background:#08151b}
#stage,#stage[data-scene="title"]{width:min(100vw,177.7777778vh);width:min(100vw,177.7777778dvh);height:min(100vh,56.25vw);height:min(100dvh,56.25vw);aspect-ratio:16/9;flex:none}
@media(orientation:portrait){
 #stage[data-scene="title"] .title-rotate-hint{inset:8px 12px;padding:6px;gap:5px}
 #stage[data-scene="title"] .title-rotate-hint::before{font-size:26px}
 #stage[data-scene="title"] .title-rotate-hint p{font-size:12px;line-height:1.35}
}

/* Entire existing canvas projection remains visible without stretching/zoom crop. */
#stage canvas{object-fit:contain;transform:none}
#stage:is([data-scene="field"],[data-scene="battle"]) canvas{transform:none}
#stage[data-scene="title"]{background-size:contain;background-position:center;background-color:#102d34}

/* 009: artwork contains ALL main-page frames. HTML supplies live type/hit areas only. */
#stage[data-scene="title"]{container-type:inline-size;background-image:url("../assets/title-one-layer.png");background-size:contain;background-position:center;background-repeat:no-repeat}
#stage[data-scene="title"] .title-home{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;padding:0!important;margin:0!important;transform:none!important;background:none!important;border:0!important;border-radius:0!important;box-shadow:none!important;overflow:visible!important;text-shadow:0 1px 2px #061f28;pointer-events:none}
#stage[data-scene="title"] .title-home::before,#stage[data-scene="title"] .title-emblem{display:none!important}
#stage[data-scene="title"] .title-logo{position:absolute;left:59.6%;top:20%;width:30.7%;height:21%;display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center}
#stage[data-scene="title"] .title-home h1{margin:0!important;font-size:clamp(21px,4.15cqw,68px)!important;line-height:1.12!important;letter-spacing:-.055em;word-break:keep-all;color:#f8ebce}
#stage[data-scene="title"] .title-logo .eyebrow{font-size:clamp(6px,.8cqw,13px)!important;letter-spacing:.15em;line-height:1.2;margin-top:2cqw;color:#d9c092}
#stage[data-scene="title"] .title-actions{position:absolute;inset:0;display:block!important;margin:0!important;width:100%!important;pointer-events:none}
#stage[data-scene="title"] .title-actions button{position:absolute;left:59.6%;width:30.7%;height:8.6%;min-height:0!important;margin:0!important;padding:0 2%!important;display:flex;justify-content:center;align-items:center;background:none!important;border:0!important;border-radius:999px!important;box-shadow:none!important;filter:none!important;font-size:clamp(12px,1.5cqw,24px)!important;line-height:1.2!important;font-weight:700;color:#f4e7cb!important;pointer-events:auto;text-shadow:0 1px 2px #081b20}
#stage[data-scene="title"] .title-actions button:nth-child(1){top:45.7%;color:#213a38!important;text-shadow:none}
#stage[data-scene="title"] .title-actions button:nth-child(2){top:55.6%}
#stage[data-scene="title"] .title-actions button:nth-child(3){top:65.5%}
#stage[data-scene="title"] .title-actions button::after{display:none!important}
#stage[data-scene="title"] .title-actions button:disabled{opacity:.42}
#stage[data-scene="title"] .title-actions button:hover:enabled{color:#fff!important;text-shadow:0 0 8px #ffe8a2}
#stage[data-scene="title"] .title-actions button:focus-visible{outline:2px dashed #fff0bd!important;outline-offset:2px!important}
#stage[data-scene="title"] .title-locale{position:absolute;left:59.6%;top:76.4%;width:30.7%;margin:0!important;display:flex;justify-content:center;gap:1cqw;font-size:clamp(8px,.85cqw,14px)!important;pointer-events:auto}
#stage[data-scene="title"] .title-locale select{background:transparent!important;border:0!important;border-bottom:1px solid #c3ad7c!important;border-radius:0;min-height:0!important;height:3cqw;max-height:38px;padding:0 4px;font-size:clamp(10px,1cqw,16px)!important;color:#f4e7cb}
#stage[data-scene="title"] .title-locale option{background:#16383a;color:#f4e7cb}
#stage[data-scene="title"] .title-language-note{position:absolute;left:59.6%;top:81.7%;width:30.7%;margin:0!important;text-align:center;font-size:clamp(8px,.7cqw,11px)!important;line-height:1.3!important}
#stage[data-scene="title"] .header-controls button{background:none!important;border:0!important;box-shadow:none!important}
@media(orientation:portrait){#stage[data-scene="title"]{background-image:none}#stage[data-scene="title"] .title-home{display:none!important}}

/* 010: third painted slot is the native language picker; lower area is Notices. */
#stage[data-scene="title"] .title-locale{left:59.6%;top:65.5%;width:30.7%;height:8.6%;gap:0;align-items:center;justify-content:center}
#stage[data-scene="title"] .title-locale label{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
#stage[data-scene="title"] .title-locale select{width:100%;height:100%!important;max-height:none!important;border:0!important;padding:0 10%!important;background:none!important;text-align:center;text-align-last:center;font-size:clamp(12px,1.5cqw,24px)!important;font-weight:700;cursor:pointer}
#stage[data-scene="title"] .title-locale select:focus-visible{outline:2px dashed #fff0bd;outline-offset:2px;border-radius:999px}
#stage[data-scene="title"] .title-notice-link{position:absolute;left:59.6%;top:76.5%;width:30.7%;height:6%;min-height:0;padding:0;border:0;background:none;color:#e2d3af;font-size:clamp(12px,1.1cqw,18px);pointer-events:auto;text-decoration:underline;text-underline-offset:4px}
.title-notice-dialog{width:min(540px,82vw);max-height:85dvh;overflow:auto;padding:24px;color:#f2e9d5;background:#14343a;border:1px solid #c6ae7d;border-radius:6px;box-shadow:0 15px 50px #0008}
.title-notice-dialog::backdrop{background:#06161acc}
.title-notice-dialog h2{margin:0 0 14px;font-size:22px}
.title-notice-dialog p{font-size:15px;line-height:1.7;margin:0 0 20px}
.title-notice-dialog button{min-height:44px;min-width:90px;border:1px solid #c6ae7d;background:#244a50;color:#fff1d7;border-radius:3px}
.title-notice-dialog button:focus-visible{outline:2px solid #ffe4ad;outline-offset:3px}
@media(max-height:420px){.title-notice-dialog{padding:16px}.title-notice-dialog p{font-size:13px;line-height:1.5;margin-bottom:12px}}
/* Keep native picker affordance inside, not on the painted gold edge. */
#stage[data-scene="title"] .title-locale select{appearance:none;-webkit-appearance:none}
#stage[data-scene="title"] .title-locale::after{content:"⌄";position:absolute;right:6%;top:50%;transform:translateY(-55%);color:#eeddb4;font-size:clamp(12px,1.5cqw,24px);line-height:1;pointer-events:none}

/* 013 exploration-only slim horizontal menu; touch targets remain 44px. */
#stage[data-scene="field"] .command-ribbon{grid-template-columns:minmax(0,1fr);bottom:22px}
#stage[data-scene="field"] .field-panel{transform:none;display:flex;align-items:center;gap:8px;padding:4px 6px;border-width:1px;--touch:44px;background:#112b35e8}
#stage[data-scene="field"] .quick-actions{flex:1;gap:3px;min-width:0}
#stage[data-scene="field"] .quick-card{flex-direction:row;min-height:44px;gap:5px;padding:3px 5px;font-size:13px;white-space:nowrap}
#stage[data-scene="field"] .quick-icon{font-size:15px}
#stage[data-scene="field"] .quick-card small{display:none}
#stage[data-scene="field"] .field-utility{margin:0;gap:5px;flex-shrink:0;align-items:center}
#stage[data-scene="field"] .field-utility .row{flex-wrap:nowrap;gap:3px}
#stage[data-scene="field"] .field-utility button{min-height:44px;min-width:44px;padding:3px 7px;font-size:12px}
#stage[data-scene="field"] .field-panel .log{position:absolute;left:0;bottom:100%;margin:0 0 3px;max-width:80%;font-size:11px;background:#102a32b8;padding:2px 6px;pointer-events:none}
#stage[data-scene="field"] .field-leader{display:none}
@media(max-width:740px){
 #stage[data-scene="field"] .field-panel{gap:4px;padding:3px}
 #stage[data-scene="field"] .quick-card{font-size:12px;gap:2px;padding:3px 2px}
 #stage[data-scene="field"] .quick-icon{display:none}
 #stage[data-scene="field"] .field-utility{position:absolute;right:0;bottom:calc(100% + 5px)}
 #stage[data-scene="field"] .field-panel .log{max-width:45%;overflow:hidden;text-overflow:ellipsis}
}
#stage[data-scene="field"] .command-ribbon .field-panel{transform:none!important}
#stage[data-scene="field"] .command-ribbon .field-panel{max-width:none}
/* 013: party banners 10 percent wider, original height and text sizing. */
@media(max-width:970px){#stage:not([data-scene="title"]) .top:has(.party){grid-template-columns:auto minmax(0,min(400.4px,50.6vw)) minmax(0,1fr)}}
@media(min-width:971px){#stage:not([data-scene="title"]) .top:has(.party){grid-template-columns:auto minmax(528px,616px) minmax(0,1fr)}}


/* 014: fixed 800x450 UI plane scaled with the actual 16:9 stage. */
#stage{container-type:inline-size}
@container(max-width:1100px){
 #stage:not([data-scene="title"]) #hud{width:800px;height:450px;inset:0 auto auto 0;transform:scale(calc(100cqw / 800px));transform-origin:top left}
 #stage:not([data-scene="title"]) .stage-header{transform:scale(calc(100cqw / 800px));transform-origin:top right;width:800px;left:auto;right:0}
 #stage:not([data-scene="title"]) .header-controls{transform:none;gap:4px}
 #stage:not([data-scene="title"]) .header-controls button{min-width:34px;min-height:34px;font-size:12px;padding:3px 6px}
 #stage:not([data-scene="title"]) .top{inset:7px 7px auto;gap:6px}
 #stage:not([data-scene="title"]) .top:has(.party){grid-template-columns:94px 400.4px minmax(0,1fr)}
 #stage:not([data-scene="title"]) .top .location{min-width:0;max-width:94px;font-size:11px;padding:4px}
 #stage:not([data-scene="title"]) .top .supplies{font-size:11px;max-width:200px;margin-top:42px}
 #stage:not([data-scene="title"]) .party{gap:4px;transform:none}
 #stage:not([data-scene="title"]) .party .card{grid-template-columns:18px minmax(0,1fr);padding:4px;gap:3px}
 #stage:not([data-scene="title"]) .party .portrait{width:18px}
 #stage:not([data-scene="title"]) .party .member-name{font-size:11px;margin-bottom:2px}
 #stage:not([data-scene="title"]) .party .meter{grid-template-columns:14px minmax(8px,1fr) auto;font-size:8px;line-height:1.3}
 #stage:not([data-scene="title"]) .party .meter>span:last-child{display:initial}
 #stage:not([data-scene="title"]) .dialog{max-height:420px!important;transform:none!important;font-size:12px;padding:12px}
 #stage:not([data-scene="title"]) .overlay{padding:12px;overflow:hidden}
 #stage:not([data-scene="title"]) .dialog button{min-height:34px}
 #stage:not([data-scene="title"]) .inv-grid{max-height:300px}
 #stage:not([data-scene="title"]) .dialog .portrait{width:26px}
 #stage[data-scene="field"] .command-ribbon{left:7px;right:7px;bottom:22px}
 #stage[data-scene="field"] .field-panel{padding:4px 6px;gap:6px}
 #stage[data-scene="field"] .quick-card{font-size:12px;min-height:44px;gap:3px;padding:3px 4px}
 #stage[data-scene="field"] .quick-icon{display:none}
 #stage[data-scene="field"] .field-utility{position:static;margin:0;gap:5px}
 #stage[data-scene="field"] .field-utility button{font-size:12px;min-width:44px;min-height:44px}
 #stage[data-scene="field"] .field-panel .log{max-width:80%;font-size:10px;display:block}
 #stage[data-scene="field"] #field-stick{left:7px;bottom:110px;width:65px}
}
@container(min-width:600px) and (max-width:1100px){#stage[data-scene="field"] .quick-icon{display:inline;font-size:15px}}

.equip-preview{display:block;white-space:normal;line-height:1.35;color:#d8eddd;margin-top:3px}.equip-wearer{margin:7px 0}.inv-detail .detail-actions .member-choice:has(.equip-preview){width:100%;text-align:left}.inv-detail .detail-actions .member-label:has(.equip-preview){min-width:0;white-space:normal}

.dialog:has(.equip-preview){width:min(660px,100%)}.inv-detail .primary .equip-preview{color:#17352d}.dialog:has(.equip-preview) .inv-body{grid-template-columns:minmax(0,1fr) minmax(0,1.1fr)}

/* 021: explicit town-only sprint; native pointer and keyboard activation. */
.sprint-toggle[aria-pressed="true"]{outline:2px solid #efcc7d;outline-offset:1px}.sprint-toggle small{opacity:.75;margin-left:.25em}


/* 020 — Skill compendium; other modal styles are unchanged. */
#stage .dialog:has(.skill-guide){
 width:min(754px,100%);padding:15px;color:#eaf1e9;transform:none;
 background:linear-gradient(138deg,#1d3d38,#122826 60%,#15302d);
 border:1px solid #ab8e60;border-radius:12px;box-shadow:0 16px 46px #040809b9;
}
.skill-tabs{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:7px;margin:10px 0 12px}
#stage .skill-tabs .skill-hero-tab{
 display:flex;align-items:center;gap:8px;text-align:left;min-width:0;min-height:55px;padding:6px 8px;
 border:1px solid #67847a;border-radius:7px;background:linear-gradient(#34554b,#244139);color:#e9f1e9;
}
#stage .skill-guide .skill-hero-tab .portrait{width:38px;flex:none}
.skill-hero-tab strong,.skill-hero-tab small{display:block;line-height:1.2}
.skill-hero-tab strong{font-size:14px}.skill-hero-tab small{font-size:11px;color:#c9dbcc;margin-top:3px}
#stage .skill-tabs .skill-hero-tab[aria-selected="true"]{border-color:#e7ba68;background:linear-gradient(#4b6044,#2a493d);box-shadow:inset 0 -3px #e7ba68}
.skill-hero-tab:focus-visible{outline:2px solid #ffe6a9;outline-offset:2px}
.skill-panels{display:grid;grid-template-columns:1fr 1.25fr 1fr;gap:9px}
.skill-shelf{min-width:0;border:1px solid #55756b;border-radius:8px;padding:8px;background:#122722;align-self:start}
.skill-shelf h3{margin:0 0 7px;padding:1px 1px 6px;border-bottom:1px solid #55756b;color:#f1d197;font-size:14px}
.skill-card{min-width:0;padding:7px;background:#234038;border:1px solid #55796b;border-radius:6px}
.skill-card+.skill-card{margin-top:6px}
.skill-card.is-mastered{border-color:#d9ad64;background:linear-gradient(125deg,#384537,#253e33)}
.skill-card-main{display:flex;gap:6px;align-items:center;min-width:0}
.skill-card-icon{width:32px;height:32px;flex:none;display:grid;place-items:center;background:#142d29;border:1px solid #739b88;border-radius:7px;color:#aceaac}
.skill-card-icon[data-kind="공격"]{color:#ffd78f}.skill-card-icon[data-kind="방어"]{color:#9ddaff}
.skill-card-icon svg{width:21px;height:21px}
.skill-card-copy{min-width:0;overflow-wrap:anywhere}.skill-card-copy strong{font-size:13px}
.skill-card-meta{display:flex;flex-wrap:wrap;gap:5px;font-size:11px;color:#c5e4d6}
.skill-card-meta span:first-child{color:#9fd5ff}
.skill-card .skill-card-effect,.skill-card .skill-card-gear,.skill-card .skill-card-tip,.skill-shelf .skill-card-empty{margin:4px 0 0;font-size:11px;line-height:1.3;overflow-wrap:anywhere}
.skill-card .skill-card-effect,.skill-card .skill-card-tip,.skill-shelf .skill-card-empty{color:#c7d9cd}
.skill-card .skill-card-gear{color:#ecd398}
.skill-card-ap{display:flex;gap:4px;flex-wrap:wrap;align-items:center;justify-content:space-between;margin:5px 0 2px;font-size:11px;color:#c5e4d6}
.skill-card-badge{display:inline-block;padding:2px 5px;border-radius:3px;border:1px solid #d9ad6478;color:#ffe2a4;font-size:10px;background:#433923}
.skill-card.is-mastered .skill-card-badge{margin-top:6px}
.skill-card progress{display:block;width:100%;height:5px;accent-color:#f0c674;border:0;border-radius:3px;overflow:hidden;background:#182922}
.skill-card progress::-webkit-progress-bar{background:#182922}
.skill-card progress::-webkit-progress-value{background:linear-gradient(90deg,#bf9055,#f0c674)}
.skill-guide-footer{justify-content:flex-end;margin-top:11px}
@container(max-width:1100px){
 #stage:not([data-scene="title"]) .dialog:has(.skill-guide){width:min(754px,100%);padding:12px}
}


/* Keep the existing actions visible while long skill lists scroll. */
#stage .dialog:has(.skill-guide){display:flex;flex-direction:column;overflow:hidden}
.skill-guide{display:flex;flex-direction:column;min-height:0}
.skill-tabs,.skill-guide-footer{flex:none}
.skill-panels{min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-color:#7f9c86 #142a24}


/* 031: authored cloth/brass skins; original layout metrics and hit boxes retained.
   Restricted to adventure/combat HUD. Title painted slots and inventory untouched. */
#stage:is([data-scene="field"],[data-scene="battle"]) :is(.party .card,.top .plate,.command-ribbon .panel,.command-ribbon button,.header-controls button){
 position:relative;isolation:isolate;border-color:transparent!important;border-radius:0!important;background:transparent!important;box-shadow:none!important;text-shadow:0 1px 2px #071d1b;
}
#stage:is([data-scene="field"],[data-scene="battle"]) :is(.party .card,.top .plate,.command-ribbon .panel,.command-ribbon button,.header-controls button)::before{
 content:"";position:absolute;inset:0;z-index:-1;pointer-events:none;border-style:solid;border-width:0;border-image:var(--hud031-art) 20 120 fill / 6px 14px / 0 stretch;
}
#stage:is([data-scene="field"],[data-scene="battle"]) .party .card{--hud031-art:url('../assets/hud031/party.png')}
#stage:is([data-scene="field"],[data-scene="battle"]) .top .plate{--hud031-art:url('../assets/hud031/short.png');color:#f6e9c7}
#stage:is([data-scene="field"],[data-scene="battle"]) .top .plate :is(strong,small){color:#f6e9c7}
#stage[data-scene="field"] .command-ribbon .panel{--hud031-art:url('../assets/hud031/field.png')}
#stage[data-scene="battle"] .command-ribbon .panel{--hud031-art:url('../assets/hud031/battle.png')}
#stage:is([data-scene="field"],[data-scene="battle"]) :is(.command-ribbon button,.header-controls button){--hud031-art:url('../assets/hud031/short.png');color:#f7e9c7}
#stage:is([data-scene="field"],[data-scene="battle"]) .command-ribbon button::before{border-image-width:4px 8px}
#stage:is([data-scene="field"],[data-scene="battle"]) .party .portrait{border-radius:0;box-shadow:none;border-color:#ac9265}
#stage:is([data-scene="field"],[data-scene="battle"]) .party .card.ready::before{filter:brightness(1.4)}
#stage:is([data-scene="field"],[data-scene="battle"]) :is(.command-ribbon button,.header-controls button):is(:hover,:focus-visible,.primary)::before{filter:brightness(1.35)}
#stage:is([data-scene="field"],[data-scene="battle"]) .command-ribbon button.primary{color:#fff0bd!important}
#stage:is([data-scene="field"],[data-scene="battle"]) .command-ribbon :is(.battle-buttons,.submenu){border-color:#b5a07466}
/* Keep brass end motifs out of HP digits and portrait at compact sizes. */
#stage:is([data-scene="field"],[data-scene="battle"]) .party .card::before{border-image-width:5px 5px}
#stage:is([data-scene="field"],[data-scene="battle"]) .header-controls button::before{border-image-width:4px 5px}
/* 033 comparison controls; independent of game state and existing command bindings. */
#free-view-controls{position:absolute;left:1%;top:19%;z-index:4;display:flex;align-items:center;gap:4px;padding:4px 6px;background:#152b29e8;color:#f8e9c5;border:1px solid #baa16c;font-size:12px}
#free-view-controls[hidden]{display:none}
#free-view-controls button{min-height:34px;padding:4px 8px;font-size:12px}
#free-view-controls button[aria-pressed=true]{background:#8a7045;color:white}
@media(max-height:450px){#free-view-controls{top:25%;font-size:10px;padding:2px}#free-view-controls button{font-size:10px;padding:3px 5px;min-height:30px}}
/* 041: standalone practice entry and independent controls. */
#stage[data-scene="title"] .practice-entry{position:absolute;bottom:5%;left:4%;pointer-events:auto}
#stage[data-scene="title"] .practice-entry button{padding:6px 16px;min-height:38px;background:#102825ed;color:#ffe4a5;border:1px solid #b89457;font-size:clamp(12px,1.2cqw,18px);text-shadow:0 1px 2px black}
#stage[data-scene="field"] .practice-hud .supplies{margin:0 155px 0 0;text-align:right}
#stage[data-scene="field"] .practice-hud .plate small{display:block}
#stage[data-scene="field"] .practice-ribbon .field-panel{justify-content:space-between;flex-wrap:wrap;padding:5px 8px;gap:4px}
#stage[data-scene="field"] .practice-ribbon .field-utility .row{flex-wrap:wrap}
#stage[data-scene="field"] .practice-ribbon button{white-space:nowrap;padding:3px 9px}
#stage[data-scene="field"] .practice-ribbon .field-utility:last-child{margin-left:auto}
@container(max-width:1100px){#stage[data-scene="field"] .practice-hud .supplies{max-width:245px;margin-right:90px}}
#stage:has(.practice-hud) #compass{display:none}
#stage[data-scene="field"] .top.practice-hud .location{min-width:0;max-width:170px}
#stage[data-scene="field"] .top.practice-hud .supplies{margin-right:120px}
@container(max-width:1100px){#stage[data-scene="field"] .top.practice-hud .supplies{margin-right:95px}}
