/* ACCRETE — UI shell. dark glass, whisper-quiet, lowercase. */

@font-face {
  font-family: 'Manrope';
  src: url('../assets/fonts/Manrope-Variable.ttf') format('truetype');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #050510;
  --ink: #e6eef8;
  --ink-2: rgba(230, 238, 248, 0.64);
  --ink-3: rgba(230, 238, 248, 0.38);
  --ink-4: rgba(230, 238, 248, 0.18);
  --cyan: #9fe6ff;
  --cyan-2: #6fd3ff;
  --gold: #ffd9a8;
  --rose: #ff7a90;
  --violet: #c9b8ff;
  --green: #7dff9a;
  --line: rgba(190, 220, 255, 0.14);
  --line-2: rgba(190, 220, 255, 0.28);
  --glass: rgba(8, 12, 26, 0.5);
  --glass-2: rgba(12, 18, 36, 0.62);
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --gutter: clamp(20px, 6vw, 96px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Manrope', -apple-system, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; letter-spacing: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
img { max-width: 100%; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.hidden { display: none !important; }

:focus { outline: none; }
:focus-visible {
  outline: 1px solid rgba(159, 230, 255, 0.85);
  outline-offset: 6px;
  border-radius: 6px;
}

/* touch / keyboard specific copy */
html.is-touch .kb-only { display: none !important; }
html:not(.is-touch) .touch-only { display: none !important; }

/* ---------- canvases ---------- */
#game, canvas#overlay, .overlay-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  z-index: 0;
}
canvas#overlay, .overlay-canvas { z-index: 1; pointer-events: none; background: transparent; }

/* ---------- backdrop (key art) ---------- */
#backdrop {
  position: fixed; inset: 0;
  z-index: 8;
  overflow: hidden;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s var(--ease);
}
body[data-screen="menu"] #backdrop,
body[data-screen="levels"] #backdrop,
body[data-screen="options"] #backdrop,
body[data-screen="intro"] #backdrop { opacity: 1; }

#backdrop picture {
  position: absolute; inset: -4%;
  display: block;
  animation: kenburns 52s ease-in-out infinite alternate;
  will-change: transform;
  transition: filter 0.8s var(--ease);
}
#backdrop img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 50%;
  display: block;
}
@media (orientation: landscape) { #backdrop img { transform: scaleX(-1); } }
body[data-screen="levels"] #backdrop picture,
body[data-screen="options"] #backdrop picture,
body[data-screen="intro"] #backdrop picture { filter: brightness(0.5) saturate(0.85); }

#backdrop .scrim {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(5, 5, 16, 0.88) 0%, rgba(5, 5, 16, 0.6) 30%, rgba(5, 5, 16, 0.08) 62%, rgba(5, 5, 16, 0.3) 100%),
    linear-gradient(180deg, rgba(5, 5, 16, 0.35) 0%, rgba(5, 5, 16, 0) 28%, rgba(5, 5, 16, 0) 68%, rgba(5, 5, 16, 0.72) 100%);
  transition: opacity 0.8s var(--ease);
}
@media (orientation: portrait) {
  #backdrop .scrim {
    background:
      linear-gradient(180deg, rgba(5, 5, 16, 0.86) 0%, rgba(5, 5, 16, 0.62) 34%, rgba(5, 5, 16, 0.12) 58%, rgba(5, 5, 16, 0.05) 78%, rgba(5, 5, 16, 0.6) 100%);
  }
}
body[data-screen="levels"] #backdrop .scrim,
body[data-screen="options"] #backdrop .scrim {
  background: radial-gradient(120% 90% at 50% 40%, rgba(5, 5, 16, 0.35), rgba(5, 5, 16, 0.85));
}

@keyframes kenburns {
  from { transform: scale(1.02) translate(0, 0); }
  to   { transform: scale(1.11) translate(-1.4%, 1.1%); }
}

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 10;
  padding: calc(var(--sat) + 16px) calc(var(--sar) + 16px) calc(var(--sab) + 16px) calc(var(--sal) + 16px);
  overflow: hidden;
}
.screen.open { display: flex; }
.screen[aria-hidden="true"] { display: none; }

/* everything animates in with a fade + 8px rise */
.screen.open .rise {
  animation: rise 0.7s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 70ms + 40ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* glass scrim for screens that sit over live play */
#pause, #overlay.screen {
  background: rgba(5, 5, 16, 0.55);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  backdrop-filter: blur(18px) saturate(1.1);
}

