:root {
  --accent: #ffb27a;
  --ink: #ffffff;
  --ink-dim: rgba(255, 255, 255, 0.74);
  --glass: rgba(22, 16, 48, 0.46);
  --stroke: rgba(255, 255, 255, 0.18);
  --dark: #1a1430;
  --gold: #ffd166;
  --radius: 18px;
  --t-xs: 0.68rem;
  --t-s: 0.84rem;
  --t-m: 1rem;
  --t-l: 1.6rem;
  --t-xl: 3.4rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #16122c;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: var(--t-m);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }

#canvas { position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block; touch-action: none; }
.vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(120% 95% at 50% 45%, transparent 58%, rgba(6, 4, 18, 0.42) 100%);
}

/* No backdrop blur on in-game glass: over a live WebGL canvas, Safari
   recomputes every blurred layer every frame. A denser tint reads the same. */
.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  box-shadow: 0 10px 30px rgba(10, 5, 30, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  color: var(--ink);
}
[data-theme="azure"] { --glass: rgba(10, 40, 90, 0.46); }

/* ---------- level transition: clouds close, the world changes, clouds part ---------- */
.wipe { position: fixed; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; --cloud: #fff1eb; }
.wipe::before {
  content: ""; position: absolute; inset: 0; background: var(--cloud); opacity: 0;
  transition: opacity 0.3s ease 0.28s;
}
.wipe.in::before { opacity: 1; }
.wipe.out::before { opacity: 0; transition: opacity 0.35s ease 0s; }
.wipe i {
  position: absolute; width: 95vmax; height: 95vmax; border-radius: 50%;
  background: radial-gradient(circle, var(--cloud) 0%, var(--cloud) 36%, transparent 70%);
  opacity: 0; transform: translate(-50%, -50%) scale(0.2);
}
.wipe i:nth-child(1) { left: 8%; top: 12%; --dx: -60vw; --dy: -40vh; }
.wipe i:nth-child(2) { left: 88%; top: 8%; --dx: 60vw; --dy: -40vh; }
.wipe i:nth-child(3) { left: 50%; top: 42%; --dx: 0vw; --dy: -70vh; }
.wipe i:nth-child(4) { left: 6%; top: 72%; --dx: -70vw; --dy: 20vh; }
.wipe i:nth-child(5) { left: 94%; top: 66%; --dx: 70vw; --dy: 20vh; }
.wipe i:nth-child(6) { left: 38%; top: 96%; --dx: -30vw; --dy: 60vh; }
.wipe i:nth-child(7) { left: 72%; top: 30%; --dx: 60vw; --dy: -10vh; }
.wipe i:nth-child(8) { left: 28%; top: 30%; --dx: -60vw; --dy: -10vh; }
.wipe.in i { animation: puff-in 0.62s cubic-bezier(0.3, 0.7, 0.4, 1) forwards; }
.wipe.out i { opacity: 1; transform: translate(-50%, -50%) scale(1.3); animation: puff-out 0.8s cubic-bezier(0.5, 0, 0.75, 0.6) forwards; }
.wipe i:nth-child(2n) { animation-delay: 0.06s; }
.wipe i:nth-child(3n) { animation-delay: 0.11s; }
@keyframes puff-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
}
@keyframes puff-out {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
  to { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.7); }
}

/* ---------- loader ---------- */
.loader {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: #16122c; transition: opacity 0.7s ease, visibility 0.7s;
}
.loader.gone { opacity: 0; visibility: hidden; }
.loader-cube {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent);
  box-shadow: 0 0 30px var(--accent);
  animation: loader-roll 0.9s cubic-bezier(0.6, 0, 0.4, 1) infinite;
}
@keyframes loader-roll {
  0% { transform: translateX(-24px) rotate(0deg); }
  50% { transform: translateX(24px) rotate(90deg); }
  100% { transform: translateX(-24px) rotate(0deg); }
}

/* ---------- title ---------- */
.title {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 8vh) 20px calc(var(--safe-bottom) + 28px);
  pointer-events: none;
  transition: opacity 0.5s ease, transform 0.5s ease, visibility 0.5s;
}
body:not(.at-title) .title { opacity: 0; visibility: hidden; transform: translateY(-12px); }
/* Title readability (founder, 20 Nov: "title screen looks bad"): the name and the buttons sit on soft dark
   bands, so islands drifting behind them never swallow the text. Plain gradients: no blur over the live canvas. */
