:root{color-scheme:dark;font-family:-apple-system,BlinkMacSystemFont,"Hiragino Sans",sans-serif;background:#080c15;color:#f5f5fb;-webkit-text-size-adjust:100%}
*{box-sizing:border-box}
body{margin:0}
button,a{-webkit-tap-highlight-color:transparent}
button{font:inherit;touch-action:manipulation;color:inherit;background:#1c293d;border:1px solid #77879b;border-radius:8px;min-height:48px}
button:disabled{opacity:.45}
button:focus-visible,a:focus-visible{outline:3px solid #ffe4a7;outline-offset:2px}
[hidden]{display:none!important}
p{margin:0}
.retreat-shell{max-width:450px;margin:auto;padding:3px 5px max(5px,env(safe-area-inset-bottom));min-height:calc(100svh - var(--nav-height,88px));display:flex}
.retreat-stage{width:100%;min-width:0;min-height:calc(100svh - var(--nav-height,88px) - 8px);display:flex;flex-direction:column;gap:10px;padding:10px;border:1px solid #b6a079;border-radius:16px;background:radial-gradient(ellipse at 50% 34%,#344054,#111b2a 65%);overflow:hidden}
.hud{display:flex;justify-content:space-between;gap:10px;font-variant-numeric:tabular-nums}
.hud>span{display:flex;align-items:center;gap:5px;color:#ffedca}
.hud small{font-size:10px;color:#b8c6d5}
.route{display:flex;justify-content:space-between;gap:4px;padding:0;margin:0;list-style:none}
.route li{display:grid;place-items:center;flex:1;min-width:0;height:27px;background:#101b2c;border:1px solid #67738a;border-radius:6px;font-size:12px;color:#aab6c9}
.route .cleared{color:#ffe09a;border-color:#e5bd70}
.route .current{color:white;border-color:#b1e6ee;background:#294656}
.chamber{flex:1;min-height:180px;display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;position:relative;padding:8px 0;background:linear-gradient(90deg,#0b122300, #8899b00d,#0b122300)}
.room-icon{font-size:28px;line-height:1}
.room-label{font-weight:800;font-size:16px;color:#f7deac;margin-top:8px}
.treasure{display:flex;align-items:center;gap:20px;height:100px;color:#e5bd70;font-size:23px}
.treasure b{font-size:62px;filter:drop-shadow(0 0 14px #efbe6955)}
.reward{font-size:18px;color:#ffe5a7;font-weight:800}
.notice{font-size:12px;color:#ccd7e8;min-height:1.5em;margin-top:8px}
.buddy{display:flex;align-items:center;gap:10px;min-height:96px}
.buddy img{width:100px;height:100px;object-fit:contain;align-self:flex-end;filter:drop-shadow(0 3px 6px #0007)}
.buddy>div{min-width:0;flex:1}
.buddy strong{font-size:14px}
.buddy small{display:block;font-size:11px;color:#f1cf87;margin-top:3px}
.buddy p{font-size:13px;line-height:1.5;background:#ffffff0b;border:1px solid #d2dbea22;border-radius:10px 10px 10px 3px;padding:7px 9px;margin-top:5px}
.clue-panel{padding:10px;background:#0b1425b8;border:1px solid #899ab44d;border-radius:10px}
.clue-panel>p{font-size:14px;font-weight:700;line-height:1.4}
.risk-row{display:flex;gap:8px;justify-content:space-between;align-items:center;margin-top:8px;font-size:11px;color:#abcbd3}
.risk-row strong{font-size:13px;color:#a8efb5;white-space:nowrap}
.risk-meter{height:5px;background:#394358;margin-top:7px;border-radius:8px;overflow:hidden}
.risk-meter i{display:block;height:100%;background:#a8efb5}
.clue-panel[data-danger=mid] .risk-row strong{color:#f6cc7d}
.clue-panel[data-danger=mid] .risk-meter i{background:#f6cc7d}
.clue-panel[data-danger=high] .risk-row strong{color:#ffa89b}
.clue-panel[data-danger=high] .risk-meter i{background:#ffa89b}
.hint{font-size:12px;text-align:center;color:#d1d9e8;margin-bottom:8px;line-height:1.5}
.cast-picker{display:flex;gap:8px;justify-content:center}
.cast-picker button{display:flex;flex-direction:column;align-items:center;padding:4px 9px;background:#152637;min-width:0;flex:1}
.cast-picker img{object-fit:contain}
.cast-picker span{font-size:11px;white-space:nowrap}
.cast-picker [aria-pressed=true]{border-color:#ffe0a0;box-shadow:inset 0 0 0 1px #e5bd70;background:#3c3c3c}
.actions{display:flex;gap:8px;margin-top:auto}
.actions button{flex:1;font-weight:800;font-size:14px;padding:10px 6px;min-height:52px}
.actions .primary{background:linear-gradient(#e7c787,#bc944e);border-color:#f0d69a;color:#241b12}
.retreat-stage[data-outcome=returned],.retreat-stage[data-outcome=complete]{border-color:#ffe3a1}
.retreat-stage[data-outcome=lost] .treasure{opacity:.25}
.retreat-stage[data-outcome=complete] .treasure b{filter:drop-shadow(0 0 22px #efbe69aa)}
@media(prefers-reduced-motion:no-preference){.gain .treasure{animation:gain .45s ease-out}
.retreat-stage[data-outcome=returned] .treasure,.retreat-stage[data-outcome=complete] .treasure{animation:gain .7s ease-out}
@keyframes gain{0%{transform:scale(.8);filter:brightness(1.6)}
50%{transform:scale(1.12)}
100%{transform:scale(1)}
}
}
@media(max-height:680px){.retreat-stage{gap:6px;padding:8px}
.chamber{min-height:145px}
.treasure{height:70px}
.treasure b{font-size:48px}
.buddy{min-height:80px}
.buddy img{width:80px;height:80px}
.room-icon{font-size:22px}
.reward{font-size:16px}
}


/* Danger is conveyed by words, numbers and color together. */
.risk-row strong{padding:4px 6px;border:1px solid currentColor;border-radius:6px}
.risk-meter{height:7px}
.clue-panel[data-danger=high]{border-color:#c67a70}
.clue-panel[data-danger=mid]{border-color:#a88c58}


/* Mark the room where treasure was lost, and celebrate only earned returns. */
.route .failed{color:#ffd1c9;border-color:#d88b80;background:#562e32}

.retreat-stage[data-outcome=returned] .reward,.retreat-stage[data-outcome=complete] .reward{font-size:24px;text-shadow:0 0 15px #e5bd7044}

.chamber::after{position:absolute;inset:27% 0 auto;pointer-events:none;color:#ffe6a7;font-size:24px;white-space:pre;opacity:0}

@media(prefers-reduced-motion:no-preference){
.retreat-stage[data-outcome=returned] .chamber::after,.retreat-stage[data-outcome=complete] .chamber::after{content:'✦     ✧     ✦';animation:reward-sparks 1s ease-out both}

.gain .buddy img{animation:buddy-cheer .45s ease-out}

@keyframes reward-sparks{0%{opacity:0;transform:translateY(30px) scale(.7)}
25%{opacity:1}
100%{opacity:0;transform:translateY(-40px) scale(1.3)}
}

@keyframes buddy-cheer{40%{transform:translateY(-5px)}
100%{transform:translateY(0)}
}

}

/* Fit the decision controls into the visible phone area, including browser chrome. */
.retreat-shell{height:calc(100dvh - var(--nav-height,88px));min-height:0}
.retreat-stage{height:100%;min-height:0;overflow-y:auto}
.retreat-stage>.hud,.retreat-stage>.route,.buddy,.clue-panel,#setup,.actions{flex-shrink:0}
.actions{position:sticky;bottom:0;z-index:2;background:#111b2a;border-radius:8px}
@media(max-height:600px){
.retreat-stage{gap:5px;padding:6px}
.chamber{min-height:96px;padding:0}
.room-icon{display:none}
.room-label{font-size:14px;margin-top:0}
.treasure{height:32px;gap:16px}
.treasure b{font-size:28px}
.reward{font-size:14px}
.notice{font-size:11px;line-height:1.3;margin-top:4px;min-height:0}
.buddy{min-height:64px;gap:7px}
.buddy img{width:64px;height:64px}
.buddy p{font-size:12px;padding:4px 7px;margin-top:3px}
.clue-panel{padding:7px}
.clue-panel>p{font-size:13px}
.risk-row{margin-top:5px}
.risk-row strong{font-size:12px;padding:2px 4px}
.actions button{min-height:48px}
.cast-picker img{width:38px;height:38px}
.hint{font-size:11px}
.retreat-stage[data-phase=result] .reward{font-size:20px}
}

.cast-picker button{position:relative}
.selected-mark{position:absolute;top:3px;right:5px;font-style:normal;font-size:13px;font-weight:800;color:#ffe5a7;visibility:hidden}
[aria-pressed=true] .selected-mark{visibility:visible}
