main:has(> #tower-editor:not([hidden])), main:has(> #tower:not([hidden])) {width:min(100%,1180px)}
main > :is(#tower,#tower-editor) {padding:clamp(16px,3vw,32px);background:#152520;border-color:#596f5c}
:is(#tower,#tower-editor) h1 {font-size:clamp(1.9rem,4vw,3rem)}
:is(#tower-player,#tower-author) {display:grid;gap:14px}
:is(#tower-player,#tower-author) :is(fieldset,details,.tower-card,.tower-panel) {min-width:0;border:1px solid #526b59;border-radius:9px;padding:12px;background:#1b2c25}
:is(#tower-player,#tower-author) :is(fieldset,details) + :is(fieldset,details) {margin-top:10px}
:is(#tower-player,#tower-author) summary {cursor:pointer;font-weight:650}
:is(#tower-player,#tower-author) label {display:grid;align-content:start;gap:5px;font-size:.91rem;color:#e3ddc5}
:is(#tower-player,#tower-author) :is(select,textarea,input:not([type=checkbox])) {font:inherit;border:1px solid #627565;border-radius:5px;background:#12221c;color:inherit;padding:7px;min-width:0;max-width:100%}
:is(#tower-player,#tower-author) textarea {width:100%;min-height:65px;resize:vertical;font:14px/1.5 monospace}
:is(#tower-player,#tower-author) :is(img) {max-width:min(300px,100%);max-height:170px;object-fit:contain;image-rendering:pixelated}
.tower-fields {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(175px,100%),1fr));gap:10px;margin:8px 0}
.tower-tools {display:flex;align-items:end;gap:8px;flex-wrap:wrap}
.economy-item {flex-wrap:wrap;padding:.5rem 0;overflow-wrap:anywhere}
.economy-item > p {flex-basis:100%;margin:0}
.economy-item > img,.economy-icon {width:36px;height:36px;object-fit:contain;image-rendering:pixelated}
.economy-icon {display:grid;place-items:center;color:#efca76;font-size:1.3rem}
.economy-slot {display:grid;gap:.25rem;border-top:1px solid #456052;padding:.55rem 0;min-width:0}
.economy-slots {min-width:0}
.tower-tools [aria-pressed=true] {border-color:#f2cd75;background:#45593d}
.tower-columns {display:grid;grid-template-columns:minmax(270px, .9fr) minmax(350px,1.1fr);gap:14px;align-items:start}
:is(#tower-author,#tower-player) .tower-check {display:inline-flex;align-items:center;gap:6px;margin:5px}
.tower-scroll {overflow:auto;max-height:min(68vh,700px);min-height:175px;border:1px solid #536d58;border-radius:10px;background:#101e19}
.tower-graph {position:relative;margin:8px}
.tower-graph :is(button,small,i) {position:absolute}
.tower-graph i {height:2px;transform-origin:left;background:#607866;pointer-events:none}
.tower-graph small {left:3px;color:#bea87b}
.tower-graph button {width:113px;min-height:40px;padding:6px;background:#253b30}
.tower-graph [data-state=available] {background:#365b3f;border:2px solid #a4d790}
.tower-graph [data-state=closed] {opacity:.36}
.tower-graph [data-state=visited]::before {content:"✓ ";color:#9edda5}
.tower-graph button[aria-current] {outline:2px solid #edc66c}
.tower-option {display:flex;align-items:center;gap:12px;margin:6px 0}
.tower-message {margin:0;color:#efcc82}
.tower-message:empty {display:none}
main:has(> #map:not([hidden])) {width:min(100%,1600px);min-width:0}
body:has(#map:not([hidden])) {padding:clamp(8px,1.6vw,24px)}
main > #map {padding:0;border:0;background:transparent}
.stage-map-header {display:flex;align-items:center;gap:clamp(12px,2vw,28px);margin-bottom:10px}
#map .stage-map-header h1 {font-size:clamp(1.25rem,2.4vw,2rem);margin:0}
#map .expedition-map {height:clamp(640px,calc(100dvh - 102px),980px)}
#map #tower-player > p {margin:0}
.story-stages {margin-top:20px}
.story-stages summary {width:fit-content;cursor:pointer;padding-block:8px}
.story-stages .route {max-width:36rem;margin-top:8px}
.expedition-map {position:relative;isolation:isolate;min-height:640px;height:clamp(640px,77vh,940px);border-radius:12px;overflow:hidden;background:#102833 url("assets/tower-route/parchment.png") center/100% 100% no-repeat;}
#tower-player .expedition-title {position:absolute;width:29%;height:8%;max-width:none;top:0;left:31%;object-fit:contain;}
.expedition-chart {position:absolute;inset:12% 25% 8% 15%;}
.expedition-chart svg {position:absolute;inset:0;width:100%;height:100%;overflow:visible;}
.expedition-chart path {fill:none;stroke:#77513b;stroke-width:2;stroke-dasharray:4 5;vector-effect:non-scaling-stroke;stroke-linecap:round;}
.expedition-chart path.next {stroke:#a84912;stroke-width:3;stroke-dasharray:none;}
.expedition-chart button {display:grid;place-items:center;position:absolute;transform:translate(-50%,-50%);border:2px solid transparent;background:transparent;padding:1px;border-radius:50%;width:clamp(29px,3.8vh,44px);height:clamp(29px,3.8vh,44px);min-height:0;box-shadow:none;}
#tower-player .expedition-chart button img {width:100%;height:100%;max-width:none;pointer-events:none;object-fit:contain;image-rendering:auto;}
.expedition-chart button:disabled {opacity:1;cursor:default;}
.expedition-chart button[data-state=closed] {opacity:.42;filter:grayscale(.75);}
.expedition-chart button[data-state=available],.expedition-chart button[data-state=available]:hover {border-color:#ffe6a3;background:#fff0bb;box-shadow:0 0 0 2px #8e511b,0 0 12px #ffc662;cursor:pointer;}
.expedition-chart button:focus-visible {outline:3px solid #153d40;outline-offset:4px;}
.expedition-chart button[aria-current] {filter:drop-shadow(0 0 4px #ffe594);}
.expedition-chart button[data-room=boss] {width:28%;height:11%;}
.expedition-chart button[data-room=start] {width:12%;height:8%;}
.expedition-chart button span {position:absolute;bottom:-3px;right:-6px;color:white;background:#376637;border-radius:50%;font:bold 12px/17px sans-serif;width:17px;}
.expedition-legend {position:absolute;right:1%;top:30%;width:17%;height:38%;background:url("assets/tower-route/legend.png") center/100% 100% no-repeat;}
.expedition-keys {position:absolute;inset:22% 9% 9% 12%;display:flex;flex-direction:column;justify-content:space-between;}
.expedition-key {display:flex;align-items:center;gap:7px;font-size:clamp(.7rem,1.25vw,1rem);color:#402715;}
#tower-player .expedition-key img {width:22%;height:clamp(18px,2.8vh,30px);object-fit:contain;image-rendering:auto;}
#expedition-lab {overflow:auto;}
#expedition-report {display:block;font-size:.86rem;}
#expedition-report :is(td,th) {padding:3px;text-align:center;border-bottom:1px solid #536359;}
@media(max-width:650px){
  .expedition-map {min-height:620px;height:78vh;background-size:140% 100%;background-position:38% center;}
  .expedition-chart {inset:10% 6% 10%;}
  #tower-player .expedition-title {left:27%;width:46%;}
  .expedition-legend {inset:auto 0 0;width:100%;height:auto;display:flex;flex-direction:row;flex-wrap:wrap;gap:3px 7px;justify-content:center;padding:3px;background:#182820;}
  .expedition-keys {display:contents;}
  .expedition-key {font-size:10px;color:#fff1cd;gap:2px;}
  #tower-player .expedition-key img {width:16px;height:16px;}
}
@media(max-width:760px){.tower-columns{grid-template-columns:1fr}.tower-scroll{max-height:42vh}}
@media (min-width: 36rem) { #tower-player .tower-card.tower-event-fallback { padding-inline-end: 7.5rem; background: #1b2c25 url("assets/tower-route/event.png") right 12px top 12px / 88px 108px no-repeat; } } @media (max-width: 35.999rem) { #tower-player .tower-card.tower-event-fallback { padding-top: 5rem; background: #1b2c25 url("assets/tower-route/event.png") center 6px / 54px 66px no-repeat; } }