.title::before, .title::after { content: ""; position: absolute; left: 0; right: 0; z-index: -1; pointer-events: none; }
.title::before { top: 0; height: 44%; background: linear-gradient(to bottom, rgba(16, 10, 38, 0.74) 0%, rgba(16, 10, 38, 0.5) 48%, rgba(16, 10, 38, 0) 100%); }
.title::after { bottom: 0; height: 46%; background: linear-gradient(to top, rgba(16, 10, 38, 0.82) 0%, rgba(16, 10, 38, 0.6) 55%, rgba(16, 10, 38, 0) 100%); }
.title .glass { background: rgba(26, 19, 56, 0.78); }
.logo {
  margin: 0; display: flex; flex-direction: column; align-items: center;
  font-size: clamp(3.3rem, 17vw, 5.8rem); font-weight: 900; letter-spacing: 0.02em; line-height: 1;
}
/* "DOT" bobs letter by letter; "the block" sits under it, small and steady (name chosen by the founder, 19 Nov) */
.logo .logo-word { display: flex; gap: 0.04em; text-shadow: none; animation: none; }
.logo .logo-sub { font-size: 0.34em; letter-spacing: 0.22em; text-indent: 0.22em; text-transform: uppercase; margin-top: 0.3em; animation: none; text-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 55%, #000), 0 6px 16px rgba(0, 0, 0, 0.45); }
.logo span {
  display: inline-block;
  text-shadow:
    0 2px 0 color-mix(in srgb, var(--accent) 85%, #000),
    0 4px 0 color-mix(in srgb, var(--accent) 70%, #000),
    0 6px 0 color-mix(in srgb, var(--accent) 55%, #000),
    0 8px 0 color-mix(in srgb, var(--accent) 42%, #000),
    0 18px 30px rgba(0, 0, 0, 0.35);
  animation: letter-bob 3.4s ease-in-out infinite;
}
.logo span:nth-child(2) { animation-delay: 0.12s; }
.logo span:nth-child(3) { animation-delay: 0.24s; }
.logo span:nth-child(4) { animation-delay: 0.36s; }
.logo span:nth-child(5) { animation-delay: 0.48s; }
.logo span:nth-child(6) { animation-delay: 0.6s; }
@keyframes letter-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.tagline {
  margin: 10px 0 0; font-size: var(--t-s); font-weight: 800; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink); opacity: 0.86; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 2px 12px rgba(0, 0, 0, 0.45); text-align: center;
}
.title > .logo + .tagline { margin-top: 14px; }
.beacons { margin: 10px 0 0; padding: 5px 14px; border-radius: 999px; background: rgba(16, 10, 38, 0.62); font-size: var(--t-s); font-weight: 900; color: var(--accent); min-height: 1.2em; }
.beacons:empty { visibility: hidden; }
.title-actions { pointer-events: auto; width: min(100%, 380px); display: grid; gap: 12px; margin-top: auto; }
.cta {
  min-height: 66px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 75%, #fff), var(--accent));
  color: var(--dark);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  box-shadow: 0 12px 34px color-mix(in srgb, var(--accent) 45%, transparent), inset 0 -4px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.12s ease;
  animation: cta-glow 2.6s ease-in-out infinite;
}
.cta:active { transform: translateY(2px) scale(0.98); }
@keyframes cta-glow { 50% { box-shadow: 0 12px 44px color-mix(in srgb, var(--accent) 70%, transparent), inset 0 -4px 0 rgba(0, 0, 0, 0.12); } }
.cta-main { font-size: 1.35rem; font-weight: 900; letter-spacing: 0.04em; }
.cta-sub { font-size: var(--t-s); font-weight: 800; opacity: 0.72; }
.title-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ghost-btn {
  min-height: 60px; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-weight: 900; transition: transform 0.12s ease;
}
.ghost-btn small { font-size: var(--t-xs); font-weight: 800; color: var(--ink-dim); letter-spacing: 0.02em; }
.ghost-btn:active { transform: scale(0.97); }

/* ---------- HUD ---------- */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  padding: calc(var(--safe-top) + 10px) 12px 0;
  transition: opacity 0.45s ease, transform 0.45s ease;
}
body.at-title .hud, body.transit .hud { opacity: 0; transform: translateY(-16px); pointer-events: none; }
.level-card { padding: 9px 14px 10px; border-radius: var(--radius); min-width: 0; max-width: calc(100vw - 132px); }
.chapter {
  font-size: 0.64rem; font-weight: 900; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.level-line { display: flex; align-items: baseline; gap: 8px; margin-top: 1px; min-width: 0; }
.level-no { font-size: var(--t-l); font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; }
.level-name { font-size: 1.05rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.moves-line { font-size: var(--t-s); color: var(--ink-dim); font-weight: 700; }
.moves-line span { color: var(--ink); font-weight: 900; font-variant-numeric: tabular-nums; }
.moves-n.over { color: #ffb8a8; }
.pip-badge { display: inline-block; width: 11px; height: 11px; margin-left: 8px; border-radius: 50%; border: 2px solid #fff6e8; vertical-align: -1px; transition: background 0.3s ease, transform 0.3s ease; }
.pip-badge[hidden] { display: none; } /* levels 1 and 2 have no pip; `display` above would beat the attribute */
.pip-badge.found { background: #fff6e8; box-shadow: 0 0 10px rgba(255, 240, 210, 0.9); transform: scale(1.15); }
.level-pip { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: #fff6e8; box-shadow: 0 0 6px rgba(255, 240, 210, 0.9); }
.level-cell { position: relative; }
.hud-buttons { display: flex; gap: 8px; }
.round { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.round svg { width: 22px; height: 22px; }
.round .mute { display: none; }
.round.off .wave { display: none; }
.round.off .mute { display: inline; }
.round:active { transform: scale(0.94); }

/* ---------- controls ---------- */
.controls {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
  padding: 0 12px calc(var(--safe-bottom) + 12px);
  transition: opacity 0.45s ease, transform 0.45s ease;
  pointer-events: none;
}
.controls > * { pointer-events: auto; }
body.at-title .controls, body.transit .controls { opacity: 0; transform: translateY(24px); }
body.at-title .controls > * { pointer-events: none; }
.tools { display: flex; flex-direction: column; gap: 8px; }
.tool {
  min-height: 46px; padding: 0 14px; border-radius: 14px;
  display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 0.92rem;
  transition: transform 0.12s ease, opacity 0.2s ease;
}
.tool svg { width: 19px; height: 19px; }
.tool:active { transform: scale(0.96); }
.tool:disabled { opacity: 0.42; cursor: default; }
.badge {
  min-width: 22px; padding: 1px 7px; border-radius: 999px; font-size: 0.74rem; font-weight: 900;
  background: var(--accent); color: var(--dark); text-align: center;
}
.dpad { display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 58px); gap: 5px; }
.key { border-radius: 17px; display: grid; place-items: center; padding: 0; transition: transform 0.08s ease, background 0.12s ease; }
.key svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.key:active { transform: scale(0.92); background: color-mix(in srgb, var(--accent) 45%, transparent); }
.key-up { grid-area: 1 / 2; }
.key-left { grid-area: 2 / 1; }
.key-left svg { transform: rotate(-90deg); }
.key-right { grid-area: 2 / 3; }
.key-right svg { transform: rotate(90deg); }
.key-down { grid-area: 3 / 2; }
.key-down svg { transform: rotate(180deg); }
.dpad-hub { grid-area: 2 / 2; align-self: center; justify-self: center; width: 12px; height: 12px; border-radius: 50%; background: rgba(255, 255, 255, 0.28); }

/* ---------- coach ---------- */
.coach {
  position: fixed; z-index: 6; left: 50%; bottom: calc(var(--safe-bottom) + 212px);
  max-width: min(88vw, 420px); margin: 0; padding: 10px 16px; border-radius: 16px;
  font-size: 0.92rem; font-weight: 800; line-height: 1.35; text-align: center;
  opacity: 0; transform: translate(-50%, 10px); pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.coach.show { opacity: 1; transform: translate(-50%, 0); }
.coach.bad { color: #ffd2c8; border-color: rgba(255, 130, 110, 0.45); }
body.at-title .coach { opacity: 0; }

/* ---------- chapter card ---------- */
.chapter-card {
  position: fixed; inset: 0; z-index: 7; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0; text-align: center; padding: 0 20px;
}
.chapter-card.show { animation: chapter-in 3s ease forwards; }
.chapter-num {
  font-size: var(--t-s); font-weight: 900; letter-spacing: 0.42em; text-transform: uppercase; color: var(--accent);
  display: flex; align-items: center; gap: 14px; text-shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
}
.chapter-num::before, .chapter-num::after { content: ""; width: 34px; height: 2px; border-radius: 2px; background: currentColor; opacity: 0.7; }
.chapter-name { font-size: clamp(2.2rem, 10vw, 3.6rem); font-weight: 900; line-height: 1.05; margin-top: 8px; text-shadow: 0 8px 34px rgba(0, 0, 0, 0.45); }
.chapter-line { margin-top: 12px; max-width: 320px; font-size: var(--t-m); font-weight: 700; font-style: italic; color: var(--ink-dim); text-shadow: 0 4px 18px rgba(0, 0, 0, 0.5); }
@keyframes chapter-in {
  0% { opacity: 0; transform: translateY(14px) scale(0.98); }
  14% { opacity: 1; transform: translateY(0) scale(1); }
  72% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-10px) scale(1.01); }
}

/* ---------- sheets ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(8, 6, 20, 0.36);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  animation: fade-in 0.25s ease;
}
.sheet[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } }
.card {
  width: min(100%, 380px); padding: 22px; border-radius: 26px;
  background: rgba(28, 20, 60, 0.64);
  -webkit-backdrop-filter: blur(22px) saturate(1.5); backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  display: flex; flex-direction: column; gap: 12px; text-align: center;
  animation: card-pop 0.4s cubic-bezier(0.2, 1.3, 0.4, 1);
}
@keyframes card-pop { from { transform: translateY(18px) scale(0.96); opacity: 0; } }
.card h2 { margin: 0; font-size: var(--t-l); font-weight: 900; }
.big { margin: 0; font-size: var(--t-xl); font-weight: 900; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1; }
.sub { margin: 0; color: var(--ink-dim); font-size: var(--t-s); font-weight: 700; }
.btn {
  flex: 1; min-height: 52px; border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08);
  font-weight: 900; transition: transform 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  border: 0; color: var(--dark);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 75%, #fff), var(--accent));
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 40%, transparent);
}
.row { display: flex; gap: 10px; }
.stars { display: flex; justify-content: center; align-items: flex-end; gap: 8px; margin-top: -4px; }
.star { width: 52px; height: 52px; fill: rgba(255, 255, 255, 0.14); stroke: rgba(255, 255, 255, 0.28); stroke-width: 1; stroke-linejoin: round; transition: fill 0.2s ease; }
.star-mid { width: 66px; height: 66px; margin-bottom: 10px; }
/* The glow is a round shadow plus a round gradient, NOT filter: drop-shadow: Safari clips a filter on an <svg>
   to the element's box, which showed as a lit square behind the star (founder, 21 Nov). */
.star { box-sizing: content-box; padding: 14px; margin: -14px; border-radius: 50%; }
.star-mid { margin: -14px -14px -4px; }
.star.on {
  fill: var(--gold); stroke: #fff2c4;
  background: radial-gradient(closest-side, rgba(255, 205, 90, 0.62) 0%, rgba(255, 200, 80, 0.38) 45%, rgba(255, 200, 80, 0.12) 75%, rgba(255, 200, 80, 0) 100%);
  animation: star-pop 0.55s cubic-bezier(0.2, 1.7, 0.4, 1);
}
@keyframes star-pop { from { transform: scale(0.2) rotate(-40deg); } }
.share {
  margin: 0; padding: 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.22);
  font-family: inherit; font-size: var(--t-s); white-space: pre-wrap; -webkit-user-select: text; user-select: text;
}
.toggles { display: grid; gap: 8px; margin-top: 4px; }
.toggle {
  display: flex; justify-content: space-between; align-items: center; min-height: 50px; padding: 0 14px;
  border-radius: 14px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12); font-weight: 800;
}
.toggle i { position: relative; width: 46px; height: 28px; border-radius: 999px; background: rgba(255, 255, 255, 0.2); transition: background 0.2s ease; }
.toggle i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); transition: transform 0.2s ease;
}
.toggle[aria-checked="true"] i { background: var(--accent); }
.toggle[aria-checked="true"] i::after { transform: translateX(18px); }
.link { background: none; border: 0; color: var(--ink-dim); text-decoration: underline; padding: 8px; font-weight: 800; }

.card-wide { width: min(100%, 460px); max-height: 82dvh; }
.levels-top { display: flex; justify-content: space-between; align-items: center; }
.levels-grid { overflow-y: auto; text-align: left; padding-bottom: 4px; }
.levels-head { margin: 14px 0 8px; font-size: var(--t-xs); font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.levels-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.level-cell {
  aspect-ratio: 1; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.08);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0;
}
.level-cell:active { transform: scale(0.95); }
.level-num { font-size: 1.25rem; font-weight: 900; }
.level-stars { font-size: 0.62rem; letter-spacing: 1px; color: var(--gold); }
.level-cell.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.level-cell.locked { opacity: 0.42; cursor: default; }
.levels-head.ahead { opacity: 0.6; }

/* ---------- hats ---------- */
.title-link { pointer-events: auto; justify-self: center; color: var(--ink); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4); }
/* Hormesis Labs mark: the site's sigil in its accent gold (VISUAL_IDENTITY.md: 28 px, stroke 1.8) */
.hl-sigil { width: 28px; height: 28px; flex: none; stroke: #d4a574; stroke-width: 6.4; stroke-linecap: round; }
.made-by {
  pointer-events: auto; justify-self: center; display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px 6px 8px; border-radius: 999px; text-decoration: none;
  font-size: var(--t-s); font-weight: 700; letter-spacing: 0.02em; color: var(--ink);
}
.made-by b { font-weight: 900; }
.loader { flex-direction: column; }
.loader-brand {
  position: absolute; bottom: calc(var(--safe-bottom) + 34px); left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: var(--t-s); font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: #d4a574;
}
.hat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hat-cell {
  min-height: 64px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.07);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px; font-weight: 900;
}
.hat-cell small { font-size: var(--t-xs); font-weight: 800; color: var(--ink-dim); }
.hat-cell.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.hat-cell:disabled { opacity: 0.38; cursor: default; }

/* ---------- hints shop, toast ---------- */
.small-big { font-size: 2.6rem; }
.earn { padding: 10px 12px; border-radius: 12px; font-size: var(--t-s); font-weight: 700; color: var(--ink-dim); text-align: left; }
.earn b { color: var(--ink); }
.glass-soft { background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.12); }
.packs { display: grid; gap: 8px; }
.pack {
  display: flex; justify-content: space-between; align-items: center; min-height: 54px; padding: 0 14px;
  border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.08); font-weight: 900;
}
.pack small { font-weight: 800; color: var(--ink-dim); margin-left: 6px; }
.pack b { color: var(--accent); }
.pack.best { border-color: var(--accent); }
.pack:disabled { opacity: 0.45; cursor: default; }
.shop-note { min-height: 1.2em; }
.pack-buy { width: 100%; }
.pack-buy[hidden] { display: none; }
.paywall-earn { margin-top: 0.4rem; font-weight: 700; }
.paywall-earn[hidden] { display: none; }
.chapter-card.earned { z-index: 45; }
.restore { display: grid; gap: 8px; }
.restore-link { justify-self: center; padding: 6px 10px; background: none; border: 0; font-size: var(--t-s); font-weight: 800; color: var(--ink-dim); text-decoration: underline; text-underline-offset: 3px; }
.restore-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; text-align: left; }
.restore-input {
  flex: 1 1 auto; width: 100%; min-width: 0; min-height: 52px; padding: 0 14px; border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08);
  color: var(--ink); font: inherit; font-size: 16px; font-weight: 700;
}
.restore-input::placeholder { color: var(--ink-dim); }
.restore-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.restore-send { flex: 0 0 96px; }
.restore-send:disabled { opacity: 0.5; }
.restore-note:empty { display: none; }
.restore[hidden], .restore-form[hidden] { display: none; }
/* ---------- free levels: the paywall and the level select's locks ---------- */
.paywall-card { text-align: center; }
.paywall-buy { flex: none; width: 100%; }
.paywall-buy[hidden], .paywall-small > [hidden] { display: none; }
.paywall-small { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.level-cell.paid { opacity: 0.8; }
.level-lock { display: grid; place-items: center; color: var(--ink-dim); }
.level-lock svg { width: 16px; height: 16px; }
.levels-note { margin: 0 0 4px; text-align: center; }
.ios-hint { margin-top: 2px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 24px); z-index: 40; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px;
  background: rgba(28, 20, 60, 0.92); border: 1px solid rgba(255, 255, 255, 0.18); font-weight: 800; font-size: var(--t-s);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35); animation: card-pop 0.3s ease-out;
}
.toast[hidden] { display: none; }
.toast-btn { border: 0; border-radius: 10px; padding: 8px 12px; background: var(--accent); color: var(--dark); font-weight: 900; }

