:root {
  --font-display: 'Creepster', 'Cabinet Grotesk', serif;
  --font-body: 'Inter', system-ui, sans-serif;

  --bg: #07070b;
  --surface: rgba(14, 14, 20, 0.85);
  --surface-2: rgba(30, 28, 40, 0.9);
  --border: rgba(255, 255, 255, 0.1);
  --text: #eaeaf0;
  --text-muted: #8c8ca0;
  --accent: #ffb347;
  --danger: #ff3a4a;
  --success: #4af0a0;
  --yellow: #ffd94a;

  --panel-radius: 10px;
  --panel-blur: 14px;
  --transition: 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

html,
body {
  width: 100%;
  height: 100%;
  background: #000;
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#game-root {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at center, #120f18 0%, #000 80%),
    #000;
}

#game-frame {
  position: relative;
  width: min(100vw, calc(100vh * 1.6));
  height: min(100vh, calc(100vw / 1.6));
  max-width: 100vw;
  max-height: 100vh;
  box-shadow:
    0 0 80px rgba(0, 0, 0, 0.9),
    inset 0 0 120px rgba(0, 0, 0, 0.8);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  background: #0a0a10;
}

/* UI layers overlay the canvas */
.ui-layer {
  position: absolute;
  pointer-events: none;
  z-index: 20;
}

/* HUD */
#hud {
  top: 2%;
  left: 2%;
  right: 2%;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
}

.hud-left {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border);
  border-radius: var(--panel-radius);
  color: var(--text-muted);
  font-weight: 500;
  opacity: 0.45;
  transition:
    opacity var(--transition),
    color var(--transition),
    border-color var(--transition);
}

.hud-item.active {
  opacity: 1;
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(255, 179, 71, 0.3);
}

.hud-icon {
  font-size: 18px;
}

.hud-hint {
  padding: 8px 12px;
  background: var(--surface);
  backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border);
  border-radius: var(--panel-radius);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

/* Subtitle (speaker lines) */
#subtitle {
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  max-width: 70%;
  padding: 14px 22px;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--panel-radius);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity 400ms ease;
  pointer-events: none;
}

#subtitle.show {
  opacity: 1;
}

#subtitle.speaker::before {
  content: '📡 SPEAKER';
  display: block;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 4px;
}

#subtitle.monster {
  border-color: var(--danger);
  color: #ffc2c8;
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.1em;
}

#subtitle.note {
  border-color: var(--yellow);
  color: var(--yellow);
  font-style: italic;
}

/* Interaction prompt */
#prompt {
  left: 50%;
  top: 72%;
  transform: translate(-50%, 0);
  padding: 10px 18px;
  background: rgba(0, 0, 0, 0.88);
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--accent);
  opacity: 0;
  transition: opacity 180ms ease;
}

#prompt.show {
  opacity: 1;
}

#prompt .key {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent);
  color: #1a1a22;
  border-radius: 4px;
  font-weight: 700;
  margin: 0 4px;
}

/* Chase bar */
#chase-bar {
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, 60%);
  height: 28px;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid var(--danger);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(255, 58, 74, 0.5);
  animation: chasePulse 0.8s ease-in-out infinite;
}

@keyframes chasePulse {
  0%,
  100% {
    box-shadow: 0 0 30px rgba(255, 58, 74, 0.5);
  }
  50% {
    box-shadow: 0 0 50px rgba(255, 58, 74, 0.9);
  }
}

.chase-bar-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--danger), #ff6070);
  transform-origin: left;
  transform: scaleX(1);
  transition: transform 120ms linear;
}

.chase-bar-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

/* Mute button */
#btn-mute {
  bottom: 2%;
  right: 2%;
  width: 40px;
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  pointer-events: auto;
  display: grid;
  place-items: center;
  transition: background var(--transition);
}

#btn-mute:hover {
  background: var(--surface-2);
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  animation: fadeIn 400ms ease;
}

.overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.overlay-content {
  max-width: 560px;
  width: 90%;
  /* Scroll when content exceeds available screen height — essential on phones
     and kids' tablets where intro text pushes the "Continue" button offscreen.
     Uses 100% of the parent .overlay (which is itself inset:0 inside the game
     frame) so this works in both upright and rotated portrait modes. */
  max-height: calc(100% - 24px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 32px 28px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: center;
  color: var(--text);
  box-shadow: 0 0 60px rgba(255, 179, 71, 0.12);
}

/* Subtle scroll hint — a gradient at the bottom edge fades to let the player
   know there's more content below. Also visible scrollbar on webkit. */
.overlay-content::-webkit-scrollbar { width: 8px; }
.overlay-content::-webkit-scrollbar-track { background: transparent; }
.overlay-content::-webkit-scrollbar-thumb {
  background: rgba(255, 179, 71, 0.35);
  border-radius: 4px;
}
.overlay-content::-webkit-scrollbar-thumb:hover { background: rgba(255, 179, 71, 0.6); }

.title-brand {
  font-family: var(--font-display);
  font-size: clamp(48px, 10vw, 88px);
  color: var(--danger);
  letter-spacing: 0.08em;
  text-shadow:
    0 0 20px rgba(255, 58, 74, 0.6),
    3px 3px 0 #000;
  line-height: 1;
  margin-bottom: 8px;
  animation: titleFlicker 4s infinite;
}

/* When the title-brand contains an <img> (brand logo), render the image
   at the same footprint as the old text title and inherit the flicker
   animation from the container. The logo PNG/SVG already bakes in the
   red glow + amber underline. */
.title-brand-logo {
  display: block;
  width: min(72vw, 560px);
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  /* extra red glow to match the rest of the UI even if the SVG renders
     without Creepster loaded */
  filter: drop-shadow(0 0 18px rgba(255, 58, 74, 0.45));
}

.title-brand:has(.title-brand-logo) {
  /* Container no longer needs text-shadow when the image is present */
  text-shadow: none;
  font-size: 0; /* collapse any stray whitespace */
  margin-bottom: 4px;
}

@keyframes titleFlicker {
  0%,
  90%,
  100% {
    opacity: 1;
  }
  92% {
    opacity: 0.4;
  }
  94% {
    opacity: 1;
  }
  96% {
    opacity: 0.7;
  }
}

.title-sub {
  font-size: 14px;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 20px;
}

.title-body {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.btn-primary {
  display: inline-block;
  padding: 14px 28px;
  background: var(--danger);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    transform var(--transition),
    box-shadow var(--transition);
  box-shadow: 0 0 20px rgba(255, 58, 74, 0.5);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(255, 58, 74, 0.8);
}

.btn-ghost {
  margin-top: 16px;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition:
    color var(--transition),
    border-color var(--transition);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text);
}

.controls-hint {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.8;
}

.level-jump {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}
.level-jump-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-align: center;
}
.level-jump-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.level-jump-row .btn-ghost {
  flex: 1 1 0;
  padding: 8px 6px;
  font-size: 12px;
  min-width: 0;
  letter-spacing: 0.04em;
}

.controls-hint b {
  color: var(--accent);
  font-weight: 600;
}

/* Puzzle overlay */
.puzzle-panel {
  max-width: 620px;
}

.puzzle-title {
  font-family: var(--font-display);
  font-size: 40px;
  color: var(--yellow);
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.puzzle-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.puzzle-sequence {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  height: 24px;
}

.seq-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1a1a22;
  border: 2px solid var(--border);
  transition:
    background var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}

.seq-dot.flash {
  background: var(--yellow);
  border-color: var(--yellow);
  box-shadow: 0 0 20px var(--yellow);
}

.seq-dot.filled {
  background: var(--success);
  border-color: var(--success);
}

