/* EchoDepths: instrument, not illustration. A deep navy field, bioluminescent phosphor, water easing. */
@font-face { font-family: "Space Grotesk"; src: url("../fonts/SpaceGrotesk.ttf") format("truetype"); font-weight: 300 700; font-display: swap; }

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --bg: #050d16; --bg-2: #09182a;
  --phos: #6ef0ff; --phos-dim: #1f7686; --ember: #ff7a3d;
  --fg: #d9f1f6; --muted: #74a5b0;
  --line: color-mix(in srgb, var(--phos) 24%, transparent);
  --glow: color-mix(in srgb, var(--phos) 34%, transparent);
  --r: 4px;
  --ease: cubic-bezier(.22,.61,.36,1);
  --font: "Space Grotesk", "Helvetica Neue", system-ui, -apple-system, sans-serif;
}
body.pal-green { --phos: #7dff9c; --phos-dim: #2f6b42; --fg: #d3efdb; --muted: #6a9e78; }
body.pal-amber { --phos: #ffb347; --phos-dim: #7a5220; --fg: #f0e3cc; --muted: #a98f62; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: var(--font); overflow: hidden; overscroll-behavior: none; }
body { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; text-transform: lowercase; letter-spacing: .04em; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; background: var(--bg); }
body.eyes-closed canvas#c { visibility: hidden; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.ic { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.15em; flex: none; }

/* HUD: the only chrome during a run. Everything fixed clears the bars through --sat / --sab. */
#hud { position: fixed; inset: 0; pointer-events: none; font-size: 13px; color: var(--phos); }
#depth { position: absolute; top: calc(14px + var(--sat)); left: 16px; font-variant-numeric: tabular-nums; letter-spacing: .12em; font-weight: 500; }
#biome { position: absolute; top: calc(34px + var(--sat)); left: 16px; color: var(--muted); font-size: 11px; letter-spacing: .2em; }
#hp { position: absolute; top: calc(58px + var(--sat)); left: 16px; display: flex; gap: 6px; }
#hp i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--phos); display: block; box-shadow: 0 0 8px var(--glow); }
#hp i.lost { border-color: var(--phos-dim); box-shadow: none; opacity: .6; }
#pause { position: absolute; top: calc(10px + var(--sat)); right: 12px; width: 40px; height: 40px; pointer-events: auto; display: grid; place-items: center; padding: 0; background: color-mix(in srgb, var(--bg-2) 70%, transparent); border: 1px solid var(--line); color: var(--phos); border-radius: var(--r); font-size: 20px; opacity: .8; transition: transform .15s var(--ease), border-color .2s var(--ease); }
#pebble { position: absolute; right: 14px; bottom: calc(18px + var(--sab)); pointer-events: auto; display: inline-flex; align-items: center; gap: 8px; background: color-mix(in srgb, var(--bg-2) 70%, transparent); border: 1px solid var(--line); color: var(--phos); font: inherit; font-size: 13px; letter-spacing: .12em; padding: 10px 14px; border-radius: var(--r); text-transform: lowercase; min-height: 44px; transition: transform .15s var(--ease), border-color .2s var(--ease), opacity .2s var(--ease); }
#pebble .ic { font-size: 18px; }
#pebble b { font-weight: 500; font-variant-numeric: tabular-nums; }
#pebble[disabled] { opacity: .35; }
#pause:active, #pebble:not([disabled]):active { transform: scale(.96); border-color: var(--phos); }
#hint { position: absolute; left: 0; right: 0; bottom: calc(84px + var(--sab)); text-align: center; font-size: 15px; color: var(--phos); letter-spacing: .16em; transition: opacity .8s var(--ease); text-shadow: 0 0 14px var(--glow); }
#hint.hide { opacity: 0; }
#float { position: absolute; left: 0; right: 0; top: 34%; text-align: center; font-size: 18px; letter-spacing: .2em; color: var(--phos); opacity: 0; transition: opacity 1.2s var(--ease), transform 1.2s var(--ease); text-shadow: 0 0 14px var(--glow); }
#float.show { opacity: .9; transform: translateY(8px); }
body.eyes-closed #hint, body.eyes-closed #float, body.eyes-closed #depth, body.eyes-closed #biome, body.eyes-closed #hp { visibility: hidden; }

/* Screens: overlays on the live canvas. The title stays glass so the sonar shows through; menus sit on a deep surface. */
#screens .screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: calc(24px + var(--sat)) 22px calc(24px + var(--sab)); animation: sonarIn .6s var(--ease) both; }
#screens .screen::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .045; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
#screens .screen.deep { background: radial-gradient(90% 60% at 50% 0%, color-mix(in srgb, var(--phos) 9%, transparent), transparent 70%), color-mix(in srgb, var(--bg) 92%, transparent); }
#screens .screen.dim { background: radial-gradient(80% 50% at 50% 100%, color-mix(in srgb, var(--phos) 8%, transparent), transparent 70%), color-mix(in srgb, var(--bg) 72%, transparent); }
/* death: the sonar art of the run stays visible above the stats; the veil only thickens toward the bottom */
#screens .screen.sonar { background: linear-gradient(180deg, transparent 0%, color-mix(in srgb, var(--bg) 45%, transparent) 46%, color-mix(in srgb, var(--bg) 94%, transparent) 72%); }
@keyframes sonarIn { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stack { position: relative; display: flex; flex-direction: column; gap: 14px; width: min(420px, 100%); align-items: stretch; text-align: center; }
.stack.wide { width: min(520px, 100%); max-height: 100%; overflow-y: auto; padding: 18px 2px; scrollbar-width: none; -webkit-mask-image: linear-gradient(to bottom, transparent, #000 18px, #000 calc(100% - 18px), transparent); mask-image: linear-gradient(to bottom, transparent, #000 18px, #000 calc(100% - 18px), transparent); }
#title .stack { margin-top: auto; }
.stack.wide::-webkit-scrollbar { display: none; }
.stack.bottom { align-self: flex-end; margin-bottom: 4vh; }
.stack > * { animation: rise .55s var(--ease) both; }
.stack > :nth-child(2) { animation-delay: .05s; } .stack > :nth-child(3) { animation-delay: .1s; } .stack > :nth-child(4) { animation-delay: .15s; } .stack > :nth-child(5) { animation-delay: .2s; } .stack > :nth-child(n+6) { animation-delay: .25s; }
.menu .mbtn:nth-child(1) { animation-delay: .12s; } .menu .mbtn:nth-child(2) { animation-delay: .18s; } .menu .mbtn:nth-child(3) { animation-delay: .24s; } .menu .mbtn:nth-child(4) { animation-delay: .3s; }
.menu .mbtn { animation: rise .55s var(--ease) both; }

/* The mark: a lamp with sonar rings. Also the launcher icon. */
.mark { width: 64px; height: 64px; margin: 0 auto 4px; display: block; color: var(--phos); filter: drop-shadow(0 0 10px var(--glow)); }
.mark .lamp { fill: #fff; }
.mark .ring { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.mark .ring.r1 { opacity: .95; } .mark .ring.r2 { opacity: .6; } .mark .ring.r3 { opacity: .3; }
@keyframes pulse { 0% { transform: scale(.55); opacity: .9; } 100% { transform: scale(1.15); opacity: 0; } }
.mark .live { transform-origin: 32px 34px; animation: pulse 3.4s var(--ease) infinite; }
.mark.small { width: 40px; height: 40px; margin-bottom: 0; }

h1.wordmark { font-weight: 300; font-size: clamp(42px, 12.5vw, 64px); letter-spacing: -.015em; line-height: 1; color: var(--phos); margin: 0; text-shadow: 0 0 22px var(--glow); text-wrap: balance; }
h1.wordmark span { color: color-mix(in srgb, var(--phos) 20%, var(--phos-dim)); } /* the dim half still clears 3:1 in every palette over the lit scene */
h2 { font-weight: 400; font-size: 24px; letter-spacing: .14em; color: var(--phos); margin: 0; text-wrap: balance; text-shadow: 0 0 16px var(--glow); }
h1:focus, h2:focus { outline: none; }
.tag { color: var(--muted); margin: 0 0 6px; letter-spacing: .22em; font-size: 12px; }
.menu { display: flex; flex-direction: column; gap: 10px; }
.mbtn { position: relative; background: linear-gradient(180deg, color-mix(in srgb, var(--phos) 10%, transparent), color-mix(in srgb, var(--phos) 3%, transparent)), color-mix(in srgb, var(--bg-2) 80%, transparent); color: var(--phos); border: 1px solid var(--line); box-shadow: inset 0 1px 0 color-mix(in srgb, var(--phos) 14%, transparent), 0 10px 26px -14px var(--glow); font: inherit; font-size: 16px; letter-spacing: .16em; padding: 14px 18px; border-radius: var(--r); cursor: pointer; text-transform: lowercase; min-height: 50px; transition: transform .15s var(--ease), border-color .25s var(--ease), box-shadow .25s var(--ease), background .25s var(--ease); }
.mbtn:hover { border-color: color-mix(in srgb, var(--phos) 55%, transparent); }
.mbtn:active { transform: translateY(1px) scale(.985); box-shadow: inset 0 1px 0 color-mix(in srgb, var(--phos) 8%, transparent); }
.mbtn:focus-visible, .seg button:focus-visible, .evo:focus-visible, #pause:focus-visible, #pebble:focus-visible { outline: 2px solid var(--phos); outline-offset: 3px; }
.mbtn.primary { border-color: color-mix(in srgb, var(--phos) 70%, transparent); box-shadow: inset 0 1px 0 color-mix(in srgb, var(--phos) 24%, transparent), 0 0 0 1px color-mix(in srgb, var(--phos) 12%, transparent), 0 12px 30px -12px var(--glow); }
.mbtn.danger { color: var(--ember); border-color: color-mix(in srgb, var(--ember) 40%, transparent); background: color-mix(in srgb, var(--ember) 5%, transparent); box-shadow: none; }
.mbtn.danger.arm, .mbtn.arm { border-color: var(--ember); color: var(--ember); }
.mbtn[disabled] { opacity: .45; cursor: default; transform: none; }
.stats, .fine, .muted { color: var(--muted); font-size: 12px; letter-spacing: .12em; margin: 0; line-height: 1.6; text-wrap: balance; }
.stats { font-variant-numeric: tabular-nums; }
.body { color: var(--fg); font-size: 14px; line-height: 1.6; margin: 0; letter-spacing: .06em; text-wrap: balance; }
.card { position: relative; background: linear-gradient(180deg, color-mix(in srgb, var(--phos) 8%, transparent), transparent), color-mix(in srgb, var(--bg-2) 85%, transparent); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; text-align: left; font-size: 13px; line-height: 1.6; box-shadow: 0 14px 30px -18px var(--glow); }
.card b { color: var(--phos); font-weight: 500; letter-spacing: .12em; }
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 6px 0; }
.statgrid div { background: linear-gradient(180deg, color-mix(in srgb, var(--phos) 8%, transparent), transparent), color-mix(in srgb, var(--bg-2) 85%, transparent); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 6px; display: flex; flex-direction: column; gap: 4px; }
.statgrid small { color: var(--muted); font-size: 10px; letter-spacing: .16em; }
.statgrid b { color: var(--phos); font-weight: 500; font-size: 17px; font-variant-numeric: tabular-nums; letter-spacing: 0; }

/* Illustrations drawn inline */
.illo { display: block; flex: none; width: min(300px, 100%); height: auto; margin: 0 auto; color: var(--phos); }
.illo .wall { fill: none; stroke: var(--phos-dim); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.illo .lit { fill: none; stroke: var(--phos); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.illo .ring { fill: none; stroke: var(--phos); stroke-width: 1.2; }
.illo .lamp { fill: #fff; }
.illo .glow { fill: var(--phos); opacity: .18; }
.illo .tick { stroke: var(--muted); stroke-width: 1; }
.illo text { fill: var(--muted); font: 10px var(--font); letter-spacing: .14em; text-transform: lowercase; }

/* Options */
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid color-mix(in srgb, var(--phos) 12%, transparent); font-size: 14px; letter-spacing: .1em; text-align: left; }
.opt-row > span { color: var(--fg); }
.seg { display: flex; background: color-mix(in srgb, var(--bg-2) 85%, transparent); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: inset 0 1px 0 color-mix(in srgb, var(--phos) 8%, transparent); }
.seg button { background: transparent; color: var(--muted); border: 0; font: inherit; font-size: 13px; letter-spacing: .1em; padding: 9px 13px; cursor: pointer; text-transform: lowercase; min-height: 40px; transition: background .2s var(--ease), color .2s var(--ease), transform .12s var(--ease); }
.seg button:active { transform: scale(.96); }
.seg button.on { color: var(--bg); background: var(--phos); font-weight: 500; box-shadow: 0 0 14px var(--glow); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 46%; height: 32px; margin: 0; background: transparent; --p: 50%; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--phos) var(--p), color-mix(in srgb, var(--phos) 22%, transparent) var(--p)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin-top: -7.5px; border-radius: 50%; background: var(--bg); border: 2px solid var(--phos); box-shadow: 0 0 12px var(--glow); }
input[type=range]:focus-visible { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--phos); outline-offset: 3px; }
.note { display: block; color: var(--muted); font-size: 12px; letter-spacing: .08em; line-height: 1.55; text-align: left; margin: 2px 0 6px; }

/* Grotto */
.evo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; text-align: left; }
@media (max-width: 420px) { .evo-grid { grid-template-columns: 1fr; } }
.evo-branch h3 { font-weight: 400; font-size: 11px; letter-spacing: .26em; color: var(--muted); margin: 0 0 8px; }
.evo { position: relative; display: block; width: 100%; background: linear-gradient(180deg, color-mix(in srgb, var(--phos) 7%, transparent), transparent), color-mix(in srgb, var(--bg-2) 85%, transparent); color: var(--fg); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; font: inherit; text-align: left; cursor: pointer; margin-bottom: 8px; text-transform: lowercase; letter-spacing: .06em; box-shadow: 0 12px 26px -18px var(--glow); transition: transform .15s var(--ease), border-color .2s var(--ease), background .2s var(--ease); animation: rise .5s var(--ease) both; }
.evo:active { transform: scale(.985); }
.evo b { display: flex; align-items: center; gap: 8px; color: var(--phos); font-weight: 500; letter-spacing: .12em; font-size: 14px; }
.evo b .ic { font-size: 16px; opacity: .9; }
.evo small { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 4px; }
.evo .cost { display: block; margin-top: 8px; font-size: 12px; color: var(--phos); letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.evo.owned { border-color: color-mix(in srgb, var(--phos) 60%, transparent); }
.evo.owned .cost { color: var(--muted); }
.evo.poor { opacity: .82; }
.evo.poor .cost.short { color: var(--ember); }
.evo.pressing { border-color: var(--phos); background: color-mix(in srgb, var(--phos) 10%, transparent); }
.evo.still { animation: none; }
.evo.just { animation: bought .7s var(--ease); }
@keyframes bought { 0% { box-shadow: 0 0 0 0 var(--glow); } 100% { box-shadow: 0 0 0 18px transparent; } }

@media (prefers-reduced-motion: reduce) {
  #screens .screen, .stack > *, .menu .mbtn, .evo, .mark .live, .evo.just { animation: none; }
  .mbtn, .evo, .seg button, #pause, #pebble { transition: none; }
}
