@font-face {
  font-family: 'Instrument Serif';
  src: url('../vendor/fonts/instrument-serif.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Serif';
  src: url('../vendor/fonts/instrument-serif-italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #05060a;
  --panel: rgba(13, 16, 24, 0.82);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf4;
  --text-dim: #8b93a7;
  --accent: #38e0c8;
  --accent-2: #8b5cf6;
  --chip: rgba(255, 255, 255, 0.06);
  --chip-active: rgba(56, 224, 200, 0.16);
  /* home palette: ink, bone, signal coral */
  --bone: #ece7dc;
  --bone-dim: rgba(236, 231, 220, 0.55);
  --coral: #ff5c38;
  --hairline: rgba(236, 231, 220, 0.14);
  --serif: 'Instrument Serif', Georgia, serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#stage, #flat {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#flat { background: #000; }
#flat.hidden { display: none; }

#camvideo { display: none; }

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  z-index: 10;
  transition: opacity 0.4s ease;
}
.hud.hidden { opacity: 0; pointer-events: none; }

#status {
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-dim);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #666;
  flex: none;
}
#status.tracking .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
#status.lost .dot { background: #f0b429; }
#status.pointer .dot { background: var(--accent-2); }

.topbtns {
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 12px;
  display: flex;
  gap: 8px;
}

.iconbtn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  color: var(--text-dim);
  font-size: 17px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.iconbtn:hover { color: var(--text); }
.iconbtn.active { color: var(--accent); border-color: rgba(56, 224, 200, 0.4); }
.iconbtn[hidden] { display: none; }

/* Narrow screens: the button cluster shrinks and wraps on the right, the
   status chip stays compact on the left — they can never collide. */
@media (max-width: 720px) {
  .topbtns {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 46vw;
    gap: 6px;
  }
  .iconbtn { width: 33px; height: 33px; font-size: 14px; border-radius: 10px; }
  #status {
    max-width: 46vw;
    font-size: 11px;
    padding: 6px 10px;
  }
  #status #status-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ---------- Game HUD ---------- */

#gamehud {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#game-score {
  font-family: var(--serif);
  font-size: 26px;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
#game-combo { color: var(--accent); font-size: 15px; font-weight: 700; min-width: 2ch; }
#game-best { color: var(--text-dim); font-size: 11px; font-family: var(--mono); }
#game-time { color: var(--text); font-size: 13px; font-family: var(--mono); border-left: 1px solid var(--panel-border); padding-left: 12px; }

#gameover {
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 10, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#gameover .panel {
  text-align: center;
  padding: 28px 40px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
}
#gameover .title {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}
#gameover .final-score {
  font-family: var(--serif);
  font-size: 64px;
  line-height: 1.15;
  color: var(--accent);
}
#gameover .final-best {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 18px;
}
#gameover button {
  display: block;
  width: 200px;
  margin: 8px auto 0;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
#gameover #btn-again {
  background: var(--chip-active);
  color: var(--accent);
  border-color: rgba(56, 224, 200, 0.4);
}
#gameover #btn-exit {
  background: var(--chip);
  color: var(--text-dim);
}

/* ---------- Object picker ---------- */

#picker {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  max-width: calc(100vw - 20px);
  overflow-x: auto;
  scrollbar-width: none;
}
#picker::-webkit-scrollbar { display: none; }

#picker button {
  border: none;
  background: var(--chip);
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
#picker button.active {
  background: var(--chip-active);
  color: var(--accent);
}

/* ---------- Camera preview ---------- */

#preview {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  left: 12px;
  width: 128px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  background: #000;
}
#preview canvas { display: block; width: 100%; }

/* ---------- Settings panel ---------- */

#settings {
  top: calc(env(safe-area-inset-top, 0px) + 60px);
  right: 12px;
  width: 290px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
#settings h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 14px;
}
#settings .row { margin-bottom: 14px; }
#settings label {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
#settings label output { color: var(--text); font-variant-numeric: tabular-nums; }
#settings input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
#settings .toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-dim);
}
#settings .toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
#settings .note {
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
  opacity: 0.75;
  margin-top: 4px;
}
#settings button.reset {
  width: 100%;
  padding: 8px;
  background: var(--chip);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
}

