/* Cave UI: carved violet stone, cyan enamel, warm currency. No backdrop filters. */
:root{--game-stone:#29283e;--game-rim:#696480;--game-ink:#121522;--game-light:#b2eeff;--game-blue:#368eab;--game-cream:#f2e9ce}
body{font-family:ui-rounded,"Trebuchet MS",sans-serif}
body #game .controls{background:none;border:0;box-shadow:none;backdrop-filter:none;padding:0;overflow:visible}
body #game .tools{gap:7px;padding:5px 2px;overflow:visible;align-items:center}
body #game .tools button,body #game .tools #settings,body #game .tools #priorityButton{position:relative;width:48px;height:48px;flex:0 0 48px;margin:0;border:2px solid #696480;border-top-color:#9991aa;border-bottom:4px solid #141828;border-radius:16px 16px 19px 19px;background:linear-gradient(155deg,#545064 0 14%,#353448 15% 65%,#292b40 66%);color:#dfdfeb;box-shadow:0 4px 0 #090f20,0 6px 8px #0005,inset 0 1px #b9acc84a;transition:transform .08s,filter .08s}
body #game .tools button svg{width:28px;height:28px;stroke-width:2.4;filter:drop-shadow(0 2px 0 #111b2c)}
body #game .tools button[aria-pressed=true],body #game .tools button[aria-expanded=true],body #game .tools #digtool[aria-pressed=true]{background:linear-gradient(150deg,#79d9e8 0 10%,#397d9d 11% 62%,#285373 63%);border-color:#a6e8ec;border-bottom-color:#19364e;color:#fff7dc;box-shadow:0 4px 0 #081522,0 0 12px #4eb8df40,inset 0 1px #e5ffff8a;transform:translateY(-2px)}
body #game .tools button:active{transform:translateY(3px);box-shadow:0 1px 0 #090f20;filter:brightness(1.15)}
body #game .popover{border:2px solid #67617a;border-top-color:#ada0b1;border-bottom:5px solid #12172a;border-radius:20px;background:linear-gradient(145deg,#403a51,#282a40 45%,#1d2439);box-shadow:0 5px 0 #080f1d,0 9px 20px #0005;backdrop-filter:none}
body #game #recruitPanel.compact-recruit{padding:8px 11px 10px;border:0;border-radius:0;box-shadow:none;background:none;overflow:visible;bottom:calc(100% + 12px)}
body #game #recruitCards{gap:12px}
body #game .recruit-orb{width:66px;filter:drop-shadow(0 4px 2px #070c1e88)}
body #game .orb-face{width:66px;height:66px;border-radius:50%;overflow:hidden;border:3px solid #9ca0b9;border-top-color:#e5dcd5;border-bottom-color:#4f516d;background:radial-gradient(circle at 40% 26%,#576380,#252b47 70%);box-shadow:inset 0 0 0 3px #141b31,inset 0 0 13px #0c142b;position:relative}
body #game .orb-face svg.unit-portrait{width:62px;height:62px;stroke:none;fill:initial;transform:translateY(3px);filter:drop-shadow(0 2px 0 #111827)}
body #game .orb-price{font-size:15px;font-weight:900;color:#ffe4a1;letter-spacing:.2px;min-width:48px;padding:3px 8px;border:1px solid #74614d;border-bottom:3px solid #1b1821;border-radius:7px;background:linear-gradient(#3d3440,#201f30);text-shadow:0 2px #0e1220;margin-top:-7px;position:relative}
body #game .recruit-orb:disabled{opacity:.65}body #game .recruit-orb.locked .unit-portrait{filter:grayscale(.85) brightness(.6)}
body #game .recruit-orb:not(:disabled):active{transform:translateY(3px)}
body #game .zoom button,body #game #sound{border:2px solid #696480;border-bottom:3px solid #151a2c;background:linear-gradient(145deg,#4c4b62,#242b41);border-radius:13px;box-shadow:0 3px #090f20;color:#e3f0f8}
body #game .zoom button{width:42px;height:42px}body #game #sound{width:40px;height:40px}
body #game .popover input[type=range],#arenaUI .duration-setting input{appearance:none;height:8px;border-radius:4px;background:#11182d;box-shadow:inset 0 2px 3px #0008,0 1px #77718980;border:0;margin-top:14px;margin-bottom:10px}
body #game .popover input[type=range]::-webkit-slider-thumb,#arenaUI .duration-setting input::-webkit-slider-thumb{appearance:none;width:24px;height:26px;clip-path:polygon(50% 0,95% 22%,95% 75%,50% 100%,5% 75%,5% 22%);background:linear-gradient(135deg,#e3ffff 0 20%,#7bd9eb 21% 50%,#3994ba 51%);border:2px solid #b5ecf5;cursor:ew-resize}
#arenaUI .stone-panel{box-sizing:border-box;background:linear-gradient(135deg,#61556d 0 2%,#37354c 3% 50%,#24283f 100%);border:3px solid #82758e;border-top-color:#c1acbd;border-bottom:7px solid #12192c;border-radius:26px;clip-path:none;box-shadow:0 5px 0 #070d1c,inset 0 0 0 3px #48445d;padding:23px;max-width:370px}
#arenaUI .stone-panel h1{font:900 30px ui-rounded,"Trebuchet MS",sans-serif;letter-spacing:-1px;color:#fff1d7;text-shadow:0 3px #14182c}
#arenaUI .panel-subtitle{font-size:12px;color:#c8bcd0;margin-bottom:12px}
#arenaUI .crest{color:#7ee9fc;filter:drop-shadow(0 3px 0 #1c3156);margin-bottom:4px}
#arenaUI .primary-game{border:2px solid #a9e7ec!important;border-bottom:5px solid #1b3d59!important;border-radius:14px;clip-path:none;background:linear-gradient(#65c8d7,#3e91ac 52%,#31718f 53%);color:#f6ffff!important;font-size:17px;text-shadow:0 2px #2a5169;box-shadow:0 3px #101829,inset 0 1px #d5ffff60;padding:12px 16px}
#arenaUI .map-choice{background:linear-gradient(145deg,#292a42,#1a2034);border:2px solid #57536d!important;border-bottom:4px solid #141b2e!important;border-radius:15px;padding:6px 2px 9px;box-shadow:inset 0 1px #887b9450}
#arenaUI .map-choice.chosen{border-color:#94e4f3!important;border-bottom-color:#2a6f8a!important;background:linear-gradient(145deg,#42627c,#26324d);transform:translateY(-2px)}
#arenaUI .map-choice b{font-weight:900;color:#e9f5ff}#arenaUI .map-choice small{font-size:10px}
#arenaUI .map-stone{fill:#66618b}#arenaUI .map-tunnel{stroke:#dcc3a0}#arenaUI .map-rival{fill:#9b819e}
#arenaUI .number-choices button,#arenaUI .bot-stepper button{width:44px;height:40px;border-radius:12px;border:2px solid #706981!important;border-bottom:4px solid #14182b!important;background:linear-gradient(#4b455e,#303249);font-weight:900}
#arenaUI .number-choices button[aria-pressed=true]{background:linear-gradient(#4d97ae,#2c5678);border-color:#94dfe9!important;color:#e6ffff!important}
#arenaUI .duration-setting{border-top-color:#8c819140;margin:14px 0 18px}#arenaUI .range-ends{display:none}#arenaUI .setup-row{font-weight:700;font-size:13px}
#arenaUI .warband{background:linear-gradient(155deg,#51465c,#2c2a40 55%,#22283d);border:2px solid #85758d;border-bottom:4px solid #14182a;border-radius:12px 19px 15px 10px;clip-path:none;box-shadow:0 3px #080e20}
#arenaUI .match-clock{background:linear-gradient(#4d4255,#242a3e);border:2px solid #8b7883;border-bottom:4px solid #15192d;border-radius:9px 9px 17px 17px;clip-path:none;padding:7px 15px;color:#f6e6ca}
#arenaUI .game-key{border-radius:12px;background:linear-gradient(#50495f,#292e44);border:2px solid #82788e!important;border-bottom:4px solid #161b30!important;box-shadow:0 3px #080f20}
#arenaUI .base-chip{border-radius:10px;clip-path:none;background:#242a40;border:1px solid #5b607a;box-shadow:0 2px #0c1323}
#arenaUI .seat{border-radius:12px;background:#1b2238;border:1px solid #5d5671;border-left:4px solid var(--team)}
#arenaUI .quiet-game{font-weight:700;font-size:12px!important;color:#c4d8e4!important;min-height:40px}
@media(max-width:640px){body #game .tools{gap:6px}body #game .tools button,body #game .tools #settings,body #game .tools #priorityButton{width:44px;height:46px;flex-basis:44px;border-radius:14px 14px 17px 17px}body #game .tools button svg{width:26px;height:26px}body #game .zoom button{width:38px;height:40px}#arenaUI .stone-panel{padding:19px;max-height:calc(100dvh - 30px)}#arenaUI .warband{height:44px;max-width:calc(100vw - 106px)}#arenaUI .unit-counter{min-width:37px;padding:1px 3px}#arenaUI .match-clock{top:65px}#arenaUI .treasury{padding-right:4px;margin-right:0}#arenaUI .warband b{font-size:13px}}
@media(max-height:670px){#arenaUI .stone-panel{padding:13px 18px}#arenaUI .crest{display:none}#arenaUI .stone-panel h1{font-size:25px}#arenaUI .map-choice svg{height:38px}#arenaUI .duration-setting{margin:8px 0 12px}#arenaUI .setup-row{margin:7px 0}}
@media(prefers-reduced-motion:reduce){body #game .tools button{transition:none}}
body #modeMenu{background:linear-gradient(140deg,#4c435c,#292b43 65%);border:3px solid #8b7d98;border-top-color:#c6b5c7;border-bottom:6px solid #14192a;border-radius:25px;box-shadow:0 5px #070d1b,inset 0 0 0 3px #47415b}
body #modeMenu h1{font-weight:900;color:#fff0d3;text-shadow:0 3px #14192a}
body #modeMenu button,body #modeMenu a{border:2px solid #a4dae6;border-bottom:5px solid #1c3953;border-radius:15px;background:linear-gradient(#519bb0,#315b7e);box-shadow:0 3px #131a2d;text-shadow:0 2px #20344d}
body #modeMenu span{display:inline-flex;vertical-align:middle}body #modeMenu span svg{width:30px;height:30px;fill:none;stroke:#e6f7ff;stroke-width:2.5;filter:drop-shadow(0 2px #19344e)}body #modeMenu .version{display:none}

/* Independent outer progress rim, never hidden behind the portrait. */
body #game .recruit-orb.training .orb-face:after{content:"";position:absolute;inset:0;border-radius:50%;background:conic-gradient(from 0deg,#b5f7ff var(--training,0deg),#121a34aa 0);padding:4px;mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask-composite:exclude;-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;pointer-events:none;z-index:3}
body #game .recruit-orb.training{opacity:1}body #game .recruit-orb.training .orb-face{border-color:#468da3}
.survey-hint{position:absolute;width:26px;height:26px;display:grid;place-items:center;color:#f4cc6c;text-shadow:0 0 12px #ffbd4899;pointer-events:none;font-size:20px;opacity:.75}.survey-hint.room{color:#a9d8ef;text-shadow:0 0 12px #86cfff99}

#mapLocator{position:absolute;left:max(16px,env(safe-area-inset-left));bottom:calc(20px + env(safe-area-inset-bottom));width:38px;height:44px;border:1px solid #b2c5df38;border-radius:3px;opacity:.65;pointer-events:none;z-index:20;background:#0b10292b}#mapLocator i{position:absolute;width:5px;height:5px;border-radius:50%;background:#c1ebf5;box-shadow:0 0 5px #9ed9e877;transform:translate(-50%,-50%)}

body .edge-pick{width:48px;height:12px;border-radius:2px;background:repeating-linear-gradient(125deg,#bfdde956 0 1px,transparent 1px 7px);border:1px solid #bfdfeb36;opacity:.55}

body #game .recruit-orb[aria-disabled="true"]{opacity:.5}body #game .recruit-orb:active{transform:scale(.9)}body #game .recruit-orb{transition:transform .12s ease}#arenaUI .party-toggle{right:60px!important;top:12px!important;width:36px!important;height:36px!important;padding:6px!important;display:grid;place-items:center}#arenaUI .party-toggle svg{width:22px;height:22px}body #sound{top:12px!important;right:12px!important;width:36px!important;height:36px!important}#erosionSettings input[type=range]{touch-action:none!important}

body .survey-hint{width:76px!important;height:48px!important;border:0!important;border-radius:50%;background:radial-gradient(ellipse,#a9d7ef38,transparent 70%)!important;box-shadow:none!important;filter:blur(5px);opacity:.65}body .survey-hint.gold{background:radial-gradient(ellipse,#edbd4c55,transparent 70%)!important}body .survey-hint.danger{background:radial-gradient(ellipse,#e25a6255,transparent 70%)!important}#enemyReadout{position:absolute;left:12px;top:102px;z-index:5;font:11px system-ui;color:#f2c0bf;background:#291b2cbb;border:1px solid #94515c66;border-radius:8px;padding:5px 8px;pointer-events:none}

#mapLocator,.map-border-overlay,.survey-hint{display:none!important}

/* Both top-right actions use the viewport, never the header flex offset. */
body #game #sound,#arenaUI .party-toggle{position:fixed!important;top:calc(env(safe-area-inset-top,0px) + 12px)!important;margin:0!important;width:36px!important;height:36px!important;box-sizing:border-box}
body #game #sound{right:calc(env(safe-area-inset-right,0px) + 12px)!important;z-index:61}
#arenaUI .party-toggle{right:calc(env(safe-area-inset-right,0px) + 60px)!important}

/* Readable lobby text at actual phone CSS resolution, without shrinking to fit. */
#arenaUI .stone-panel{width:min(440px,100%);max-width:440px}
#arenaUI .panel-subtitle,#arenaUI .composition{font-size:16px;line-height:1.4;color:#e1d9e8}
#arenaUI .seat{gap:10px;padding:14px 12px;flex-wrap:wrap}
#arenaUI .seat b{font-size:18px;line-height:1.3;min-width:120px}
#arenaUI .seat small{font-size:16px;line-height:1.35;color:#d9e4df}
#arenaUI .quiet-game{font-size:17px!important;line-height:1.35;min-height:48px;color:#e4f1fa!important}
#arenaUI .primary-game{font-size:21px;line-height:1.3;min-height:52px}
#arenaUI .primary-game:disabled{opacity:1;color:#c8c6cf;background:#414252;box-shadow:inset 0 1px #ffffff18,0 4px #141726}
#arenaUI #inviteCode{font-size:22px;font-weight:800;letter-spacing:1px;color:#fff1d7;margin:14px 0}
#arenaUI .setup-row,#arenaUI .duration-setting label{font-size:17px;line-height:1.35}
#arenaUI .map-choice b{font-size:16px;line-height:1.3}
#arenaUI .size-choices button{font-size:16px;min-height:46px;padding:9px 10px}
#arenaUI .range-ends{font-size:15px;color:#ded6e4}
#arenaUI #roomCode,#arenaUI #inviteLink{font-size:17px;min-height:46px}
@media(max-width:400px){#arenaUI .stone-panel{padding:17px 14px}#arenaUI .size-choices{gap:4px}#arenaUI .size-choices button{font-size:16px;padding:9px 7px}#arenaUI .seat small{flex-basis:100%;text-align:left;padding-left:24px}#arenaUI .map-choices{gap:5px}}

.unit-health .unit-level{position:absolute;bottom:7px;left:50%;transform:translateX(-50%);color:#fff1cd;font:bold 12px/16px sans-serif;text-shadow:0 1px 3px #000,1px 0 #000;pointer-events:none}.unit-health.level-only{background:transparent;border-color:transparent;box-shadow:none}.unit-health.level-only>i{visibility:hidden}

.unit-health{overflow:visible}.unit-health>i{border-radius:3px}

#arenaUI .setup-row:has(.size-choices){display:block;text-align:left}
#arenaUI .size-choices{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));width:100%;gap:8px;margin-top:9px}
#arenaUI .number-choices.size-choices button{box-sizing:border-box;width:100%;min-width:0;height:auto;min-height:48px;padding:10px 4px;font-size:16px;line-height:1.25;white-space:normal;overflow-wrap:normal}
#arenaUI .stone-panel{min-width:0}

.unit-health .unit-level{min-width:22px;text-align:center;padding-bottom:3px}.unit-health .unit-level:before,.unit-health .unit-level:after{content:"";position:absolute;bottom:0;left:0;height:2px;border-radius:2px;width:100%;background:#182537}.unit-health .unit-level:after{background:#8ee4ef;transform:scaleX(var(--xp,0));transform-origin:left;transition:transform .2s}.unit-health .unit-level:empty{display:none}.unit-xp-gain{position:absolute;left:calc(100% + 5px);bottom:8px;font:700 12px/16px sans-serif;white-space:nowrap;color:#a7f3fa;text-shadow:0 1px 3px #000;pointer-events:none}.unit-xp-gain[hidden]{display:none}

/* Separate health and experience: never reuse one bar for two values. */
.unit-health .unit-level:before,.unit-health .unit-level:after{display:none}

.unit-health.veteran>i{background:#72dfa1!important;visibility:visible}
.unit-experience{display:none;position:absolute;left:0;top:calc(100% + 3px);width:100%;height:3px;border-radius:2px;background:linear-gradient(to right,#b99af7 calc(var(--xp,0)*100%),#201b35 0);box-shadow:0 0 0 1px #090d1d}
.unit-health.veteran .unit-experience{display:block}

.recruit-slot{position:relative;flex:none}.recruit-cancel{position:absolute;left:-7px;top:-6px;z-index:5;width:32px;height:32px;min-height:0;padding:6px;display:grid;place-items:center;border:1px solid #d39a9b;border-radius:50%;background:#542c40;color:#ffe2df;box-shadow:0 2px 0 #151222;touch-action:manipulation}.recruit-cancel svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2.5;stroke-linecap:round}.recruit-cancel:active{transform:scale(.9)}