.seq-dot.wrong {
  background: var(--danger);
  border-color: var(--danger);
  animation: shake 0.3s;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

.puzzle-frames {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.frame-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: #1a1a22;
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all var(--transition);
}

.frame-btn:hover:not(:disabled) {
  border-color: var(--yellow);
  color: var(--yellow);
  transform: translateY(-2px);
}

.frame-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.frame-btn.flashing {
  border-color: var(--yellow);
  background: #2a2618;
  box-shadow: 0 0 30px var(--yellow);
}

.frame-btn svg {
  width: 48px;
  height: 48px;
}

.puzzle-status {
  min-height: 22px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.puzzle-status.wrong {
  color: var(--danger);
}

.puzzle-status.right {
  color: var(--success);
}

/* End panel */
.end-title {
  font-family: var(--font-display);
  font-size: 56px;
  color: var(--success);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  text-shadow: 0 0 20px rgba(74, 240, 160, 0.5);
}

.end-sub {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.reward-chest {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 auto 24px;
  max-width: 400px;
}

.reward-item {
  padding: 12px;
  background: #1a1a22;
  border: 1px solid var(--yellow);
  border-radius: 6px;
  font-size: 13px;
  color: var(--yellow);
}

.end-speaker {
  font-size: 14px;
  color: var(--accent);
  font-style: italic;
  margin-bottom: 20px;
  letter-spacing: 0.05em;
}

/* Caught panel */
.caught-panel {
  background: #1a0408;
  border-color: var(--danger);
  box-shadow: 0 0 80px rgba(255, 58, 74, 0.4);
}

.caught-face {
  position: relative;
  height: 140px;
  margin-bottom: 20px;
  animation: faceZoom 0.8s ease-out;
}

@keyframes faceZoom {
  from {
    transform: scale(0.3);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.caught-face .eye {
  position: absolute;
  top: 20px;
  width: 50px;
  height: 50px;
  background: var(--yellow);
  border: 4px solid #1a1a22;
  border-radius: 50%;
  box-shadow: 0 0 40px var(--yellow);
  animation: eyePulse 1.2s ease-in-out infinite;
}

.caught-face .eye:nth-child(1) {
  left: calc(50% - 80px);
}
.caught-face .eye:nth-child(2) {
  left: calc(50% + 30px);
}

.caught-face .eye::after {
  content: '';
  position: absolute;
  inset: 10px;
  background: #1a1a22;
  border-radius: 2px;
}

@keyframes eyePulse {
  0%,
  100% {
    box-shadow: 0 0 40px var(--yellow);
  }
  50% {
    box-shadow: 0 0 70px var(--yellow);
  }
}

.caught-face .mouth {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: 40px;
  border-bottom: 6px solid #e8a0a0;
  border-radius: 0 0 100px 100px;
}

.caught-whisper {
  font-family: var(--font-display);
  font-size: 42px;
  color: #ffc2c8;
  letter-spacing: 0.15em;
  margin-bottom: 24px;
  text-shadow: 0 0 20px rgba(255, 58, 74, 0.6);
}

/* hide helper */
.hidden {
  display: none !important;
}

/* Mobile touch */
@media (max-width: 700px) {
  .hud-label {
    display: none;
  }
  .hud-hint {
    font-size: 11px;
  }
  .puzzle-title {
    font-size: 30px;
  }
  .overlay-content {
    padding: 20px 16px;
  }
}

/* === v2 additions === */
.hud-objective {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  backdrop-filter: blur(var(--panel-blur));
  max-width: 360px;
  text-align: right;
}

#hud-key1, #hud-key2 { display: none; }
#hud-key1.has, #hud-key2.has { display: flex; }

#btn-notes, #btn-tasks {
  position: absolute;
  pointer-events: auto;
  bottom: 2%;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(var(--panel-blur));
  transition: var(--transition);
}
#btn-notes { left: 2%; }
#btn-tasks { left: calc(2% + 140px); }
#btn-notes:hover, #btn-tasks:hover { background: var(--surface-2); }

.tasks-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
}
.tasks-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
}
.tasks-list li.done {
  color: var(--text-muted, #8b8b99);
  text-decoration: line-through;
  opacity: 0.75;
}
.tasks-list li .task-box {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  background: rgba(0,0,0,0.25);
}
.tasks-list li.done .task-box {
  background: #2a8a4a;
  border-color: #3fb56a;
  color: #eafff0;
}

.notes-panel { max-width: 560px; }
.notes-title {
  font-family: var(--font-display);
  font-size: 32px;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  text-align: center;
}
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 8px;
  margin-bottom: 12px;
}
.note-row {
  background: rgba(20, 18, 28, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.note-row .note-row-title {
  font-weight: 700;
  color: var(--yellow);
  margin-bottom: 4px;
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.note-row .note-row-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}
.notes-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
  font-style: italic;
}

/* Combo lock */
.combo-panel { max-width: 480px; }
.combo-title {
  font-family: var(--font-display);
  font-size: 36px;
  color: var(--danger);
  letter-spacing: 0.08em;
  text-align: center;
  margin-bottom: 8px;
}
.combo-sub {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.combo-dials {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 18px;
}
.dial {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: #0d0d12;
  border: 2px solid #2a2a36;
  border-radius: 8px;
  padding: 8px 4px;
}
.dial-btn {
  background: transparent;
  border: 0;
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 14px;
  font-family: var(--font-body);
}
.dial-btn:hover { color: var(--yellow); }
.dial-num {
  font-family: 'Courier New', monospace;
  font-size: 42px;
  font-weight: 700;
  color: var(--yellow);
  width: 56px;
  text-align: center;
  text-shadow: 0 0 10px rgba(255, 217, 74, 0.5);
}
.combo-status {
  text-align: center;
  min-height: 22px;
  margin: 10px 0;
  font-weight: 600;
}
.combo-status.bad { color: var(--danger); }
.combo-status.good { color: var(--success); }

/* Note paper */
.note-panel { max-width: 460px; }
.note-paper {
  background: #f4ecd0;
  color: #1a1208;
  padding: 24px 28px;
  border-radius: 4px;
  box-shadow:
    inset 0 0 30px rgba(120, 80, 30, 0.15),
    0 12px 40px rgba(0, 0, 0, 0.6);
  margin-bottom: 16px;
  transform: rotate(-1deg);
  font-family: 'Courier New', monospace;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 22px, rgba(120, 80, 30, 0.08) 22px 23px);
}
.note-title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  padding-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.note-text {
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Hide indicator */
#hide-indicator {
  bottom: 14%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 18, 28, 0.92);
  border: 1px solid var(--border);
  color: var(--success);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.05em;
  backdrop-filter: blur(var(--panel-blur));
  animation: pulseHide 1.2s ease-in-out infinite;
}
@keyframes pulseHide {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; box-shadow: 0 0 30px rgba(74, 240, 160, 0.4); }
}

/* ======================================================= */
/* LEVEL 2 — Flooded Sublevel styles                       */
/* ======================================================= */

.title-brand.l2 {
  color: #7ee2a8;
  text-shadow: 0 0 18px rgba(126,226,168,0.6), 0 0 4px rgba(126,226,168,1);
}
.title-sub.l2 {
  color: #9bdcff;
}
.end-title.l2 {
  color: #7ee2a8;
  text-shadow: 0 0 18px rgba(126,226,168,0.6);
}
.l2-title-panel {
  border: 2px solid rgba(126,226,168,0.35);
  background: linear-gradient(180deg, #0a1d1f 0%, #07141a 100%);
}
.end-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* Valve panel */
.valve-panel {
  border: 2px solid rgba(126,226,168,0.35);
  background: linear-gradient(180deg, #0e1f22 0%, #0a1418 100%);
  max-width: 560px;
}
.valve-title {
  font-family: 'Creepster', cursive;
  color: #7ee2a8;
  font-size: 42px;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 6px;
  text-shadow: 0 0 12px rgba(126,226,168,0.6);
}
.valve-sub {
  color: #b8d8d4;
  text-align: center;
  font-size: 14px;
  margin-bottom: 18px;
}
.valve-wheels {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.vwheel {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 130px;
}
.vwheel[data-w="0"] { border-color: rgba(255,90,90,0.5); }
.vwheel[data-w="1"] { border-color: rgba(90,160,255,0.5); }
.vwheel[data-w="2"] { border-color: rgba(255,220,90,0.5); }
.vwheel-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #cfe9df;
  text-transform: uppercase;
}
.vwheel[data-w="0"] .vwheel-label { color: #ff8c8c; }
.vwheel[data-w="1"] .vwheel-label { color: #9bd0ff; }
.vwheel[data-w="2"] .vwheel-label { color: #ffdc7a; }
.vw-btn {
  background: rgba(255,255,255,0.08);
  color: #e6f2ef;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  transition: background 120ms;
}
.vw-btn:hover { background: rgba(126,226,168,0.2); }
.vw-num {
  font-family: 'Inter', monospace;
  font-size: 40px;
  font-weight: 700;
  color: #f2fff9;
  min-width: 56px;
  text-align: center;
  text-shadow: 0 0 8px rgba(126,226,168,0.4);
}
.valve-status {
  text-align: center;
  min-height: 22px;
  color: #ffcc55;
  margin-top: 10px;
  font-weight: 600;
}

/* Cipher panel */
.cipher-panel {
  border: 2px solid rgba(155,208,255,0.35);
  background: linear-gradient(180deg, #0d1826 0%, #070d15 100%);
  max-width: 620px;
}
.cipher-title {
  font-family: 'Creepster', cursive;
  color: #9bd0ff;
  font-size: 42px;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 6px;
  text-shadow: 0 0 12px rgba(155,208,255,0.5);
}
.cipher-sub {
  color: #c0d8e8;
  text-align: center;
  font-size: 14px;
  margin-bottom: 18px;
}
.cipher-pipes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.pipe-btn {
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(155,208,255,0.3);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  color: #e6f2ef;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform 120ms, background 120ms, border-color 120ms;
}
.pipe-btn svg { width: 56px; height: 56px; }
.pipe-btn span { font-size: 12px; letter-spacing: 0.5px; }
.pipe-btn:hover {
  background: rgba(155,208,255,0.12);
  transform: translateY(-2px);
  border-color: rgba(155,208,255,0.7);
}
.pipe-btn.used {
  opacity: 0.35;
  pointer-events: none;
}
.cipher-progress {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 10px;
}
.cipher-slot {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  border: 2px dashed rgba(155,208,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #9bd0ff;
  background: rgba(0,0,0,0.25);
}
.cipher-slot.filled {
  border-style: solid;
  background: rgba(155,208,255,0.15);
  color: #ffffff;
}
.cipher-status {
  text-align: center;
  min-height: 22px;
  color: #ffcc55;
  margin-top: 6px;
  font-weight: 600;
}


/* ==========================================================
   Comic cutscene overlay (Squidley vs The Drip)
   ========================================================== */
.comic-panel {
  max-width: 900px;
  width: calc(100% - 40px);
  padding: 20px 22px 18px;
  background: linear-gradient(180deg, #fefaee 0%, #f2e6c9 100%);
  color: #1a1a1a;
  border: 3px solid #1a1a1a;
  border-radius: 6px;
  box-shadow: 8px 8px 0 rgba(0,0,0,0.45), 0 0 0 4px #fff inset;
  font-family: 'Inter', system-ui, sans-serif;
  text-align: center;
  animation: comicPop 0.35s cubic-bezier(.2,.9,.3,1.4);
}
@keyframes comicPop {
  0% { transform: scale(0.85) rotate(-1deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.comic-banner {
  position: relative;
  padding: 6px 0 14px;
  border-bottom: 3px solid #1a1a1a;
  margin-bottom: 14px;
}
.comic-badge {
  display: inline-block;
  background: #ff2a5e;
  color: #fff;
  padding: 4px 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  font-size: 11px;
  transform: rotate(-3deg);
  border: 2px solid #1a1a1a;
  box-shadow: 3px 3px 0 #1a1a1a;
  margin-bottom: 8px;
}
.comic-title {
  font-family: 'Creepster', 'Impact', system-ui, sans-serif;
  font-size: 40px;
  line-height: 1;
  letter-spacing: 2px;
  color: #1a4a2a;
  text-shadow:
    2px 2px 0 #ffcc55,
    4px 4px 0 #1a1a1a;
}
.comic-issue {
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #6a5a3a;
  margin-top: 4px;
  font-weight: 700;
}
.comic-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.comic-frame {
  margin: 0;
  position: relative;
  border: 3px solid #1a1a1a;
  border-radius: 2px;
  background: #0a1418;
  overflow: hidden;
  aspect-ratio: 5 / 4;
  box-shadow: 3px 3px 0 #1a1a1a;
  animation: panelIn 0.5s ease-out backwards;
}
.comic-frame svg {
  display: block;
  width: 100%;
  height: 100%;
}
#comic-p1 { animation-delay: 0.05s; }
#comic-p2 { animation-delay: 0.35s; }
#comic-p3 { animation-delay: 0.65s; }
@keyframes panelIn {
  0% { transform: translateY(12px) scale(0.92); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* -----------------------------------------------------------
   Ex Preshon: Origin — per-element SVG animations (post-L3 tease)
   Pixar-ish subtle motion: bobs, pulses, flickers — no jump-scares.
   ----------------------------------------------------------- */
/* Panel 1 */
#l3-comic-p1 .anim-chester-peer { transform-box: fill-box; transform-origin: center; animation: l3-peer 2.8s ease-in-out infinite; }
@keyframes l3-peer {
  0%,100% { transform: translate(0, 0); }
  50%     { transform: translate(2px, -1px); }
}
#l3-comic-p1 .anim-yearbook { transform-box: fill-box; transform-origin: center; animation: l3-yearbook 3.4s ease-in-out infinite; }
@keyframes l3-yearbook {
  0%   { transform: translate(0, 4px) rotate(-2deg); opacity: 0; }
  20%  { opacity: 1; }
  60%  { transform: translate(0, -2px) rotate(1deg); }
  100% { transform: translate(0, 4px) rotate(-2deg); opacity: 1; }
}
#l3-comic-p1 .anim-mote   { animation: l3-mote 3.6s ease-in-out infinite; }
#l3-comic-p1 .anim-mote-2 { animation-delay: 0.7s; animation-duration: 4.2s; }
#l3-comic-p1 .anim-mote-3 { animation-delay: 1.4s; animation-duration: 3.1s; }
#l3-comic-p1 .anim-mote-4 { animation-delay: 2.1s; animation-duration: 4.8s; }
@keyframes l3-mote {
  0%   { transform: translate(0, 0);  opacity: 0; }
  30%  { opacity: 0.7; }
  100% { transform: translate(-6px, -18px); opacity: 0; }
}
#l3-comic-p1 .anim-flicker { animation: l3-flicker 5s steps(1,end) infinite; }
@keyframes l3-flicker {
  0%,  92%, 94%, 100% { opacity: 0; }
  93%                 { opacity: 0.18; }
}
#l3-comic-p1 .anim-bulb { transform-box: fill-box; transform-origin: center; animation: l3-bulb 2.4s ease-in-out infinite; }
@keyframes l3-bulb {
  0%,100% { filter: drop-shadow(0 0 3px #ffd27a); opacity: 0.95; }
  50%     { filter: drop-shadow(0 0 6px #ffd27a); opacity: 1; }
}
#l3-comic-p1 .anim-flicker-cone { animation: l3-flicker-cone 5s steps(1,end) infinite; }
@keyframes l3-flicker-cone {
  0%,  92%, 94%, 100% { opacity: 1; }
  93%                 { opacity: 0.55; }
}

/* Panel 2 */
#l3-comic-p2 svg { animation: l3-zoom 7s ease-in-out infinite; transform-origin: 60% 60%; }
@keyframes l3-zoom {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.06); }
}
#l3-comic-p2 .anim-chalk   { animation: l3-chalk 3s steps(1,end) infinite; }
#l3-comic-p2 .anim-chalk-2 { animation-delay: 0.4s; }
@keyframes l3-chalk {
  0%,   86%, 90%, 100% { opacity: 1; }
  88%,  89%            { opacity: 0.35; }
}
#l3-comic-p2 .anim-boy { transform-box: fill-box; transform-origin: bottom center; animation: l3-boy-breath 3.6s ease-in-out infinite; }
@keyframes l3-boy-breath {
  0%,100% { transform: scaleY(1) translateY(0); }
  50%     { transform: scaleY(1.015) translateY(-1px); }
}
#l3-comic-p2 .anim-exlena { transform-box: fill-box; transform-origin: bottom center; animation: l3-exlena-lean 4.2s ease-in-out infinite; }
@keyframes l3-exlena-lean {
  0%,100% { transform: translate(0, 0) rotate(0deg); }
  50%     { transform: translate(-1.5px, 0) rotate(-1.5deg); }
}
#l3-comic-p2 .anim-scan { animation: l3-scan 2.6s linear infinite; }
@keyframes l3-scan {
  0%   { transform: translateY(-118px); }
  100% { transform: translateY(118px); }
}

/* Panel 3 */
#l3-comic-p3 .anim-expreshon { transform-box: fill-box; transform-origin: center bottom; animation: l3-expreshon-float 3s ease-in-out infinite; }
@keyframes l3-expreshon-float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-2px); }
}
#l3-comic-p3 .anim-exlena-dark { transform-box: fill-box; transform-origin: center bottom; animation: l3-exlena-float 3.6s ease-in-out infinite; animation-delay: 0.3s; }
@keyframes l3-exlena-float {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-1.5px); }
}
#l3-comic-p3 .anim-torch { animation: l3-torch 1.5s ease-in-out infinite; }
@keyframes l3-torch {
  0%,100% { transform: scale(1);    opacity: 0.85; }
  47%     { transform: scale(1.08); opacity: 1; }
  53%     { transform: scale(0.94); opacity: 0.7; }
}
#l3-comic-p3 .anim-eye-red  { transform-box: fill-box; transform-origin: center; animation: l3-eye-red 1.8s ease-in-out infinite; }
@keyframes l3-eye-red {
  0%,100% { transform: scale(1);   opacity: 0.9; }
  50%     { transform: scale(1.35); opacity: 1;   filter: drop-shadow(0 0 3px #ff3030); }
}
#l3-comic-p3 .anim-eye-pink { transform-box: fill-box; transform-origin: center; animation: l3-eye-pink 2.2s ease-in-out infinite; }
@keyframes l3-eye-pink {
  0%,100% { transform: scale(1);   opacity: 0.9; }
  50%     { transform: scale(1.25); opacity: 1; }
}
#l3-comic-p3 .anim-neon { animation: l3-neon 2.4s steps(1,end) infinite; }
@keyframes l3-neon {
  0%, 80%, 84%, 88%, 92%, 100% { opacity: 1; filter: drop-shadow(0 0 2px #ff5fa2); }
  82%, 90%                      { opacity: 0.3; filter: none; }
}
#l3-comic-p3 .anim-subtitle { animation: l3-subtitle 3.5s ease-in-out infinite; }
@keyframes l3-subtitle {
  0%,100% { opacity: 0.7; letter-spacing: 1px; }
  50%     { opacity: 1;   letter-spacing: 2px; }
}
#l3-comic-p3 .anim-drop   { animation: l3-drop 3s ease-in infinite; }
#l3-comic-p3 .anim-drop-2 { animation-delay: 1.4s; animation-duration: 2.6s; }
@keyframes l3-drop {
  0%   { opacity: 0; transform: translateY(0); }
  10%  { opacity: 0.8; }
  90%  { opacity: 0.5; }
  100% { opacity: 0; transform: translateY(70px); }
}

@media (prefers-reduced-motion: reduce) {
  #l3-comic-p1 .anim-chester-peer, #l3-comic-p1 .anim-yearbook, #l3-comic-p1 .anim-mote, #l3-comic-p1 .anim-flicker, #l3-comic-p1 .anim-bulb, #l3-comic-p1 .anim-flicker-cone,
  #l3-comic-p2 svg, #l3-comic-p2 .anim-chalk, #l3-comic-p2 .anim-boy, #l3-comic-p2 .anim-exlena, #l3-comic-p2 .anim-scan,
  #l3-comic-p3 .anim-torch, #l3-comic-p3 .anim-expreshon, #l3-comic-p3 .anim-exlena-dark, #l3-comic-p3 .anim-eye-red, #l3-comic-p3 .anim-eye-pink, #l3-comic-p3 .anim-neon, #l3-comic-p3 .anim-subtitle, #l3-comic-p3 .anim-drop {
    animation: none;
  }
}
.comic-caption {
  position: absolute;
  left: 6px;
  right: 6px;
  padding: 4px 8px;
  background: #fefaee;
  color: #1a1a1a;
  border: 2px solid #1a1a1a;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  z-index: 2;
  text-align: left;
}
.comic-caption.top { top: 6px; }
.comic-speech {
  position: absolute;
  padding: 6px 12px;
  background: #fff;
  color: #1a1a1a;
  border: 2.5px solid #1a1a1a;
  border-radius: 18px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.3px;
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Inter', sans-serif;
  z-index: 3;
  box-shadow: 2px 2px 0 #1a1a1a;
}
.comic-speech.right { bottom: 14px; right: 10px; }
.comic-speech.left { bottom: 14px; left: 10px; }
.comic-speech.squish {
  background: #ffe04a;
  transform: rotate(-6deg) scale(1.05);
  font-size: 15px;
}
/* speech tail */
.comic-speech::after {
  content: '';
  position: absolute;
  bottom: -10px;
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid #1a1a1a;
}
.comic-speech.right::after { right: 16px; }
.comic-speech.left::after { left: 16px; }
.comic-speech::before {
  content: '';
  position: absolute;
  bottom: -7px;
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid #fff;
  z-index: 1;
}
.comic-speech.squish::before { border-top-color: #ffe04a; }
.comic-speech.right::before { right: 19px; }
.comic-speech.left::before { left: 19px; }

.comic-footer {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.comic-tip {
  font-size: 12px;
  color: #4a3a1a;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* Collectibles gallery */
.collectibles-panel {
  max-width: 520px;
  width: calc(100% - 40px);
  padding: 22px 22px 18px;
  background: rgba(10, 20, 26, 0.98);
  border: 2px solid rgba(126,226,168,0.5);
  border-radius: 10px;
  text-align: center;
}
.collectibles-title {
  font-family: 'Creepster', 'Impact', system-ui, sans-serif;
  font-size: 32px;
  letter-spacing: 2px;
  color: #7ee2a8;
  text-shadow: 2px 2px 0 #0a0a0a;
  margin-bottom: 4px;
}
.collectibles-sub {
  color: #a9c9c2;
  font-size: 12px;
  margin-bottom: 14px;
}
.collectibles-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.collectible-item {
  background: rgba(126,226,168,0.08);
  border: 1px solid rgba(126,226,168,0.3);
  border-radius: 6px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.collectible-item.locked {
  background: rgba(80,80,80,0.2);
  border-color: rgba(120,120,120,0.2);
  color: #5a6a72;
  cursor: not-allowed;
}
.collectible-item:hover:not(.locked) {
  background: rgba(126,226,168,0.18);
  transform: translateX(2px);
}
.collectible-item .ci-title {
  color: #e6f2ef;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}
.collectible-item.locked .ci-title { color: #6a7a80; }
.collectible-item .ci-sub {
  color: #8da9a2;
  font-size: 11px;
}

#btn-collectibles {
  position: absolute;
  bottom: 10px;
  right: 60px;
  z-index: 10;
  background: rgba(10,20,26,0.8);
  border: 1px solid rgba(126,226,168,0.5);
  color: #cfe9df;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
}
#btn-collectibles:hover { background: rgba(126,226,168,0.2); }
#btn-collectibles .ci-count {
  display: inline-block;
  background: #ff2a5e;
  color: #fff;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
  font-size: 10px;
}

@media (max-width: 720px) {
  .comic-title { font-size: 28px; }
  .comic-strip { grid-template-columns: 1fr; }
  .comic-frame { aspect-ratio: 5/3; }
}

/* ======================================================= */
/* LEVEL 3 — Back Home (Expression / corridor) styles      */
/* ======================================================= */

.title-brand.l3 {
  color: #ff7a5a;
  text-shadow: 0 0 18px rgba(255,122,90,0.55), 0 0 4px rgba(255,170,90,1);
}
.title-sub.l3 {
  color: #ffae5a;
}
.end-title.l3 {
  color: #ffae5a;
  text-shadow: 0 0 18px rgba(255,170,90,0.55);
}
.l3-title-panel {
  border: 2px solid rgba(255,122,90,0.4);
  background: linear-gradient(180deg, #1a0e08 0%, #0a0606 100%);
  max-width: 600px;
}

/* Mirror puzzle */
.mirror-panel {
  border: 2px solid rgba(255,170,90,0.4);
  background: linear-gradient(180deg, #1a0e0a 0%, #0a0606 100%);
  max-width: 460px;
  padding: 24px;
}
.mirror-title {
  font-family: 'Creepster', cursive;
  color: #ff9a5a;
  font-size: 38px;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 4px;
}
.mirror-sub {
  color: #f3c7a4;
  font-size: 13px;
  text-align: center;
  margin-bottom: 18px;
}
.mirror-board {
  display: grid;
  grid-template-columns: repeat(3, 70px);
  gap: 10px;
  justify-content: center;
  margin: 10px auto 16px;
}
.mirror-tile {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  background: #170a08;
  border: 2px solid #5a3a22;
  color: #fff;
  font-size: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 100ms ease, border-color 120ms ease, background 120ms ease;
  font-family: serif;
}
.mirror-tile:hover { transform: translateY(-2px); border-color: #ff9a5a; }
.mirror-tile.fixed {
  background: #0a0404;
  border-color: #ffae5a;
  cursor: default;
  box-shadow: inset 0 0 12px rgba(255,170,90,0.18);
}
.mirror-status {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  min-height: 18px;
  margin: 4px 0 12px;
  color: #f3c7a4;
}

/* Code panel */
.code-panel {
  border: 2px solid rgba(255,170,90,0.4);
  background: linear-gradient(180deg, #1a0e0a 0%, #0a0606 100%);
  max-width: 480px;
  padding: 24px;
}
.code-title {
  font-family: 'Creepster', cursive;
  color: #ff9a5a;
  font-size: 38px;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 4px;
}
.code-sub {
  color: #f3c7a4;
  font-size: 12px;
  text-align: center;
  margin-bottom: 18px;
  min-height: 32px;
  line-height: 1.45;
}
.code-wheels {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin: 8px 0 18px;
}
.codewheel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.4);
  border: 1px solid #5a3a22;
  border-radius: 8px;
  padding: 8px 6px;
  min-width: 60px;
}
.cw-btn {
  background: rgba(255,170,90,0.15);
  border: 1px solid rgba(255,170,90,0.4);
  color: #ffae5a;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 4px;
  font-weight: 700;
  font-size: 14px;
  transition: background 100ms ease;
}
.cw-btn:hover { background: rgba(255,170,90,0.32); }
.cw-num {
  font-family: 'Courier New', monospace;
  font-size: 32px;
  color: #fff5c4;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
  text-shadow: 0 0 8px rgba(255,170,90,0.55);
}
.code-status {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  min-height: 18px;
  margin: 4px 0 12px;
}

/* ---------------- Intro cutscene ---------------- */
.intro-panel {
  max-width: 960px;
  width: 95%;
}
.intro-strip {
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 10px 0 16px;
}
@media (max-width: 900px) {
  .intro-strip { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .intro-strip { grid-template-columns: repeat(2, 1fr); }
}
.intro-rules {
  background: rgba(12, 6, 20, 0.6);
  border: 1px solid rgba(255, 176, 208, 0.25);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 10px auto 16px;
  max-width: 640px;
  font-size: 15px;
  line-height: 1.55;
  color: #f0e6f0;
}
.intro-rules div { margin: 4px 0; }
.intro-rules b { color: #ffd66a; }

/* ---------------- Mother glimpse panel ---------------- */
.mother-panel {
  max-width: 420px;
  text-align: center;
}
.mother-panel .note-paper { text-align: left; }

/* ---------------- Persistent coin pill (HUD) ---------------- */
/* Always visible, even when parent #hud is hidden on later levels */
#hud-coins {
  position: fixed !important;
  top: 10px;
  left: 10px;
  z-index: 1000;
  display: flex !important;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #ffd84a;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 216, 74, 0.5);
  font: 700 13px system-ui, sans-serif;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
#hud-coins .hud-icon { font-size: 14px; }

/* ============================================================
   Mobile / Touch Controls
   ============================================================ */

/* Only visible when body.has-touch (added by shared-touch.js) */
#touch-controls { display: none; }
body.has-touch #touch-controls {
  display: block;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
}

body.has-touch #touch-controls .touch-stick,
body.has-touch #touch-controls .touch-actions {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom, 14px));
  pointer-events: auto;
}

/* ---- Analog Thumbstick ---- */
.touch-stick {
  left: max(14px, env(safe-area-inset-left, 14px));
  width: 168px;
  height: 168px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  -webkit-touch-callout: none;
}
.stick-base {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 45%, rgba(40,40,60,0.55) 0%, rgba(10,10,18,0.7) 70%);
  border: 2px solid rgba(255, 217, 74, 0.38);
  box-shadow:
    0 4px 18px rgba(0,0,0,0.55),
    inset 0 2px 0 rgba(255,255,255,0.06),
    inset 0 -8px 20px rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0.9;
  transition: border-color 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
  touch-action: none;
}
.stick-base.engaged {
  border-color: rgba(255, 217, 74, 0.85);
  box-shadow:
    0 0 0 2px rgba(255, 217, 74, 0.15),
    0 4px 22px rgba(255, 217, 74, 0.25),
    inset 0 2px 0 rgba(255,255,255,0.08);
  opacity: 1;
}
.stick-ring {
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  border: 1px dashed rgba(255, 217, 74, 0.22);
  pointer-events: none;
}
.stick-cross {
  position: absolute; inset: 0;
  pointer-events: none;
  color: rgba(255, 217, 74, 0.55);
  font-size: 13px;
  font-weight: 700;
}
.stick-cross .ind {
  position: absolute;
  transform: translate(-50%, -50%);
  transition: color 90ms ease, text-shadow 90ms ease, transform 90ms ease;
}
.stick-cross .ind.up    { left: 50%; top: 10%; }
.stick-cross .ind.down  { left: 50%; top: 90%; }
.stick-cross .ind.left  { left: 10%; top: 50%; }
.stick-cross .ind.right { left: 90%; top: 50%; }
.stick-cross .ind.on {
  color: #fff7d0;
  text-shadow: 0 0 10px rgba(255, 217, 74, 0.9);
}
.stick-knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 42%; height: 42%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 32%, #fff0a8 0%, #ffd94a 45%, #c49a18 100%);
  border: 2px solid rgba(0,0,0,0.35);
  box-shadow:
    0 4px 12px rgba(0,0,0,0.6),
    inset 0 2px 4px rgba(255,255,255,0.5),
    inset 0 -4px 8px rgba(0,0,0,0.3);
  pointer-events: none;
  /* No transition during drag — every frame of finger movement must
     show instantly. A transition would add perceived input lag. */
  will-change: transform;
}

/* ---- Action Buttons (A / B / X) ---- */
.touch-actions {
  right: max(14px, env(safe-area-inset-right, 14px));
  display: flex;
  gap: 14px;
  align-items: center;
}

.touch-btn {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  -webkit-touch-callout: none;
  border: none;
  font-family: inherit;
  color: #ffd94a;
  background: rgba(14, 14, 20, 0.55);
  border: 2px solid rgba(255, 217, 74, 0.4);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.5),
    inset 0 2px 0 rgba(255,255,255,0.08),
    inset 0 -4px 10px rgba(0,0,0,0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-weight: 800;
  /* Only animate visual props — never transform. Transform is instant so
     the press feedback feels mechanical, not rubbery. */
  transition: background 100ms ease, box-shadow 100ms ease, opacity 100ms ease;
  opacity: 0.92;
  will-change: transform, background;
}
.touch-btn.active {
  transform: scale(0.94);
  opacity: 1;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.6),
    inset 0 2px 10px rgba(0,0,0,0.35);
}

.touch-btn.action {
  position: relative;
  width: 80px; height: 80px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
}
.touch-btn.action .btn-glyph {
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 3px rgba(0,0,0,0.5);
}
.touch-btn.action .btn-sub {
  position: absolute;
  bottom: 8px;
  left: 0; right: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  opacity: 0.78;
}

/* A = primary action (green, biggest emphasis) */
.touch-btn.action.a {
  background:
    radial-gradient(circle at 35% 30%, rgba(140, 255, 170, 0.35), rgba(74, 208, 120, 0.25) 60%, rgba(20, 80, 50, 0.35) 100%);
  border-color: rgba(120, 240, 160, 0.75);
  color: #eafff2;
}
.touch-btn.action.a.active {
  background:
    radial-gradient(circle at 35% 30%, rgba(180, 255, 200, 0.6), rgba(74, 208, 120, 0.55) 60%, rgba(20, 80, 50, 0.5) 100%);
}
/* B = jump/space (blue) */
.touch-btn.action.b {
  background:
    radial-gradient(circle at 35% 30%, rgba(160, 200, 255, 0.3), rgba(90, 140, 230, 0.22) 60%, rgba(20, 30, 70, 0.35) 100%);
  border-color: rgba(140, 180, 240, 0.65);
  color: #eaf1ff;
}
.touch-btn.action.b.active {
  background:
    radial-gradient(circle at 35% 30%, rgba(200, 225, 255, 0.55), rgba(90, 140, 230, 0.5) 60%, rgba(20, 30, 70, 0.5) 100%);
}
/* X = menu/close (red, smaller) */
.touch-btn.action.x {
  width: 58px; height: 58px;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 170, 180, 0.28), rgba(220, 70, 90, 0.22) 60%, rgba(90, 20, 30, 0.35) 100%);
  border-color: rgba(255, 120, 135, 0.65);
  color: #ffe2e5;
  align-self: flex-start;
  margin-top: 6px;
}
.touch-btn.action.x .btn-glyph { font-size: 24px; }
.touch-btn.action.x .btn-sub { bottom: 5px; font-size: 9px; }
.touch-btn.action.x.active {
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 200, 210, 0.55), rgba(220, 70, 90, 0.55) 60%, rgba(90, 20, 30, 0.5) 100%);
}

/* Tighter on small phones */
@media (max-height: 420px) {
  .touch-stick { width: 140px; height: 140px; }
  .touch-btn.action { width: 68px; height: 68px; }
  .touch-btn.action .btn-glyph { font-size: 26px; }
  .touch-btn.action .btn-sub { font-size: 9px; bottom: 6px; }
  .touch-btn.action.x { width: 50px; height: 50px; }
  .touch-btn.action.x .btn-glyph { font-size: 20px; }
  .touch-actions { gap: 10px; }
}

/* Wide but short (landscape phones): allow more breathing room */
@media (min-width: 700px) and (max-height: 500px) {
  .touch-stick { width: 176px; height: 176px; }
  .touch-btn.action { width: 84px; height: 84px; }
}

/* Don't let touch controls block overlay buttons */
body.has-touch .overlay:not(.hidden) ~ #touch-controls { opacity: 0.35; pointer-events: none; }
body.has-touch .overlay:not(.hidden) ~ #touch-controls .touch-btn[data-k="Escape"] { pointer-events: auto; opacity: 1; }

/* ============================================================
   Portrait-orientation nudge (game is designed for landscape)
   ============================================================ */
#orient-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #07070b;
  color: #eaeaf0;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  font-family: var(--font-body, system-ui, sans-serif);
}
#orient-hint .panel {
  max-width: 320px;
  padding: 24px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  background: rgba(20,20,30,0.8);
}
#orient-hint h2 { font-family: var(--font-display); color: #ffd94a; font-size: 28px; margin-bottom: 10px; letter-spacing: 1px; }
#orient-hint .icon { font-size: 42px; margin-bottom: 12px; }
#orient-hint p { opacity: 0.8; line-height: 1.45; font-size: 14px; }

/* Show in portrait on touch devices — but NOT when the user has entered
   pseudo-fullscreen (we rotate the game to landscape instead). */
@media (orientation: portrait) and (max-height: 900px) {
  body.has-touch:not(.pseudo-fullscreen) #orient-hint { display: flex; }
  body.has-touch:not(.pseudo-fullscreen) #touch-controls { display: none; }
}

/* Hide desktop-only hints on touch */
body.has-touch .desktop-only { display: none !important; }

/* Bigger tap targets for overlay buttons on touch */
body.has-touch .overlay button,
body.has-touch #overlay-title button,
body.has-touch .btn-primary {
  min-height: 48px;
  min-width: 48px;
  font-size: 16px;
}

/* ============================================================
   GRAPHICS POLISH — atmospheric overlays layered on top of the
   canvas for a cleaner, more cinematic look across all levels.
   These are pure CSS so no render code is touched.
   • Radial vignette darkens the corners (depth cue)
   • Subtle film grain (pre-baked SVG noise) adds texture warmth
   • Soft top-down light tint brightens the centre
   ============================================================ */
#game-frame {
  position: relative; /* already set elsewhere but ensure for ::after */
}
/* Give the raw canvas output a tiny clarity boost — adds bite to edges and
   slightly richer colour without breaking any level's art intent. */
#game {
  filter: contrast(1.06) saturate(1.09) brightness(1.015);
  image-rendering: auto;
}
#game-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5; /* above canvas, below HUD/overlays */
  background:
    /* Warm centre highlight */
    radial-gradient(ellipse 70% 50% at 50% 38%, rgba(255, 224, 170, 0.06), transparent 65%),
    /* Corner vignette */
    radial-gradient(ellipse 120% 90% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.42) 100%),
    /* Subtle film grain via SVG noise */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.6  0 0 0 0 0.6  0 0 0 0 0.6  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 100% 100%, 100% 100%, 140px 140px;
  mix-blend-mode: normal;
  opacity: 0.95;
}
/* Disable polish on specific overlays where it would interfere */
body.polish-off #game-frame::after { display: none; }

/* ============================================================
   PER-LEVEL GRAPHICS TUNING (L1–L5)
   Each level gets its own color grade on the canvas + a second
   atmospheric pass above the canvas (below HUD). This makes every
   chapter feel visually distinct and "cleaner / more realistic"
   without touching the canvas render code.
   ============================================================ */

/* Shared: an extra atmosphere pass stacked on top of #game, sitting
   just above #game-frame::after so levels can layer their own mood
   light, god-rays, or dust motes. */
#game-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4; /* above canvas (auto), below #game-frame::after (5) */
  background: transparent;
  opacity: 1;
  transition: background 400ms ease, opacity 400ms ease;
}

/* ---- Level 1: warm, soft daylight attic ---- */
body.level-1 #game {
  filter: contrast(1.08) saturate(1.12) brightness(1.02) hue-rotate(-2deg);
}
body.level-1 #game-frame::before {
  background:
    radial-gradient(ellipse 60% 45% at 55% 30%, rgba(255, 218, 150, 0.10), transparent 70%),
    radial-gradient(ellipse 90% 70% at 50% 90%, rgba(60, 20, 40, 0.18), transparent 75%);
}

/* ---- Level 2: cool moonlit corridor ---- */
body.level-2 #game {
  filter: contrast(1.10) saturate(0.96) brightness(0.97) hue-rotate(6deg);
}
body.level-2 #game-frame::before {
  background:
    radial-gradient(ellipse 55% 40% at 50% 20%, rgba(140, 180, 255, 0.09), transparent 65%),
    linear-gradient(180deg, rgba(10, 14, 28, 0.18) 0%, transparent 40%, rgba(0, 0, 0, 0.22) 100%);
}

/* ---- Level 3: industrial rust + sodium lamps ---- */
body.level-3 #game {
  filter: contrast(1.12) saturate(1.08) brightness(0.96) hue-rotate(-8deg);
}
body.level-3 #game-frame::before {
  background:
    radial-gradient(ellipse 50% 30% at 50% 25%, rgba(255, 168, 80, 0.10), transparent 65%),
    radial-gradient(circle at 80% 70%, rgba(255, 130, 40, 0.05), transparent 45%),
    linear-gradient(0deg, rgba(30, 14, 4, 0.20), transparent 55%);
}