/* ---------- Home ---------- */

#home {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  overflow-y: auto;
  /* The lens ring deliberately hangs off the right edge — clip it so the
     menu can never be dragged or focus-scrolled sideways. */
  overflow-x: hidden;
  overflow-x: clip;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 6vh max(6vw, 24px);
  color: var(--bone);
  /* the live scene stays faintly visible on the right */
  background:
    linear-gradient(100deg, rgba(5, 6, 10, 0.97) 42%, rgba(5, 6, 10, 0.72) 70%, rgba(5, 6, 10, 0.45) 100%);
  transition: opacity 0.5s ease;
}
#home.hidden { opacity: 0; pointer-events: none; }
#home.gone { display: none; }

#home .lens {
  position: absolute;
  top: 50%;
  right: -12vmin;
  width: 68vmin;
  height: 68vmin;
  transform: translateY(-50%);
  color: rgba(236, 231, 220, 0.22);
  pointer-events: none;
}
#home .lens svg {
  width: 100%;
  height: 100%;
  animation: lens-spin 90s linear infinite;
}
@keyframes lens-spin { to { transform: rotate(360deg); } }

.masthead { margin-bottom: 4.5vh; }
.masthead .kicker {
  font-family: var(--mono);
  font-size: clamp(10px, 1.3vw, 13px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin-bottom: 1vh;
}
.masthead h1 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(56px, 11vw, 128px);
  line-height: 0.95;
  letter-spacing: -0.01em;
}
.masthead h1 .dot { color: var(--coral); font-style: normal; }

.exps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  max-width: 780px;
}

.card {
  --rx: 0deg;
  --ry: 0deg;
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  padding: clamp(14px, 2vh, 20px) 18px;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--c) 28%, transparent);
  background:
    radial-gradient(120% 160% at 0% 0%, color-mix(in srgb, var(--c) 14%, transparent), transparent 60%),
    rgba(10, 12, 18, 0.55);
  color: var(--bone);
  cursor: pointer;
  font-family: inherit;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform: perspective(700px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 0.15s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  opacity: 0;
  animation: card-in 0.55s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.13s; }
.card:nth-child(3) { animation-delay: 0.21s; }
.card:nth-child(4) { animation-delay: 0.29s; }
.card:nth-child(5) { animation-delay: 0.37s; }
.card:nth-child(6) { animation-delay: 0.45s; }
.card:nth-child(7) { animation-delay: 0.53s; }
.card:nth-child(8) { animation-delay: 0.61s; }
.card:nth-child(9) { animation-delay: 0.69s; }
.card:nth-child(10) { animation-delay: 0.77s; }
.card:nth-child(11) { animation-delay: 0.85s; }
.card:nth-child(12) { animation-delay: 0.93s; }
.card:nth-child(13) { animation-delay: 1.01s; }
.card:nth-child(14) { animation-delay: 1.09s; }
.card:nth-child(15) { animation-delay: 1.17s; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.card:hover, .card:focus-visible {
  border-color: color-mix(in srgb, var(--c) 70%, transparent);
  box-shadow: 0 12px 40px -12px color-mix(in srgb, var(--c) 45%, transparent);
}
.card:active { transform: perspective(700px) scale(0.98); }

.card .meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.card .no {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: color-mix(in srgb, var(--c) 80%, var(--bone));
  margin-bottom: 2px;
}
.card .name {
  font-family: var(--serif);
  font-size: clamp(22px, 2.8vw, 30px);
  line-height: 1.12;
}
.card .desc {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--bone-dim);
  margin-top: 3px;
}
.card .arrow {
  font-size: 18px;
  color: var(--bone-dim);
  transition: transform 0.25s ease, color 0.25s ease;
}
.card:hover .arrow, .card:focus-visible .arrow { color: var(--c); transform: translateX(5px); }

/* --- card visuals: tiny living scenes, pure CSS --- */

