:root {
  --bg: #04050a;
  --panel: rgba(12, 16, 28, 0.88);
  --panel-solid: #0c101c;
  --line: rgba(160, 200, 255, 0.13);
  --line-strong: rgba(160, 200, 255, 0.28);
  --text: #d9e6fb;
  --muted: #7c89a4;
  --faint: #7884a0; /* still below --muted, but 4.5:1 even on the journal's tinted day cells */
  --cyan: #92d6ff;
  --gold: #ffc868;
  --ember: #ff7a5c;
  --green: #7ddb9f;
  --blue: #6db8ff;
  --r: 16px;
  --display: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --ui: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--ui); overflow: hidden; }
* { scrollbar-width: thin; scrollbar-color: rgba(146, 214, 255, 0.2) transparent; }
body { -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
kbd { font-family: var(--mono); font-size: 0.78em; padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; color: var(--text); }
em { font-style: italic; color: var(--cyan); }

#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; transition: opacity 0.4s; }
body.dim-bg #world { opacity: 0.3; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.75) 100%); }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0; overflow-y: auto; overflow-x: hidden;
  display: none; flex-direction: column; align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  animation: fadein 0.35s ease; z-index: 10;
}
.screen.active { display: flex; }
.screen.dim { background: rgba(4, 5, 10, 0.94); justify-content: center; }
.screen.overlay { justify-content: flex-end; pointer-events: none; overflow: hidden; }
.screen.overlay .panel { max-height: 100%; overflow-y: auto; } /* a short phone scrolls the results instead of clipping the buttons */
@media (min-width: 640px) and (min-aspect-ratio: 13/10) {
  .screen.overlay { justify-content: center; align-items: flex-end; padding-right: 32px; }
  .screen.overlay .panel { width: 420px; }
  #resMore { display: none; } /* beside the map there's room: "How everyone did" is always open */
}
/* With the panel under the map, "How everyone did" opens on request. */
@media (max-width: 639px), (max-aspect-ratio: 13/10) {
  #resPanel:not(.more) #resGlobal { display: none; }
}
/* The buttons stay pinned to the panel's bottom edge when it scrolls (short or landscape phones). */
#resPanel .res-actions { position: sticky; bottom: -18px; margin: 12px -20px -18px; padding: 10px 20px 18px; background: rgb(12, 16, 28); border-radius: 0 0 22px 22px; z-index: 1; }
.more-btn { width: 100%; margin-top: 10px; min-height: 40px; font-size: 0.9rem; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.col { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 14px; }
.col.narrow { max-width: 400px; margin: auto 0; }
.col.wide { max-width: 760px; }
.col.center { align-items: center; text-align: center; }

.topbar { width: 100%; max-width: 760px; display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-bottom: 4px; }
.topbar-actions { display: flex; gap: 8px; }
.topbar-start { display: flex; align-items: center; gap: 8px; min-width: 0; }
a.icon-btn { color: var(--text); text-decoration: none; }
.topbar-title { font-family: var(--display); font-size: 1.35rem; font-weight: 600; letter-spacing: 0.02em; }
.icon-btn-spacer { width: 40px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: rgba(20, 26, 42, 0.6);
  cursor: pointer; display: inline-grid; place-items: center; font-size: 15px; transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: rgba(40, 52, 80, 0.8); border-color: var(--line-strong); }

.btn {
  appearance: none; border: 1px solid var(--line-strong); background: rgba(24, 32, 52, 0.7); color: var(--text);
  padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: 0.95rem; cursor: pointer;
  transition: transform 0.12s, background 0.15s, box-shadow 0.2s;
}
.btn:hover { background: rgba(40, 54, 86, 0.85); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(180deg, #a8e0ff, #6fb8f0); color: #06101e; border-color: transparent; box-shadow: 0 0 24px rgba(120, 190, 255, 0.35); }
.btn.primary:hover { box-shadow: 0 0 34px rgba(120, 190, 255, 0.55); }
.btn.gold { background: linear-gradient(180deg, #ffe09a, #f0ac3a); color: #1d1204; border-color: transparent; box-shadow: 0 0 26px rgba(255, 190, 90, 0.4); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(40, 54, 86, 0.4); }
.btn.big { padding: 15px 30px; font-size: 1.05rem; }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.row { display: flex; gap: 10px; justify-content: center; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.kicker { margin: 0; font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.screen-title { font-family: var(--display); font-weight: 600; font-size: 2.2rem; line-height: 1.1; margin: 4px 0 8px; }
.fine { color: var(--muted); font-size: 0.85rem; line-height: 1.5; margin: 0; }
.section-h { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin: 10px 0 0; font-weight: 500; }

/* ---------- home ---------- */
.logo { font-family: var(--display); font-weight: 500; font-style: italic; font-size: clamp(4rem, 17vw, 5.6rem); line-height: 0.9; margin: 6px 0 0; text-align: center; letter-spacing: 0.04em; color: #e8f3ff; text-shadow: 0 0 28px rgba(140, 200, 255, 0.45), 0 0 2px rgba(255, 255, 255, 0.6); }
.tagline { margin: -4px 0 6px; text-align: center; color: var(--muted); font-family: var(--display); font-style: italic; font-size: 1.15rem; }
.preview { text-align: center; font-size: 0.8rem; color: var(--gold); border: 1px dashed rgba(255, 200, 104, 0.4); border-radius: 10px; padding: 6px 10px; }
.preview a { color: inherit; font-weight: 700; }

.streak { display: flex; align-items: baseline; gap: 6px; padding: 6px 12px 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(20, 26, 42, 0.6); }
.streak b { font-family: var(--mono); font-size: 1rem; }
.streak small { color: var(--muted); font-size: 0.78rem; }
.streak .flame { font-size: 1rem; filter: grayscale(1) brightness(0.6); }
.streak.lit .flame { filter: none; }
.streak.risk .flame { filter: none; animation: flicker 1.4s infinite; }
.streak.risk small { color: var(--gold); }
@keyframes flicker { 0%, 100% { opacity: 1; } 45% { opacity: 0.55; } 55% { opacity: 0.9; } }

.cave-card { display: flex; flex-direction: column; gap: 10px; }
#caveAction { display: flex; flex-direction: column; gap: 12px; }
.cave-meta { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.cave-card h2 { font-family: var(--display); font-weight: 600; font-size: 1.9rem; margin: 0; line-height: 1.05; }
.mod { display: flex; gap: 10px; align-items: flex-start; font-size: 0.88rem; color: var(--muted); line-height: 1.4; }
.mod b { color: var(--text); font-weight: 600; }
.mod .mod-ico { font-size: 1.1rem; line-height: 1.2; }
.mod.big { justify-content: center; text-align: left; max-width: 340px; }
.glimmer { color: var(--gold); font-family: var(--display); font-style: italic; font-size: 1.08rem; text-shadow: 0 0 14px rgba(255, 200, 104, 0.5); animation: glimmer 3s ease-in-out infinite; }
@keyframes glimmer { 0%, 100% { opacity: 0.75; } 50% { opacity: 1; } }

.done-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: rgba(146, 214, 255, 0.06); border: 1px solid var(--line); }
.done-summary .ds-stars { color: var(--gold); font-size: 1.3rem; letter-spacing: 2px; }
.done-summary .ds-time { font-family: var(--mono); font-size: 1.25rem; }
.done-summary .ds-sub { color: var(--muted); font-size: 0.78rem; }
.home-global { margin-top: 18px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-actions .btn { flex: 1; }

.home-nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.nav-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px 12px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; transition: border-color 0.15s, transform 0.12s;
}
.nav-btn:hover { border-color: var(--line-strong); }
.nav-btn:active { transform: scale(0.97); }
.nav-ico { font-size: 1.35rem; height: 28px; display: grid; place-items: center; }
.nav-lbl { font-weight: 600; font-size: 0.9rem; }
.nav-btn small { color: var(--muted); font-size: 0.74rem; }
.nav-btn.hot { border-color: rgba(255, 200, 104, 0.55); box-shadow: 0 0 22px rgba(255, 190, 90, 0.18); animation: hot 2.2s ease-in-out infinite; }
.nav-btn.hot small { color: var(--gold); font-weight: 600; }
@keyframes hot { 0%, 100% { box-shadow: 0 0 14px rgba(255, 190, 90, 0.12); } 50% { box-shadow: 0 0 30px rgba(255, 190, 90, 0.35); } }
.cocoon-ico::before { content: ''; width: 16px; height: 23px; border-radius: 50% 50% 48% 48% / 42% 42% 58% 58%; background: radial-gradient(circle at 40% 35%, #efe6d2, #9b917b 60%, #4d463a); display: block; }
.nav-btn.hot .cocoon-ico::before { animation: wobble 1.6s ease-in-out infinite; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 2px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: var(--mono); font-size: 0.66rem; color: var(--faint); }
.wd i { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-style: normal; font-size: 0.7rem; color: var(--muted); }
.wd.done i { background: rgba(146, 214, 255, 0.14); border-color: rgba(146, 214, 255, 0.5); color: var(--cyan); }
.wd.gold i { background: rgba(255, 200, 104, 0.16); border-color: rgba(255, 200, 104, 0.6); color: var(--gold); }
.wd.today i { border-color: var(--cyan); border-style: dashed; animation: glimmer 2s infinite; }
.wd.today { color: var(--text); }
.wd.missed i { opacity: 0.4; }
.countdown { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 2px 0 0; line-height: 1.6; }
.countdown b { font-family: var(--mono); color: var(--text); font-weight: 500; font-size: 1rem; }
.countdown .tease { font-family: var(--display); font-style: italic; color: var(--text); font-size: 1.05rem; }

/* ---------- how to ---------- */
.howto { list-style: none; padding: 0; margin: 6px 0 4px; display: flex; flex-direction: column; gap: 14px; }
.howto li { display: flex; gap: 14px; align-items: flex-start; line-height: 1.45; font-size: 0.93rem; }
.howto small { display: block; color: var(--muted); margin-top: 3px; font-size: 0.8rem; }
.how-ico { width: 34px; height: 34px; flex: none; border-radius: 10px; background: rgba(146, 214, 255, 0.08); border: 1px solid var(--line); display: grid; place-items: center; }
#scrHelp .btn { align-self: center; margin-top: 8px; }

/* ---------- briefing ---------- */
#scrBrief { background: radial-gradient(ellipse at center, rgba(4, 5, 10, 0.6), rgba(4, 5, 10, 0.92)); justify-content: center; }
#scrBrief .col { gap: 16px; }
.coach {
  position: fixed; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 64px); transform: translateX(-50%); z-index: 6;
  width: min(92vw, 380px); margin: 0; padding: 10px 14px; border-radius: 14px; text-align: center; pointer-events: none;
  background: var(--panel); border: 1px solid var(--line-strong); color: var(--text); font-size: 0.95rem; line-height: 1.4;
}
.coach b { color: var(--cyan); }
#hud.tutorial #hudTime { visibility: hidden; }
.tut-text { color: var(--muted); line-height: 1.5; margin: 0; }
.tut-text b { color: var(--text); }
.opts { display: grid; gap: 8px; margin: 12px 0 16px; }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.opt:has(input:checked) { border-color: var(--line-strong); background: rgba(146, 214, 255, 0.08); }
.opt input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--cyan); }
.opt span { color: var(--muted); font-size: 0.9rem; line-height: 1.4; }
.opt b { display: block; color: var(--text); font-size: 1rem; }
.brief-assist { margin: 0; color: var(--cyan); font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.04em; }
body.lefty #btnChirp { right: auto; left: max(18px, env(safe-area-inset-left)); }
.brief-event { margin: 0; color: #ffb36b; font-family: var(--display); font-style: italic; font-size: 1.02rem; }
.brief-par { font-family: var(--mono); font-size: 0.8rem; line-height: 1.6; color: var(--muted); margin: 0; white-space: pre-line; }
.brief-controls { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; color: var(--muted); font-size: 0.82rem; margin: 0; }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: flex; } .brief-controls:not(.touch-only) { display: none; } }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start;
  padding: max(10px, env(safe-area-inset-top)) 14px 0; pointer-events: none; z-index: 5;
}
.hud-cell { display: flex; flex-direction: column; gap: 6px; }
.hud-right { flex-direction: row; justify-content: flex-end; align-items: center; gap: 10px; }
.hud-right .icon-btn { pointer-events: auto; }
.hud-mid { align-items: center; }
.hud-left { align-items: flex-start; }
.hint-btn {
  pointer-events: auto; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer;
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  background: linear-gradient(90deg, rgba(146, 214, 255, 0.2) calc(var(--ready, 1) * 100%), rgba(20, 26, 42, 0.6) 0);
}
.hint-btn small { font-size: inherit; color: var(--ember); letter-spacing: 0; text-transform: none; }
.hint-btn:hover { border-color: var(--line-strong); }
.hint-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.hint-btn.cooling { cursor: default; color: var(--faint); }
.hint-btn.cooling:hover { border-color: var(--line); }
#hudCave { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.12em; color: var(--faint); text-transform: uppercase; }
#hudTime { font-family: var(--mono); font-size: 1.6rem; font-weight: 500; color: #e6f2ff; text-shadow: 0 0 12px rgba(140, 200, 255, 0.4); font-variant-numeric: tabular-nums; }
#hudSub { font-family: var(--mono); font-size: 0.7rem; color: var(--faint); }
#hudSub .pen { color: var(--ember); }
.pips { display: flex; gap: 6px; }
.pip { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid rgba(255, 222, 150, 0.35); transition: all 0.3s; }
.pip.on { background: radial-gradient(circle, #fff3d6, #ffc868); border-color: transparent; box-shadow: 0 0 12px rgba(255, 210, 130, 0.9); }
.pip.golden { border-style: dashed; border-color: rgba(255, 200, 104, 0.6); }
.pip.golden.on { background: radial-gradient(circle, #fff6d0, #ffb020); box-shadow: 0 0 16px rgba(255, 190, 60, 1); }
.hud-cocoons { font-family: var(--mono); font-size: 0.78rem; color: var(--gold); display: flex; align-items: center; gap: 6px; }
.hud-cocoons.pop { animation: pop 0.6s ease; }
@keyframes pop { 0% { transform: scale(1); } 30% { transform: scale(1.5); } 100% { transform: scale(1); } }

#btnChirp {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); z-index: 5;
  width: 78px; height: 78px; border-radius: 50%; border: 1px solid rgba(146, 214, 255, 0.4);
  background: radial-gradient(circle, rgba(146, 214, 255, 0.18), rgba(146, 214, 255, 0.04)); color: var(--cyan);
  font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.1em; touch-action: none;
}
#btnChirp:active { background: rgba(146, 214, 255, 0.3); }
#btnChirp::before {
  content: ''; position: absolute; inset: -5px; border-radius: 50%; opacity: 0; transition: opacity 0.15s; pointer-events: none;
  background: conic-gradient(rgba(146, 214, 255, 0.75) calc(var(--ready, 1) * 360deg), rgba(146, 214, 255, 0.1) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
}
#btnChirp.cooling { color: var(--muted); border-color: rgba(146, 214, 255, 0.15); }
#btnChirp.cooling::before { opacity: 1; }

#toasts { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(92vw, 420px); }
.toast { padding: 9px 16px; border-radius: 999px; background: rgba(10, 14, 26, 0.85); border: 1px solid var(--line-strong); font-size: 0.9rem; text-align: center; animation: toast 2.4s ease forwards; backdrop-filter: blur(4px); }
.toast.gold { color: var(--gold); border-color: rgba(255, 200, 104, 0.6); box-shadow: 0 0 24px rgba(255, 190, 90, 0.3); font-weight: 600; }
.toast.bad { color: var(--ember); border-color: rgba(255, 122, 92, 0.5); }
.toast.big { font-family: var(--display); font-size: 1.3rem; font-style: italic; }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px) scale(0.96); } 10% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }

/* ---------- results ---------- */
.panel { pointer-events: auto; width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 22px 20px 18px; position: relative; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 -10px 60px rgba(0, 0, 0, 0.6); transition: opacity 0.3s, transform 0.3s; animation: rise 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.1); max-height: calc(100% - 20px); overflow-y: auto; }
.panel.peeking { transform: translateY(calc(100% - 58px)); opacity: 0.92; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.results { text-align: center; display: flex; flex-direction: column; gap: 6px; }
.peek { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; font-size: 15px; }
#resCave { padding-inline: 48px; } /* clear of the peek button, whatever the cave's name */
.res-title { font-family: var(--display); font-weight: 600; font-size: 1.9rem; margin: 0; }
.stars { display: flex; justify-content: center; gap: 10px; font-size: 2.2rem; margin: 2px 0; }
.stars span { color: #262d40; transition: color 0.2s, text-shadow 0.2s, transform 0.3s; }
.stars span.on { color: var(--gold); text-shadow: 0 0 18px rgba(255, 200, 104, 0.8); animation: starpop 0.45s ease; }
@keyframes starpop { 0% { transform: scale(0.3) rotate(-30deg); } 60% { transform: scale(1.35); } 100% { transform: scale(1); } }
.res-time { font-family: var(--mono); font-size: 2.5rem; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.res-par { color: var(--muted); font-size: 0.82rem; font-family: var(--mono); }
.res-stats { display: flex; justify-content: center; gap: 18px; color: var(--muted); font-size: 0.85rem; margin: 6px 0 4px; flex-wrap: wrap; }
.res-stats b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.rewards { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.rewards li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: rgba(146, 214, 255, 0.05); border: 1px solid var(--line); font-size: 0.9rem; animation: slidein 0.35s ease both; }
.rewards li.gold { border-color: rgba(255, 200, 104, 0.45); background: rgba(255, 200, 104, 0.08); color: #ffe2a8; }
.rewards li.muted { color: var(--muted); }
.rewards li .ri { width: 22px; text-align: center; flex: none; }
.rewards li .rv { margin-left: auto; font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
@keyframes slidein { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
.nearmiss { color: var(--gold); font-family: var(--display); font-style: italic; font-size: 1.05rem; margin: 6px 0 0; animation: slidein 0.4s ease both; }
.res-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.res-actions .row .btn { flex: 1; }

/* ---------- hatchery ---------- */
#scrHatch { background: radial-gradient(ellipse at 50% 45%, rgba(40, 50, 80, 0.35), transparent 60%), rgba(4, 5, 10, 0.9); }
.hatch-stage { flex: 1; width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; min-height: 380px; }
.cocoon-wrap { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.cocoon { width: 150px; cursor: pointer; transform-origin: 50% 0; animation: sway 3.2s ease-in-out infinite; outline: none; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.6)); transition: filter 0.4s; }
.cocoon:focus-visible { outline: 2px solid var(--muted); outline-offset: 8px; border-radius: 16px; }
.screen:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.cocoon-svg { width: 100%; display: block; overflow: visible; }
.cocoon .thread { stroke: rgba(230, 230, 230, 0.5); stroke-width: 1; fill: none; }
.cocoon .shell { fill: url(#cgPlain); }
.cocoon.golden .shell { fill: url(#cgGold); }
.cocoon .silk path { fill: none; stroke: rgba(255, 255, 255, 0.18); stroke-width: 1.2; }
.cocoon .cracks path { fill: none; stroke: #16110a; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 80; stroke-dashoffset: 80; transition: stroke-dashoffset 0.25s ease; }
.cocoon.k1 .c1, .cocoon.k2 .c2, .cocoon.k3 .c3 { stroke-dashoffset: 0; }
.cocoon.shake { animation: shake 0.35s ease; }
.cocoon.golden { filter: drop-shadow(0 0 22px rgba(255, 190, 70, 0.6)); }
.cocoon.tease-2 { filter: drop-shadow(0 0 26px rgba(109, 184, 255, 0.95)); }
.cocoon.tease-3 { filter: drop-shadow(0 0 30px rgba(255, 200, 90, 1)) drop-shadow(0 0 60px rgba(255, 120, 200, 0.6)); }
.cocoon.tease-shiny { animation: sway 3.2s ease-in-out infinite, hue 1.6s linear infinite; }
@keyframes hue { from { filter: drop-shadow(0 0 26px rgba(255, 255, 255, 0.8)) hue-rotate(0deg); } to { filter: drop-shadow(0 0 26px rgba(255, 255, 255, 0.8)) hue-rotate(360deg); } }
@keyframes sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes wobble { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
@keyframes shake { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-12deg) scale(1.04); } 45% { transform: rotate(10deg); } 70% { transform: rotate(-6deg); } }
.hatch-hint { color: var(--muted); font-size: 0.9rem; margin: 0; animation: glimmer 2s infinite; }
.cocoon.burst { animation: burst 0.35s ease forwards; }
@keyframes burst { to { transform: scale(1.5); opacity: 0; } }

.reveal { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; position: relative; animation: rise 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.reveal canvas { width: 320px; height: 260px; max-width: 86vw; position: relative; z-index: 1; }
.rays { position: absolute; left: 50%; top: 130px; width: 520px; height: 520px; margin: -260px 0 0 -260px; border-radius: 50%; pointer-events: none; opacity: 0.55; background: repeating-conic-gradient(from 0deg, var(--rc, rgba(180, 200, 230, 0.25)) 0deg 6deg, transparent 6deg 18deg); -webkit-mask: radial-gradient(circle, #000 10%, transparent 65%); mask: radial-gradient(circle, #000 10%, transparent 65%); animation: spin 18s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.reveal h3, .modal-card h3 { font-family: var(--display); font-weight: 600; font-size: 2rem; margin: 4px 0 0; line-height: 1.05; position: relative; z-index: 1; }
.latin { font-family: var(--display); font-style: italic; color: var(--muted); margin: 0; font-size: 1.1rem; position: relative; z-index: 1; }
.rarity { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.2em; text-transform: uppercase; margin: 8px 0 0; position: relative; z-index: 1; }
.flavor { color: var(--muted); font-size: 0.9rem; line-height: 1.5; max-width: 320px; margin: 8px 0 0; position: relative; z-index: 1; }
.badges { display: flex; gap: 6px; justify-content: center; min-height: 22px; position: relative; z-index: 1; }
.badge { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.14em; padding: 3px 9px; border-radius: 999px; font-weight: 500; }
.badge.new { background: var(--cyan); color: #06101e; }
.badge.dup { border: 1px solid var(--line-strong); color: var(--muted); }
.badge.dust { border: 1px solid rgba(255, 200, 104, 0.5); color: var(--gold); }
.spec.locked.buyable { cursor: pointer; border-color: rgba(255, 200, 104, 0.45); }
#modalBuy { margin-top: 10px; }
.badge.shiny { background: linear-gradient(90deg, #ff9de2, #9dd8ff, #b6ffb0, #ffe29d); color: #140a1a; }
.hatch-actions { width: 100%; max-width: 440px; display: flex; justify-content: center; min-height: 52px; }
.empty { text-align: center; color: var(--text); }
.empty p { margin: 4px 0; }

/* ---------- cabinet ---------- */
.cab-progress { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.bar { height: 6px; border-radius: 99px; background: rgba(146, 214, 255, 0.1); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--gold)); border-radius: inherit; transition: width 0.8s ease; }
.cab-section h3 { display: flex; align-items: center; gap: 8px; }
.cab-section h3 span { color: var(--faint); letter-spacing: 0.1em; }
.cab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-top: 8px; }
.spec { position: relative; border-radius: 12px; border: 1px solid var(--line); background: rgba(12, 16, 28, 0.8); padding: 6px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; transition: border-color 0.15s, transform 0.12s; min-width: 0; }
.spec:hover { border-color: var(--line-strong); transform: translateY(-1px); }
button.spec { font: inherit; color: inherit; width: 100%; }
button.spec:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.spec canvas { width: 88px; height: 72px; }
.spec .sn { font-size: 0.7rem; text-align: center; line-height: 1.2; color: var(--text); padding: 0 2px; min-height: 2.4em; display: flex; align-items: center; }
.spec.locked { cursor: default; }
.spec.locked .sn { color: var(--faint); }
.spec .cnt { position: absolute; top: 5px; right: 7px; font-family: var(--mono); font-size: 0.62rem; color: var(--muted); }
.spec .sh { position: absolute; top: 4px; left: 6px; font-size: 0.7rem; }

/* ---------- journal ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-family: var(--mono); font-size: 1.35rem; font-weight: 500; }
.stat small { color: var(--muted); font-size: 0.72rem; }
.stat-grid.small .stat b { font-size: 1.05rem; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .cd { aspect-ratio: 1; border-radius: 7px; background: rgba(146, 214, 255, 0.04); border: 1px solid transparent; display: grid; place-items: center; font-family: var(--mono); font-size: 0.62rem; color: var(--faint); }
.cal .cd.s1 { background: rgba(146, 214, 255, 0.14); color: var(--muted); }
.cal .cd.s2 { background: rgba(146, 214, 255, 0.3); color: var(--text); }
.cal .cd.s3 { background: rgba(146, 214, 255, 0.55); color: #06101e; }
/* Past days are links that replay that cave. */
a.wd, a.cd { text-decoration: none; }
a.wd:hover i, .cal a.cd:hover { border-color: var(--cyan); }
a.wd:focus-visible, .cal a.cd:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 8px; }
.cal .cd.g { box-shadow: inset 0 0 0 2px var(--gold); }
.cal .cd.today { border-color: var(--cyan); }
.cal .cd.future { opacity: 0.3; }
.dist { display: flex; flex-direction: column; gap: 6px; }
.dist .dr { display: grid; grid-template-columns: 52px 1fr 30px; gap: 8px; align-items: center; font-size: 0.8rem; color: var(--gold); }
.dist .dr span:last-child { color: var(--muted); font-family: var(--mono); text-align: right; }
.dist .db { height: 14px; border-radius: 4px; background: rgba(255, 200, 104, 0.12); overflow: hidden; }
.dist .db i { display: block; height: 100%; background: rgba(255, 200, 104, 0.7); border-radius: 4px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(2, 3, 8, 0.8); display: grid; place-items: center; padding: 16px; animation: fadein 0.2s ease; }
.modal-card { position: relative; width: 100%; max-width: 380px; background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 20px; padding: 18px 18px 22px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.modal-card canvas { width: 280px; height: 228px; max-width: 80vw; }
.modal-x { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; }
.day-card h3 { margin: 4px 0 2px; font-family: var(--display); font-size: 1.5rem; font-weight: 600; }
.day-line { margin: 0 0 10px; color: var(--muted); font-family: var(--mono); font-size: 0.82rem; }
.day-map { width: 100%; }
.day-map canvas { display: block; width: 100%; height: auto; border-radius: 12px; }
.day-map .fine { padding: 18px 0; }
.day-strip { margin: 10px 0 4px; letter-spacing: 1px; }
.day-card .btn { margin-top: 8px; }
.route-btn { position: absolute; top: 8px; left: 8px; width: 44px; height: 44px; font-size: 15px; }
.route-btn[aria-pressed="true"] { border-color: var(--cyan); background: rgba(146, 214, 255, 0.16); }

@media (max-width: 350px) {
  .streak small { display: none; }
}
@media (max-width: 380px) {
  .screen-title { font-size: 1.9rem; }
  .cave-card h2 { font-size: 1.6rem; }
  .res-time { font-size: 2.1rem; }
  .wd i { width: 26px; height: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
/* the same for the site-wide Reduce motion setting (hub/prefs.js) */
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