/* ---- Level 4: verdant overgrowth, dappled green light ---- */
body.level-4 #game {
  filter: contrast(1.08) saturate(1.14) brightness(1.01) hue-rotate(4deg);
}
body.level-4 #game-frame::before {
  background:
    radial-gradient(ellipse 70% 40% at 40% 15%, rgba(180, 255, 170, 0.08), transparent 65%),
    radial-gradient(circle at 75% 80%, rgba(40, 80, 50, 0.14), transparent 60%),
    linear-gradient(0deg, rgba(10, 20, 14, 0.22), transparent 50%);
}

/* ---- Level 5: cold blue dread, low visibility ---- */
body.level-5 #game {
  filter: contrast(1.14) saturate(0.88) brightness(0.92) hue-rotate(10deg);
}
body.level-5 #game-frame::before {
  background:
    radial-gradient(ellipse 45% 35% at 50% 45%, rgba(120, 180, 255, 0.06), transparent 68%),
    radial-gradient(ellipse 100% 80% at 50% 50%, transparent 30%, rgba(0, 4, 14, 0.40) 100%),
    linear-gradient(180deg, rgba(6, 10, 24, 0.28) 0%, transparent 50%);
}

/* ============================================================
   FULLSCREEN BUTTON + PSEUDO-FULLSCREEN MODE
   ============================================================ */

