:root { color-scheme: dark; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; background: #0b4a6e; }
body { font-family: system-ui, "Hiragino Sans", "Noto Sans JP", sans-serif; color: rgba(255,255,255,.88); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
#sea { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#sea:active { cursor: grabbing; }
.overlay { text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.overlay svg { filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); pointer-events: none; }
[hidden] { display: none !important; }

/* 深さの計器。押せる見た目にしない */
.gauge { position: fixed; left: calc(12px + env(safe-area-inset-left)); top: calc(12px + env(safe-area-inset-top)); width: 96px; height: 56px; padding: 4px 8px; background: rgba(3,18,28,.42); border: 1px solid rgba(180,230,255,.28); border-radius: 12px; color: #d8f6ff; pointer-events: none; }
.gauge-value { font: 28px/28px ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gauge-value small { font-size: 14px; margin-left: 2px; }
.gauge-dir { font-size: 13px; line-height: 16px; }

.round { position: fixed; top: calc(12px + env(safe-area-inset-top)); width: 44px; height: 44px; border-radius: 22px; background: rgba(3,22,34,.32); border: 1px solid rgba(255,255,255,.35); color: rgba(255,255,255,.88); font: inherit; font-size: 13px; line-height: 1; white-space: nowrap; display: grid; place-items: center; cursor: pointer; text-shadow: 0 1px 3px rgba(0,0,0,.6); touch-action: manipulation; }
.round:active { transform: scale(.92); }
.round:focus-visible, .swim:focus-visible { outline: 2px solid #bfeeff; outline-offset: 3px; }
.sound { right: calc(12px + env(safe-area-inset-right)); }
.sound .slash { display: none; }
.sound.off .slash { display: inline; }
.sound.off .wave { display: none; }
.sound.idle .wave { opacity: .35; }
.lang { right: calc(64px + env(safe-area-inset-right)); }
html[lang="en"] .lang { font-size: 11px; }

/* 進む */
/* 止まっている時も、岩や珊瑚や白い砂の上で見える濃さにする。白い縁の外と内に暗い縁を重ねる */
.swim { position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); width: 88px; height: 88px; margin-left: -44px; border-radius: 50%; background: rgba(3,22,34,.64); border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0,14,24,.75), inset 0 0 0 1px rgba(0,14,24,.5), 0 3px 14px 2px rgba(0,0,0,.45); color: #fff; font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; touch-action: none; cursor: pointer; text-shadow: 0 1px 3px rgba(0,0,0,.8); transition: transform .08s, background-color .2s, border-color .2s; }
body.deep .swim { background: rgba(3,22,34,.56); }
.swim.down { transform: scale(.94); }
.swim .pause { display: none; }
.swim.on { background: rgba(38,128,166,.72); }
body.deep .swim.on { background: rgba(32,104,138,.62); }
/* 水面や海底で、それより上（下）へ進めない時: ボタンと計器に、橙の「端の線」を出す。文は足さない */
.swim .wall { position: absolute; left: 22px; right: 22px; height: 6px; border-radius: 3px; background: #ffc45c; box-shadow: 0 0 0 1px rgba(0,14,24,.7); display: none; }
.swim.limit-down { border-bottom-color: #ffc45c; }
.swim.limit-up { border-top-color: #ffc45c; }
.swim.limit-down .wall { display: block; bottom: 8px; }
.swim.limit-up .wall { display: block; top: 8px; }
/* ほとんど動けていない時: 縁を橙の破線にして、泳いでいる印の輪を止める */
.swim.on.stalled { border-color: #ffc45c; border-style: dashed; background: rgba(3,22,34,.64); }
.swim.on.stalled::before { animation: none; opacity: 0; }
.gauge.limit-down, .gauge.limit-up { color: #ffd58a; }
.gauge.limit-down { box-shadow: inset 0 -4px 0 #ffc45c; }
.gauge.limit-up { box-shadow: inset 0 4px 0 #ffc45c; }
.swim.on .pause { display: inline; }
.swim.on .go { display: none; }
.swim.on .go-icon { animation: none; }
/* 泳いでいる間は、呼吸の周期のごく弱い輪を外に出す */
.swim::before, .swim::after { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 1px solid rgba(190,236,255,.7); opacity: 0; pointer-events: none; }
.swim.on::before { animation: breathe 6s ease-in-out infinite; }
/* 押した瞬間に広がる輪 */
.swim.down::after { animation: press .45s ease-out; }
@keyframes breathe { 0%, 100% { opacity: .15; transform: scale(.98); } 45% { opacity: .6; transform: scale(1.05); } }
@keyframes press { from { opacity: .9; transform: scale(.92); } to { opacity: 0; transform: scale(1.3); } }

/* 最初の案内。下の方に出して、海の主役に重ねない */
.guide { position: fixed; left: 20px; right: 20px; bottom: calc(132px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 15px; line-height: 1.5; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .5s, visibility .5s; }
.guide.show { opacity: 1; visibility: visible; }
.guide-text { padding: 3px 14px; border-radius: 16px; background: rgba(3,22,34,.34); color: #fff; max-width: 100%; text-wrap: balance; }
.guide-art { display: none; }
.guide[data-kind="look"] .guide-art-look { display: block; }
.guide[data-kind="swim"] .guide-art-swim { display: block; order: 2; }
.guide[data-kind="depth"] .guide-art-depth { display: block; }
.finger { animation: swipe 3.2s ease-in-out infinite; }
@keyframes swipe {
  0% { transform: translate(0, 0); } 15% { transform: translate(-30px, 0); } 38% { transform: translate(30px, 0); }
  52% { transform: translate(0, 0); } 66% { transform: translate(0, -13px); } 86% { transform: translate(0, 13px); } 100% { transform: translate(0, 0); }
}
.guide-art-swim { animation: nod 1.2s ease-in-out infinite; }
.guide-art-depth { animation: nod 1.6s ease-in-out infinite; }
@keyframes nod { 50% { translate: 0 5px; } }
@media (prefers-reduced-motion: reduce) { .guide-art-swim, .guide-art-depth { animation: none; } .swim.on::before { animation: none; opacity: .4; } }

.pc-keys { display: none; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(8px + env(safe-area-inset-bottom)); width: max-content; max-width: 100%; padding: 2px 12px; border-radius: 12px; background: rgba(3,22,34,.34); text-align: center; font-size: 12px; color: rgba(255,255,255,.88); pointer-events: none; }
@media (min-width: 900px) {
  .swim { width: 80px; height: 80px; margin-left: -40px; bottom: calc(38px + env(safe-area-inset-bottom)); }
  .pc-keys { display: block; }
}
/* 横向きのスマホなど、低い画面では進むを右下へ */
@media (max-height: 499px) {
  .swim { left: auto; right: calc(24px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); width: 76px; height: 76px; margin: 0; }
  .guide { bottom: calc(24px + env(safe-area-inset-bottom)); left: 120px; right: 120px; }
  .guide[data-kind="swim"] { left: auto; right: 12px; bottom: calc(106px + env(safe-area-inset-bottom)); max-width: 240px; }
}

/* 地図（周回3）。ボタンは計器の下の左。開いている間は暗い板の上に海図を出し、後ろの海は見えたまま */
.map-btn { position: fixed; z-index: 6; left: calc(12px + env(safe-area-inset-left)); top: calc(76px + env(safe-area-inset-top)); height: 44px; min-width: 44px; padding: 0 14px 0 11px; border-radius: 22px; background: rgba(3,22,34,.4); border: 1px solid rgba(255,255,255,.4); color: rgba(255,255,255,.92); font: inherit; font-size: 13px; line-height: 1; white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; touch-action: manipulation; }
.map-btn.seen { padding: 0; width: 44px; }
.map-btn.seen .map-btn-label { display: none; }
.map-btn:active { transform: scale(.94); }
.map-btn[aria-expanded="true"] { background: rgba(38,128,166,.78); border-color: #fff; }
.map-btn:focus-visible, .map-close:focus-visible { outline: 2px solid #bfeeff; outline-offset: 3px; }
.map-overlay { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(2,10,18,.46); touch-action: none; }
.map-card { --map: min(calc(100vw - 28px), calc(100vh - 220px), 700px); width: calc(var(--map) + 16px); padding: 4px 8px 8px; border-radius: 16px; background: rgba(3,16,28,.66); border: 1px solid rgba(180,230,255,.3); box-shadow: 0 6px 30px rgba(0,0,0,.4); }
@supports (height: 100dvh) { .map-card { --map: min(calc(100vw - 28px), calc(100dvh - 220px), 700px); } }
@media (min-width: 900px) { .map-card { --map: min(calc(100vw - 28px), calc(100vh - 340px), 640px); } }
.map-head { display: flex; align-items: center; justify-content: center; position: relative; height: 44px; font-size: 15px; font-weight: 600; letter-spacing: .08em; color: #e6f8ff; }
.map-close { position: absolute; right: 0; top: 0; width: 44px; height: 44px; border-radius: 22px; background: none; border: 0; color: #fff; display: grid; place-items: center; cursor: pointer; touch-action: manipulation; }
.map-frame { position: relative; width: var(--map); height: var(--map); border-radius: 8px; overflow: hidden; background: #0b2a4a; }
.map-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: .97; }
.map-names { position: absolute; inset: 0; pointer-events: none; font-size: clamp(10px, calc(var(--map) * .031), 15px); line-height: 1.1; color: #fff; text-shadow: 0 0 3px #04121f, 0 0 3px #04121f, 0 1px 2px #04121f; white-space: nowrap; }
.map-name { position: absolute; }
.map-name.side-c { transform: translate(-50%, -50%); }
.map-name.side-l { transform: translate(calc(-100% - 5px), -50%); }
.map-name.side-r { transform: translate(5px, -50%); }
.map-name.side-b { transform: translate(-50%, 15px); }
.map-name.side-t { transform: translate(-50%, calc(-100% - 6px)); }
/* 白い点は名前のすぐ横（点の位置が場所）。塔は点が名前の右、割れ目とアーチは点が名前の左 */
.map-name.dot::before, .map-name.dot::after { content: none; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1.5px #04121f; vertical-align: middle; position: relative; top: -.5px; }
.map-name.dot.side-r::before { content: ""; margin-right: 4px; }
.map-name.dot.side-l::after { content: ""; margin-left: 4px; }
.map-name.dot.side-r { transform: translate(-3px, -50%); }
.map-name.dot.side-l { transform: translate(calc(-100% + 3px), -50%); }
/* 自分の矢じりの下になる名前は薄くする */
.map-name { transition: opacity .15s; }
.map-name.dim { opacity: .28; }
.map-north { position: absolute; left: 8px; top: 6px; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 0 3px #04121f, 0 0 3px #04121f; }
.map-scale { position: absolute; left: 8px; bottom: 6px; font-size: 11px; color: #fff; text-shadow: 0 0 3px #04121f, 0 0 3px #04121f; display: flex; flex-direction: column; gap: 2px; }
.map-scale i { display: block; width: 10%; width: calc(var(--map) * .1); height: 5px; border: 2px solid #fff; border-top: 0; box-shadow: 0 0 3px #04121f; }
.map-me { position: absolute; width: 64px; height: 64px; margin: -32px 0 0 -32px; transform: rotate(var(--yaw, 0rad)); pointer-events: none; }
.map-me svg { display: block; filter: drop-shadow(0 0 3px rgba(0,0,0,.7)); }
.map-depth { height: 32px; display: flex; align-items: center; justify-content: center; font: 16px ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; color: #d8f6ff; }
/* 凡例: 色の帯（浅い → 深い）。色は絵の段の色（ui/map.js の STOPS）と同じ並び */
.map-legend { height: 22px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12px; color: #d8f6ff; }
.map-ramp { display: block; width: calc(var(--map) * .5); max-width: 220px; height: 10px; border-radius: 5px; border: 1px solid rgba(255,255,255,.5); background: linear-gradient(90deg, #8ce8d6, #56cdd4, #34a8ce, #227aba, #185094, #0e2a60, #061034); }
@media (max-height: 499px) { .map-card { --map: min(calc(100vw - 28px), calc(100vh - 150px), 700px); } }
/* 海の外周の帯で押し戻されている間の短い文。画面の下の方 */
.edge-note { position: fixed; z-index: 4; left: 20px; right: 20px; bottom: calc(196px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 40px); margin: 0 auto; padding: 4px 14px; border-radius: 16px; background: rgba(3,22,34,.5); color: #fff; font-size: 15px; line-height: 1.5; text-align: center; text-wrap: balance; pointer-events: none; }
@media (max-height: 499px) { .edge-note { bottom: calc(24px + env(safe-area-inset-bottom)); left: 120px; right: 120px; max-width: calc(100% - 240px); } }
.no-webgl .edge-note { display: none !important; }
.no-webgl .map-btn, .no-webgl .map-overlay { display: none !important; }
.no-ui .map-overlay { display: none !important; }

/* 写真（周回4）。シャッターは地図のボタンの下（左の列）。隣に、撮った写真があればアルバムのボタン */
.photo-bar { position: fixed; z-index: 4; left: calc(12px + env(safe-area-inset-left)); top: calc(128px + env(safe-area-inset-top)); display: flex; gap: 8px; pointer-events: none; }
.photo-btn { pointer-events: auto; height: 44px; min-width: 44px; padding: 0 14px 0 11px; border-radius: 22px; background: rgba(3,22,34,.4); border: 1px solid rgba(255,255,255,.4); color: rgba(255,255,255,.92); font: inherit; font-size: 13px; line-height: 1; white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; touch-action: manipulation; }
.photo-btn.seen, .photo-album-btn { padding: 0; width: 44px; }
.photo-btn.seen .photo-btn-label { display: none; }
.photo-btn.down { transform: scale(.92); background: rgba(255,255,255,.5); }
.photo-btn:active { transform: scale(.94); }
.photo-btn[aria-expanded="true"] { background: rgba(38,128,166,.78); border-color: #fff; }
.photo-btn:focus-visible, .photo-close:focus-visible, .photo-back:focus-visible, .photo-thumb:focus-visible, .photo-cell:focus-visible, .photo-actions button:focus-visible { outline: 2px solid #bfeeff; outline-offset: 3px; }
/* シャッターの光。0.15 秒ほど、まぶしすぎない白 */
.photo-flash { position: fixed; inset: 0; z-index: 8; background: #fff; opacity: 0; pointer-events: none; }
.photo-flash.go { animation: shutter .16s ease-out; }
@keyframes shutter { 0% { opacity: .5; } 100% { opacity: 0; } }
/* 撮れた写真の小さい絵。左下の隅に 2 秒ほど。押すとアルバム */
.photo-thumb { position: fixed; z-index: 4; left: calc(12px + env(safe-area-inset-left)); bottom: calc(28px + env(safe-area-inset-bottom)); width: 64px; height: 64px; padding: 0; border: 2px solid #fff; border-radius: 10px; overflow: hidden; background: #0b2a4a; box-shadow: 0 2px 10px rgba(0,0,0,.5); cursor: pointer; touch-action: manipulation; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb.in { animation: thumb-in .25s ease-out; }
@keyframes thumb-in { from { transform: translateY(10px) scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.photo-toast { position: fixed; z-index: 9; left: calc(12px + env(safe-area-inset-left)); top: calc(184px + env(safe-area-inset-top)); max-width: min(280px, calc(100vw - 24px)); padding: 6px 12px; border-radius: 12px; background: rgba(3,22,34,.7); border: 1px solid rgba(255,255,255,.3); font-size: 13px; line-height: 1.45; color: #fff; pointer-events: none; }
.photo-overlay { position: fixed; inset: 0; z-index: 7; display: grid; place-items: end center; padding: 56px 0 10px; background: rgba(2,10,18,.6); touch-action: none; }
.photo-card { width: min(calc(100vw - 20px), 720px); max-height: calc(100vh - 66px); display: flex; flex-direction: column; padding: 4px 8px 10px; border-radius: 16px; background: rgba(3,16,28,.86); border: 1px solid rgba(180,230,255,.3); box-shadow: 0 6px 30px rgba(0,0,0,.4); }
@supports (height: 100dvh) { .photo-card { max-height: calc(100dvh - 66px); } }
.photo-head { display: flex; align-items: center; justify-content: center; position: relative; height: 44px; flex: none; font-size: 15px; font-weight: 600; letter-spacing: .08em; color: #e6f8ff; }
.photo-close, .photo-back { position: absolute; top: 0; width: 44px; height: 44px; border-radius: 22px; background: none; border: 0; color: #fff; display: grid; place-items: center; cursor: pointer; touch-action: manipulation; }
.photo-close { right: 0; }
.photo-back { left: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; min-height: 0; }
.photo-cell { aspect-ratio: 1; padding: 0; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; overflow: hidden; background: #0b2a4a; cursor: pointer; touch-action: manipulation; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.photo-empty { padding: 36px 12px; text-align: center; font-size: 14px; color: rgba(255,255,255,.7); }
.photo-single { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.photo-big { display: grid; place-items: center; min-height: 0; max-height: calc(100vh - 250px); border-radius: 8px; overflow: hidden; background: #04121f; }
@supports (height: 100dvh) { .photo-big { max-height: calc(100dvh - 250px); } }
.photo-big img { max-width: 100%; max-height: calc(100vh - 250px); object-fit: contain; display: block; }
@supports (height: 100dvh) { .photo-big img { max-height: calc(100dvh - 250px); } }
.photo-meta { text-align: center; font-size: 13px; color: #d8f6ff; font-variant-numeric: tabular-nums; }
.photo-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.photo-actions button { min-width: 84px; height: 44px; padding: 0 16px; border-radius: 22px; background: rgba(3,22,34,.5); border: 1px solid rgba(255,255,255,.45); color: #fff; font: inherit; font-size: 14px; cursor: pointer; touch-action: manipulation; }
.photo-actions button.sure { background: #b3412f; border-color: #ffd0c4; }
.no-webgl .photo-bar, .no-webgl .photo-overlay, .no-webgl .photo-thumb, .no-webgl .photo-toast { display: none !important; }
.no-ui .photo-overlay, .no-ui .photo-bar, .no-ui .photo-thumb, .no-ui .photo-toast { display: none !important; }
.boot-failed .photo-bar, .boot-failed .photo-thumb { display: none; }
@media (max-height: 499px) { .photo-big, .photo-big img { max-height: calc(100vh - 130px); } }

/* 読み込み、失敗、WebGL がない知らせ。JS を待たずに青い水が出る */
.notice { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 0 28px; text-align: center; background: linear-gradient(#7fd8ea, #1c86ad 48%, #0b4a6e); color: #fff; font-size: 16px; line-height: 1.7; transition: opacity .6s, visibility .6s; z-index: 10; text-shadow: 0 1px 3px rgba(0,30,50,.55); }
.notice.done { opacity: 0; visibility: hidden; pointer-events: none; }
.notice-text { position: relative; max-width: 30em; text-wrap: balance; }
.notice button { position: relative; font: inherit; padding: 10px 24px; border-radius: 22px; border: 1px solid #fff; background: rgba(3,22,34,.32); color: #fff; cursor: pointer; }
.bubbles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.bubbles i { position: absolute; bottom: -30px; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(255,255,255,.7); animation: rise 5s linear infinite; }
.bubbles i:nth-child(1) { left: 18%; animation-delay: 0s; }
.bubbles i:nth-child(2) { left: 31%; width: 8px; height: 8px; animation-delay: -1.4s; }
.bubbles i:nth-child(3) { left: 47%; animation-delay: -2.9s; }
.bubbles i:nth-child(4) { left: 58%; width: 9px; height: 9px; animation-delay: -0.7s; }
.bubbles i:nth-child(5) { left: 72%; width: 18px; height: 18px; animation-delay: -3.6s; }
.bubbles i:nth-child(6) { left: 84%; width: 7px; height: 7px; animation-delay: -2.1s; }
@keyframes rise { to { transform: translateY(-110vh); } }

/* コードが届かない時（boot-guard.js）は、泡の画面と「もう一度」だけ */
.boot-failed .overlay, .boot-failed .dafb-btn { display: none; }
/* WebGL がない時は言語のボタンだけ残す。知らせより上に出す */
.no-webgl .lang { z-index: 11; }
.no-webgl .swim, .no-webgl .gauge, .no-webgl .sound, .no-webgl .guide, .no-webgl .pc-keys { display: none !important; }
.no-ui .overlay, .no-ui .dafb-btn { display: none !important; }
