/* Chapter gates use the existing camp palette and cards. */
.castle-entry:not(.has-target){background:linear-gradient(#f4f3e3,#e9edd8);border-color:#d7dfc1;box-shadow:0 3px 0 #d9dfc8}.castle-entry .castle-entry-caption{overflow-wrap:anywhere}.castle-section-label{font-size:13px;color:#798969;margin:4px 0 8px}.castle-section-label:not(:first-child){margin-top:17px}.castle-goal{border:1px solid #d9dfc6;background:#f8f8ed;border-radius:13px;padding:11px;margin-bottom:9px}.castle-goal.is-ready{border-color:#dcc384;background:linear-gradient(#fff8dc,#f2edcf)}.castle-goal-heading{display:flex;align-items:center;gap:8px}.castle-goal-heading>div{flex:1;min-width:0}.castle-goal-heading b{display:block;font-size:14px;line-height:1.4}.castle-goal-heading small{display:block;font-size:12px;color:#849372;margin-top:3px;line-height:1.4}.castle-goal-heading>.primary:not(.mother-btn){min-height:40px;padding:8px 10px;font-size:13px;border-radius:10px;flex:none}.castle-goal-progress{margin:9px 0 10px;color:#839171;font-size:12px}.castle-goal-progress>i{display:block;height:6px;border-radius:4px;background:#dfe5cf;margin-top:5px;overflow:hidden}.castle-goal-progress em{display:block;height:100%;border-radius:4px;background:#9caf73}.castle-goal-loot{margin-top:9px;padding-top:8px;border-top:1px solid #d9d9b57a}.castle-goal-loot>small{display:block;font-size:11px;color:#89916c;margin-bottom:5px}.castle-goal-loot .castle-rewards{justify-content:flex-start;gap:7px 11px}.castle-goal-loot .castle-rewards>span{font-size:13px}.castle-goal-loot .castle-rewards svg{width:21px;height:21px}.castle-history{border-top:1px solid #dde3cc;padding-top:10px;margin:14px 0 8px}.castle-history>summary{font-size:14px;cursor:pointer;padding:4px 0}.castle-history>summary>b{float:right;background:#e7ecd6;padding:2px 8px;border-radius:8px;font-size:12px}.castle-history-map{margin:12px 0}.castle-history-map h4{font-size:13px;color:#83916f;margin:0 0 4px}.castle-history-row{display:flex;align-items:center;gap:7px;min-height:37px;border-bottom:1px solid #e8ebdb}.castle-history-row>span{width:20px;height:20px;color:#809c5b}.castle-history-row svg{width:100%;height:100%}.castle-history-row>b{font-size:14px}.castle-history-row>small{font-size:12px;color:#899573;text-align:right;flex:1;line-height:1.4}.castle-history-empty{font-size:13px;color:#8b967c;padding:14px 0}
.castle-report-entry{display:flex;align-items:center;gap:10px;width:100%;padding:12px;border:1px solid #d6bf7e;border-radius:14px;background:linear-gradient(#fff5d5,#efe4b9);color:var(--ink);text-align:left;margin:5px 0 12px;box-shadow:0 3px 0 #d8cca1}.castle-report-entry>svg{width:42px;height:48px;flex:none}.castle-report-entry>span{min-width:0}.castle-report-entry b{display:block;font-size:16px;line-height:1.3}.castle-report-entry small{display:block;margin-top:5px;font-size:12px;line-height:1.4;color:#7b805b}
.stats-row:has(.castle-entry){gap:7px}.stats-row:has(.castle-entry)>.stat{min-width:0;padding:10px 8px}.castle-entry{position:relative;text-align:left;background:linear-gradient(#fff5d5,#efe4b9);border-color:#d9bf78;box-shadow:0 3px 0 #d8cca1}.castle-entry-value{display:flex;align-items:center;gap:6px}.castle-entry-value>svg{width:29px;height:29px;flex:none}.castle-entry .castle-entry-caption{display:block;margin-top:3px;font-size:12px;color:#8a784a}.castle-entry .notice-dot{right:6px;top:6px}
#dialog:not(.mother-modal):has(.castle-list){width:calc(100% - 28px);max-width:390px;max-height:84dvh;padding:20px 14px 14px;overflow:hidden}.castle-list{display:flex;flex-direction:column;max-height:calc(84dvh - 36px);min-height:0}.castle-list>h2{font-size:22px;margin-right:25px}.castle-list-rule{font-size:12px;line-height:1.5;margin:7px 0 14px;color:#7e8d6e}.castle-list-scroll{overflow:auto;min-height:0;padding:2px 1px 4px;scrollbar-width:thin}.castle-resume{width:100%;min-height:42px;margin:0 0 12px;border-radius:11px;font-size:13px;padding:8px}
.castle-map-list{border:1px solid #d7dfc1;border-radius:13px;background:#f2f3e2;overflow:hidden;margin-bottom:10px}.castle-map-list>summary{list-style:none;display:flex;align-items:center;gap:8px;min-height:66px;padding:9px;cursor:pointer}.castle-map-list>summary::-webkit-details-marker{display:none}.castle-map-list>summary:after{content:'';width:7px;height:7px;border-right:2px solid #879671;border-bottom:2px solid #879671;transform:rotate(45deg);flex:none;margin:0 2px 4px 3px}.castle-map-list[open]>summary:after{transform:rotate(225deg);margin-top:6px}.castle-map-emblem{width:37px;height:42px;flex:none}.castle-map-emblem>svg{width:100%;height:100%}.castle-map-list summary>span:nth-child(2){flex:1;min-width:0}.castle-map-list summary b{display:block;font-size:15px;line-height:1.3}.castle-map-list summary small{font-size:12px;color:#82916c;display:block;margin-top:4px}.castle-map-status{font-size:12px;color:#7e8554;flex:none}.castle-map-stages{border-top:1px solid #dde3cc;padding:0 9px;background:#fffdf1}.castle-stage{display:flex;align-items:center;gap:7px;padding:11px 0;border-bottom:1px solid #e8ebd9}.castle-stage:last-child{border-bottom:0}.castle-stage-icon{width:27px;height:32px;flex:none;opacity:.72}.castle-stage-icon>svg{width:100%;height:100%}.castle-stage.is-cleared .castle-stage-icon{color:#7f9a5b}.castle-stage-info{flex:1;min-width:0}.castle-stage-info b{font-size:13px;line-height:1.3;display:block}.castle-stage-info small{display:block;font-size:12px;line-height:1.3;margin-top:4px;color:#889575}.castle-stage-status{font-size:12px;color:#8b987c}.castle-stage .primary:not(.mother-btn){font-size:12px;min-height:38px;padding:8px 10px;border-radius:9px;flex:none}.castle-stage.is-ready .castle-stage-icon{opacity:1}.castle-stage.is-locked{color:#94a084}
.view.castle-view{display:flex;flex-direction:column;gap:8px;padding:6px 12px 9px;overflow:hidden}.castle-challenge-heading{display:flex;align-items:center;gap:9px;min-height:42px;flex:none}.castle-back{display:grid;place-items:center;border:1px solid #d5debc;border-radius:11px;background:#edf0dd;width:38px;height:38px;flex:none}.castle-back>svg{width:23px;height:23px}.castle-challenge-heading>div{flex:1;min-width:0}.castle-challenge-heading b{display:block;font-size:15px;line-height:1.3}.castle-challenge-heading small{display:block;font-size:12px;color:#82926d;line-height:1.3;margin-top:2px}.castle-challenge-heading>span{font-size:12px;white-space:nowrap;color:#7a8b65}
.castle-scene{flex:1 1 0;min-height:110px}.castle-scene-score{position:absolute;inset:7px 7px auto;z-index:2}.castle-score{display:flex;align-items:center;justify-content:center;gap:7px;padding:6px 8px;border:1px solid #c9d1b690;border-radius:10px;background:#fffbe9e6;min-height:37px}.castle-score-side{display:flex;align-items:center;gap:5px}.castle-score-side small{font-size:12px;color:#718061}.castle-score-side b{font-size:22px;font-variant-numeric:tabular-nums;line-height:1;color:#557744}.castle-score-side.enemy b{color:#b55d48}.castle-score-side i{display:flex;gap:3px}.castle-score-side em{width:6px;height:6px;background:#d4dbc2;border:1px solid #bfc9ac;border-radius:50%}.castle-score-side.ally em.filled{background:#7da75a;border-color:#63894a}.castle-score-side.enemy em.filled{background:#d47a5f;border-color:#b5604d}.castle-score-target{font-size:12px;color:#83916e;margin:0 3px;white-space:nowrap}.castle-scene .scene-foot{left:8px;right:8px;font-size:12px;bottom:6px}
.castle-lower{position:relative;flex:none;min-height:0}.castle-forge-heading{display:flex;align-items:center;justify-content:space-between;gap:6px;height:43px;margin-bottom:5px}.castle-forge-heading h2{font-size:18px;line-height:1.2}.castle-stage-controls{display:flex;align-items:center;gap:8px;flex:none}.castle-stage-controls .remaining{padding:4px 8px}.castle-stage-controls .remaining b{font-size:26px}.castle-stage-controls .remaining small{font-size:12px}.castle-keep-count{font-size:16px;font-weight:800;color:#71824d;font-variant-numeric:tabular-nums}.castle-stage-controls>.primary:not(.mother-btn){font-size:13px;min-height:37px;padding:7px 10px;border-radius:10px}.castle-battle-clock{font-size:16px;color:#7b8c68;font-variant-numeric:tabular-nums}
.castle-board{--tile:clamp(36px,calc((100dvh - 368px)/4),66px);gap:5px;padding:6px}.castle-board .cell{touch-action:none}.castle-board .tile>img{width:78%;height:78%;object-fit:contain}.castle-board .cell.is-kept{z-index:2;box-shadow:0 0 0 3px #b49341,0 3px 0 #8c793d}.castle-board .cell.is-kept .tile{border-color:#fff0a4;filter:brightness(1.08)}.castle-selected-check{position:absolute;top:2px;right:2px;border-radius:50%;background:#f7dc86;color:#68723f;width:18px;height:18px;box-shadow:0 1px 2px #4e603448;z-index:3;display:grid;place-items:center}.castle-selected-check svg{width:14px;height:14px}.castle-board.is-selecting .cell:not(.empty):not(.is-kept){opacity:.78}.castle-lower.is-choosing .castle-forge-content{visibility:hidden;pointer-events:none}.castle-choice-panel{position:absolute;inset:0;background:var(--cream);padding:7px 0;display:flex;flex-direction:column;justify-content:center;animation:choice-enter .32s ease-out}.castle-choice-panel>h2{text-align:center;font-size:21px;margin-bottom:13px}.castle-choice-panel .choice{min-height:185px}.castle-choice-panel .choice b{display:flex;flex-direction:column;justify-content:center;min-height:37px}.castle-choice-panel .choice small{font-size:12px}.castle-choice-panel .choice .offer-power{font-size:12px}
.castle-result{flex:none;padding:12px 7px 7px;display:flex;flex-direction:column;gap:12px;min-height:200px}.castle-result-title{display:flex;align-items:center;justify-content:center;gap:12px}.castle-result-title>svg{width:56px;height:56px;flex:none}.castle-result h2{font-size:22px;line-height:1.3}.castle-result-title p{font-size:13px;color:#7e8d6b;margin-top:4px;line-height:1.4}.castle-result-label{font-size:12px;text-align:center;color:#899775}.castle-rewards{display:flex;justify-content:center;gap:11px;flex-wrap:wrap}.castle-rewards>span{display:flex;align-items:center;gap:3px;font-size:15px}.castle-rewards svg{width:23px;height:23px}.castle-pending-note{text-align:center;font-size:12px;line-height:1.4;color:#9c885b}.castle-result-actions{display:flex;gap:9px;margin-top:3px}.castle-result-actions>button{flex:1;min-height:44px;padding:10px 7px;font-size:15px;border-radius:12px}
@media(max-height:640px){.view.castle-view{gap:5px;padding:4px 10px 6px}.castle-challenge-heading{min-height:38px}.castle-challenge-heading b{font-size:14px}.castle-scene-score{inset:5px 5px auto}.castle-score{gap:4px;padding:4px;min-height:31px}.castle-score-side{gap:3px}.castle-score-side b{font-size:19px}.castle-score-side em{width:5px;height:5px}.castle-score-target{margin:0 2px}.castle-forge-heading{height:37px;margin-bottom:4px}.castle-forge-heading h2{font-size:16px}.castle-stage-controls>.primary:not(.mother-btn){min-height:34px}.castle-choice-panel{padding-top:3px;justify-content:flex-start}.castle-choice-panel>h2{font-size:19px;margin-bottom:8px}.castle-choice-panel .choice{min-height:151px}.castle-result{min-height:180px;padding-top:7px;gap:8px}.castle-result h2{font-size:20px}.castle-result-title>svg{width:45px;height:45px}}
@media(max-width:350px){.stats-row:has(.castle-entry){gap:5px}.stats-row:has(.castle-entry)>.stat{padding:9px 6px}.stats-row:has(.castle-entry) .stat strong{font-size:23px}.castle-entry-value{gap:3px}.castle-entry-value>svg{width:25px;height:25px}.castle-score{gap:4px}.castle-score-side{gap:3px}.castle-score-side i{gap:2px}.castle-score-target{margin:0}.castle-challenge-heading b{font-size:14px}.castle-map-list>summary{gap:6px}.castle-map-list summary b{font-size:14px}.castle-map-status{max-width:57px;white-space:normal;text-align:right}.castle-stage .primary:not(.mother-btn){padding:7px 8px}.castle-rewards{gap:8px}.castle-rewards>span{font-size:14px}}
@media(prefers-reduced-motion:reduce){.castle-choice-panel{animation:none}}

/* Keep preparation controls above the board; combat gets a separate full field. */
.view.castle-view{gap:6px;padding-top:2px;padding-bottom:8px}
.castle-challenge-heading{min-height:36px;gap:9px;margin:0;flex:none}
.castle-challenge-heading>b{flex:1;min-width:0;font-size:17px;line-height:1.3}
.castle-challenge-heading>b>small{display:inline;font-size:13px;font-weight:600;color:#80906a;white-space:nowrap;margin-left:4px}
.castle-back{width:35px;height:35px;border-radius:10px}
.castle-back>svg{width:22px;height:22px}
.castle-score-strip{flex:none;min-height:0}
.castle-score-strip .castle-score{background:#f2f0db;border-color:#d8dec5;min-height:33px;padding:5px 8px}
.castle-score-strip .castle-score-side b{font-size:22px}
.castle-round-tag{position:absolute;top:8px;left:8px;z-index:2;padding:4px 7px;border-radius:7px;background:#fffbe6de;font-size:12px;line-height:1.3;color:#6f8157;pointer-events:none}
.castle-assembly-scene{min-height:130px}
.castle-forge-heading{position:relative;isolation:isolate;height:44px;margin:0 0 5px;flex:none}
.castle-forge-heading:has(.scene-feedback)>h2{visibility:hidden}
.castle-forge-heading>.scene-feedback{position:absolute;inset:0 94px 0 0;min-height:0;max-height:100%;overflow:hidden;flex-direction:column;align-items:flex-start;justify-content:center;gap:1px;padding:1px 4px 1px 8px}
.castle-forge-heading>.scene-feedback strong{font-size:18px;line-height:1.2}
.castle-forge-heading>.scene-feedback small{font-size:11px;line-height:1.2;padding:1px 5px}
.castle-forge-heading>.scene-feedback.is-combo strong{font-size:20px}
.castle-board{--tile:clamp(36px,calc((100dvh - 380px)/4),66px)}
.castle-board-wrap{min-height:0}
.castle-launch-mark{display:grid;place-items:center;width:39px;height:35px;border-radius:9px;background:#f2e4b5;color:#8b7945;animation:castle-flag-pulse .8s ease-in-out infinite}
.castle-launch-mark>svg{width:26px;height:26px}
.castle-lower.is-launching .castle-board{filter:saturate(.85)}
.castle-battle-numbers{display:flex;justify-content:space-between;align-items:center;gap:14px;padding:1px 8px 3px;flex:none;font-size:13px;color:#6c805c;font-variant-numeric:tabular-nums}
.castle-battle-numbers>span{display:flex;align-items:baseline;gap:7px}
.castle-battle-numbers b{font-size:25px;line-height:1.1;color:#54783e}
.castle-battle-numbers>span:last-child b{color:#b65d48}
.castle-battle-scene{min-height:170px;flex:1 1 0}
.castle-battle-scene .castle-battle-clock{position:absolute;right:10px;bottom:8px;z-index:2;border-radius:7px;background:#fffbe7db;font-size:13px;padding:4px 7px;pointer-events:none}
.castle-battle-power{display:flex;justify-content:space-between;gap:12px;padding:4px 5px;flex:none;font-size:12px;line-height:1.4;color:#7b8a68;font-variant-numeric:tabular-nums}
.castle-battle-power>span{display:flex;align-items:baseline;flex-wrap:wrap;column-gap:5px}
.castle-battle-power>span:last-child{justify-content:flex-end;text-align:right}
.castle-battle-power b{font-size:18px;line-height:1.2;color:#527143}
.castle-battle-power>span:last-child b{color:#a75f4e}
.castle-round-result{position:absolute;top:16%;left:50%;transform:translateX(-50%);max-width:80%;padding:8px 18px;border:1px solid #c5d19d;border-radius:12px;background:#f5f4dce8;color:#597e3f;font-size:23px;font-weight:900;line-height:1.3;text-align:center;z-index:3;pointer-events:none;animation:castle-result-pop .35s ease-out}
.castle-round-result.is-enemy{background:#fbedd8e8;border-color:#d3af8e;color:#a2644f}
@keyframes castle-flag-pulse{0%,100%{transform:translateX(0)}50%{transform:translateX(3px)}}
@keyframes castle-result-pop{from{opacity:0;transform:translateX(-50%) scale(.85)}to{opacity:1;transform:translateX(-50%) scale(1)}}
@media(max-height:640px){.view.castle-view{gap:5px;padding-top:1px;padding-bottom:5px}.castle-challenge-heading{min-height:34px}.castle-back{width:33px;height:33px}.castle-challenge-heading>b{font-size:15px}.castle-score-strip .castle-score{min-height:29px;padding:4px 5px}.castle-assembly-scene{min-height:110px}.castle-forge-heading{height:40px;margin-bottom:4px}.castle-battle-numbers{padding-top:0;padding-bottom:1px}.castle-battle-numbers b{font-size:22px}.castle-battle-power b{font-size:16px}.castle-round-result{font-size:20px;padding:7px 14px}.castle-result{min-height:170px}}
@media(max-width:350px){.castle-challenge-heading>b{font-size:15px}.castle-challenge-heading>b>small{font-size:12px}.castle-forge-heading h2{font-size:16px}.castle-stage-controls{gap:5px}.castle-stage-controls>.primary:not(.mother-btn){font-size:12px;padding:7px 8px}.castle-forge-heading>.scene-feedback{right:84px}.castle-forge-heading>.scene-feedback strong{font-size:17px}.castle-forge-heading>.scene-feedback.is-combo strong{font-size:18px}.castle-battle-power{gap:7px;font-size:11px}.castle-battle-power b{font-size:16px}}
@media(prefers-reduced-motion:reduce){.castle-launch-mark,.castle-round-result{animation:none}}


.castle-enemy-name{position:absolute;top:9px;right:10px;max-width:64%;padding:4px 8px;border-radius:7px;background:#fff9e5db;color:#986044;font-size:13px;font-weight:800;pointer-events:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.castle-enemy-name.is-boss{background:#fff0c9ed;color:#9b5d36;border:1px solid #d2ad69}
.castle-enemy-name>svg{display:inline-block;width:16px;height:16px;vertical-align:-3px}

/* Current goals stay above a permanently expanded history by default. */
.castle-list>h2{margin:0;text-align:center}
#dialog:not(.mother-modal)[data-kind="castles"].has-text-heading>.dialog-text-heading{left:53px;right:53px;margin:0;text-align:center;justify-content:center}
.castle-list-rule{text-align:center;flex:none;margin:0 0 13px}
.castle-list .castle-section-label{text-align:center}
.castle-history>summary{position:relative;padding-right:28px;padding-left:28px;text-align:center;font-weight:750}
.castle-history>summary>b{position:absolute;right:0;top:4px;float:none}