#fullscreen-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1000;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  background: rgba(10, 10, 16, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffd94a;
  border-radius: 8px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 150ms, transform 150ms, border-color 150ms;
  pointer-events: auto;
  touch-action: manipulation;
}

#fullscreen-btn:hover,
#fullscreen-btn:focus-visible {
  background: rgba(30, 26, 40, 0.9);
  border-color: rgba(255, 217, 74, 0.5);
  outline: none;
}

#fullscreen-btn:active {
  transform: scale(0.94);
}

/* Hide the in-frame fullscreen button entirely on touch devices —
   the fixed #mobile-fs-btn takes over so the player doesn't see two FS boxes. */
body.has-touch #fullscreen-btn {
  display: none !important;
}

/* When in pseudo-fullscreen, force game-root to take over EVERYTHING.
   Works even when iframe sandbox blocks true fullscreen. */
body.pseudo-fullscreen {
  overflow: hidden !important;
}

body.pseudo-fullscreen #game-root {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  /* Use 100svh where supported so the browser UI bars are accounted for */
  height: 100svh !important;
  z-index: 2147483647 !important; /* max z-index */
  margin: 0 !important;
  padding: 0 !important;
}

body.pseudo-fullscreen #game-frame {
  width: min(100vw, calc(100svh * 1.6)) !important;
  height: min(100svh, calc(100vw / 1.6)) !important;
}

