/* Responsive overrides use #ui so scene-injected styles cannot override them. */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}
html, body { width: 100%; height: 100%; touch-action: auto; }
body { height: 100dvh; }
#ui, #touch, #loading { width: var(--app-width, 100%); height: var(--app-height, 100dvh); }
#ui button { touch-action: manipulation; }
#ui .btn, #ui .st-tab, #ui .mute-btn { min-height: 44px; }
#ui .mute-btn { width: 44px; }
#ui .start {
  padding: calc(var(--safe-top) + 7dvh) calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 6dvh) calc(var(--safe-left) + 16px);
  gap: 16px; overflow-y: auto; pointer-events: auto; touch-action: pan-y;
}
#ui .start > * { flex-shrink: 0; max-width: 100%; }
#ui .logo-zh { font-size: clamp(32px, 10vw, 52px); }
#ui .start-stats, #ui .exp-loadout-title { text-align: center; line-height: 1.6; overflow-wrap: anywhere; }
#ui .hud-top { left: calc(max(var(--safe-left), var(--platform-safe-left, 0px)) + 16px); right: calc(max(var(--safe-right), var(--platform-safe-right, 0px)) + 12px); }
#ui .o2label { flex-shrink:0; min-width:28px; padding-left:2px; white-space:nowrap; }
#ui .hud-o2can { left: calc(var(--safe-left) + 12px); }
#ui .hud-bag { right: calc(var(--safe-right) + 12px); }
@media (orientation: landscape) {
  #ui .boss-hud { top: calc(var(--safe-top) + 50px); left: calc(var(--safe-left) + 90px); right: calc(var(--safe-right) + 220px); }
}
#ui .layer-bag { padding: calc(var(--safe-top) + 12px) calc(var(--safe-right) + 12px) calc(var(--safe-bottom) + 12px) calc(var(--safe-left) + 12px); }
@media (max-width: 480px) {
  #ui .layer-bag { align-items: flex-end; }
  #ui .bag-panel { width: 100%; padding: 12px; }
  #ui .bag-head { flex-wrap: wrap; }
  #ui .bag-ad { order: 3; width: 100%; justify-content: center; }
  #ui .bag-list { gap: 10px; padding: 2px; }
  #ui .bag-row { padding: 9px 7px; }
  #ui .bag-inspect { position: relative; grid-template-columns: 38px minmax(0,1fr); gap: 6px; padding-bottom: 17px; }
  #ui .bag-inspect>img { width: 38px; height: 40px; }
  #ui .bag-name { font-size: 14px; }
  #ui .bag-amount { position: absolute; bottom: 0; right: 0; font-size: 12px; }
  #ui .bag-facts { margin-top: 6px; padding: 7px; gap: 4px; font-size: 10px; }
  #ui .bag-facts>span { display: flex; flex-direction: column; gap: 2px; }
  #ui .bag-facts>span:last-child { text-align: right; }
  #ui .bag-facts b { font-size: 14px; margin: 0; }
  #ui .bag-facts small { font-size: 10px; }
  #ui .bag-card-foot>small { display: none; }
  #ui .bag-row.giant .bag-card-foot { flex-wrap:wrap; }
  #ui .bag-row.giant .catch-giant-label { display:block; }
  #ui .bag-row.shiny .catch-shiny-label { display:block; }
  #ui .bag-discard { width: 100%; min-width: 0; padding: 7px 4px; font-size: 13px; }
}
@media (max-height: 400px) {
  #ui .bag-panel { gap: 6px; padding: 8px 12px; }
  #ui .bag-head h2 { font-size: 20px; margin: 0; }
}
#ui .hud-hint { padding: 0 calc(var(--safe-right) + 12px) 0 calc(var(--safe-left) + 12px); }
#ui .sh-wrap, #ui .sh-end {
  padding-left: calc(var(--safe-left) + 12px); padding-right: calc(var(--safe-right) + 12px);
}
#ui .sh-card { min-height: 0; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; }
#ui .sh-card > * { flex-shrink: 0; }
#ui .rs-list, #ui .up-list { overflow: visible; }
#ui .up-card { grid-template-columns: 52px minmax(0, 1fr) auto; }
#ui .up-mid { min-width: 0; overflow-wrap: anywhere; }
#ui .mp-wrap, #ui .st-wrap { left: var(--safe-left); right: var(--safe-right); }
#ui .mp-scroll, #ui .st-list { touch-action: pan-y; }
#ui .sh-hud, #ui .ck-hud { padding-left: calc(var(--safe-left) + 10px); padding-right: calc(var(--safe-right) + 10px); }
#ui .toast { max-width: calc(100% - var(--safe-left) - var(--safe-right) - 24px); text-align: center; overflow-wrap: anywhere; }
.touch-guides { display: none; }
@media (pointer: coarse) {
  #ui .touch-guides {
    position: absolute; left: calc(var(--safe-left) + 20px); right: calc(var(--safe-right) + 20px);
    bottom: calc(var(--safe-bottom) + 72px); display: flex; justify-content: space-between;
    pointer-events: none; color: #dff6ff99; font-size: 12px; text-shadow: 0 2px 2px #000;
  }
  #ui .touch-guides span { border: 1px solid #bff2ff44; border-radius: 50%; width: 76px; height: 76px; display: grid; place-content: center; text-align: center; line-height: 1.6; background: #03101a22; }
  #ui .hud-hint { font-size: 12px; }
}
@media (max-width: 380px) {
  #ui .o2bar { width: 90px; }
  #ui .leveltag { font-size: 19px; }
  #ui .st-card { grid-template-columns: 48px minmax(0, 1fr) 72px; gap: 6px; padding: 8px 6px; }
  #ui .st-icw { width: 48px; }
  #ui .st-ic.w { max-width: 48px; object-fit: contain; }
  #ui .st-act { width: 72px; min-width: 0; padding: 6px 2px; }
  #ui .st-st { grid-template-columns: 26px minmax(6px, 1fr) 48px; gap: 3px; }
  #ui .st-st em { font-size: 11px; }
  #ui .st-name { font-size: 16px; }
  #ui .mp-head { padding-left: 8px; padding-right: 8px; }
  #ui .mp-title { font-size: 24px; letter-spacing: 4px; }
  #ui .mp-med { width: 64px; height: 64px; }
  #ui .mp-med img.bp { max-width: 76px; max-height: 64px; object-fit: contain; }
  #ui .mp-node { gap: 8px; }
  #ui .mp-foot { flex-wrap: wrap; }
  #ui .mp-name small { display: block; margin: 4px 0 0; }
  #ui .sh-card { padding: 12px 10px; }
  #ui .rs-row { grid-template-columns: 38px minmax(0, 1fr) auto 12px 24px auto; gap: 4px; padding: 5px; }
  #ui .rs-fish { width: 38px; }
  #ui .rs-serving { width: 24px; object-fit: contain; }
  #ui .rs-name, #ui .rs-sv, #ui .rs-n { font-size: 13px; }
  #ui .up-card { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 6px; padding: 7px 5px; }
  #ui .up-ic { width: 36px; height: 36px; }
  #ui .up-buy { min-width: 66px; padding: 8px 5px; }
  #ui .ck-top { gap: 4px; }
  #ui .ck-moves { min-width: 70px; padding-inline: 8px; }
  #ui .ck-money b { min-width: 32px; }
}
@media (max-height: 500px) {
  #ui .start { padding-top: calc(var(--safe-top) + 16px); padding-bottom: calc(var(--safe-bottom) + 14px); gap: 10px; }
  #ui .logo-zh { font-size: 34px; }
  #ui .logo-en { font-size: 12px; margin-top: 8px; letter-spacing: 6px; }
  #ui .daytag { font-size: 30px; }
  #ui .leveltag { margin-top: 0; font-size: 18px; }
  #ui .start-bottom { gap: 6px; }
  #ui .btn.big { font-size: 19px; padding: 8px 22px; }
  #ui .st-top { height: 82px; gap: 2px; position: relative; padding-right: 140px; }
  #ui .st-title { font-size: 24px; }
  #ui .st-money { position: absolute; right: 16px; top: 0; }
  #ui .st-foot { padding-top: 6px; padding-bottom: calc(var(--safe-bottom) + 8px); }
  #ui .st-foot small { display: none; }
  #ui .toasts.st-toasts { top: calc(var(--safe-top) + 58px); }
  #ui .hud-catch { top: calc(var(--safe-top) + 70px); }
  #ui .catch-card { padding: 6px 12px; }
  #ui .cc-name { font-size: 18px; }
  #ui .cc-fish { max-height: 64px; object-fit: contain; }
  #ui .touch-guides { bottom: calc(var(--safe-bottom) + 42px); }
  #ui .touch-guides span { width: 62px; height: 62px; }
}
@media (orientation: landscape) and (max-height: 600px) {
  /* Keep the board's right-hand play area clear of HUD and inventory. */
  #ui .ck-hud { right: auto; width: 43%; }
  #ui .ck-top { flex-wrap: wrap; justify-content: center; gap: 6px; }
  #ui .ck-moves { order: 3; }
  #ui .ck-bottom { left: var(--safe-left); right: auto; width: calc(43% - var(--safe-left)); }
  #ui .ck-stock { max-height: 64px; overflow-y: auto; pointer-events: auto; touch-action: pan-y; }
  #ui .ck-hint { font-size: 12px; }
}