.viz {
  position: relative;
  width: 52px;
  height: 52px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--c);
}

/* Portal: frames rushing out of a tunnel */
.viz-portal i {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--c);
  border-radius: 10px;
  opacity: 0;
  animation: tunnel 2.8s linear infinite;
}
.viz-portal i:nth-child(2) { animation-delay: 0.93s; }
.viz-portal i:nth-child(3) { animation-delay: 1.86s; }
@keyframes tunnel {
  0% { transform: scale(0.25); opacity: 0; }
  30% { opacity: 0.9; }
  100% { transform: scale(1.1); opacity: 0; }
}

/* Bubbles: rising, wobbling spheres */
.viz-bubbles i {
  position: absolute;
  bottom: 0;
  border-radius: 50%;
  border: 1.2px solid var(--c);
  background: radial-gradient(circle at 32% 30%, color-mix(in srgb, var(--c) 55%, transparent), transparent 60%);
  animation: rise 3.2s ease-in infinite;
}
.viz-bubbles i:nth-child(1) { left: 4px; width: 14px; height: 14px; }
.viz-bubbles i:nth-child(2) { left: 22px; width: 9px; height: 9px; animation-delay: 0.9s; }
.viz-bubbles i:nth-child(3) { left: 34px; width: 12px; height: 12px; animation-delay: 1.7s; }
.viz-bubbles i:nth-child(4) { left: 14px; width: 7px; height: 7px; animation-delay: 2.4s; }
@keyframes rise {
  0% { transform: translateY(6px) translateX(0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(-46px) translateX(5px); opacity: 0; }
}

/* Mirror: pulsing neon face */
.viz-mirror svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--c) 70%, transparent));
  animation: maskpulse 2.6s ease-in-out infinite;
}
@keyframes maskpulse {
  0%, 100% { opacity: 0.55; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.02); }
}

/* Conductor: equalizer */
.viz-eq {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  padding-bottom: 8px;
}
.viz-eq i {
  width: 5px;
  height: 30px;
  border-radius: 3px;
  background: linear-gradient(to top, var(--c), color-mix(in srgb, var(--c) 30%, transparent));
  transform-origin: bottom;
  animation: eq 1.1s ease-in-out infinite;
}
.viz-eq i:nth-child(1) { animation-delay: 0s; }
.viz-eq i:nth-child(2) { animation-delay: 0.18s; }
.viz-eq i:nth-child(3) { animation-delay: 0.36s; }
.viz-eq i:nth-child(4) { animation-delay: 0.1s; }
.viz-eq i:nth-child(5) { animation-delay: 0.28s; }
@keyframes eq {
  0%, 100% { transform: scaleY(0.25); }
  50% { transform: scaleY(1); }
}

/* Pool: rings rippling outward */
.viz-ripple i {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 8px;
  height: 8px;
  border: 1.4px solid var(--c);
  border-radius: 50%;
  opacity: 0;
  animation: ripplering 2.7s ease-out infinite;
}
.viz-ripple i:nth-child(2) { animation-delay: 0.9s; }
.viz-ripple i:nth-child(3) { animation-delay: 1.8s; }
@keyframes ripplering {
  0% { transform: scale(0.4); opacity: 0.9; }
  100% { transform: scale(6.2); opacity: 0; }
}

/* Puppet: a little jig */
.viz-puppet svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--c) 60%, transparent));
  transform-origin: 50% 60%;
  animation: jig 1.4s ease-in-out infinite;
}
@keyframes jig {
  0%, 100% { transform: rotate(-5deg) translateY(0); }
  25% { transform: rotate(0deg) translateY(-3px); }
  50% { transform: rotate(5deg) translateY(0); }
  75% { transform: rotate(0deg) translateY(-3px); }
}

/* Blink: the reticle blinks */
.viz-blink svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--c) 55%, transparent));
  animation: reticle-blink 3.2s ease-in-out infinite;
}
@keyframes reticle-blink {
  0%, 88%, 96%, 100% { transform: scaleY(1); }
  92% { transform: scaleY(0.08); }
}