/* Hide the portrait nag overlay while in pseudo-fullscreen */
body.pseudo-fullscreen #orient-hint { display: none !important; }

/* ============================================================
   Portrait orientation — TWO modes
   ============================================================

   The game was originally built for landscape (1.6:1 aspect). On a phone
   held in portrait we have two options:

   1. NATIVE PORTRAIT (default — body.portrait-native + pseudo-fullscreen):
      Canvas sits at the top of the viewport at full width; the bottom
      portion becomes a dedicated control strip with the thumbstick on the
      left and A/B buttons on the right. No rotation. Feels like a real
      mobile game, and crucially the whole canvas is always visible
      without the player having to tilt the phone.

   2. ROTATED LANDSCAPE (legacy — body.pseudo-fullscreen without
      .portrait-native): #game-root rotates 90° so the game fills the
      whole screen in landscape while the phone is held vertically. This
      is kept as a fallback / alternative we can toggle from JS.
   ============================================================ */

/* ---- Mode 1: Native portrait (preferred for phones) ---- */
@media (orientation: portrait) {
  body.pseudo-fullscreen.portrait-native #game-root {
    /* No rotation — keep the game-root upright in the portrait viewport. */
    width: 100vw !important;
    height: 100svh !important;
    transform: none !important;
    top: 0 !important;
    left: 0 !important;
    /* Override grid-centering so the frame sits at the TOP instead of
       vertically centered with empty space above AND below. */
    display: block !important;
  }
  body.pseudo-fullscreen.portrait-native #game-frame {
    /* Full width, aspect-locked 1.6:1, pinned to the top of the viewport.
       The remaining space (100svh - width/1.6) becomes the control strip. */
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    height: calc(100vw / 1.6) !important;
    max-width: 100vw !important;
    max-height: 100svh !important;
    margin: 0 !important;
  }
  /* The control strip is the area between the game-frame bottom and the
     viewport bottom. Provide a subtle divider so it reads as a distinct
     zone. The strip is a visual guide; touch controls themselves live in
     #touch-controls (position:fixed full screen) and pin themselves to the
     bottom corners so they naturally land inside this strip. */
  body.pseudo-fullscreen.portrait-native #game-root::after {
    content: '';
    position: absolute;
    top: calc(100vw / 1.6);
    left: 0;
    right: 0;
    bottom: 0;
    background:
      radial-gradient(ellipse at 50% 0%, rgba(60, 30, 50, 0.28) 0%, transparent 70%),
      linear-gradient(180deg, #0c0810 0%, #060409 100%);
    pointer-events: none;
    z-index: 0;
  }
  /* Touch controls: upright (no rotation). Shrink stick/buttons a touch so
     they share the strip comfortably on narrow phones. */
  body.pseudo-fullscreen.portrait-native.has-touch #touch-controls {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100svh !important;
    transform: none !important;
    z-index: 2147483647 !important;
  }
  body.pseudo-fullscreen.portrait-native .touch-stick {
    width: 150px !important;
    height: 150px !important;
    bottom: max(18px, env(safe-area-inset-bottom, 18px)) !important;
    left: max(14px, env(safe-area-inset-left, 14px)) !important;
  }
  body.pseudo-fullscreen.portrait-native .touch-actions {
    bottom: max(18px, env(safe-area-inset-bottom, 18px)) !important;
    right: max(14px, env(safe-area-inset-right, 14px)) !important;
    gap: 12px !important;
  }
  body.pseudo-fullscreen.portrait-native .touch-btn.action {
    width: 72px !important;
    height: 72px !important;
  }
  /* Menu button: anchor to the real viewport top-left, inside the canvas
     frame, not rotated. */
  body.pseudo-fullscreen.portrait-native #touch-menu-btn {
    top: max(54px, env(safe-area-inset-top, 54px)) !important;
    left: 12px !important;
    transform: none !important;
  }
  /* Fullscreen button: upright, top-right. */
  body.pseudo-fullscreen.portrait-native #fullscreen-btn {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    left: auto !important;
    bottom: auto !important;
    transform: none !important;
  }
  /* Give the HUD breathing room on the right so the gem counter / hint
     text doesn't sit beneath the fixed fullscreen + hide-controls buttons.
     Two 52px buttons + 10px gap + 8px edge inset = ~130px reserved zone. */
  body.pseudo-fullscreen.portrait-native.has-touch #hud {
    right: 132px !important;
  }
  /* Orient-hint and portrait nag should stay hidden in this mode. */
  body.pseudo-fullscreen.portrait-native #orient-hint { display: none !important; }

  /* Overlays should cover the ENTIRE viewport in native portrait, not just
     the small canvas area at the top. Their base rule uses position:absolute
     inset:0 which scopes them to the nearest positioned ancestor (#game-frame,
     which is 360×225 here). Escape that so the player has the full screen
     for intro text, level select, notes, and puzzles. */
  body.pseudo-fullscreen.portrait-native .overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 2147483640 !important; /* above canvas + controls, below menu-btn */
  }
  /* Touch controls are hidden while any overlay is open to prevent accidental
     taps on the thumbstick when reaching for the CTA button on a tall overlay. */
  body.pseudo-fullscreen.portrait-native .overlay:not(.hidden) ~ #touch-controls,
  body.pseudo-fullscreen.portrait-native:has(.overlay:not(.hidden)) #touch-controls {
    opacity: 0.25 !important;
    pointer-events: none !important;
  }
}