/* Settlement details scroll within the card; headings and actions never scroll. */
#ui .sh-card.rs, #ui .sl-summary .sh-card {
  display:grid; grid-template-rows:auto minmax(0,1fr) auto;
  min-width:0; overflow:hidden;
}
#ui .rs > .settlement-body, #ui .sl-summary .settlement-body {
  min-width:0; min-height:0; overflow-x:hidden; overflow-y:auto;
  scrollbar-width:none; touch-action:pan-y; overscroll-behavior:contain;
}
#ui .settlement-body::-webkit-scrollbar { display:none; }
#ui .rs .rs-list { margin-inline:0; padding-inline:0; overflow:visible; }
#ui .rs > .settlement-footer, #ui .sl-summary .settlement-footer {
  min-width:0; margin-top:10px; padding:10px 0 4px; border-top:1px solid #e6b77b44;
}
#ui .sl-summary .settlement-footer { display:flex; flex-direction:column; align-items:center; gap:6px; }
#ui .sl-summary .settlement-footer p { margin:0; }
#ui .sl-summary .settlement-footer .btn { max-width:100%; margin:0; }
/* Keep the right edge anchored in landscape; extra width grows leftward. */
#ui .sh-card.rs:has(.rs-recover) { width:min(500px,100%); scrollbar-width:none; }
#ui .sh-card.rs::-webkit-scrollbar { display:none; }
#ui .rs-actions { display:flex; justify-content:center; align-items:stretch; flex-wrap:nowrap; gap:12px; margin-top:12px; }
#ui .rs-actions .rs-go { align-self:stretch; margin:0; min-width:0; padding:12px 16px; white-space:nowrap; }
#ui .rs-actions:has(.rs-recover) .rs-go { flex:0 0 164px; }
#ui .rs-recover { justify-content:center; text-align:left; width:auto; flex:1 1 248px; min-width:0; max-width:100%; min-height:68px; gap:12px; padding:10px 14px; border:2px solid #274a19; border-radius:6px; background:linear-gradient(#c3f69a,#78d861); color:#14310c; box-shadow:0 4px 0 #3f772c,inset 0 2px 0 #e9ffcc; transition:transform .08s,box-shadow .08s; touch-action:manipulation; }
#ui .rs-recover img { width:34px; height:30px; flex-shrink:0; }
#ui .rs-recover span { min-width:0; }
#ui .rs-recover b { display:block; font-weight:normal; font-size:19px; line-height:1.25; }
#ui .rs-recover small { display:block; font-size:12px; line-height:1.3; margin-top:6px; opacity:.84; white-space:nowrap; }
#ui .rs-recover:active:not(:disabled) { transform:translateY(3px); box-shadow:0 1px 0 #3f772c,inset 0 2px 0 #e9ffcc; }
#ui .rs-recover:focus-visible { outline:2px solid #e9ffcc; outline-offset:6px; }
#ui .rs-recover:disabled { filter:grayscale(1) brightness(.7); opacity:1; cursor:default; }
@media(prefers-reduced-motion:reduce) { #ui .rs-recover { transition:none; } }
@media(max-width:480px) {
  #ui .rs-actions { gap:8px; }
  #ui .rs-actions:has(.rs-recover) .rs-go { flex:0 0 auto; font-size:clamp(16px,4.4vw,20px); padding:10px 8px; letter-spacing:0; }
  #ui .rs-recover { gap:6px; padding:10px 8px; min-height:64px; }
  #ui .rs-recover img { width:26px; height:23px; }
  #ui .rs-recover b { font-size:17px; }
  #ui .rs-recover small { font-size:11px; }
}

#ui .hud-bell { position:absolute; top:calc(var(--safe-top) + 134px); left:calc(var(--safe-left) + 12px); display:flex; align-items:center; gap:5px; min-height:44px; padding:5px 8px; color:#ffdfa0; background:#092233ee; border:2px solid #d2ab60; border-radius:7px; font:12px var(--font-zh); pointer-events:auto; }
#ui .hud-bell img { width:23px; height:27px; object-fit:contain; image-rendering:pixelated; }
#ui .hud-bell:disabled { opacity:.45; }
#ui .combat-notice { position:absolute; left:50%; top:calc(var(--safe-top) + 184px); transform:translateX(-50%); width:max-content; max-width:calc(100% - 24px); padding:7px 10px; background:#30171ef2; border:2px solid #ffdf83; color:#fff2b5; font:16px var(--font-zh); text-align:center; pointer-events:none; z-index:8; }
#ui .combat-notice[hidden] { display:none; }
@media (max-width:480px) { #ui .combat-notice { top:calc(var(--safe-top) + 188px); font-size:14px; } }

/* Collection access stays beside departure on narrow screens. */
.start-departure-actions { display:flex; align-items:stretch; justify-content:center; gap:10px; max-width:100%; }
.start-departure-actions .btn { min-width:0; padding-inline:clamp(14px,4vw,30px); }
.reward-note { display:block;flex-basis:100%;font:12px/1.4 var(--font-zh);color:#d9f6b8;white-space:normal;text-align:center; }
.bag-ad:has(.reward-note) { flex-wrap:wrap;justify-content:center;row-gap:3px; }
#ui .oxygen-reward { flex:0 1 220px;flex-direction:column;flex-wrap:nowrap;justify-content:center;min-width:0;min-height:56px;gap:3px;text-align:center; }
#ui .oxygen-reward .reward-note { flex-basis:auto;width:100%; }
#ui .oxygen-reward-text { font-size:inherit;line-height:1.25;white-space:normal;overflow-wrap:anywhere; }
#ui .start { scrollbar-width:none; }
#ui .start::-webkit-scrollbar { display:none; }
@media (max-width:480px) {
  #ui .start-departure-actions { width:100%;gap:8px; }
  #ui .start-departure-actions .godive { flex:0 0 auto;padding-inline:12px;font-size:20px; }
  #ui .oxygen-reward { flex:1 1 0; }
}

#ui .start-departure-actions .btn.big {font-size:clamp(14px,2.7vw,22px);padding:12px 16px;border-radius:6px;}
#ui .oxygen-reward {display:flex;align-items:center;}
