body:has(.market-shell){height:100dvh;display:flex;flex-direction:column}
body:has(.market-shell)>.topbar{flex-shrink:0}
body:has(.market-shell)>#main{flex:1;min-height:0}
.market-shell{height:100%;min-height:0;grid-template-rows:auto minmax(0,1fr) auto}
.market-shell .phasebar{padding:.45rem .8rem;gap:.6rem;min-height:0}
.market-shell .objective-strip{box-shadow:none;padding:.3rem .6rem;gap:.4rem}
.market-shell .objective-strip img{width:40px;height:56px}
.market-shell .objective-strip strong{font-size:1rem}
.market-shell .objective-value{font-size:.95rem}
.market-shell .objective-strip small{font-size:.8rem}
.market-shell .objective-live{display:none}
.market-view{min-height:0;height:auto;overscroll-behavior:contain;padding:.6rem 1rem}
.market-head{gap:.6rem}
.market-head h2{font-size:1.7rem;margin:0 auto 0 0}
.market-finish{display:flex;gap:.5rem;max-width:none}
.market-finish button{font-size:.9rem;white-space:nowrap}
.market-guidance{padding:.45rem .7rem;margin:.55rem auto}
.market-guidance strong{font-size:.95rem}
.market-guidance small{display:block;color:#e8d2af;font-size:.85rem;margin-top:.15rem}
.market-columns{max-width:1400px;grid-template-columns:repeat(6,minmax(0,1fr));gap:.6rem;margin:.5rem auto}
.market-column h3{font:600 .95rem/1.3 system-ui,sans-serif;min-height:28px;margin:0 0 .4rem}
.market-offers{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.35rem;align-items:start}
.market-offer{min-width:0;display:flex;flex-direction:column;align-items:center;gap:.35rem}
.market-card{width:100%;max-width:94px;margin:0;box-shadow:2px 4px 5px #0006}
.market-card>span{display:block;padding:.3rem .1rem;background:#f1dfb6;color:#32261c;font-size:.8rem;font-weight:650;line-height:1.2}
.market-card:disabled>span{background:#3b2e23;color:#f1dfb6}
.market-offer-name{font-size:.8rem;font-weight:500;line-height:1.25;text-align:center;overflow-wrap:anywhere}
.market-offer .market-inspect{font-size:.8rem;min-height:44px;margin:0;padding:.35rem .2rem;max-width:110px}
.deck-buy{min-height:44px;font-size:.85rem;margin-top:.4rem;padding:.4rem .2rem}
.market-fairies{gap:.4rem}
.market-fairies button{min-height:48px;gap:.2rem;padding:.35rem .4rem;font-size:.85rem;flex-wrap:wrap}
.market-fairies button small{margin-left:auto;font-size:.75rem;color:#e8d2af}
.market-fairies .icon{width:24px;height:24px}
.market-help{display:block;margin:0;min-height:44px;font-size:.85rem;padding:.4rem .6rem}
.market-shell .objective-strip>div{gap:0;line-height:1.2}
.market-shell .objective-strip strong .icon{width:24px;height:24px}
.market-pocket{display:flex;align-items:center;gap:.7rem;padding:.4rem .8rem;background:#231c15;border-top:1px solid #a38964;min-height:87px}
.market-pocket-heading{flex-shrink:0;display:grid;gap:.2rem;font-size:.9rem}
.market-pocket-heading small{font-size:.8rem}
.market-pocket-cards{display:flex;gap:.4rem;align-items:center;flex:1;min-width:0;min-height:70px;overflow-x:auto;padding:3px;scrollbar-width:thin}
.market-pocket-card{width:48px;flex:0 0 48px;padding:0;border:0;border-radius:3px;background:transparent;position:relative}
.market-pocket-card img{width:100%;height:67px;object-fit:contain;display:block}
.market-pocket-card span{position:absolute;bottom:0;left:0;right:0;background:#231c15ed;color:#f1dfb6;font-size:.65rem;padding:2px 0;text-align:center}
.market-pocket-empty{font-size:.85rem;color:#d4bf9b}
.market-pocket-divider{font-size:.8rem;margin:0 .3rem;white-space:nowrap}
.market-pocket-actions{display:flex;gap:.4rem;flex-shrink:0}
.market-pocket-actions button{font-size:.85rem;padding:.5rem .6rem}
.market-help-list{max-width:760px}
.market-help-list p{margin:.5rem 0 1.2rem}
.symbol-guide{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1.1rem 1.4rem;margin:1.5rem 0}
.symbol-guide section{display:flex;gap:.65rem;align-items:flex-start;min-width:0}
.symbol-guide-icon{padding:.35rem;flex-shrink:0;background:#f1dfb6;border-radius:5px}
.symbol-guide-icon .icon{width:36px;height:36px}
.symbol-guide h3,.equipment-guide h3{font-size:1.2rem;margin:.1rem 0 .4rem}
.symbol-guide p,.equipment-guide p{font-size:.95rem;margin:.35rem 0}
.symbol-example{color:#d4bf9b;line-height:1.5}
.equipment-guide{border-top:1px solid #8c765b;padding:.7rem 0}
.waiting-party{margin:.8rem 0;padding:.65rem;background:#302319;border:1px solid #a38964;border-radius:5px}
.waiting-party>strong{font-size:.95rem}
.waiting-party>div{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap;margin-top:.65rem}
.waiting-party>div>span{flex:1;font-size:.9rem;min-width:100px}
.waiting-party small{display:block;font-size:.8rem;margin-top:.2rem}
.waiting-party button{display:flex;align-items:center;gap:.35rem;font-size:.85rem}
.waiting-party button img{width:25px;height:32px;object-fit:contain}
.opponent-bar small{font-size:.75rem;line-height:1.3;color:#e8d2af}
.route-level-legend{display:flex;gap:.3rem .7rem;flex-wrap:wrap;margin:.3rem 0 .5rem;font-size:.8rem;color:#e8d2af}
.route-level-legend>span{display:flex;gap:.3rem;align-items:center}
.route-level-legend i{width:23px;height:0;border-top:3px solid #f6c665}
.route-level-legend .tunnel-sample{border-top-style:dashed;border-color:#c5b89e}
.route-level-legend small{flex-basis:100%;font-size:.75rem;color:#d4bf9b}
.notice{pointer-events:none}
.results-shell{display:block;min-height:0}
.results-shell .results-view h1{font-size:clamp(1.8rem,4vw,3rem)}
.refresh-preparation{max-width:850px;margin:1.5rem auto;text-align:left}
.refresh-preparation>.primary{display:block;margin:1rem auto;min-width:180px}
.optimizer-tools{display:grid;gap:.35rem;margin-bottom:1rem;padding:.65rem .8rem;border-left:4px solid #f6c665;background:#231c15;color:#f1dfb6}
.optimizer-tools strong{font-size:1.1rem}.optimizer-tools small{color:#e8d2af}
.refresh-preparation .route-replay{display:flex;justify-content:center;flex-wrap:wrap;gap:.8rem;margin:1.5rem auto}
.refresh-preparation .route-replay .hand-card{width:110px}
.refresh-preparation .route-replay img{width:100%;margin:0}
.refresh-preparation .objective-strip{max-width:400px;margin:auto}
.refresh-preparation .inventory{justify-content:center}
@media(max-width:1050px){.market-columns{grid-template-columns:repeat(3,minmax(0,1fr));max-width:800px;gap:.7rem 1rem}.market-card{max-width:100px}.market-pocket-heading small{display:none}}
@media(max-width:650px){
  .market-shell .phasebar{padding:.4rem .5rem;gap:.35rem;align-items:center}
  .market-shell .phase-name{font-size:1rem}
  .market-stages{flex-basis:auto;min-width:0;font-size:.8rem}
  .market-shell .objective-strip{flex-basis:100%;padding:.25rem .5rem}
  .market-shell .objective-strip img{width:34px;height:48px}
  .market-shell .objective-strip>div{grid-template-columns:auto auto;gap:.1rem .7rem;align-items:center}
  .market-shell .objective-strip small{font-size:.75rem;grid-column:1/-1}
  .market-shell .objective-strip strong{font-size:1rem}
  .market-view{padding:.5rem}
  .market-head{gap:.4rem}
  .market-head h2{font-size:1.3rem}
  .market-coins{font-size:.85rem}
  .market-finish{flex-basis:100%;display:grid;grid-template-columns:1fr 1fr;gap:.4rem}
  .market-finish button{padding:.4rem .25rem;font-size:.85rem}
  .market-guidance{padding:.4rem .5rem;margin:.45rem auto}
  .market-guidance strong{font-size:.9rem}
  .market-guidance small{font-size:.8rem}
  .market-columns{grid-template-columns:repeat(2,minmax(0,1fr));gap:.7rem .6rem;margin:.6rem auto}
  .market-column h3{font-size:.9rem;flex-wrap:wrap}
  .market-card{max-width:83px}
  .market-fairies button{min-height:50px;font-size:.8rem}
  .market-fairies button small{font-size:.7rem}
  .market-pocket{padding:.3rem .4rem;gap:.4rem;min-height:83px}
  .market-pocket-heading{font-size:.8rem;max-width:62px}
  .market-pocket-cards{gap:.35rem}
  .market-pocket-empty{font-size:.75rem}
  .market-pocket-actions button{width:44px;padding:0;font-size:0}
  .market-pocket-actions button[data-symbol-help]::after{content:'?';font-size:1.25rem}
  .market-pocket-actions #marketScore{display:none}
  .symbol-guide{grid-template-columns:1fr;gap:1rem}
  .refresh-preparation .route-replay .hand-card{width:82px}
  .refresh-preparation .route-replay{gap:.65rem}
}
@media(min-width:651px){.board-tools{max-width:calc(100% - 190px);flex-wrap:wrap}}

body:has(.dungeon-shell){height:100dvh;display:flex;flex-direction:column;overflow:hidden}
body:has(.dungeon-shell)>.topbar{flex-shrink:0}
body:has(.dungeon-shell)>#main{flex:1;min-height:0}
.dungeon-shell{height:100%;min-height:0;grid-template-columns:minmax(0,1fr) 350px;grid-template-rows:auto minmax(0,1fr)}
.dungeon-shell .phasebar{grid-column:1;grid-row:1;min-height:0;padding:.4rem .75rem;gap:.5rem}
.dungeon-shell .phase-name{font-size:1.15rem;white-space:nowrap}
.dungeon-shell .phasebar:has(.mission-goals){max-height:32dvh;overflow:auto}
.dungeon-shell .phase-detail{font-size:.875rem;flex:1;min-width:140px}
.dungeon-shell .objective-strip{position:static;margin:0;padding:.35rem .5rem;gap:.5rem;box-shadow:none;width:270px;flex-shrink:0}
.dungeon-shell .objective-strip img{width:42px;height:59px}
.dungeon-shell .objective-strip strong{font-size:1.1rem}
.dungeon-shell .objective-strip>div{line-height:1.2;gap:.08rem;flex:1;grid-template-columns:minmax(0,1fr) auto;align-items:center}
.dungeon-shell .objective-strip>div>small,.dungeon-shell .objective-live{grid-column:1/-1}
.dungeon-shell .objective-strip .icon{width:24px;height:24px}
.dungeon-shell .objective-strip small,.dungeon-shell .objective-live{font-size:.8rem}
.dungeon-shell .objective-value{font-size:.95rem}
.dungeon-shell .board-zone{grid-column:1;grid-row:2}
.board-slot{height:150px;display:grid;place-items:center}
.board-slot::after{content:'+';font:32px/1 system-ui,sans-serif;color:#f1dfb6}
.placement-edges{position:absolute;inset:0;z-index:13;pointer-events:none}
.placement-edges button{position:absolute;pointer-events:auto;width:106px;min-height:44px;padding:.35rem .25rem;font-size:.8rem;background:#34271bf0;border-color:#c8ab7b}
.float-tools button{min-width:44px}
.dungeon-shell:not(.is-drawing) .board-tools #undo,.dungeon-shell:not(.is-drawing) .board-tools #erase,.dungeon-shell:not(.is-drawing) .board-tools #finishDrawing{display:none}
.dungeon-shell .hand-zone{grid-column:2;grid-row:1/span 2;display:flex;flex-direction:column;gap:.4rem;min-height:0;overflow:visible;padding:.5rem .65rem;border-left:1px solid #69523a;border-top:0;position:relative}
.dungeon-shell .placement-guide{position:absolute;z-index:35;top:76px;left:.5rem;right:.5rem;margin:0}
.dungeon-shell .hand-heading{flex:0 0 auto;margin:0;gap:.35rem;flex-wrap:wrap;align-items:center}
.dungeon-shell .hand-heading>.inventory{margin-right:auto;font-size:.875rem;gap:.4rem}
.dungeon-shell .hand-heading button{padding:.4rem .5rem;font-size:.85rem;min-height:44px}
.dungeon-shell .round-ready:empty{display:none}
.dungeon-shell .hand-label{font-family:Georgia,serif;font-size:1.15rem;margin:.1rem .1rem 0}
.dungeon-shell .card-hand{flex:1 1 auto;min-height:0;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:repeat(2,minmax(0,1fr));align-items:center;justify-items:center;gap:12px 10px;overflow:visible;padding:10px 4px;margin:0}
.dungeon-shell .hand-card{height:auto;width:100%;aspect-ratio:215/300;max-width:100%;max-height:100%;min-height:44px;transform:none;touch-action:none}
.dungeon-shell .hand-card img{width:100%;height:100%;object-fit:contain}
.dungeon-shell .hand-card:hover{transform:translateY(-3px)}
.dungeon-shell .hand-card[aria-pressed=true]{transform:translateY(-3px);outline:3px solid var(--gold)}
.dungeon-shell .hand-card.used{opacity:.72;filter:none}
.dungeon-shell .hand-card.used:after{bottom:0;font-size:.7rem;padding:.2rem}
.dungeon-shell .spell-hand{grid-column:auto;margin:0;min-width:0;width:100%;height:100%;max-height:145px;align-items:center;justify-content:center;gap:.3rem}
.dungeon-shell .spell-hand button{min-width:0;width:calc(50% - 3px);max-width:54px;min-height:44px}
.dungeon-shell .build-next{flex:0 0 auto;margin:0;padding:0;gap:.3rem;align-items:stretch;flex-direction:column}
.dungeon-shell .build-next p{font-size:.85rem;margin:0;min-height:1.3em}
.dungeon-shell .build-actions{display:grid;grid-template-columns:1fr 1fr;gap:.4rem}
.dungeon-shell .build-next button{width:100%;min-height:44px;padding:.4rem .25rem;font-size:.85rem}
.dungeon-shell .route-tally{flex:0 0 auto;min-height:44px;max-height:62px;flex-wrap:nowrap;overflow-x:auto;gap:.5rem;padding:.25rem 0;scrollbar-width:thin}
.dungeon-shell .route-tally>*{flex-shrink:0}
.dungeon-shell .phasebar .route-tally{flex:1;min-width:0;min-height:54px;max-height:76px;padding:.4rem .55rem;border:1px solid #8e7151;border-radius:4px;background:#34261b;gap:.65rem}
.dungeon-shell .tally-empty{white-space:normal;font-size:.85rem}
.dungeon-shell .tally-caption{font-size:.8rem}
.dungeon-shell .route-level-legend{flex:0 0 auto;margin:0;gap:.3rem .7rem;min-height:20px}
.dungeon-shell .route-direction-fallback{flex:0 0 auto;display:flex;flex-wrap:nowrap;align-items:center;max-height:52px;overflow:auto;margin:0;padding:0}
.dungeon-shell .route-direction-fallback strong{display:none}
.dungeon-shell .route-direction-fallback button{flex-shrink:0}
.dungeon-shell .table-status{flex:0 0 auto;order:20;border-top:1px solid #69523a;position:relative}
.table-status summary{cursor:pointer;min-height:44px;display:flex;align-items:center;gap:.4rem;font-size:.85rem;padding:.35rem .2rem;color:#f1dfb6}
.table-status summary:before{content:'▸'}
.table-status[open] summary:before{content:'▾'}
.dungeon-shell .table-status .opponent-bar{position:absolute;bottom:100%;right:0;width:100%;z-index:35;background:#30251c;border:1px solid #a38964;padding:.4rem;box-shadow:0 -4px 14px #0006;display:grid;grid-template-columns:1fr;gap:.3rem}
.dungeon-shell .opponent-bar button{min-height:44px;flex-wrap:nowrap;justify-content:flex-start;gap:.5rem;font-size:.85rem}
.dungeon-shell .opponent-bar small{margin-left:auto}
.dungeon-shell .waiting-party{flex:0 0 auto;margin:0;padding:.5rem;max-height:195px;overflow:auto}
.dungeon-shell .waiting-party>div{margin-top:.3rem}
.dungeon-shell .group-equipment{flex:0 0 auto;font-size:.85rem}
@media(max-width:1100px) and (min-width:751px){.dungeon-shell{grid-template-columns:minmax(0,1fr) 300px}.dungeon-shell .phase-detail{display:none}}
@media(max-width:750px){
  body:has(.dungeon-shell) .topbar{position:relative;gap:.2rem;padding:.2rem .5rem 1rem;min-height:64px;flex-wrap:nowrap}
  body:has(.dungeon-shell) .topbar .wordmark{font-size:1rem;white-space:nowrap}
  body:has(.dungeon-shell) .topbar nav{flex:0 0 auto;flex-wrap:nowrap;gap:0}
  body:has(.dungeon-shell) .ta-audio-controls{display:none}
  body:has(.dungeon-shell) .topbar #connection{position:absolute;top:auto;bottom:2px;left:.5rem;font-size:.65rem;padding:0}
  body:has(.dungeon-shell) #settings{font-size:0;width:44px;padding:0}
  body:has(.dungeon-shell) #settings::after{content:'⚙';font-size:1.4rem}
  body:has(.dungeon-shell) .topbar nav #help{font-size:.8rem;padding:.35rem .4rem}
  .dungeon-shell{grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto}
  .dungeon-shell .phasebar{grid-column:1;grid-row:1;padding:.3rem .45rem;gap:.3rem}
  .dungeon-shell .phase-detail{display:none}
  .dungeon-shell .objective-strip{flex:1;min-width:0;width:auto;padding:.25rem .4rem}
  .dungeon-shell .objective-strip img{width:32px;height:45px}
  .dungeon-shell .objective-strip strong{font-size:.95rem}
  .dungeon-shell .objective-strip small,.dungeon-shell .objective-live{font-size:.7rem}
  .dungeon-shell .objective-value{font-size:.8rem}
  .dungeon-shell .hand-zone{grid-column:1;grid-row:3;border-left:0;border-top:1px solid #69523a;padding:.3rem .4rem;gap:.2rem;display:grid;grid-template-columns:minmax(0,1fr) auto}
  .dungeon-shell .placement-guide{top:auto;bottom:calc(100% + 8px)}
  .dungeon-shell .hand-heading{grid-column:1;grid-row:1;flex-wrap:nowrap}
  .dungeon-shell .hand-label{display:none}
  .dungeon-shell .card-hand{grid-column:1/-1;grid-row:2;display:grid;grid-template-columns:repeat(5,minmax(0,1fr)) 48px;grid-template-rows:1fr;gap:7px;padding:6px 3px;height:clamp(78px,calc((100vw - 46px)*.28 + 12px),138px);flex:none}
  .dungeon-shell .hand-card{height:auto;width:100%;max-height:100%;max-width:100%}
  .dungeon-shell .spell-hand{flex-direction:column;gap:2px}
  .dungeon-shell .spell-hand:empty{display:none}
  .dungeon-shell .card-hand:not(:has(.spell-hand button)){grid-template-columns:repeat(5,minmax(0,1fr))}
  .dungeon-shell .spell-hand button{width:32px;max-height:calc(50% - 1px);min-height:0}
  .dungeon-shell .spell-hand img{max-height:100%;object-fit:contain}
  .dungeon-shell .build-next{grid-column:1/-1;grid-row:3;display:block}
  .dungeon-shell .build-next p{display:none}
  .dungeon-shell .build-actions{grid-template-columns:1fr 1fr}
  .dungeon-shell .route-tally{grid-column:1/-1;grid-row:4;min-height:32px;max-height:44px}
  .dungeon-shell .phasebar .route-tally{flex-basis:100%;min-height:34px;max-height:44px;order:3;padding:.2rem .4rem}
  .dungeon-shell .table-status{grid-column:2;grid-row:1;border:0;order:0}
  .dungeon-shell .table-status summary{font-size:0;width:44px;padding:.3rem;justify-content:center}
  .dungeon-shell .table-status summary:before{content:'♟';font-size:1.3rem}
  .dungeon-shell .table-status .opponent-bar{width:min(300px,90vw);bottom:100%}
  .dungeon-shell .route-level-legend{grid-column:1/-1;grid-row:5;font-size:.75rem}
  .dungeon-shell .route-direction-fallback{grid-column:1/-1;grid-row:6;display:flex;flex-wrap:nowrap;align-items:center;max-height:52px;margin:0;padding:0;overflow:auto}
  .dungeon-shell .route-direction-fallback strong{display:none}
  .dungeon-shell .route-direction-fallback button{flex-shrink:0}
  .dungeon-shell .waiting-party,.dungeon-shell .group-equipment{grid-column:1/-1}
  .dungeon-shell .board-tip{display:none}
  .dungeon-shell.is-drawing .board-tools #drawTool{display:none}
  .dungeon-shell .board-tools #placeTool,.dungeon-shell .board-tools #erase{font-size:0;min-width:44px;padding:.4rem .5rem}
  .dungeon-shell .board-tools #placeTool::after{content:'Cards';font-size:.85rem}
  html[lang=fr] .dungeon-shell .board-tools #placeTool::after{content:'Cartes'}
  .dungeon-shell .board-tools #erase::after{content:'×';font-size:1.2rem}
  .dungeon-shell .board-tools #finishDrawing{font-size:.8rem;padding:.4rem .5rem}
}
