:root { --cy: #5fe3ff; --cy2: #1fb6d9; --or: #ffb547; --pk: #ff6fb5; --bg: #021120; --glass: rgba(6, 30, 52, .78); --ln: rgba(120, 220, 255, .22); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: #e6f7ff; overflow: hidden; overscroll-behavior: none;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

/* screens */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; z-index: 10; animation: fadeIn .45s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.panel-screen { justify-content: center; padding: max(16px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); }
.panel-screen.dim { background: rgba(0, 6, 14, .55); backdrop-filter: blur(2px); }
.panel { width: min(560px, 100%); max-height: 100%; overflow-y: auto; background: var(--glass); border: 1px solid var(--ln); border-radius: 22px;
  padding: 20px 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .06); backdrop-filter: blur(6px); touch-action: pan-y; }
.panel.narrow { width: min(380px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.panel h2 { margin: 0 0 10px; font-size: 22px; letter-spacing: .06em; color: var(--cy); text-shadow: 0 0 18px rgba(95, 227, 255, .45); }
.muted { color: #9cc3d6; font-size: 14px; margin: 0 0 12px; line-height: 1.4; }
.panel-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.pearls-total, .pearls-inline { color: #f4f0ff; font-weight: 700; }
.pearls-total::before, .pearls-inline::before { content: "● "; color: #e9e4ff; text-shadow: 0 0 8px #b9d8ff; }

.btn { border: 1px solid rgba(120, 220, 255, .35); background: linear-gradient(180deg, rgba(30, 90, 130, .55), rgba(8, 40, 70, .7)); border-radius: 14px;
  padding: 13px 18px; font-size: 17px; font-weight: 650; letter-spacing: .02em; color: #e8fbff; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); transition: transform .12s, filter .12s; }
.btn:active { transform: scale(.96); filter: brightness(1.25); }
.btn.primary { background: linear-gradient(180deg, #38d9ff, #0d8fc0); border-color: #9af0ff; color: #02253a; font-size: 19px; box-shadow: 0 0 24px rgba(56, 217, 255, .45), 0 6px 18px rgba(0, 0, 0, .4); }
.btn.small { padding: 10px 12px; font-size: 15px; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: #9cc3d6; }
.btn.off { opacity: .55; }
.btn:disabled { opacity: .45; }
.row2 { display: flex; gap: 10px; } .row2 > * { flex: 1; }

/* title */
#sTitle { justify-content: space-between; padding: max(9vh, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom)); pointer-events: none; }
#sTitle > * { pointer-events: auto; }
.title-wrap { text-align: center; pointer-events: none !important; }
#logo { margin: 0; font-size: clamp(30px, 10.4vw, 64px); font-weight: 900; letter-spacing: .08em; line-height: 1;
  background: linear-gradient(100deg, #9ff3ff 0%, #ffffff 40%, #5fe3ff 50%, #ffffff 60%, #9ff3ff 100%); background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 5s linear infinite, logoIn 1.6s cubic-bezier(.2, .8, .2, 1) both;
  filter: drop-shadow(0 0 14px rgba(95, 227, 255, .6)); }
@keyframes shimmer { from { background-position: 125% 0; } to { background-position: -125% 0; } }
@keyframes logoIn { from { opacity: 0; letter-spacing: .5em; filter: blur(8px); } to { opacity: 1; } }
.sub-logo { margin-top: 8px; font-size: clamp(14px, 4.4vw, 22px); letter-spacing: .7em; padding-left: .7em; color: #ffcf7a; font-weight: 700; text-shadow: 0 0 14px rgba(255, 181, 71, .7); animation: fadeIn 1.2s .8s both; }
.tagline { margin: 14px 0 0; color: #a9d9ec; font-size: 15px; font-style: italic; animation: fadeIn 1.2s 1.4s both; }
.menu { width: min(360px, 100%); display: flex; flex-direction: column; gap: 10px; animation: fadeIn .9s 1.1s both; }
.menu .btn { backdrop-filter: blur(3px); }
.ver { text-align: center; font-size: 11px; color: #5d8aa0; }

/* dive grid */
.dive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.dive { position: relative; text-align: left; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--ln); background: linear-gradient(180deg, rgba(20, 80, 120, .5), rgba(3, 20, 38, .8)); min-height: 86px; }
.dive b { display: block; font-size: 13px; color: var(--cy); letter-spacing: .08em; }
.dive span.nm { display: block; font-size: 15px; font-weight: 700; margin: 2px 0 4px; }
.dive small { color: #8fb7c9; font-size: 12px; }
.dive .st { position: absolute; right: 10px; top: 8px; color: #ffcf5a; font-size: 14px; letter-spacing: 1px; }
.dive .st i { color: #2a4a5c; font-style: normal; }
.dive.locked { opacity: .45; } .dive.locked::after { content: "🔒"; position: absolute; right: 10px; bottom: 8px; }

/* shop */
.shop-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--ln); border-radius: 16px; margin-bottom: 10px; background: rgba(4, 26, 46, .6); }
.shop-item .ic { font-size: 30px; width: 46px; text-align: center; }
.shop-item .info { flex: 1; } .shop-item .info b { font-size: 16px; } .shop-item .info p { margin: 2px 0 6px; font-size: 13px; color: #9cc3d6; }
.pips { display: flex; gap: 5px; } .pips i { width: 22px; height: 7px; border-radius: 4px; background: #183a4e; } .pips i.on { background: linear-gradient(90deg, #5fe3ff, #b5f5ff); box-shadow: 0 0 8px #5fe3ff; }
.shop-item .btn { min-width: 86px; padding: 10px; font-size: 15px; }
.shop-item.bought { animation: pop .5s ease; } @keyframes pop { 40% { transform: scale(1.04); box-shadow: 0 0 30px rgba(95, 227, 255, .6); } }

.how { margin: 0; padding-left: 18px; line-height: 1.45; font-size: 15px; } .how li { margin-bottom: 8px; } .how b { color: #bff4ff; }

/* story card */
#sStory { justify-content: center; padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); background: radial-gradient(ellipse at 50% 30%, rgba(8, 50, 80, .6), rgba(0, 4, 10, .92)); }
.story-card { width: min(520px, 100%); max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; background: var(--glass); border: 1px solid var(--ln); border-radius: 22px; padding: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
#art { width: 100%; height: auto; aspect-ratio: 600 / 380; border-radius: 14px; background: #02101e; display: block; }
.story-chapter { margin: 12px 4px 0; font-size: 12px; letter-spacing: .3em; color: var(--or); font-weight: 700; }
.story-title { margin: 2px 4px 6px; font-size: 24px; font-weight: 800; color: #eafcff; }
.story-lines { min-height: 120px; padding: 0 4px; }
.sl { margin: 8px 0; opacity: 0; transform: translateY(6px); transition: opacity .5s, transform .5s; }
.sl.show { opacity: 1; transform: none; }
.sl .who { font-size: 11px; letter-spacing: .18em; font-weight: 700; color: var(--cy); }
.sl.log .who { color: var(--or); }
.sl .tx { font-size: 16px; line-height: 1.45; color: #dff3fb; }
.sl.log .tx { font-family: ui-monospace, "Roboto Mono", "Courier New", monospace; font-size: 14.5px; color: #ffe2b0; }
.story-btns { display: flex; gap: 10px; margin-top: 10px; } .story-btns .btn.small { flex: 0 0 90px; } .story-btns .primary { flex: 1; }

/* cinematic */
.cine { justify-content: flex-end; padding: 0 18px max(60px, calc(env(safe-area-inset-bottom) + 40px)); pointer-events: auto; }
.cine-sub { max-width: 560px; text-align: center; font-size: 18px; line-height: 1.5; color: #f0fbff; text-shadow: 0 2px 8px #000, 0 0 2px #000; min-height: 4.5em; transition: opacity .6s; }
.cine-sub .who { display: block; font-size: 11px; letter-spacing: .25em; color: var(--cy); margin-bottom: 4px; }
.cine-sub.log .who { color: var(--or); } .cine-sub.log { font-family: ui-monospace, "Roboto Mono", monospace; font-size: 16px; color: #ffe8c2; }
.skip { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; }

/* HUD */
#hud { position: absolute; left: 0; right: 0; top: 0; z-index: 5; padding: max(8px, env(safe-area-inset-top)) 10px 0; pointer-events: none; }
.hud-top { display: flex; justify-content: space-between; gap: 8px; }
.hud-left { flex: 1; max-width: 230px; background: rgba(2, 18, 34, .55); border: 1px solid rgba(120, 220, 255, .15); border-radius: 14px; padding: 7px 10px; }
.hud-name { font-size: 12px; font-weight: 700; letter-spacing: .06em; color: #bdefff; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars { display: flex; flex-direction: column; gap: 5px; }
.bar { display: flex; align-items: center; gap: 6px; } .bar .ico { font-style: normal; font-size: 11px; width: 18px; color: #9cd; text-align: center; font-weight: 700; }
.track { flex: 1; height: 8px; background: rgba(255, 255, 255, .1); border-radius: 5px; overflow: hidden; }
.fill { height: 100%; width: 100%; border-radius: 5px; transition: width .15s linear; }
.fill.o2 { background: linear-gradient(90deg, #2bd1ff, #a8f3ff); box-shadow: 0 0 8px #2bd1ff; }
.fill.hull { background: linear-gradient(90deg, #ff9b3d, #ffd38a); }
.fill.bat { background: linear-gradient(90deg, #e9d23b, #fff59a); }
.fill.warn { animation: blink .5s steps(2) infinite; background: #ff4d5e !important; box-shadow: 0 0 10px #ff4d5e; }
@keyframes blink { 50% { opacity: .35; } }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.depth { font-variant-numeric: tabular-nums; background: rgba(2, 18, 34, .55); border: 1px solid rgba(120, 220, 255, .15); border-radius: 12px; padding: 3px 10px; }
.depth b { font-size: 22px; color: #eafcff; } .depth small { color: #8fc; margin-left: 2px; }
.counts { display: flex; gap: 8px; font-size: 14px; font-weight: 700; } #hFrag { color: var(--or); text-shadow: 0 0 8px rgba(255, 181, 71, .6); } #hPearl { color: #f1edff; }
.icon-btn { pointer-events: auto; width: 44px; height: 40px; border-radius: 12px; border: 1px solid rgba(120, 220, 255, .3); background: rgba(2, 18, 34, .65); font-size: 14px; letter-spacing: -2px; }
.press { margin: 8px auto 0; width: max-content; padding: 4px 12px; border-radius: 10px; background: rgba(255, 50, 70, .25); border: 1px solid #ff4d5e; color: #ffb3bb; font-size: 12px; font-weight: 800; letter-spacing: .2em; animation: blink .6s steps(2) infinite; }

/* controls */
#controls { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
#stickZone { position: absolute; left: 0; bottom: 0; width: 62%; height: 62%; pointer-events: auto; }
#stickBase { position: absolute; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%; left: 90px; bottom: 30px; top: auto;
  border: 2px solid rgba(140, 230, 255, .35); background: radial-gradient(circle, rgba(95, 227, 255, .12), rgba(95, 227, 255, .03) 70%); transition: opacity .2s; opacity: .55; }
#stickBase.on { opacity: 1; }
#stickKnob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #bff6ff, #2fb8e0 60%, #0b6f96); box-shadow: 0 0 18px rgba(95, 227, 255, .6); }
#stickHint { position: absolute; left: 30px; bottom: 6px; font-size: 11px; letter-spacing: .15em; color: rgba(190, 240, 255, .55); text-transform: uppercase; transition: opacity .5s; }
.ctl { position: absolute; pointer-events: auto; border-radius: 50%; border: 2px solid rgba(140, 230, 255, .45); background: radial-gradient(circle at 45% 35%, rgba(40, 120, 160, .75), rgba(4, 30, 52, .85)); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 26px; color: #dff; box-shadow: 0 6px 20px rgba(0, 0, 0, .45); }
.ctl small { font-size: 10px; letter-spacing: .12em; font-weight: 800; margin-top: 2px; }
.ctl.sonar { width: 96px; height: 96px; right: 18px; bottom: max(26px, env(safe-area-inset-bottom)); }
.ctl.light { width: 70px; height: 70px; right: 112px; bottom: max(96px, calc(env(safe-area-inset-bottom) + 70px)); font-size: 22px; }
.ctl.light.on { background: radial-gradient(circle at 45% 35%, #fff8c8, #ffd34d 55%, #b88a10); color: #3a2a00; border-color: #fff2a8; box-shadow: 0 0 26px rgba(255, 220, 90, .7); }
.ctl.sonar.cool { opacity: .5; }
.ctl.sonar .ring { position: absolute; inset: -2px; border-radius: 50%; border: 2px solid #5fe3ff; opacity: 0; }
.ctl.sonar.ping .ring { animation: ringOut .7s ease-out; }
@keyframes ringOut { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(1.8); } }
.ctl:active { filter: brightness(1.3); }

.toast { position: absolute; left: 50%; top: 31%; transform: translate(-50%, -10px); z-index: 30; padding: 8px 16px; border-radius: 14px; background: rgba(2, 24, 44, .8); border: 1px solid rgba(120, 220, 255, .35);
  font-weight: 700; font-size: 15px; color: #e8fbff; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.gold { color: #ffd88a; border-color: rgba(255, 181, 71, .6); } .toast.red { color: #ffb3bb; border-color: rgba(255, 77, 94, .6); } .toast.green { color: #b9ffcf; border-color: rgba(80, 255, 150, .5); }
.hint { position: absolute; left: 50%; top: calc(env(safe-area-inset-top) + 132px); transform: translateX(-50%); z-index: 6; width: min(330px, 86vw); text-align: center; padding: 10px 14px; border-radius: 14px; background: rgba(2, 24, 44, .78); border: 1px solid rgba(120, 220, 255, .3); font-size: 15px; line-height: 1.35; pointer-events: none; animation: hintIn .4s both; }
@keyframes hintIn { from { opacity: 0; } to { opacity: 1; } }

/* results */
.res-kicker { font-size: 12px; letter-spacing: .3em; font-weight: 800; color: #7dffb0; } .res-kicker.red { color: #ff7d8a; }
.result h2 { margin: 0; }
.stars { display: flex; justify-content: center; gap: 12px; font-size: 52px; line-height: 1; margin: 4px 0; }
.stars span { color: #1d3b4d; text-shadow: none; transform: scale(.7); transition: color .3s, transform .4s cubic-bezier(.3, 1.8, .5, 1), text-shadow .3s; }
.stars span.on { color: #ffd34d; transform: scale(1.1); text-shadow: 0 0 22px rgba(255, 211, 77, .9); }
.checks { list-style: none; margin: 0; padding: 0; text-align: left; font-size: 14px; }
.checks li { padding: 6px 4px; border-bottom: 1px solid rgba(120, 220, 255, .1); opacity: 0; transition: opacity .4s; display: flex; justify-content: space-between; gap: 8px; }
.checks li.show { opacity: 1; } .checks li .ok { color: #7dffb0; } .checks li .no { color: #ff8d98; }
.res-pearls { font-size: 16px; color: #efeaff; } .res-pearls b { font-size: 20px; }

#curtain { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 50; transition: opacity .35s ease; }
#curtain.on { opacity: 1; }

@media (orientation: landscape) and (max-height: 520px) {
  #sTitle { padding-top: 14px; flex-direction: row; align-items: center; justify-content: space-around; }
  #logo { font-size: 7vw; } .tagline { display: none; }
  #stickZone { width: 50%; height: 80%; }
  .story-card { flex-direction: row; flex-wrap: wrap; max-width: 860px; width: 100%; } #art { width: 44%; } .story-card > div { }
  .hint { bottom: 30%; }
}