/* ---- Mode 2: Rotated landscape fallback ----
   Used when body.pseudo-fullscreen is active but .portrait-native is NOT.
   Rotates #game-root 90° so the game fills the screen as landscape. */
@media (orientation: portrait) {
  body.pseudo-fullscreen:not(.portrait-native) #game-root {
    /* Swap: use viewport HEIGHT as the horizontal axis, WIDTH as vertical */
    width: 100svh !important;
    height: 100vw !important;
    /* Rotate around origin and shift back into view */
    transform: rotate(90deg) translateY(-100vw) !important;
    transform-origin: top left !important;
    top: 0 !important;
    left: 0 !important;
  }
  body.pseudo-fullscreen:not(.portrait-native) #game-frame {
    width: min(100svh, calc(100vw * 1.6)) !important;
    height: min(100vw, calc(100svh / 1.6)) !important;
    max-width: 100svh !important;
    max-height: 100vw !important;
  }
  body.pseudo-fullscreen.has-touch:not(.portrait-native) #touch-controls {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100svh !important;
    height: 100vw !important;
    transform: rotate(90deg) translateY(-100vw) !important;
    transform-origin: top left !important;
    z-index: 2147483647 !important;
  }
  body.pseudo-fullscreen:not(.portrait-native) #fullscreen-btn {
    position: fixed !important;
    top: auto !important;
    bottom: 10px !important;
    left: 10px !important;
    right: auto !important;
    transform: rotate(90deg) !important;
    transform-origin: center center !important;
    z-index: 2147483647 !important;
  }
}

/* Swap the icon when in fullscreen mode */
body.pseudo-fullscreen #fullscreen-btn .fs-enter,
:fullscreen #fullscreen-btn .fs-enter { display: none; }

body.pseudo-fullscreen #fullscreen-btn .fs-exit,
:fullscreen #fullscreen-btn .fs-exit { display: block; }

/* Also support browser-native fullscreen styling */
#game-root:fullscreen,
#game-frame:fullscreen {
  background: #000;
}

#game-frame:fullscreen {
  width: min(100vw, calc(100vh * 1.6));
  height: min(100vh, calc(100vw / 1.6));
}

