:root {
  color-scheme: dark;
  font: 15px/1.45 "PingFang SC","Microsoft YaHei",system-ui,sans-serif;
  --ink:#f0f5f5; --muted:#b4c3c6; --accent:#78e7d5; --amber:#ffcd77;
  --plate:#17262bed; --panel:#132126fa; --slot:#23363d; --line:#475d63;
  --left:max(16px,env(safe-area-inset-left)); --right:max(16px,env(safe-area-inset-right));
  --top:max(16px,env(safe-area-inset-top)); --bottom:max(16px,env(safe-area-inset-bottom));
  --pad:92px; --compass:96px; --shadow:0 5px 18px #08151840;
}
* { box-sizing:border-box }
[hidden] { display:none !important }
body { margin:0; overflow:hidden; background:#15282c; color:var(--ink) }
button,summary { cursor:pointer; -webkit-tap-highlight-color:transparent }
button { font:inherit; color:inherit; padding:7px 14px; border:1px solid var(--line); border-radius:2px; background:var(--slot) }
button:disabled { cursor:default; background:#283438; color:#a4b1b3; border-color:#49585b }
:focus-visible { outline:2px solid var(--accent); outline-offset:2px }
button:active:not(:disabled) { filter:brightness(.91) }
@media (hover:hover) {button:hover:not(:disabled) { border-color:var(--accent) }}
::selection { background:#83d9cb; color:#112729 }
#world,#hud { position:fixed; inset:0; width:100%; height:100% }
#world { display:block; outline:0; touch-action:none }
#hud { pointer-events:none; user-select:none }
#hud button,#stick { pointer-events:auto }
.location,.navigation,.roster,.kit,.notice,#bearingTape,#stick,#fastSwim,#stamina { position:absolute }
.location { left:var(--left); top:var(--top); max-width:44vw }
.location-title { display:flex; align-items:center; gap:12px; padding:7px 24px 9px 13px; background:linear-gradient(100deg,#132024ef,#172b32c9); clip-path:polygon(0 0,100% 0,100% calc(100% - 10px),calc(100% - 10px) 100%,0 100%); border-top:1px solid #a2ddd199 }
.island-icon { display:block; flex:none; border-radius:3px }
.island,.place { display:block }
.island { color:#afd8d4; font-size:11px; font-weight:650; letter-spacing:.17em }
.place { font-size:clamp(18px,2vw,24px); line-height:1.25; letter-spacing:.04em }
#bearingTape { left:50%; top:var(--top); width:320px; height:42px; transform:translateX(-50%); background:linear-gradient(90deg,transparent,#132329b8 18% 82%,transparent) }
.navigation { top:var(--top); right:var(--right); display:grid; justify-items:end; gap:6px }
#openMap { padding:3px; width:var(--compass); aspect-ratio:1; overflow:hidden; border-radius:50%; background:#102226d9; border:1px solid #d0dfdcb3; box-shadow:var(--shadow) }
#mini { width:100%; height:100%; display:block; border-radius:50% }
.controls,.help,.combat-buttons,#placementControls { display:flex; gap:3px }
.controls button { width:34px; min-height:34px; padding:0; background:var(--plate); font:600 20px/1 system-ui }
.roster { left:var(--left); bottom:var(--bottom) }
#openPartners { display:grid; justify-items:start; gap:6px; text-align:left; line-height:1.15; background:transparent; border:0; padding:0 }
.roster-summary { display:flex; align-items:center; gap:10px; min-height:34px; padding:5px 9px; border:1px solid var(--line); background:var(--plate); box-shadow:var(--shadow) }
.roster strong { display:block; font-size:14px }
.roster small { color:var(--muted); font-size:11px; font-variant-numeric:tabular-nums }
#activePortraits { display:flex; gap:6px }
#activePortraits:empty { display:none }
#activePortraits img { display:block; width:48px; height:48px; object-fit:contain; padding:3px; background:var(--plate); border:1px solid #637e80; border-radius:3px; box-shadow:0 2px 5px #08151840 }
progress { appearance:none; border:0; background:#0a151a; border-radius:0; overflow:hidden; display:block; height:5px; accent-color:var(--bar,var(--accent)) }
progress::-webkit-progress-bar { background:#0a151a }
progress::-webkit-progress-value { background:var(--bar,var(--accent)) }
progress::-moz-progress-bar { background:var(--bar,var(--accent)) }
.kit { right:var(--right); bottom:var(--bottom); width:min(258px,44vw); display:grid; justify-items:end; gap:7px }
.help { gap:4px }
.help button { display:flex; align-items:center; gap:6px; min-height:42px; padding:5px 12px; background:var(--plate); font-weight:650; box-shadow:var(--shadow) }
.help img { width:19px; height:19px; object-fit:contain; filter:brightness(0) invert(.92) }
.actions { display:grid; justify-items:end; gap:6px; width:100% }
.actions:not(:has(> :not([hidden]))) { display:none }
#combatHud { padding:8px; background:var(--plate); border:1px solid var(--line); box-shadow:var(--shadow); width:100% }
#captureGauge { position:absolute; width:74px; height:74px; transform:translate(-50%,-50%); color:#ffe18b }
#captureGauge[data-phase="caught"] { color:#8dffdc }
#captureGauge[data-phase="escaped"] { color:#ffad91 }
#captureGauge svg { width:100%; height:100%; overflow:visible; fill:none; stroke-width:6.5 }
.gauge-outline { stroke:#000; stroke-width:8.5 }
.gauge-track { stroke:#20363e }
#captureArc { stroke-linecap:round }
.gauge-readout { position:absolute; left:80%; top:0; display:grid; padding:3px 9px 4px; border-left:2px solid currentColor; background:#13282eeb; white-space:nowrap; line-height:1.1 }
.gauge-readout small { font-size:10px; color:#f0f5f5 }
.gauge-readout strong { font-size:19px; font-variant-numeric:tabular-nums }
#combatTarget { font-size:14px; color:var(--ink) }
#hud.in-battle :is(.location,.navigation,.roster,.help,#bearingTape,#stick,#interact,#fastSwim) { display:none }
.combat-buttons #retreat { display:flex; align-items:center; justify-content:center }
#captureReadout { margin:2px 0 0; font-size:12px; color:#b8e9df; font-variant-numeric:tabular-nums }
.combat-buttons { margin-top:6px }
.combat-buttons button { flex:1; min-width:0; min-height:40px; padding:5px; font-size:13px; line-height:1.25; font-weight:650 }
#petCapture { color:#0b2424; background:var(--accent); border-color:var(--accent) }
.combat-buttons button { position:relative; display:grid; grid-template-rows:32px auto; justify-items:center; align-content:center; align-items:center; gap:3px }
#petCapture img { width:23px; height:30px; object-fit:contain }
#partnerSkill:disabled img { opacity:.46 }
#partnerSkill small { position:absolute; top:6px; left:50%; transform:translateX(-50%); min-width:32px; line-height:32px; color:white; font-size:13px; text-shadow:0 1px 3px black; font-variant-numeric:tabular-nums }
#petCapture:disabled { background:#718c88 }
#partnerSkill:not(:disabled) { color:var(--amber); border-color:#a58857 }
.pet-health { position:absolute; top:0; left:0; display:grid; gap:3px; padding:3px 6px 4px; min-width:70px; background:#142428d9; border-bottom:1px solid #cfdcdd8a; font-size:11px; font-weight:650; text-align:center }
.pet-health progress { width:100%; height:3px; --bar:#efa374 }
.pet-health.partner progress { --bar:var(--accent) }
.pet-health.targeted { border-color:var(--amber); color:#ffdf9e }
.pet-health .capture-cue,.pet-health.stunned progress { display:none }
.pet-health.stunned { isolation:isolate; padding:25px 10px 6px; color:var(--ink); background:transparent; border:0; white-space:nowrap; font-variant-numeric:tabular-nums }
.pet-health.stunned::before { content:""; position:absolute; inset:0; z-index:-1; background:var(--panel); border-top:2px solid var(--accent); clip-path:polygon(0 0,100% 0,100% calc(100% - 6px),calc(100% - 6px) 100%,0 100%) }
.pet-health.stunned .capture-cue { position:absolute; inset:0; width:100%; height:100%; display:flex; align-items:flex-start; justify-content:center; padding:4px 0; background:transparent; border:0; color:var(--accent); font-size:14px; font-weight:700; touch-action:manipulation }
.pet-health.stunned:focus-within { outline:2px solid var(--accent); outline-offset:2px }
.pet-health.stunned::after { content:""; position:absolute; top:100%; left:50%; transform:translateX(-50%); border:5px solid transparent; border-top-color:var(--panel); border-bottom:0; pointer-events:none }
#interact,#fastSwim,#placementControls button { min-height:42px; background:var(--plate); font-weight:650 }
#interact { position:absolute; left:50%; top:clamp(var(--top),calc(var(--feet-y) + 10px),calc(100% - var(--bottom) - 44px)); transform:translateX(-50%); display:flex; align-items:center; justify-content:center; gap:8px; background:#a6eddb; border-color:#e0fff3; color:#102823 }
.key { font:700 12px/1 system-ui; padding:4px; border:1px solid currentColor; border-radius:2px }
#stick { left:var(--left); bottom:var(--bottom); width:var(--pad); aspect-ratio:1; border-radius:50%; border:1px solid #bcd5d799; background:#13292f72; touch-action:none }
#stick i { position:absolute; width:6px; height:2px; background:#e0eeecd9; top:5%; left:calc(50% - 3px) }
#stick i:nth-child(2) { left:90%; top:50%; rotate:90deg }
#stick i:nth-child(3) { top:94% }
#stick i:nth-child(4) { left:3%; top:50%; rotate:90deg }
#nub { position:absolute; width:42%; height:42%; left:29%; top:29%; border-radius:50%; border:1px solid #dcf4ecb3; background:#79aaacb8 }
#fastSwim { left:calc(var(--left) + var(--pad) + 5px); bottom:var(--bottom); touch-action:none; font-size:12px; padding:5px }
#stamina { display:grid; place-items:center; width:36px; height:36px; transform:translate(-50%,-50%); border-radius:50%; background:conic-gradient(var(--bar,var(--accent)) var(--fill,100%),#21353a 0); color:white; font:700 11px/1 system-ui }
#stamina.low { --bar:var(--amber) }
#stamina span { display:grid; place-items:center; width:28px; height:28px; border-radius:50%; background:#15252d }
.notice { top:calc(var(--top) + 75px); left:var(--left); max-width:min(37vw,380px); padding:8px 12px; font-size:13px; background:linear-gradient(100deg,#182b30f5,#16292ddc); border-bottom:1px solid #8cd1c783; box-shadow:var(--shadow) }
#petMood { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap }
#boot { position:fixed; inset:0; z-index:5; display:grid; place-items:center; background:#14252a; color:var(--ink); font-weight:650 }
@media (pointer:fine) { #stick,#fastSwim { display:none } }
@media (pointer:coarse) {
  .roster { bottom:calc(var(--bottom) + var(--pad) + 10px) }
  .controls { gap:0 }
  .controls button { position:relative; isolation:isolate; width:42px; height:42px; border:0; background:transparent; font-size:16px }
  .controls button::before { content:""; position:absolute; inset:6px; z-index:-1; border:1px solid var(--line); border-radius:2px; background:var(--plate) }
  .key { display:none }
}
@media (max-width:640px) {
  :root { --compass:74px; --pad:76px; --left:max(10px,env(safe-area-inset-left)); --right:max(10px,env(safe-area-inset-right)); --top:max(10px,env(safe-area-inset-top)); --bottom:max(12px,env(safe-area-inset-bottom)) }
  #bearingTape { display:none }
  #activePortraits img { width:40px; height:40px } .roster strong { font-size:13px }
  .combat-buttons button { padding-inline:1px; font-size:12px }
  .notice { max-width:54vw; top:calc(var(--top) + 61px) }
  .kit { width:min(52vw,220px) } .help button { padding-inline:9px }
}
@media (max-height:460px) { :root { --compass:60px; --pad:66px; --top:max(8px,env(safe-area-inset-top)); --bottom:max(8px,env(safe-area-inset-bottom)) } .notice { max-width:38vw } }
@media (pointer:coarse) and (max-width:640px) and (orientation:portrait) {
  :root { --pad:clamp(104px,28vw,124px); --compass:clamp(96px,26vw,116px) }
  #hud { --stick-bottom:max(calc(18% - var(--pad)/2),calc(var(--bottom) + 50px)) }
  #stick { left:51%; bottom:var(--stick-bottom); transform:translateX(-50%) }
  #interact { max-height:44px; top:clamp(var(--top),calc(var(--feet-y) + 10px),calc(100% - var(--stick-bottom) - var(--pad) - 50px)) }
  .roster { bottom:var(--bottom) }
  #fastSwim { left:var(--left); bottom:calc(var(--bottom) + 88px) }
  #hud:not(.in-battle) #combatHud { width:calc(49vw - var(--pad)/2 - var(--right) - 6px) }
  #hud:not(.in-battle) .combat-buttons { flex-wrap:wrap }
  #hud:not(.in-battle) .combat-buttons button { min-width:44px }
  #placementControls { flex-wrap:wrap; justify-content:flex-end; max-width:calc(49vw - var(--pad)/2 - var(--right) - 6px) }
}
@media (pointer:coarse) and (max-width:375px) and (orientation:portrait) {
  #hud { --stick-bottom:max(calc(18% - var(--pad)/2),calc(var(--bottom) + 86px)) }
}
@media (pointer:coarse) and (max-height:460px) and (orientation:landscape) {
  :root { --pad:84px; --compass:84px }
}

#doorFade { position:fixed; inset:0; z-index:4; background:#302d2a; pointer-events:auto }
#homeExitHint {
  display:none; position:absolute; width:24px; height:17px;
  translate:-50% -50%; background:rgba(255,255,255,.72);
  clip-path:polygon(0 0,100% 0,50% 100%);
  animation:exit-arrow-pulse 1.6s ease-in-out infinite;
}
@keyframes exit-arrow-pulse {
  0%,75%,100% { transform:translateY(0); opacity:.75 }
  37% { transform:translateY(2px); opacity:1 }
}
@media (prefers-reduced-motion:reduce) {
  #homeExitHint { animation:none }
}
#hud.indoors #homeExitHint { display:block }
#hud.indoors :is(.navigation,.kit,.roster,#bearingTape,#stamina,#petHealthLabels,#captureGauge) { display:none }
#hud.indoors #interact { left:clamp(5em,var(--station-x,50%),calc(100% - 5em)) }