/* Pinscreen: a wave rolls through the pins */
.viz-pins {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 7px;
}
.viz-pins i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
  animation: pinwave 1.8s ease-in-out infinite;
}
.viz-pins i:nth-child(1) { animation-delay: 0s; }
.viz-pins i:nth-child(2) { animation-delay: 0.12s; }
.viz-pins i:nth-child(3) { animation-delay: 0.24s; }
.viz-pins i:nth-child(4) { animation-delay: 0.12s; }
.viz-pins i:nth-child(5) { animation-delay: 0.24s; }
.viz-pins i:nth-child(6) { animation-delay: 0.36s; }
.viz-pins i:nth-child(7) { animation-delay: 0.24s; }
.viz-pins i:nth-child(8) { animation-delay: 0.36s; }
.viz-pins i:nth-child(9) { animation-delay: 0.48s; }
@keyframes pinwave {
  0%, 100% { transform: scale(0.5); opacity: 0.35; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* Infinity: squares spiralling inward forever */
.viz-fractal i {
  position: absolute;
  inset: 0;
  border: 1.4px solid var(--c);
  border-radius: 6px;
  opacity: 0;
  animation: dive 3.3s linear infinite;
}
.viz-fractal i:nth-child(2) { animation-delay: 1.1s; }
.viz-fractal i:nth-child(3) { animation-delay: 2.2s; }
@keyframes dive {
  0% { transform: scale(1.05) rotate(0deg); opacity: 0; }
  25% { opacity: 0.9; }
  100% { transform: scale(0.08) rotate(70deg); opacity: 0; }
}

/* Shuffle: a 3x3 with one tile forever sliding into the gap */
.viz-shuffle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 6px;
}
.viz-shuffle i {
  border: 1.2px solid var(--c);
  border-radius: 3px;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  aspect-ratio: 1;
}
.viz-shuffle i:nth-child(5) {
  animation: slidepiece 2.4s ease-in-out infinite;
}
.viz-shuffle i:nth-child(9) { visibility: hidden; }
@keyframes slidepiece {
  0%, 35% { transform: translate(0, 0); }
  50%, 85% { transform: translate(calc(100% + 3px), calc(100% + 3px)); }
  100% { transform: translate(0, 0); }
}

/* Kaleido: a slowly turning mandala */
.viz-kaleido {
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    var(--c), transparent 25deg, var(--c) 45deg, transparent 70deg,
    var(--c) 90deg, transparent 115deg, var(--c) 135deg, transparent 160deg,
    var(--c) 180deg, transparent 205deg, var(--c) 225deg, transparent 250deg,
    var(--c) 270deg, transparent 295deg, var(--c) 315deg, transparent 340deg, var(--c)
  );
  opacity: 0.7;
  -webkit-mask: radial-gradient(circle, transparent 22%, black 26%, black 92%, transparent 96%);
  mask: radial-gradient(circle, transparent 22%, black 26%, black 92%, transparent 96%);
  animation: mandala 10s linear infinite;
  width: 46px;
  height: 46px;
}
@keyframes mandala { to { transform: rotate(360deg); } }

/* Light Brush: a stroke draws itself */
.viz-brush svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--c) 70%, transparent));
}
.viz-brush path {
  animation: paint 3.4s ease-in-out infinite;
}
@keyframes paint {
  0% { stroke-dashoffset: 70; opacity: 0.4; }
  55% { stroke-dashoffset: 0; opacity: 1; }
  80% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 70; opacity: 0.4; }
}

/* Echoes: staggered ghost circles */
.viz-echoes { position: relative; }
.viz-echoes i {
  position: absolute;
  inset: 8px;
  border: 1.6px solid var(--c);
  border-radius: 50%;
  animation: echodrift 2.6s ease-in-out infinite;
}
.viz-echoes i:nth-child(2) { animation-delay: 0.35s; opacity: 0.55; }
.viz-echoes i:nth-child(3) { animation-delay: 0.7s; opacity: 0.3; }
@keyframes echodrift {
  0%, 100% { transform: translateX(-7px); }
  50% { transform: translateX(7px); }
}