/* ============================================================
   Fullscreen splash (mobile only).
   Shown on first load on Android Chrome so the user's tap can
   satisfy the Fullscreen API's user-gesture requirement.
   ============================================================ */
#fs-splash {
  position: fixed;
  inset: 0;
  z-index: 2147483646; /* just below pseudo-fullscreen's game-root */
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 40%, rgba(60, 20, 30, 0.85) 0%, rgba(10, 6, 12, 0.96) 70%),
    #07050a;
  color: #ffd94a;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  animation: fs-splash-in 200ms ease;
}
@keyframes fs-splash-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.fs-splash-out {
  animation: fs-splash-fade 380ms ease forwards !important;
}
@keyframes fs-splash-fade {
  to { opacity: 0; transform: scale(1.02); }
}
.fs-splash-inner {
  text-align: center;
  padding: 0 24px;
  max-width: 360px;
}
.fs-splash-icon {
  color: rgba(255, 217, 74, 0.85);
  margin-bottom: 16px;
  filter: drop-shadow(0 0 18px rgba(255, 120, 120, 0.35));
  animation: fs-pulse 1.6s ease-in-out infinite;
}
@keyframes fs-pulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50%      { transform: scale(1.08); opacity: 1; }
}
.fs-splash-title {
  font-family: 'Creepster', system-ui, sans-serif;
  font-size: clamp(44px, 11vw, 64px);
  line-height: 1;
  color: #ff4a4a;
  text-shadow: 0 3px 0 rgba(0,0,0,0.5), 0 0 22px rgba(255, 74, 74, 0.35);
  letter-spacing: 1.5px;
  margin: 0 0 18px 0;
}
.fs-splash-cta {
  font-size: clamp(17px, 4.5vw, 22px);
  font-weight: 800;
  color: #ffd94a;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.fs-splash-sub {
  font-size: 13px;
  color: rgba(255, 240, 200, 0.6);
  font-weight: 500;
  letter-spacing: 0.4px;
}
/* Hide splash when game root is actually rotated/scaled so two UIs don't
   fight each other. */
body.pseudo-fullscreen #fs-splash {
  /* Keep it on top even when pseudo is active \u2014 first tap should still
     trigger real fullscreen. */
  z-index: 2147483647;
}

/* ============================================================
   Mobile fullscreen button \u2014 pinned to the real viewport corner
   (not inside the rotated #game-frame). Always visible on touch.
   ============================================================ */
#mobile-fs-btn {
  position: fixed;
  top: max(8px, env(safe-area-inset-top, 8px));
  right: max(8px, env(safe-area-inset-right, 8px));
  /* Must exceed #game-root's stacking context (z:2147483647 in portrait-native). */
  z-index: 2147483647;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 14px;
  border: 2px solid rgba(255, 217, 74, 0.7);
  background:
    linear-gradient(180deg, rgba(30, 14, 22, 0.92), rgba(14, 6, 12, 0.96));
  color: #ffd94a;
  font-family: inherit;
  font-weight: 800;
  font-size: 9px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 217, 74, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 120ms ease, background 160ms ease, box-shadow 160ms ease;
}
#mobile-fs-btn:active {
  transform: scale(0.94);
  background: linear-gradient(180deg, rgba(60, 28, 40, 0.96), rgba(30, 14, 22, 0.98));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}
#mobile-fs-btn.is-fs {
  color: #ffb0b0;
  border-color: rgba(255, 140, 140, 0.7);
}
.mobile-fs-label {
  font-size: 8.5px;
  opacity: 0.85;
  letter-spacing: 1.2px;
  line-height: 1;
  margin-top: 1px;
}
/* Only show on touch devices — desktop already has the in-frame button. */
body:not(.has-touch) #mobile-fs-btn {
  display: none;
}

/* ============================================================
   Hide-controls toggle (touch devices only) — lets a player using
   a connected keyboard on a touchscreen device hide the on-screen
   gamepad to reclaim screen space.
   ============================================================ */
#hide-controls-btn {
  position: fixed;
  top: max(8px, env(safe-area-inset-top, 8px));
  right: calc(max(8px, env(safe-area-inset-right, 8px)) + 62px); /* left of #mobile-fs-btn */
  /* Must exceed #game-root's stacking context. */
  z-index: 2147483647;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 14px;
  border: 2px solid rgba(126, 226, 168, 0.6);
  background: linear-gradient(180deg, rgba(14, 22, 18, 0.92), rgba(6, 14, 10, 0.96));
  color: #7ee2a8;
  font-family: inherit;
  font-weight: 800;
  font-size: 9px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(126, 226, 168, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 120ms ease, background 160ms ease;
}
body.has-touch #hide-controls-btn { display: flex; }
#hide-controls-btn:active { transform: scale(0.94); }
#hide-controls-btn.is-hidden {
  color: #e7c7ff;
  border-color: rgba(186, 154, 255, 0.6);
}
.hide-controls-label {
  font-size: 8.5px;
  opacity: 0.85;
  letter-spacing: 1.2px;
  line-height: 1;
  margin-top: 1px;
}
/* When user toggles controls off, hide the on-screen gamepad. */
body.controls-hidden #touch-controls { display: none !important; }
body.controls-hidden #touch-menu-btn { display: none !important; }
/* While actually in real fullscreen on desktop, the in-frame button is fine \u2014
   hide the mobile one to avoid duplicates on a connected keyboard scenario. */
#mobile-fs-btn.is-fs {
  opacity: 0.7;
}

/* ============================================================
   Hold-to-exit menu button (touch devices only)
   Top-left corner, away from the thumbstick and action cluster.
   Must be held 800ms to avoid accidental exits.
   ============================================================ */
#touch-menu-btn {
  display: none;
  position: fixed;
  top: 54px;
  left: 12px;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 120, 135, 0.55);
  background: radial-gradient(circle at 35% 30%, rgba(80, 24, 34, 0.78), rgba(40, 12, 18, 0.9) 70%);
  color: #ffe2e5;
  z-index: 2147483645;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  overflow: visible;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  transition: transform 140ms ease, background 160ms ease, border-color 160ms ease;
}
body.has-touch #touch-menu-btn { display: block; }

#touch-menu-btn .menu-glyph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  z-index: 2;
  pointer-events: none;
}

/* Progress ring drawn with a conic-gradient; --p goes 0 → 1 as held. */
#touch-menu-btn .menu-ring {
  --p: 0;
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(#ff6b7d calc(var(--p) * 360deg), rgba(255, 120, 135, 0.12) 0);
  mask: radial-gradient(circle, transparent 56%, black 58%);
  -webkit-mask: radial-gradient(circle, transparent 56%, black 58%);
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 120ms ease;
}
#touch-menu-btn.holding .menu-ring { opacity: 1; }

#touch-menu-btn .menu-label {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
  background: rgba(10, 8, 14, 0.78);
  color: #ffd0d5;
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 120, 135, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
  z-index: 3;
}
#touch-menu-btn.holding .menu-label { opacity: 1; }

#touch-menu-btn.holding {
  transform: scale(1.05);
  border-color: rgba(255, 180, 190, 0.95);
  background: radial-gradient(circle at 35% 30%, rgba(180, 40, 60, 0.95), rgba(60, 14, 22, 0.95) 70%);
}
#touch-menu-btn.triggered {
  background: radial-gradient(circle at 35% 30%, rgba(255, 220, 230, 0.95), rgba(220, 80, 100, 0.95) 70%);
  transform: scale(0.92);
}

/* No overlay-based fade rule — JS guards the hold trigger when the title overlay
   is visible, so an accidental hold on the menu screen is harmless. */