/* ---------- typography bits ---------- */
.eyebrow {
  font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.32em; text-transform: lowercase;
  color: var(--ink-3);
}
.screen-title {
  font-size: 1.05rem; font-weight: 400;
  letter-spacing: 0.34em; text-transform: lowercase;
  color: var(--ink-2);
  text-indent: 0.34em;
}
.screen-meta {
  font-size: 0.74rem; letter-spacing: 0.18em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------- text items (the menu's "buttons") ---------- */
.menu-list { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.menu-item {
  position: relative;
  display: block;
  min-height: 44px;
  padding: 8px 12px 8px 26px;
  margin-left: -26px;
  font-size: clamp(1.55rem, 2.6vw, 2.15rem);
  font-weight: 300;
  letter-spacing: 0.05em;
  line-height: 1.2;
  color: rgba(230, 238, 248, 0.74);
  text-align: left;
  text-transform: lowercase;
  border-radius: 8px;
  transition: color 0.25s var(--ease), text-shadow 0.35s var(--ease), transform 0.4s var(--ease);
}
.menu-item::before {
  content: '';
  position: absolute; left: 6px; top: 50%;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan), 0 0 22px rgba(159, 230, 255, 0.5);
  transform: translateY(-50%) scale(0);
  opacity: 0;
  transition: transform 0.35s var(--ease), opacity 0.3s;
}
.menu-item:hover, .menu-item:focus-visible, .menu-item.is-active {
  color: #fff;
  text-shadow: 0 0 18px rgba(159, 230, 255, 0.6), 0 0 42px rgba(120, 180, 255, 0.28);
  transform: translateX(6px);
  outline: none;
}
.menu-item:hover::before, .menu-item:focus-visible::before, .menu-item.is-active::before {
  transform: translateY(-50%) scale(1);
  opacity: 1;
}
.menu-item:active { color: var(--gold); text-shadow: 0 0 20px rgba(255, 217, 168, 0.6); transition-duration: 0.08s; }
.menu-item.primary { color: rgba(255, 255, 255, 0.92); }
.menu-item.secondary { font-size: clamp(1.05rem, 1.6vw, 1.3rem); color: var(--ink-3); }

.text-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 10px;
  font-size: 0.82rem; font-weight: 400;
  letter-spacing: 0.2em; text-transform: lowercase;
  color: var(--ink-2);
  border-radius: 8px;
  transition: color 0.2s, text-shadow 0.3s;
}
.text-btn svg { width: 18px; height: 18px; }
.text-btn:hover, .text-btn:focus-visible { color: #fff; text-shadow: 0 0 14px rgba(159, 230, 255, 0.55); }
.text-btn.back { margin-left: -10px; }
.text-btn.danger { color: rgba(255, 122, 144, 0.7); }
.text-btn.danger:hover, .text-btn.danger:focus-visible { color: var(--rose); text-shadow: 0 0 14px rgba(255, 122, 144, 0.5); }
.text-btn.danger.armed { color: var(--rose); text-shadow: 0 0 14px rgba(255, 122, 144, 0.7); }

/* ---------- title screen ---------- */
#menu { align-items: flex-start; justify-content: center; padding-left: calc(var(--sal) + var(--gutter)); }
#menu .menu-inner { display: flex; flex-direction: column; align-items: flex-start; gap: 0; max-width: 620px; }

.wordmark {
  /* DRIFT is one unbreakable word at 0.34em tracking, so it has to be sized against the
     space actually left after the gutter *and* the safe-area insets — a plain vw clamp
     overflows (and gets clipped by .screen) on a notched phone. */
  font-size: clamp(1.9rem, min(6.4vw, (100vw - var(--sal) - var(--sar) - var(--gutter) - 16px) / 5.6), 6.2rem);
  font-weight: 200;
  letter-spacing: 0.34em;
  line-height: 1;
  color: #eef5ff;
  text-shadow: 0 0 22px rgba(159, 230, 255, 0.36), 0 0 70px rgba(120, 180, 255, 0.22);
  animation: rise 0.7s var(--ease) both, wordglow 6.5s ease-in-out 0.8s infinite alternate !important;
}
@keyframes wordglow {
  from { text-shadow: 0 0 22px rgba(159, 230, 255, 0.34), 0 0 70px rgba(120, 180, 255, 0.2); }
  to   { text-shadow: 0 0 28px rgba(159, 230, 255, 0.62), 0 0 90px rgba(120, 180, 255, 0.34), 0 0 140px rgba(120, 180, 255, 0.16); }
}
.tagline {
  margin-top: 14px;
  font-size: 0.78rem; font-weight: 400;
  letter-spacing: 0.36em;
  color: var(--ink-3);
  text-transform: lowercase;
}
.continue {
  display: inline-flex; align-items: baseline; gap: 12px;
  min-height: 44px;
  margin: 22px 0 0 -8px;
  padding: 6px 8px;
  font-size: 0.86rem; font-weight: 400;
  letter-spacing: 0.14em;
  color: var(--ink-2);
  border-radius: 8px;
  text-align: left;
  transition: color 0.25s, text-shadow 0.3s;
}
.continue-k {
  font-size: 0.68rem; letter-spacing: 0.3em;
  color: var(--gold);
  opacity: 0.85;
}
.continue::after { content: '→'; margin-left: 2px; color: var(--ink-3); transition: transform 0.35s var(--ease); display: inline-block; }
.continue:hover, .continue:focus-visible { color: #fff; text-shadow: 0 0 14px rgba(255, 217, 168, 0.4); }
.continue:hover::after { transform: translateX(4px); }
.continue[hidden] { display: none; }
#menu .menu-list { margin-top: 26px; }
.menu-foot {
  position: absolute;
  left: calc(var(--sal) + var(--gutter));
  bottom: calc(var(--sab) + 26px);
  font-size: 0.72rem; letter-spacing: 0.2em;
  color: var(--ink-3);
}

@media (orientation: portrait) {
  #menu { align-items: center; justify-content: flex-start; padding-left: calc(var(--sal) + 16px); padding-top: calc(var(--sat) + 13vh); }
  #menu .menu-inner { align-items: center; text-align: center; }
  .wordmark { text-indent: 0.34em; font-size: clamp(1.9rem, min(11.5vw, (100vw - var(--sal) - var(--sar) - 40px) / 7.7), 4.2rem); }
  .menu-list { align-items: center; }
  .menu-item { padding: 8px 14px; margin-left: 0; text-align: center; }
  .menu-item::before { display: none; }
  .menu-item:hover, .menu-item:focus-visible, .menu-item.is-active { transform: none; }
  #menu .menu-list { margin-top: 22px; }
  .continue { margin-left: 0; justify-content: center; }
  /* left/right insets still matter here: portrait on a device held in a case, and the
     brief portrait layout on a rotating landscape-notched phone. */
  .menu-foot { left: 0; right: 0; text-align: center; padding: 0 calc(var(--sar) + 24px) 0 calc(var(--sal) + 24px); }
}

/* ---------- screen header (levels / options) ---------- */
.screen-head {
  position: absolute;
  top: calc(var(--sat) + 10px);
  left: calc(var(--sal) + var(--gutter));
  right: calc(var(--sar) + var(--gutter));
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 56px;
}
.screen-head .back { justify-self: start; }
.screen-head .screen-title { text-align: center; }
.screen-head .screen-meta { justify-self: end; white-space: nowrap; }
@media (max-width: 640px) {
  .screen-head { grid-template-columns: auto 1fr auto; }
  .screen-head .screen-title { font-size: 0.9rem; letter-spacing: 0.26em; text-indent: 0.26em; }
  .screen-head .screen-meta { font-size: 0.68rem; letter-spacing: 0.12em; }
}

/* ---------- level select ---------- */
#level-select { justify-content: center; gap: 18px; padding-left: 0; padding-right: 0; }

#chapter-tabs {
  display: flex; gap: 4px;
  padding: 0 calc(var(--sal) + var(--gutter));
  width: 100%;
  justify-content: center;
}
#chapter-tabs button {
  min-height: 44px; padding: 8px 14px;
  font-size: 0.74rem; font-weight: 500;
  letter-spacing: 0.24em; text-transform: lowercase;
  color: var(--ink-3);
  border-radius: 8px;
  position: relative;
  transition: color 0.25s;
}
#chapter-tabs button::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: 6px;
  height: 1px; background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  transform: scaleX(0); transition: transform 0.35s var(--ease);
}
#chapter-tabs button:hover { color: var(--ink-2); }
#chapter-tabs button.is-active { color: #fff; }
#chapter-tabs button.is-active::after { transform: scaleX(1); }
#chapter-tabs .tab-name { margin-left: 8px; color: inherit; opacity: 0.6; }
@media (max-width: 640px) { #chapter-tabs .tab-name { display: none; } }

.rail {
  display: flex; align-items: flex-start;
  gap: 40px;
  width: 100%;
  overflow-x: auto; overflow-y: hidden;
  padding: 18px calc(var(--sar) + var(--gutter)) 24px calc(var(--sal) + var(--gutter));
  scroll-snap-type: x mandatory;
  scroll-padding-left: calc(var(--sal) + var(--gutter));
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.rail::-webkit-scrollbar { display: none; }
.rail::after { content: ''; flex: none; width: 1px; }

.chapter { flex: none; display: flex; flex-direction: column; gap: 14px; scroll-snap-align: start; }
.chapter-head { display: flex; align-items: baseline; gap: 12px; padding-left: 2px; }
.chapter-num {
  font-size: 0.72rem; font-weight: 500; letter-spacing: 0.3em;
  color: var(--gold); opacity: 0.85;
}
.chapter-name { font-size: 1.05rem; font-weight: 300; letter-spacing: 0.12em; color: var(--ink); }
.chapter-type { font-size: 0.68rem; letter-spacing: 0.24em; color: var(--ink-3); }
.cards { display: flex; gap: 14px; }

.card {
  position: relative;
  flex: none;
  width: clamp(212px, 16.5vw, 250px);
  aspect-ratio: 212 / 134;
  border-radius: 14px;
  overflow: hidden;
  scroll-snap-align: start;
  background: var(--card-grad, linear-gradient(160deg, #141b3a, #070a18));
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  text-align: left;
  color: var(--ink);
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease), border-color 0.3s;
  isolation: isolate;
}
.card::before {  /* decorative mote highlight for the gradient fallback */
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 64% 44%, rgba(255, 255, 255, 0.34) 0, rgba(255, 255, 255, 0.12) 9%, transparent 16%),
    radial-gradient(circle at 26% 70%, rgba(255, 255, 255, 0.12) 0, transparent 8%),
    radial-gradient(circle at 82% 78%, rgba(255, 255, 255, 0.1) 0, transparent 6%);
  z-index: 0;
}
.card img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  z-index: 1;
  transition: transform 0.6s var(--ease), opacity 0.5s ease;
}
.card img.loaded { opacity: 0.95; }
.card .shade {
  position: absolute; inset: 0; z-index: 2;
  background: linear-gradient(180deg, rgba(5, 5, 16, 0.3) 0%, rgba(5, 5, 16, 0) 36%, rgba(5, 5, 16, 0.2) 62%, rgba(5, 5, 16, 0.88) 100%);
}
.card .num {
  position: absolute; left: 12px; top: 10px; z-index: 3;
  font-size: 0.66rem; font-weight: 500; letter-spacing: 0.24em;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.card .glyph {
  position: absolute; right: 10px; top: 9px; z-index: 3;
  width: 18px; height: 18px;
  color: rgba(230, 238, 248, 0.7);
  filter: drop-shadow(0 0 6px rgba(159, 230, 255, 0.35));
}
.card .name {
  position: absolute; left: 12px; right: 12px; bottom: 30px; z-index: 3;
  font-size: 1rem; font-weight: 400; letter-spacing: 0.06em;
  color: #fff;
  text-transform: lowercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
}
.card .meta {
  position: absolute; left: 12px; right: 12px; bottom: 10px; z-index: 3;
  display: flex; align-items: center; gap: 6px;
  font-size: 0.66rem; letter-spacing: 0.18em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.card .meta svg { width: 13px; height: 13px; }
.card.is-done .meta { color: var(--green); }
.card.is-done .meta svg { filter: drop-shadow(0 0 6px rgba(125, 255, 154, 0.6)); }
.card.is-next { border-color: rgba(255, 217, 168, 0.55); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 217, 168, 0.18), 0 0 30px rgba(255, 217, 168, 0.14); }
.card.is-next .meta { color: var(--gold); }
/* Locked cards dim their *contents*, never the card itself: an opacity on the whole card
   lets the key art behind the rail bleed through and the plate stops reading as a plate. */
.card.is-locked { cursor: default; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.card.is-locked::after {
  content: ''; position: absolute; inset: 0; z-index: 2;
  background: rgba(5, 5, 16, 0.62);
  -webkit-backdrop-filter: saturate(0.3);
  backdrop-filter: saturate(0.3);
}
.card.is-locked::before { opacity: 0.35; }
.card.is-locked img { filter: grayscale(0.7) brightness(0.7); }
.card.is-locked .name { color: var(--ink-2); }
.card.is-locked .num, .card.is-locked .glyph, .card.is-locked .meta { opacity: 0.6; }
.card:not(.is-locked):hover, .card:not(.is-locked):focus-visible {
  transform: translateY(-4px);
  border-color: var(--line-2);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(159, 230, 255, 0.24), 0 0 34px rgba(159, 230, 255, 0.18);
  outline: none;
}
.card:not(.is-locked):hover img { transform: scale(1.05); }
.card:not(.is-locked):active { transform: translateY(-2px) scale(0.99); transition-duration: 0.1s; }

.card.t-ambient    { --card-grad: linear-gradient(155deg, #13334a 0%, #0c1a3a 55%, #05081a 100%); }
.card.t-antimatter { --card-grad: linear-gradient(155deg, #0f3a2a 0%, #1c1440 55%, #07061a 100%); }
.card.t-solar      { --card-grad: linear-gradient(155deg, #5a3212 0%, #2b1424 55%, #0b0716 100%); }
.card.t-sentient   { --card-grad: linear-gradient(155deg, #4c1226 0%, #2a0e2a 55%, #0a0614 100%); }
.card.t-antimatter::before { background: radial-gradient(circle at 64% 44%, rgba(125, 255, 154, 0.5) 0, rgba(125, 255, 154, 0.14) 9%, transparent 16%), radial-gradient(circle at 26% 70%, rgba(199, 139, 255, 0.24) 0, transparent 8%); }
.card.t-solar::before { background: radial-gradient(circle at 60% 46%, rgba(255, 196, 107, 0.6) 0, rgba(255, 196, 107, 0.16) 12%, transparent 22%), radial-gradient(ellipse at 60% 46%, transparent 26%, rgba(255, 196, 107, 0.12) 30%, transparent 34%); }
.card.t-sentient::before { background: radial-gradient(circle at 64% 44%, rgba(255, 138, 160, 0.42) 0, rgba(255, 138, 160, 0.12) 9%, transparent 16%), radial-gradient(circle at 30% 66%, rgba(255, 90, 110, 0.2) 0, transparent 9%); }

.rail-hint {
  font-size: 0.68rem; letter-spacing: 0.22em;
  color: var(--ink-4);
  padding: 0 calc(var(--sal) + var(--gutter));
}

@media (max-width: 640px) {
  .card { width: 196px; }
  .rail { gap: 30px; }
}

/* ---------- options ---------- */
#options { justify-content: center; }
.panel {
  width: min(560px, 100%);
  max-height: calc(100vh - var(--sat) - var(--sab) - 110px);
  max-height: calc(100dvh - var(--sat) - var(--sab) - 110px);
  overflow-y: auto; overflow-x: hidden;
  padding: 10px 28px 22px;
  margin-top: 56px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(1.1);
  backdrop-filter: blur(20px) saturate(1.1);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  scrollbar-width: none;
  touch-action: pan-y;
}
.panel::-webkit-scrollbar { display: none; }
.opt-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
  min-height: 60px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(190, 220, 255, 0.07);
}
.opt-row:last-of-type { border-bottom: 0; }
.opt-row label {
  font-size: 0.86rem; font-weight: 400;
  letter-spacing: 0.16em; text-transform: lowercase;
  color: var(--ink-2);
  flex: none;
}

/* range */
.range {
  --v: 80%;
  -webkit-appearance: none; appearance: none;
  width: min(220px, 48%);
  height: 44px;
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--cyan) 0, var(--cyan-2) var(--v), var(--line-2) var(--v));
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px;
  margin-top: -7px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  box-shadow: 0 0 0 4px rgba(159, 230, 255, 0.12), 0 0 14px rgba(159, 230, 255, 0.7);
  transition: box-shadow 0.25s, transform 0.25s var(--ease);
}
.range:hover::-webkit-slider-thumb, .range:focus-visible::-webkit-slider-thumb { transform: scale(1.15); box-shadow: 0 0 0 6px rgba(159, 230, 255, 0.16), 0 0 18px rgba(159, 230, 255, 0.9); }
.range::-moz-range-track { height: 2px; border-radius: 2px; background: var(--line-2); }
.range::-moz-range-progress { height: 2px; border-radius: 2px; background: var(--cyan-2); }
.range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 4px rgba(159, 230, 255, 0.12), 0 0 14px rgba(159, 230, 255, 0.7); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-runnable-track { box-shadow: 0 0 0 1px rgba(159, 230, 255, 0.5); }

/* switch */
.switch {
  position: relative;
  width: 46px; height: 26px;
  border-radius: 999px;
  background: rgba(190, 220, 255, 0.12);
  border: 1px solid var(--line);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
  flex: none;
}
.switch::before { content: ''; position: absolute; inset: -9px 0; } /* 44px tap target */
.switch i {
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(230, 238, 248, 0.55);
  transition: transform 0.35s var(--ease), background 0.3s, box-shadow 0.3s;
}
.switch[aria-checked="true"] { background: rgba(111, 211, 255, 0.22); border-color: rgba(159, 230, 255, 0.5); box-shadow: 0 0 16px rgba(159, 230, 255, 0.2); }
.switch[aria-checked="true"] i { transform: translateX(20px); background: #fff; box-shadow: 0 0 12px rgba(159, 230, 255, 0.9); }

/* segmented */
.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(190, 220, 255, 0.07);
  border: 1px solid var(--line);
}
.seg button {
  min-height: 34px; padding: 6px 12px;
  font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.16em; text-transform: lowercase;
  color: var(--ink-3);
  border-radius: 999px;
  transition: color 0.2s, background 0.3s, box-shadow 0.3s;
}
.seg button:hover { color: var(--ink-2); }
.seg button[aria-checked="true"] { color: #fff; background: rgba(159, 230, 255, 0.14); box-shadow: 0 0 14px rgba(159, 230, 255, 0.2), inset 0 0 0 1px rgba(159, 230, 255, 0.35); }
.seg button:focus-visible { outline-offset: 2px; }

@media (max-width: 480px) {
  .panel { padding: 6px 18px 16px; margin-top: 50px; border-radius: 18px; }
  .opt-row { gap: 12px; }
  .opt-row label { font-size: 0.8rem; letter-spacing: 0.12em; }
  .seg button { padding: 6px 9px; letter-spacing: 0.1em; }
  .range { width: 44%; }
}

/* cheat-sheet */
.cheatsheet-slot { margin-top: 16px; width: 100%; }
.cheatsheet {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 20px; row-gap: 8px;
  font-size: 0.74rem; letter-spacing: 0.1em;
  color: var(--ink-3);
}
.cheatsheet > div { display: contents; }
.cheatsheet dt { color: var(--ink-2); font-weight: 500; letter-spacing: 0.16em; white-space: nowrap; }
.cheatsheet dd { text-transform: lowercase; }
.supporter { border-bottom: 1px solid rgba(190, 220, 255, 0.07); }
.supporter .opt-row { border-bottom: 0; }
.supporter [hidden], #btn-supporter-menu[hidden] { display: none !important; }
.supporter-actions { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: flex-end; }
.text-btn.accent { color: #ffd98a; }
.text-btn.accent:hover { color: #fff1cc; }
.opt-note { margin: -4px 0 12px; font-size: 0.82rem; line-height: 1.5; color: var(--ink-2, #9fb4d8); }
.opt-note .c-dawn { color: #ffc46b; font-weight: 600; }
.opt-note .c-aurora { color: #c4a3ff; font-weight: 600; }
.panel .cheatsheet-slot { padding-top: 12px; border-top: 1px solid rgba(190, 220, 255, 0.07); }

/* ---------- pause ---------- */
.pause-inner { display: flex; flex-direction: column; align-items: flex-start; gap: 18px; width: min(440px, 100%); }
#pause .menu-list { margin-left: 26px; }
#pause .cheatsheet-slot { margin-top: 10px; padding-top: 18px; border-top: 1px solid var(--line); }
@media (max-height: 520px) { #pause .cheatsheet-slot { display: none; } }

/* ---------- results ---------- */
.results { display: flex; flex-direction: column; align-items: center; text-align: center; width: min(720px, 100%); gap: 4px; }
.bigword {
  font-size: clamp(2.8rem, 8vw, 6rem);
  font-weight: 200;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  line-height: 1.05;
  color: #fff;
  text-transform: lowercase;
}
#overlay[data-outcome="win"] .bigword {
  background: linear-gradient(180deg, #ffffff 0%, #ffe9c8 55%, #ffd9a8 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(255, 217, 168, 0.35)) drop-shadow(0 0 60px rgba(255, 217, 168, 0.15));
}
#overlay[data-outcome="lose"] .bigword {
  background: linear-gradient(180deg, #ffffff 0%, #ffb8c4 55%, #ff7a90 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(255, 122, 144, 0.35)) drop-shadow(0 0 60px rgba(255, 90, 110, 0.15));
}
.results-sub { margin-top: 10px; font-size: 0.92rem; letter-spacing: 0.2em; color: var(--ink-2); }
.stats {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 4px 0;
  margin-top: 34px;
  padding: 16px 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  width: min(600px, 100%);
}
.stats[hidden] { display: none; }
.stat { flex: 1 1 120px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 10px; }
.stat b { font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 300; letter-spacing: 0.04em; color: #fff; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.66rem; letter-spacing: 0.26em; color: var(--ink-3); text-transform: lowercase; }
.results-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 30px; }
.results-actions .menu-item { margin-left: 0; padding: 8px 26px; text-align: center; }
.results-actions .menu-item::before { display: none; }
.results-actions .menu-item:hover, .results-actions .menu-item:focus-visible { transform: none; }
#btn-overlay-secondary[hidden] { display: none; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}
body[data-screen="play"] #hud { opacity: 1; }
body[data-screen="pause"] #hud { opacity: 0.35; }

#hud-left {
  position: absolute;
  top: calc(var(--sat) + 14px);
  left: calc(var(--sal) + 18px);
  display: flex; align-items: center; gap: 12px;
}
#mass-ring { position: relative; width: 56px; height: 56px; }
#mass-ring svg, #warp-dial svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
#mass-ring .track, #warp-dial .track { fill: none; stroke: rgba(190, 220, 255, 0.14); stroke-width: 2; }
#mass-ring .prog {
  fill: none;
  stroke: url(#hud-grad-mass);
  stroke: var(--cyan);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 157.08;
  stroke-dashoffset: 125;
  filter: drop-shadow(0 0 5px rgba(159, 230, 255, 0.8));
  transition: stroke-dashoffset 0.35s var(--ease), stroke 0.5s;
}
#mass-ring.is-largest .prog { stroke: var(--gold); filter: drop-shadow(0 0 6px rgba(255, 217, 168, 0.9)); }
#mass-value {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
#rank { display: flex; flex-direction: column; gap: 2px; }
#rank-label { font-size: 0.9rem; font-weight: 400; letter-spacing: 0.08em; color: var(--ink); text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6); }
#rank-sub { font-size: 0.64rem; letter-spacing: 0.24em; color: var(--ink-3); text-transform: lowercase; }
#mass-ring.is-largest + #rank #rank-label { color: var(--gold); }

#hud-right {
  position: absolute;
  top: calc(var(--sat) + 14px);
  right: calc(var(--sar) + 18px);
  display: flex; align-items: center; gap: 14px;
}
#warp { display: flex; align-items: center; gap: 10px; opacity: 0.45; transition: opacity 0.4s; }
#warp.is-bent { opacity: 1; }
#warp-label { font-size: 0.9rem; font-weight: 400; letter-spacing: 0.1em; font-variant-numeric: tabular-nums; color: var(--ink); text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6); }
#warp-dial { width: 50px; height: 50px; }
#warp-dial .track { stroke-dasharray: 113.1 150.8; stroke: rgba(190, 220, 255, 0.2); }
#warp-dial .prog {
  fill: none;
  stroke: var(--violet);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 45 150.8;
  filter: drop-shadow(0 0 5px rgba(201, 184, 255, 0.8));
  transition: stroke-dasharray 0.2s linear, stroke 0.4s;
}
#warp-dial svg { transform: rotate(135deg); }
#warp-dial #warp-tick { stroke: rgba(230, 238, 248, 0.5); stroke-width: 1.5; transform-origin: 28px 28px; transform: rotate(108deg); }
#warp.is-fast .prog { stroke: var(--cyan); filter: drop-shadow(0 0 5px rgba(159, 230, 255, 0.8)); }
#warp.is-slow .prog { stroke: var(--gold); filter: drop-shadow(0 0 5px rgba(255, 217, 168, 0.8)); }

.icon-btn {
  display: none;
  width: 44px; height: 44px;
  align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(8, 12, 26, 0.45);
  border: 1px solid var(--line);
  color: var(--ink-2);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  pointer-events: auto;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover, .icon-btn:focus-visible { color: #fff; border-color: var(--line-2); }
.icon-btn:active { background: rgba(159, 230, 255, 0.16); }
html.is-touch #btn-pause { display: flex; }
/* The HUD is faded out (not removed) on every menu screen, so the pause button must stop
   accepting taps or it swallows the top-right corner of the title screen. */
body:not([data-screen="play"]) #btn-pause { pointer-events: none; }

#objective {
  position: absolute;
  top: calc(var(--sat) + 22px);
  left: 50%;
  transform: translate(-50%, 6px);
  max-width: min(70vw, 560px);
  text-align: center;
  font-size: 0.72rem; font-weight: 400;
  letter-spacing: 0.3em; text-transform: lowercase;
  color: var(--ink-2);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}
#objective.show { opacity: 1; transform: translate(-50%, 0); }
#objective em { font-style: normal; color: #fff; }
@media (max-width: 700px) {
  /* narrow screens: the ring and dial own the top row, the caption sits beneath */
  #objective { top: calc(var(--sat) + 84px); max-width: 82vw; }
}

#warp-strip {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(14vh + var(--sab));
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: 10px;
  padding-bottom: calc(var(--sab) + 14px);
  background: linear-gradient(180deg, transparent, rgba(159, 230, 255, 0.05));
  font-size: 0.7rem; letter-spacing: 0.26em;
  color: var(--ink-2);
  opacity: 0;
  transition: opacity 0.8s var(--ease);
}
#warp-strip.show { opacity: 1; }
#warp-strip i {
  display: block;
  width: min(60vw, 320px); height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 12px rgba(159, 230, 255, 0.6);
  animation: stripPulse 2.4s ease-in-out infinite;
}
@keyframes stripPulse { 0%, 100% { opacity: 0.5; transform: scaleX(0.7); } 50% { opacity: 1; transform: scaleX(1); } }

#hud-danger {
  position: fixed; inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 160px 20px rgba(210, 60, 96, 0.30), inset 0 0 40px 4px rgba(255, 90, 120, 0.12);
  transition: opacity 0.6s ease;
}
#hud-danger.breathe { animation: dangerBreathe 2.4s ease-in-out infinite; }
@keyframes dangerBreathe { 0%, 100% { box-shadow: inset 0 0 160px 20px rgba(210, 60, 96, 0.30), inset 0 0 40px 4px rgba(255, 90, 120, 0.12); } 50% { box-shadow: inset 0 0 190px 30px rgba(210, 60, 96, 0.38), inset 0 0 48px 6px rgba(255, 90, 120, 0.16); } }

/* ---------- hint (lower third) + toast ---------- */
#hint {
  position: fixed;
  left: 50%; bottom: calc(var(--sab) + 20vh);
  transform: translate(-50%, 8px);
  z-index: 6;
  max-width: min(84vw, 640px);
  text-align: center;
  font-size: clamp(0.95rem, 1.5vw, 1.15rem);
  font-weight: 300;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.8), 0 0 30px rgba(159, 230, 255, 0.2);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
#hint.show { opacity: 1; transform: translate(-50%, 0); }

#toast {
  position: fixed;
  left: 50%; bottom: calc(var(--sab) + 28px);
  transform: translate(-50%, 8px);
  z-index: 20;
  padding: 10px 18px;
  font-size: 0.76rem; letter-spacing: 0.2em; text-transform: lowercase;
  color: var(--ink);
  background: var(--glass-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
  white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #backdrop picture { animation: none; }
  .wordmark { animation: none !important; }
  .screen.open .rise { animation-duration: 0.01s; animation-delay: 0s; }
  #warp-strip i, #hud-danger.breathe { animation: none; }
  *, *::before, *::after { transition-duration: 0.01s !important; }
}
html.reduced-motion #backdrop picture { animation: none; }
html.reduced-motion .wordmark { animation: none !important; }
html.reduced-motion .screen.open .rise { animation-duration: 0.01s; animation-delay: 0s; }
html.reduced-motion #warp-strip i, html.reduced-motion #hud-danger.breathe { animation: none; }
html.reduced-motion *, html.reduced-motion *::before, html.reduced-motion *::after { transition-duration: 0.01s !important; }

/* ---------- colour-blind palette hooks ---------- */
html.cb { --rose: #ffb347; }
html.cb #hud-danger { box-shadow: inset 0 0 130px 30px rgba(255, 179, 71, 0.4), inset 0 0 36px 8px rgba(255, 179, 71, 0.22); }

/* First-play presentation: retain the original key art and quiet visual identity. */
#menu { justify-content: safe center; padding-top: calc(var(--sat) + 44px); padding-bottom: calc(var(--sab) + 90px); overflow-y: auto; touch-action: pan-y; }
#menu .menu-inner { width: min(480px, 100%); max-width: 100%; flex: none; }
.menu-eyebrow { font-size: .67rem; font-weight: 500; letter-spacing: .24em; color: #9cb3c4; margin-bottom: 24px; }
#menu .wordmark { font-size: clamp(2rem, min(5.4vw, (100vw - var(--sal) - var(--sar) - var(--gutter) - 32px) / 7.7), 4.65rem); }
#menu .tagline { margin-top: 14px; color: #92a9bb; font-size: .69rem; letter-spacing: .32em; }
.menu-premise { margin-top: 25px; font-size: 1.08rem; font-weight: 300; line-height: 1.65; color: #c8d6e3; letter-spacing: .005em; text-wrap: pretty; }
.begin-button { margin-top: 28px; display: flex; align-items: center; justify-content: space-between; gap: 24px; width: min(348px, 100%); min-height: 74px; padding: 15px 22px; border: 1px solid rgba(183,231,246,.62); border-radius: 12px; color: #102736; text-align: left; background: #c4e9f2; box-shadow: 0 3px 28px rgba(124,205,234,.1), inset 0 1px 0 rgba(255,255,255,.7); transition: background .2s, transform .2s, box-shadow .2s; }
.begin-button strong { display: block; font-size: 1.08rem; font-weight: 600; letter-spacing: .02em; }
.begin-button small { display: block; margin-top: 4px; font-size: .68rem; font-weight: 500; letter-spacing: .06em; opacity: .73; }
.begin-button svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.begin-button:hover { background: #e0f5fa; box-shadow: 0 5px 32px rgba(124,205,234,.22); }
.begin-button:hover svg { transform: translateX(3px); }
.begin-button:active { transform: scale(.98); }
.begin-button:focus-visible { outline: 2px solid #fff; outline-offset: 5px; }
#menu #continue { display: none; }
#menu .menu-list { width: min(348px, 100%); margin-top: 20px; gap: 0; align-items: stretch; }
#menu .mode-item { display: flex; align-items: center; gap: 15px; width: 100%; min-height: 61px; margin: 0; padding: 12px 0; border-radius: 0; border-bottom: 1px solid rgba(170,199,223,.13); text-align: left; font-size: .98rem; font-weight: 400; letter-spacing: .035em; color: #c8d8e7; }
#menu .mode-item::before { display: none; }
.mode-item > svg { width: 23px; height: 23px; color: #8fabbe; flex: none; }
.mode-item small { display: block; font-size: .66rem; font-weight: 400; letter-spacing: .025em; color: #94a8ba; margin-top: 4px; }
.mode-item .mode-arrow { margin-left: auto; font-size: 1.15rem; color: #8299ad; padding-right: 2px; }
#menu .mode-item:hover, #menu .mode-item:focus-visible { transform: none; text-shadow: none; color: #fff; background: rgba(174,217,237,.055); }
#menu .mode-item:focus-visible { outline: 1px solid var(--cyan); outline-offset: 3px; border-radius: 4px; }
.menu-utility { width: min(348px, 100%); display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-top: 15px; }
.menu-utility > .text-btn { min-height: 44px; padding: 10px 0; font-size: .72rem; letter-spacing: .06em; color: #a7baca; }
.how-to { flex: 1; min-width: 0; }
.how-to summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; min-height: 44px; font-size: .72rem; letter-spacing: .06em; color: #a7baca; }
.how-to summary::-webkit-details-marker { display: none; }
.how-to summary span { margin-right: 10px; color: var(--cyan); font-size: 1.2rem; }
.how-to[open] summary span { transform: rotate(45deg); }
.how-to summary:hover { color: #fff; }
.how-to summary:focus-visible { outline: 1px solid var(--cyan); outline-offset: 2px; }
.how-to-body { padding: 4px 0 10px; }
.how-to-body p { margin-bottom: 13px; font-size: .75rem; line-height: 1.65; color: #a9becf; }
.how-to-body b { display: block; color: #dcebf6; font-weight: 500; font-size: .65rem; letter-spacing: .13em; margin-bottom: 4px; }
.menu-signature { position: absolute; right: calc(var(--sar) + var(--gutter)); bottom: calc(var(--sab) + 98px); text-align: right; display: flex; flex-direction: column; gap: 6px; color: #afc4d4; font-size: .76rem; letter-spacing: .16em; font-weight: 300; pointer-events: none; }
#menu .menu-foot { position: static; margin-top: 28px; flex: none; display: flex; align-items: center; gap: 12px; font-size: .62rem; letter-spacing: .07em; color: #93a7b8; }
.menu-foot svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.menu-foot i { width: 2px; height: 2px; border-radius: 50%; background: currentColor; }
#objective { max-width: min(44vw, 540px); letter-spacing: .12em; font-size: .72rem; color: #b5c7d8; }
#objective-track { position: absolute; top: calc(var(--sat) + 51px); left: 50%; transform: translateX(-50%); width: min(260px, 36vw); text-align: center; }
.goal-track { height: 2px; border-radius: 2px; background: rgba(192,222,244,.16); overflow: hidden; }
#goal-progress-fill { display: block; width: 100%; height: 100%; background: #b0dfea; transform: scaleX(0); transform-origin: left; transition: transform .3s; }
#goal-progress-text { display: block; margin-top: 7px; font-size: .61rem; letter-spacing: .075em; color: #9db6c8; font-variant-numeric: tabular-nums; }
#btn-pause { display: flex; }
#warp-controls { position: absolute; bottom: calc(var(--sab) + 22px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 5px; background: rgba(9,18,31,.84); border: 1px solid rgba(176,211,233,.2); border-radius: 12px; backdrop-filter: blur(14px); pointer-events: auto; }
#warp-controls .warp-caption { font-size: .63rem; font-weight: 400; letter-spacing: .07em; padding: 0 12px; color: #9db5c7; white-space: nowrap; }
#warp-controls button { width: 44px; height: 44px; border-radius: 7px; font-size: .8rem; font-weight: 500; color: #a8bdce; font-variant-numeric: tabular-nums; transition: color .2s, background .2s, transform .2s; }
#warp-controls button:hover { color: #fff; background: rgba(166,222,243,.1); }
#warp-controls button[aria-pressed="true"] { background: #bfdfeb; color: #102736; }
#warp-controls button:active { transform: scale(.94); }
#warp-controls button:focus-visible { outline: 2px solid #d7f1fc; outline-offset: 1px; }
body:not([data-screen="play"]) #warp-controls { visibility: hidden; pointer-events: none; }
#warp-strip { justify-content: flex-start; padding-top: 5px; font-size: .6rem; }
#hint { bottom: calc(var(--sab) + 110px); padding: 12px 18px; width: max-content; max-width: min(84vw, 570px); border: 1px solid rgba(183,218,236,.12); border-radius: 10px; background: rgba(8,16,29,.86); font-size: .85rem; line-height: 1.65; font-weight: 400; letter-spacing: .025em; text-shadow: none; backdrop-filter: blur(12px); }
body:not([data-screen="play"]) #hint { visibility: hidden; }
html:not(.inverted-thrust) .inverted-thrust-copy, html.inverted-thrust .normal-thrust, html:not(.cb) .accessible-palette, html.cb .standard-palette { display: none; }
@media (orientation: portrait) {
  #menu { align-items: center; justify-content: flex-start; padding: calc(var(--sat) + 48px) calc(var(--sar) + 28px) calc(var(--sab) + 35px) calc(var(--sal) + 28px); }
  #menu .menu-inner { align-items: flex-start; text-align: left; width: min(430px, 100%); }
  #menu .wordmark { text-indent: 0; font-size: clamp(1.65rem, min(9.8vw, (100vw - var(--sal) - var(--sar) - 56px) / 7.7), 3.8rem); }
  .menu-eyebrow { margin-bottom: 20px; font-size: .59rem; letter-spacing: .2em; }
  #menu .tagline { font-size: .61rem; letter-spacing: .28em; }
  .menu-premise { font-size: .96rem; margin-top: 22px; line-height: 1.7; }
  .begin-button { margin-top: 23px; width: 100%; min-height: 71px; }
  #menu .menu-list, .menu-utility { width: 100%; }
  .menu-signature { display: none; }
  #menu .menu-foot { position: static; width: min(430px, 100%); padding: 0; margin-top: 26px; text-align: left; flex-wrap: wrap; gap: 8px; font-size: .57rem; letter-spacing: .02em; flex: none; }
  #backdrop .scrim { background: linear-gradient(180deg, rgba(5,5,16,.88), rgba(5,5,16,.76) 40%, rgba(5,5,16,.53) 76%, rgba(5,5,16,.82)); }
}
@media (max-width: 700px) {
  #objective { top: calc(var(--sat) + 85px); max-width: 86vw; width: max-content; font-size: .68rem; }
  #objective-track { top: calc(var(--sat) + 116px); width: min(260px, 60vw); }
  #warp-controls { bottom: calc(var(--sab) + 18px); }
  #warp-controls .warp-caption { padding: 0 9px; font-size: .6rem; }
  #hint { bottom: calc(var(--sab) + 106px); font-size: .78rem; }
}
@media (max-height: 760px) and (orientation: landscape) {
  #menu { justify-content: flex-start; padding-top: calc(var(--sat) + 30px); }
  .menu-eyebrow { margin-bottom: 17px; }
  #menu .wordmark { font-size: clamp(1.8rem, 4.8vw, 3.8rem); }
  .menu-premise { margin-top: 18px; font-size: .94rem; }
  .begin-button { margin-top: 19px; min-height: 65px; }
  #menu .menu-list { margin-top: 12px; }
  #menu .mode-item { min-height: 56px; padding: 10px 0; }
  .menu-utility { margin-top: 8px; }
  #menu .menu-foot { position: static; margin-top: 28px; flex: none; }
  #menu .menu-signature { bottom: calc(var(--sab) + 44px); }
}
@media (max-height: 500px) and (orientation: landscape) {
  #menu .menu-inner { width: min(460px, 80%); }
  #menu .menu-signature { display: none; }
  #objective { top: calc(var(--sat) + 17px); max-width: 40vw; }
  #objective-track { top: calc(var(--sat) + 51px); width: 32vw; }
  #hint { bottom: calc(var(--sab) + 87px); padding: 8px 14px; }
}

/* Leave the original bottom-edge gesture lane clear of the new touch controls. */
html.is-touch #warp-controls { bottom: calc(var(--sab) + 14vh + 12px); }
html.is-touch #hint { bottom: calc(var(--sab) + 14vh + 86px); }

/* ---------- how to play (menu button + animated intro) ---------- */
.howto-btn { flex: 1; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 0; color: #dcebf6; text-align: left; background: none; border: 0; cursor: pointer; }
.howto-btn svg { width: 28px; height: 28px; flex: none; fill: none; stroke: var(--cyan); stroke-width: 1.2; }
.howto-btn svg path { fill: var(--cyan); stroke: none; }
.howto-btn span { font-size: .8rem; letter-spacing: .05em; }
.howto-btn small { display: block; margin-top: 2px; font-size: .62rem; letter-spacing: .06em; color: var(--ink-3); }
.howto-btn:hover span, .howto-btn:focus-visible span { color: #fff; }
.howto-btn:hover svg { filter: drop-shadow(0 0 8px rgba(159, 230, 255, 0.6)); }
.howto-btn:focus-visible { outline: 1px solid var(--cyan); outline-offset: 4px; border-radius: 6px; }
.pause-howto { margin: 4px auto 0; min-height: 44px; font-size: .78rem; letter-spacing: .08em; }

#intro { background: rgba(4, 6, 16, 0.6); -webkit-backdrop-filter: blur(16px) saturate(1.1); backdrop-filter: blur(16px) saturate(1.1); }
.intro { width: min(560px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.intro-cards { width: 100%; }
.intro-card { display: none; flex-direction: column; align-items: center; text-align: center; }
.intro-card.on { display: flex; animation: introIn .5s var(--ease) both; }
@keyframes introIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.intro-card canvas { display: block; width: 100%; height: min(40vh, 290px); border-radius: 16px; border: 1px solid rgba(159, 230, 255, 0.12); background: radial-gradient(ellipse at 28% 18%, rgba(46, 64, 120, 0.4), rgba(6, 8, 20, 0.65) 70%); }
.intro-card h3 { margin-top: 18px; font-size: 1.5rem; font-weight: 300; letter-spacing: .08em; color: #eef6fc; }
.intro-card h3 span { margin-right: 10px; vertical-align: middle; font-size: .72rem; font-weight: 500; letter-spacing: .2em; color: var(--cyan); }
.intro-card p { max-width: 440px; min-height: 5em; margin-top: 10px; font-size: .9rem; line-height: 1.65; color: #b6c8d6; }
.c-edible { color: #8fdcff; font-weight: 500; }
.c-lethal { color: #ff9aae; font-weight: 500; }
html.cb .c-lethal { color: #ffc47a; }
.intro-nav { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 4px; }
.intro-nav .text-btn { min-height: 44px; padding: 0 6px; font-size: .78rem; letter-spacing: .08em; }
.intro-dots { display: flex; gap: 6px; }
.intro-dots i { width: 22px; height: 22px; display: grid; place-items: center; cursor: pointer; }
.intro-dots i::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: rgba(230, 238, 248, 0.22); transition: background .3s, transform .3s, box-shadow .3s; }
.intro-dots i.on::before { background: var(--cyan); transform: scale(1.25); box-shadow: 0 0 10px rgba(159, 230, 255, 0.6); }
.intro-next { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 20px; border: 1px solid rgba(183, 231, 246, 0.62); border-radius: 12px; background: #c4e9f2; color: #102736; font-weight: 600; letter-spacing: .03em; cursor: pointer; transition: background .2s; }
.intro-next svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.intro-next:hover { background: #e0f5fa; }
.intro-next:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
html.reduced-motion .intro-card.on { animation: none; }
@media (max-width: 480px) {
  .intro-card canvas { height: 34vh; }
  .intro-card h3 { font-size: 1.25rem; }
  .intro-card p { font-size: .84rem; }
}

/* ---------- phone landscape (short viewport): two-column title, tighter panels ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  #menu { justify-content: center; padding-top: calc(var(--sat) + 14px); padding-bottom: calc(var(--sab) + 14px); padding-left: calc(var(--sal) + 28px); padding-right: calc(var(--sar) + 28px); overflow-y: auto; }
  #menu .menu-inner {
    display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-auto-flow: column;
    grid-template-rows: auto auto auto auto auto; column-gap: clamp(28px, 6vw, 72px); row-gap: 0;
    width: min(760px, 100%); align-items: start;
  }
  #menu .menu-inner > .menu-eyebrow, #menu .menu-inner > .wordmark, #menu .menu-inner > .tagline, #menu .menu-inner > .menu-premise, #menu .menu-inner > .begin-button { grid-column: 1; }
  #menu .menu-list { grid-column: 2; grid-row: 1 / 4; margin-top: 0; width: 100%; align-self: center; }
  .menu-utility { grid-column: 2; grid-row: 4 / 6; margin-top: 6px; width: 100%; }
  .menu-eyebrow { margin-bottom: 8px; font-size: .58rem; }
  #menu .wordmark { font-size: clamp(1.6rem, 4.2vw, 2.6rem); }
  #menu .tagline { margin-top: 8px; font-size: .58rem; letter-spacing: .26em; }
  .menu-premise { margin-top: 10px; font-size: .8rem; line-height: 1.5; }
  .begin-button { margin-top: 12px; min-height: 52px; padding: 9px 16px; width: 100%; }
  .begin-button strong { font-size: .92rem; }
  .begin-button small { margin-top: 2px; font-size: .6rem; }
  #menu .mode-item { min-height: 46px; padding: 7px 0; font-size: .86rem; gap: 12px; }
  .mode-item small { font-size: .6rem; margin-top: 2px; }
  .mode-item > svg { width: 19px; height: 19px; }
  .howto-btn { min-height: 38px; padding: 4px 0; }
  .howto-btn svg { width: 22px; height: 22px; }
  .howto-btn span { font-size: .74rem; }
  .menu-utility > .text-btn { min-height: 38px; padding: 6px 0; }
  #menu .menu-foot, #menu .menu-signature { display: none; }

  .screen-head { top: calc(var(--sat) + 2px); min-height: 44px; }
  #options { justify-content: flex-start; padding-top: calc(var(--sat) + 48px); }
  .panel { margin-top: 0; max-height: calc(100dvh - var(--sat) - var(--sab) - 62px); padding: 2px 20px 12px; }
  .opt-row { min-height: 44px; }
  .panel .cheatsheet-slot { display: none; }
  #level-select { gap: 8px; padding-top: calc(var(--sat) + 44px); }
  #level-select .rail-hint { display: none; }

  .results { gap: 0; }
  .bigword { font-size: clamp(2rem, 7vh, 3.2rem); }
  .results-sub { margin-top: 2px; font-size: .78rem; }
  .stats { margin-top: 8px; }
  .results-actions { flex-direction: row; gap: 18px; margin-top: 10px; }
  .pause-inner { gap: 8px; }
  #pause .menu-item { padding: 6px 14px; }
  #pause .pause-howto { margin-top: 0; }
}