/* ---------- story ---------- */
/* The story plays over the living world: a dark band at the bottom, the scene above. */
body.in-story .title { opacity: 0; visibility: hidden; }
.story {
  z-index: 30; align-items: flex-end; padding: 0;
  background: linear-gradient(to top, rgba(8, 6, 20, 0.92) 0%, rgba(8, 6, 20, 0.6) 26%, rgba(8, 6, 20, 0) 56%), linear-gradient(to bottom, rgba(8, 6, 20, 0.7) 0%, rgba(8, 6, 20, 0) 14%);
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.story-card {
  gap: 14px; width: min(100%, 560px); padding: 0 24px calc(var(--safe-bottom) + 26px);
  background: none; border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; animation: none;
}
.story .story-dot { display: none; }
.story-text.in { animation: story-line 0.9s ease both; }
@keyframes story-line { from { opacity: 0; transform: translateY(10px); } }
.story .row { justify-content: center; }
.story .btn { flex: 0 1 150px; min-height: 46px; }
.story-dot {
  position: relative; width: 62px; height: 112px; margin: 0 auto; border-radius: 14px;
  background: linear-gradient(180deg, #3b4176, #252949);
  box-shadow: 0 12px 30px rgba(10, 10, 40, 0.45), inset 0 -5px 0 rgba(0, 0, 0, 0.2), inset 0 2px 0 rgba(255, 255, 255, 0.15);
  animation: dot-bob 2.4s ease-in-out infinite;
}
.dot-eye { position: absolute; top: 20px; width: 14px; height: 17px; border-radius: 50%; background: #fff6ec; box-shadow: inset 2px -3px 0 3px #151729; animation: dot-blink 4s infinite; }
.dot-eye:first-child { left: 13px; }
.dot-eye:nth-child(2) { right: 13px; }
.dot-smile { position: absolute; left: 50%; top: 40px; width: 16px; height: 8px; margin-left: -8px; border: 3px solid #fff6ec; border-top: 0; border-radius: 0 0 12px 12px; }
.dot-line { position: absolute; left: 4px; right: 4px; top: 55px; height: 3px; border-radius: 2px; background: #efe6d2; }
.dot-pin { position: absolute; left: 50%; top: 53px; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: #d9a441; }
@keyframes dot-bob { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-6px) rotate(-4deg); } }
@keyframes dot-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
.story-text { margin: 0; min-height: 4.4em; font-size: clamp(1.2rem, 4.6vw, 1.6rem); font-weight: 800; line-height: 1.4; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6); text-wrap: balance; }
.story-dots { display: flex; justify-content: center; gap: 6px; }
.story-dots span { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); transition: background 0.2s ease, transform 0.2s ease; }
.story-dots span.on { background: var(--accent); transform: scale(1.3); }
.win-story { margin: -6px 0 0; font-size: var(--t-s); font-weight: 800; font-style: italic; color: var(--accent); }

/* ---------- the iPhone app (html.native, set by app.js): no long-press callouts, nothing selectable ---------- */
.native { -webkit-touch-callout: none; }
.native .share { -webkit-user-select: none; user-select: none; }

/* ---------- flat fallback ---------- */
.flat-only { display: none; }
body.flat .flat-only { display: block; position: fixed; top: calc(var(--safe-top) + 70px); right: 12px; z-index: 5; }
body.flat .title, body.flat #menuBtn, body.flat #undoBtn, body.flat .vignette { display: none; }

@media (min-width: 700px) {
  .dpad { grid-template-columns: repeat(3, 62px); grid-template-rows: repeat(3, 62px); }
  .coach { bottom: calc(var(--safe-bottom) + 230px); }
}
@media (prefers-reduced-motion: reduce) {
  .logo span, .cta, .card, .sheet, .star.on, .chapter-card.show, .loader-cube, .story-dot, .dot-eye, .wipe i { animation: none; }
  .wipe { display: none; }
  .chapter-card.show { opacity: 1; }
}

/* The pitch sits under the pay button and shows only with it (web and the app's Apple button alike). */
.paywall-pitch { margin: 0.5rem 0 0; font-size: 0.9rem; opacity: 0.85; }
.paywall-buy[hidden] ~ .paywall-pitch, .paywall-buy[hidden] ~ .paywall-bonus, .paywall-bonus[hidden] { display: none; }
.paywall-bonus { margin: 0.5rem 0 0; font-size: 0.9rem; font-weight: 800; }
.paywall-buy[hidden] ~ .paywall-keep, .paywall-keep[hidden] { display: none; }

/* shown only when JavaScript is off: what the game is, in words */
.noscript { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; gap: 12px; padding: 24px; text-align: center; background: #16122c; color: #fff; }