/* ---------- Difficulty picker (title screen) ---------- */
.difficulty-picker {
  margin: 14px auto 10px;
  padding: 10px 12px;
  max-width: 420px;
  background: rgba(20, 14, 28, 0.55);
  border: 1px solid rgba(150, 110, 200, 0.25);
  border-radius: 12px;
  text-align: center;
}
.difficulty-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #c9b8e4;
  opacity: 0.8;
  margin-bottom: 6px;
}
.difficulty-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.difficulty-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  background: rgba(30, 22, 44, 0.7);
  border: 1px solid rgba(150, 110, 200, 0.22);
  border-radius: 10px;
  color: #dfd4f0;
  font-family: inherit;
  cursor: pointer;
  transition: all 140ms ease;
  min-height: 48px;
}
.difficulty-option:hover {
  background: rgba(50, 38, 72, 0.85);
  border-color: rgba(180, 140, 230, 0.45);
}
.difficulty-option .d-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.difficulty-option .d-age {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  opacity: 0.65;
  text-transform: uppercase;
}
.difficulty-option[aria-checked="true"] {
  background: linear-gradient(135deg, rgba(120, 70, 200, 0.55), rgba(180, 60, 120, 0.45));
  border-color: rgba(230, 180, 255, 0.75);
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(230, 180, 255, 0.35) inset,
              0 4px 14px rgba(120, 60, 200, 0.35);
}
/* Difficulty palette: easy=green, medium=amber, hard=red, extreme=purple */
.difficulty-option[data-tier="easy"][aria-checked="true"]    { background: linear-gradient(135deg, #1f8a3a, #14602a); border-color: #6aee8a; box-shadow: 0 0 0 1px rgba(106,238,138,0.45) inset, 0 4px 14px rgba(30,160,60,0.35); }
.difficulty-option[data-tier="medium"][aria-checked="true"]  { background: linear-gradient(135deg, #c68a18, #7a5208); border-color: #ffce6a; box-shadow: 0 0 0 1px rgba(255,206,106,0.45) inset, 0 4px 14px rgba(210,140,30,0.35); }
.difficulty-option[data-tier="hard"][aria-checked="true"]    { background: linear-gradient(135deg, #c42a2a, #7a1212); border-color: #ff6a6a; box-shadow: 0 0 0 1px rgba(255,106,106,0.45) inset, 0 4px 14px rgba(210,40,40,0.4); }
.difficulty-option[data-tier="extreme"][aria-checked="true"] { background: linear-gradient(135deg, #7a28c4, #401460); border-color: #c77bff; box-shadow: 0 0 0 1px rgba(199,123,255,0.5) inset, 0 0 20px rgba(140,60,220,0.45); }

/* Small HUD badge showing current difficulty */
.difficulty-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 6px;
  margin-left: 6px;
  border-radius: 6px;
  background: rgba(20, 14, 28, 0.7);
  border: 1px solid rgba(150, 110, 200, 0.35);
  color: #dfd4f0;
  vertical-align: middle;
}
[data-difficulty-badge][data-tier="easy"]    { color: #6aee8a; border-color: rgba(106, 238, 138, 0.5); }
[data-difficulty-badge][data-tier="medium"]  { color: #ffce6a; border-color: rgba(255, 206, 106, 0.5); }
[data-difficulty-badge][data-tier="hard"]    { color: #ff6a6a; border-color: rgba(255, 106, 106, 0.55); }
[data-difficulty-badge][data-tier="extreme"] { color: #c77bff; border-color: rgba(199, 123, 255, 0.6); text-shadow: 0 0 6px rgba(140, 60, 220, 0.5); }

/* v22 — Title screen cast poster */
.title-cast-poster {
  display: block;
  width: 100%;
  max-width: 720px;
  height: auto;
  margin: 0 auto 18px auto;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(90, 230, 210, 0.12);
  image-rendering: auto;
}
@media (max-width: 640px) {
  .title-cast-poster { max-width: 100%; margin-bottom: 12px; border-radius: 8px; }
}

/* v22 — Certificate system (player name, unlock modal, cert overlay) */
.name-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  margin: 10px auto 14px auto;
  width: 100%;
  max-width: 320px;
}
.name-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(230, 230, 240, 0.6);
  font-weight: 600;
}
.name-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(20, 20, 28, 0.7);
  border: 1px solid rgba(90, 230, 210, 0.28);
  border-radius: 10px;
  color: #f2f2f4;
  font: 600 15px/1.2 system-ui, -apple-system, sans-serif;
  text-align: center;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.name-input:focus {
  border-color: rgba(90, 230, 210, 0.7);
  box-shadow: 0 0 0 3px rgba(90, 230, 210, 0.18);
}

/* Locked jump buttons */
.btn-ghost.locked {
  opacity: 0.42;
  cursor: not-allowed;
  position: relative;
}
.btn-ghost.locked::after {
  content: ' 🔒';
  font-size: 12px;
}

/* "Have a key?" link */
.key-unlock-link {
  display: block;
  margin: 10px auto 0 auto;
  background: transparent;
  border: none;
  color: rgba(140, 220, 200, 0.85);
  font: 500 12px/1 system-ui, sans-serif;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  padding: 6px 10px;
}
.key-unlock-link:hover { color: #7ce9c8; }

/* Key modal */
.key-modal {
  max-width: 420px;
  padding: 26px 24px;
  text-align: center;
}
.key-title {
  font: 700 22px/1.2 system-ui, sans-serif;
  color: #f2f2f4;
  margin-bottom: 8px;
}
.key-sub {
  font-size: 13px;
  color: rgba(220, 220, 230, 0.68);
  margin-bottom: 16px;
  line-height: 1.5;
}
.key-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: rgba(20, 20, 28, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  color: #f2f2f4;
  font: 600 14px/1.2 ui-monospace, 'SF Mono', Menlo, monospace;
  text-align: center;
  letter-spacing: 0.08em;
  outline: none;
  text-transform: uppercase;
}
.key-input:focus {
  border-color: rgba(90, 230, 210, 0.6);
  box-shadow: 0 0 0 3px rgba(90, 230, 210, 0.18);
}
.key-result {
  min-height: 20px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
}
.key-result.success { color: #6aee8a; }
.key-result.error { color: #ff7070; }
.key-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

/* Certificate overlay */
#overlay-certificate .overlay-content {
  max-width: 720px;
  padding: 30px 28px;
}
.cert-card {
  background: linear-gradient(180deg, #f7f2e4 0%, #ede4cd 100%);
  border-radius: 12px;
  padding: 34px 34px 28px 34px;
  color: #2a241a;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}
.cert-card[data-tier="easy"]    { box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 0 0 3px #1f8a3a; }
.cert-card[data-tier="medium"]  { box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 0 0 3px #c68a18; }
.cert-card[data-tier="hard"]    { box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 0 0 3px #c42a2a; }
.cert-card[data-tier="extreme"] { box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 0 0 3px #7a28c4; }
.cert-inner { position: relative; text-align: center; }
.cert-corner { position: absolute; width: 18px; height: 18px; border: 2px solid #c9a04a; }
.cert-corner.tl { top: -4px; left: -4px; border-right: 0; border-bottom: 0; }
.cert-corner.tr { top: -4px; right: -4px; border-left: 0; border-bottom: 0; }
.cert-corner.bl { bottom: -4px; left: -4px; border-right: 0; border-top: 0; }
.cert-corner.br { bottom: -4px; right: -4px; border-left: 0; border-top: 0; }
.cert-brand {
  font: 800 34px/1 'Creepster', 'Chiller', cursive, system-ui;
  color: #c42a2a;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.cert-subbrand {
  font: 600 13px/1 system-ui, sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #7a6340;
  margin-bottom: 18px;
}
.cert-line {
  font: 400 14px/1.5 system-ui, sans-serif;
  color: #5a4a30;
  margin: 4px 0;
}
.cert-name {
  font: 700 30px/1.2 'Georgia', serif;
  color: #2a241a;
  margin: 8px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
  padding-bottom: 6px;
  display: inline-block;
  min-width: 60%;
}
.cert-title {
  font: 700 18px/1.2 'Georgia', serif;
  color: #3a2e1a;
  margin: 6px 0 14px 0;
}
.cert-diffrow { margin: 6px 0 20px 0; }
.cert-diff-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font: 700 12px/1 system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  margin-right: 8px;
}
.cert-diff-badge[data-tier="easy"]    { background: #1f8a3a; }
.cert-diff-badge[data-tier="medium"]  { background: #c68a18; }
.cert-diff-badge[data-tier="hard"]    { background: #c42a2a; }
.cert-diff-badge[data-tier="extreme"] { background: #7a28c4; }
.cert-diff-label {
  font: 500 12px/1 system-ui, sans-serif;
  color: #7a6340;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.cert-daterow {
  margin: -8px 0 18px 0;
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: center;
}

/* "Your Certificates" panel on the title screen */
.cert-panel {
  margin: 16px auto 8px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 215, 120, 0.25);
  background: rgba(20, 14, 8, 0.55);
  border-radius: 10px;
  max-width: 520px;
}
.cert-panel.hidden { display: none; }
.cert-panel-label {
  font: 600 11px/1 system-ui, sans-serif;
  color: #e5cf8a;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 10px;
  text-align: center;
}
.cert-panel-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.cert-panel-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: #f1e8d2;
  font: 600 12px/1 system-ui, sans-serif;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.cert-panel-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 215, 120, 0.45);
}
.cert-panel-btn-tier {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font: 700 10px/1 system-ui, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
}
.cert-panel-btn-tier[data-tier="easy"]    { background: #1f8a3a; }
.cert-panel-btn-tier[data-tier="medium"]  { background: #c68a18; }
.cert-panel-btn-tier[data-tier="hard"]    { background: #c42a2a; }
.cert-panel-btn-tier[data-tier="extreme"] { background: #7a28c4; }
.cert-panel-btn-label {
  font: 500 11px/1 system-ui, sans-serif;
  letter-spacing: 0.04em;
  color: #e5dfcf;
}
.cert-date-label {
  font: 500 11px/1 system-ui, sans-serif;
  color: #7a6340;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.cert-date {
  font: 600 14px/1 'Cormorant Garamond', Georgia, serif;
  color: #2a241a;
  letter-spacing: 0.02em;
}
.cert-sig {
  display: flex;
  justify-content: space-around;
  margin: 22px 0 18px 0;
  gap: 20px;
}
.cert-sig-line { flex: 1; }
.cert-sig-stroke {
  height: 1px;
  background: #2a241a;
  margin-bottom: 4px;
  font-style: italic;
  font-family: 'Dancing Script', cursive;
  color: #2a241a;
}
.cert-sig-caption {
  font: 500 10px/1.2 system-ui, sans-serif;
  color: #5a4a30;
  letter-spacing: 0.06em;
}
.cert-keyrow {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed rgba(0, 0, 0, 0.2);
}
.cert-keylabel {
  font: 600 10px/1 system-ui, sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #7a6340;
  margin-bottom: 4px;
}
.cert-key {
  font: 700 16px/1.2 ui-monospace, 'SF Mono', Menlo, monospace;
  color: #2a241a;
  letter-spacing: 0.1em;
}
.cert-keyhint {
  font: 400 10px/1.3 system-ui, sans-serif;
  color: #7a6340;
  margin-top: 4px;
}
.cert-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

@media (max-width: 640px) {
  .cert-card { padding: 22px 18px; }
  .cert-brand { font-size: 26px; }
  .cert-name { font-size: 22px; }
  .cert-title { font-size: 15px; }
  .cert-sig { gap: 12px; }
}

/* v23 — Mum cage cutscene bitmap overlay */
.mother-cage-scene {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
  background: radial-gradient(ellipse at center 70%, #1a1020 0%, #0a0410 70%);
  border-radius: 6px;
  overflow: hidden;
}
.mother-cage-mum {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  height: 165px;
  width: auto;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
  z-index: 1;
}
.mother-cage-bars {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
