/* Ocean Cycle: natural-history documentary. Deep blues, glassy dark panels, light sans-serif type, aqua for the one thing that matters. */
:root {
  --deep: #06121f;
  --glass: rgba(6, 20, 36, 0.58);
  --glass-strong: rgba(6, 18, 32, 0.88);
  --line: rgba(190, 225, 245, 0.16);
  --ink: #e8f3fa;
  --muted: #9db9cc;
  --aqua: #6fd3e8;
  --aqua-deep: #2b8fb0;
  --heart: #ff5d73;
  --warn: #ffd23f;
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--deep); color: var(--ink);
  font-family: "Avenir Next", "Helvetica Neue", "Segoe UI", system-ui, sans-serif; font-weight: 400;
  -webkit-user-select: none; user-select: none; touch-action: none; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
#surface { position: fixed; inset: 0; touch-action: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.panel { background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(190, 225, 245, 0.16); border-radius: 12px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud-top { position: absolute; left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); top: calc(7px + var(--safe-t)); display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
#hud-left { padding: 4px 10px 5px; width: 250px; }
#cycle-label { font-weight: 600; letter-spacing: 0.02em; font-size: 15px; }
#size-label { color: #c3d9e8; font-size: 12px; margin-top: 2px; line-height: 1.2; overflow-wrap: anywhere; }
#ladder { display: flex; gap: 5px; margin-top: 3px; align-items: flex-end; }
#ladder .rung { flex: 1; height: 22px; color: rgba(157, 185, 204, 0.45); display: flex; align-items: center; justify-content: center; border-bottom: 2px solid transparent; transition: color .25s; }
#ladder .rung svg { width: 100%; height: 100%; fill: currentColor; }
#ladder .rung.past { color: rgba(157, 185, 204, 0.8); }
#ladder .rung.now { color: var(--aqua); border-bottom-color: var(--aqua); filter: drop-shadow(0 0 5px rgba(111, 211, 232, 0.55)); }
#hud-mid { position: absolute; left: 50%; transform: translateX(-50%); padding: 5px 10px 6px; width: 250px; }
#hearts { display: flex; gap: 3px; justify-content: center; }
.heart { width: 20px; height: 20px; display: block; }
.heart svg { width: 100%; height: 100%; display: block; }
.heart path { fill: rgba(232, 243, 250, 0.05); stroke: rgba(210, 228, 240, 0.7); stroke-width: 1.8; transition: fill .2s; }
.heart.full path { fill: var(--heart); stroke: #ffc4cc; }
.heart.lost { animation: heartLost .7s ease-out; }
@keyframes heartLost { 0% { transform: scale(1.5); filter: drop-shadow(0 0 7px #ff5d73); } 100% { transform: scale(1); filter: none; } }
#growth { margin-top: 4px; }
#growth-bar { height: 7px; border-radius: 4px; background: rgba(190, 225, 245, 0.14); overflow: hidden; }
#growth-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #3aa6c4, #8ee6c9); border-radius: 4px; transition: width .25s; }
#growth-label { display: block; margin-top: 3px; font-size: 12.5px; line-height: 1.2; color: #d4e6f1; text-align: center; }
#hud-right { display: flex; gap: 10px; align-items: flex-start; margin-left: auto; }
#zone-readout { padding: 7px 12px; font-size: 13px; max-width: 230px; line-height: 1.25; margin-top: 3px; }
.round { pointer-events: auto; width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); color: var(--ink);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); display: grid; place-items: center; padding: 0; touch-action: manipulation; }
.round svg { width: 24px; height: 24px; fill: currentColor; }

#chips { position: absolute; left: 50%; transform: translateX(-50%); top: calc(110px + var(--safe-t)); display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(60vw, 520px); }
.chip { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-radius: 999px; background: var(--glass-strong); border: 1px solid var(--line); font-size: 15px; text-align: left; }
.chip svg { width: 24px; height: 24px; flex: none; }
.chip.warn { border-color: rgba(255, 210, 63, 0.75); background: rgba(52, 40, 4, 0.82); color: #fff1b8; }
.chip.shelter { gap: 12px; border-radius: 18px; padding: 8px 18px 8px 12px; border: 2px solid rgba(255, 150, 150, 0.8); background: rgba(48, 12, 18, 0.88); }
.chip.shelter svg { width: 44px; height: 44px; fill: #ffd0d0; }
.shelter-text { display: flex; flex-direction: column; gap: 2px; }
.chip.shelter b { font-size: 18px; font-weight: 600; line-height: 1.2; }
.chip.shelter span { font-size: 16px; color: #ffe3e3; }
.chip.shelter.resting { border-color: rgba(142, 230, 201, 0.8); background: rgba(6, 40, 34, 0.88); }
.chip.shelter.resting svg { display: none; }
.chip.shelter.resting span { display: none; }

.edge-arrow { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; will-change: transform; }
.edge-arrow svg { width: 40px; height: 40px; fill: var(--aqua); filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.55)); }
.edge-arrow span { font-size: 13px; color: var(--ink); text-shadow: 0 1px 5px rgba(0, 0, 0, 0.8); margin-top: -2px; }
.edge-arrow.soft { opacity: 0.5; }
.edge-arrow.soft svg { fill: #a7efcf; width: 30px; height: 30px; }
.edge-arrow .rot { display: block; }
#arrow-shelter svg { width: 60px; height: 60px; fill: #ffb3b3; }
#arrow-shelter span { font-size: 17px; font-weight: 600; background: rgba(48, 12, 18, 0.82); padding: 2px 10px; border-radius: 999px; margin-top: 0; white-space: nowrap; }

.card { text-align: center; padding: 8px 24px 10px; border-radius: 16px; background: var(--glass-strong); border: 1px solid var(--line); animation: cardIn .45s ease-out; max-width: 100%; }
.card small { display: block; letter-spacing: 0.22em; text-transform: uppercase; font-size: 11px; color: var(--aqua); }
.card strong { display: block; font-size: 22px; font-weight: 400; margin-top: 1px; }
.card span { display: block; color: #c3d9e8; font-size: 15px; line-height: 1.3; }
.card #depths-label { color: var(--muted); font-size: 14px; }
@keyframes cardIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
#toast { position: absolute; left: 50%; bottom: calc(112px + var(--safe-b)); transform: translateX(-50%); padding: 8px 18px; border-radius: 999px; background: var(--glass-strong); border: 1px solid var(--line); font-size: 16px; opacity: 0; transition: opacity .3s; max-width: min(46vw, 480px); text-align: center; }
#toast.show { opacity: 1; }

#joy-base, #joy-knob { position: absolute; left: 0; top: 0; border-radius: 50%; opacity: 0; transition: opacity .15s; }
#joy-base { width: 128px; height: 128px; margin: -64px 0 0 -64px; border: 2px solid rgba(190, 225, 245, 0.4); background: rgba(6, 20, 36, 0.3); }
#joy-knob { width: 56px; height: 56px; margin: -28px 0 0 -28px; background: rgba(232, 243, 250, 0.85); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4); }
#joy.active #joy-base, #joy.active #joy-knob { opacity: 1; }
#coach { position: absolute; left: calc(24px + var(--safe-l)); bottom: calc(34px + var(--safe-b)); max-width: min(38vw, 360px); padding: 8px 15px; border-radius: 16px; background: var(--glass-strong); border: 1px solid rgba(111, 211, 232, 0.3); font-size: 16px; line-height: 1.3; color: var(--ink); transition: opacity .8s; }
#coach.gone { opacity: 0; }

#ability-btn { pointer-events: auto; position: absolute; right: calc(34px + var(--safe-r)); bottom: calc(34px + var(--safe-b)); width: 124px; height: 124px; border-radius: 50%; border: 2px solid rgba(111, 211, 232, 0.8);
  background: radial-gradient(circle at 50% 30%, rgba(43, 143, 176, 0.85), rgba(10, 52, 82, 0.92)); color: var(--ink); touch-action: manipulation; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; box-shadow: 0 0 24px rgba(111, 211, 232, 0.22); }
#ability-btn { position: absolute; }
#ability-btn strong { font-size: 14px; font-weight: 600; letter-spacing: 0.01em; line-height: 1.1; padding: 0 12px; }
#ability-btn span { font-size: 28px; font-weight: 300; line-height: 1.2; color: #fff; font-variant-numeric: tabular-nums; }
#ability-btn.empty span { font-size: 20px; font-weight: 500; }
#ability-ring { position: absolute; inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); pointer-events: none; }
#ability-ring circle { fill: none; stroke-width: 5; }
#ability-ring .track { stroke: rgba(190, 225, 245, 0.15); }
#ability-ring .arc { stroke: #bff6ff; stroke-linecap: round; stroke-dasharray: 289; stroke-dashoffset: 289; opacity: 0; }
#ability-btn.running .arc { opacity: 1; }
#ability-btn:active { transform: scale(0.95); }
#ability-btn.active { background: radial-gradient(circle at 50% 30%, #6fd3e8, #1d7fa3); }
#ability-btn.empty { border-color: rgba(157, 185, 204, 0.4); background: rgba(10, 24, 38, 0.7); color: rgba(232, 243, 250, 0.55); box-shadow: none; }
#ability-btn.empty span { color: var(--muted); }
#ability-btn.empty strong { color: var(--muted); }

/* Overlays */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background: radial-gradient(ellipse at 50% 30%, rgba(14, 62, 98, 0.55), rgba(3, 9, 18, 0.9)); z-index: 10; overflow: hidden; }
#lore, #pause, #event-card, #confirm, #savenote { background: rgba(3, 9, 18, 0.62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 20; }
.sheet { width: min(680px, 100%); max-height: 100%; background: var(--glass-strong); border: 1px solid var(--line); border-radius: 22px; padding: 26px 34px 24px; text-align: center; }
.title-sheet { background: rgba(6, 18, 32, 0.7); }
.small-sheet { width: min(520px, 100%); }
.lore-sheet { width: min(600px, 100%); }
h1 { margin: 0 0 8px; font-size: 56px; font-weight: 200; letter-spacing: 0.04em; }
h2 { margin: 0 0 8px; font-size: 30px; font-weight: 300; }
.sheet small { display: block; }
.lede { font-size: 19px; line-height: 1.45; color: #d4e6f1; margin: 8px 0 14px; }
.small { font-size: 14px; color: var(--muted); margin: 10px 0 0; line-height: 1.4; }
.muted { color: var(--muted); }
.error { color: #ffb4a8; }
.stack { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 8px; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
button { font: inherit; color: var(--ink); cursor: pointer; }
.primary, .quiet { min-height: 56px; padding: 10px 28px; border-radius: 16px; font-size: 19px; border: 1px solid var(--line); touch-action: manipulation; }
.primary { background: linear-gradient(180deg, #3aa6c4, #1f7a99); border-color: rgba(190, 240, 255, 0.5); font-weight: 600; }
.primary small { font-weight: 400; font-size: 14px; color: #d9f3fb; margin-top: 2px; }
.stack .primary, .stack .quiet { min-width: 300px; }
.quiet { background: rgba(190, 225, 245, 0.08); }
.link { color: var(--aqua); font-size: 17px; padding: 10px; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; touch-action: manipulation; }
.lore-icon { width: 120px; height: 56px; margin: 0 auto 4px; color: var(--aqua); }
.lore-icon svg { width: 100%; height: 100%; fill: currentColor; }
#lore-size { letter-spacing: 0.14em; text-transform: uppercase; font-size: 13px; color: var(--aqua); }
.tag-version { margin: 14px 0 0; font-size: 12px; color: rgba(157, 185, 204, 0.6); }

#rotate { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; background: var(--deep); padding: 20px; }
#rotate svg { width: 72px; height: 72px; color: var(--aqua); }
@media (orientation: portrait) and (max-width: 900px) { #rotate { display: grid; } }

@media (max-width: 1100px), (max-height: 780px) {
  h1 { font-size: 46px; }
  .lede { font-size: 17px; }
  #hud-left { width: 270px; }
  #hud-mid { width: 250px; }
  .heart { width: 20px; height: 20px; }
  #ability-btn { width: 116px; height: 116px; }
}
@media (max-height: 560px) {
  .sheet { padding: 14px 24px; }
  h1 { font-size: 36px; }
  .lede { font-size: 15px; margin: 4px 0 8px; }
}
@media (prefers-reduced-motion: reduce) { .card, .heart.lost, #fx-hot.on { animation: none; } #event-ladder .rung, #fx-cold, #fx-hot { transition: none; } }

/* Screen-edge feedback: cheap overlays, opacity only. */
.fx { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
#fx-hurt { box-shadow: inset 0 0 110px 34px rgba(255, 50, 60, 0.75); }
#fx-hurt.pulse { animation: hurt .7s ease-out; }
@keyframes hurt { 0% { opacity: 0.9; } 100% { opacity: 0; } }
#fx-cold { background: radial-gradient(ellipse at 50% 50%, rgba(200, 235, 255, 0) 52%, rgba(205, 238, 255, 0.34) 84%, rgba(235, 248, 255, 0.6) 100%); transition: opacity .6s; }
#fx-cold.on { opacity: 1; }
#fx-hot { background: radial-gradient(ellipse at 50% 50%, rgba(255, 140, 40, 0) 55%, rgba(255, 130, 30, 0.3) 85%, rgba(255, 90, 20, 0.5) 100%); transition: opacity .6s; }
#fx-hot.on { opacity: 1; animation: shimmer 2.4s ease-in-out infinite; }
@keyframes shimmer { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
.notice { color: #d4e6f1; }
.title-sheet .notice { background: rgba(111, 211, 232, 0.1); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-size: 15px; }

/* Event cards */
#event-ladder { display: flex; gap: 10px; justify-content: center; margin: 10px 0 4px; }
#event-ladder .rung { width: 54px; height: 28px; color: rgba(157, 185, 204, 0.3); transition: color .35s, filter .35s; }
#event-ladder .rung svg { width: 100%; height: 100%; fill: currentColor; }
#event-ladder .rung.lit { color: var(--aqua); filter: drop-shadow(0 0 6px rgba(111, 211, 232, 0.6)); }
#event-card.death .sheet { border-color: rgba(255, 150, 150, 0.5); }
#event-card.death #event-btn { min-width: 280px; min-height: 68px; font-size: 22px; }

/* Death and cycle cards */
#event-card.wait #event-text, #event-card.wait #event-btn { visibility: hidden; }
#event-icon { width: 120px; height: 52px; margin: 4px auto 2px; color: var(--aqua); }
#event-icon svg { width: 100%; height: 100%; fill: currentColor; filter: drop-shadow(0 0 6px rgba(111, 211, 232, 0.5)); }
#event-card.cycle h2 { font-size: 52px; font-weight: 200; letter-spacing: 0.02em; }
#event-ladder { position: relative; }
#event-ladder .line { position: absolute; left: 27px; right: 27px; top: 50%; height: 2px; margin-top: -1px; background: rgba(157, 185, 204, 0.22); }
#event-ladder .line b { display: block; width: 0; height: 100%; background: var(--aqua); }
#event-ladder .rung { position: relative; }
#event-krill { width: 56px; height: 28px; margin: 6px auto 0; color: var(--aqua); opacity: 0; transition: opacity .6s; }
#event-krill svg { width: 100%; height: 100%; fill: currentColor; }
#event-card.krill-on #event-krill { opacity: 1; }
#growth-label.compact { white-space: nowrap; }

/* v0.2: level tag, move chips, records */
#level-tag { font-size: 12px; color: #ffe9a8; letter-spacing: 0.03em; line-height: 1.2; }
#status-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chip.move { padding: 5px 12px; font-size: 14px; border-color: rgba(142, 230, 201, 0.55); background: rgba(6, 36, 40, 0.78); color: #d9fff2; }
.chip.move[hidden] { display: none; }
.chip.move svg { width: 20px; height: 20px; }
.chip.move svg .track { fill: none; stroke: rgba(217, 255, 242, 0.25); stroke-width: 3; }
.chip.move svg .arc { fill: none; stroke: #8ee6c9; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 56.55; stroke-dashoffset: 56.55; }
.records { margin: 0 0 8px; font-size: 16px; color: #ffe9a8; text-align: center; }
.records[hidden] { display: none; }
#event-best { margin: 0; font-weight: 600; color: #ffe9a8; text-align: center; }
#event-best[hidden] { display: none; }
#event-card.wait #event-best { visibility: hidden; }

.chip.move.best { border-color: rgba(255, 233, 168, 0.6); background: rgba(52, 40, 4, 0.78); color: #ffe9a8; }