/* Starflight: canyon ridge + a pulsing star */
.viz-flight svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--c) 60%, transparent));
}
.viz-flight .star {
  transform-origin: 30px 14px;
  animation: starpulse 1.8s ease-in-out infinite;
}
@keyframes starpulse {
  0%, 100% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* Vanish: the outline fades away */
.viz-vanish svg {
  width: 100%;
  height: 100%;
  animation: fadeaway 3s ease-in-out infinite;
}
@keyframes fadeaway {
  0%, 100% { opacity: 0.95; }
  50% { opacity: 0.12; }
}

.smallprint {
  margin-top: 4vh;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: rgba(236, 231, 220, 0.4);
}
.linklike {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: rgba(236, 231, 220, 0.55);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linklike:hover { color: var(--coral); }

@media (max-width: 680px) {
  #home {
    justify-content: flex-start;
    padding-top: max(5vh, 34px);
    padding-bottom: max(6vh, 40px);
    background: linear-gradient(165deg, rgba(5, 6, 10, 0.94) 30%, rgba(5, 6, 10, 0.6) 100%);
  }
  #home .lens { top: 4vh; right: -16vmin; width: 62vmin; height: 62vmin; transform: none; }
  .masthead { margin-bottom: 2.5vh; }
  .exps { grid-template-columns: 1fr; gap: 10px; }
  .card { padding: 12px 14px; gap: 12px; border-radius: 15px; }
  .viz { width: 44px; height: 44px; }
  .card .desc { font-size: 11px; }
}

/* ---------- View controls & sub bar ---------- */

#viewctl {
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#subbar {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  max-width: calc(100vw - 20px);
  overflow-x: auto;
  scrollbar-width: none;
}
#subbar::-webkit-scrollbar { display: none; }
#subbar button {
  border: none;
  background: var(--chip);
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  text-transform: capitalize;
}
#subbar button.active {
  background: var(--chip-active);
  color: var(--accent);
}

/* ---------- Controls splash ---------- */

#splash {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 10, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#splash[hidden] { display: none; }
#splash .panel {
  width: min(400px, calc(100vw - 48px));
  padding: 26px 28px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
}
#splash .title {
  font-family: var(--serif);
  font-size: 30px;
  margin-bottom: 18px;
}
#splash .row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 0;
  border-top: 1px solid var(--hairline);
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.45;
}
#splash .row .ico {
  font-size: 26px;
  flex: none;
  width: 36px;
  text-align: center;
}
#splash #splash-ok {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  border: none;
  border-radius: 13px;
  background: var(--chip-active);
  color: var(--accent);
  border: 1px solid rgba(56, 224, 200, 0.4);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* ---------- Infinity hand cursor ---------- */

#flycursor {
  position: fixed;
  z-index: 12;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border: 2.5px solid rgba(129, 140, 248, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 16px rgba(129, 140, 248, 0.5), inset 0 0 12px rgba(129, 140, 248, 0.25);
  pointer-events: none;
  transition: border-color 0.15s ease;
}
#flycursor[hidden] { display: none; }
#flycursor.reverse { border-color: rgba(255, 92, 56, 0.95); box-shadow: 0 0 16px rgba(255, 92, 56, 0.5); }

/* ---------- Back swipe ---------- */

.edgezone {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 22px;
  z-index: 15;
  /* invisible, but catches edge-started touches before the scene does */
}
#edge-left { left: 0; }
#edge-right { right: 0; }
.edgezone[hidden] { display: none; }

#backhint {
  position: fixed;
  z-index: 40;
  width: 46px;
  height: 46px;
  margin-top: -23px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  color: var(--accent);
  font-size: 20px;
  pointer-events: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#backhint[hidden] { display: none; }
#backhint.armed {
  background: var(--chip-active);
  border-color: rgba(56, 224, 200, 0.5);
  box-shadow: 0 0 18px rgba(56, 224, 200, 0.4);
}

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  z-index: 30;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 80px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  padding: 10px 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  font-size: 13px;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: calc(100vw - 40px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
