/* ==========================================================================
   Lumbrelia · Primera Brasa — Atmospheric Dark-Fantasy Mobile UI
   ========================================================================== */

:root {
  --bg-deep: #07050c;
  --bg-card: rgba(16, 11, 27, 0.78);
  --bg-card-solid: #120c1f;
  --border-gold: rgba(216, 178, 110, 0.28);
  --border-soft: rgba(255, 255, 255, 0.1);
  --text-main: #f4eefc;
  --text-muted: #b4a5cb;
  --gold: #e4c17a;

  /* Variant defaults (Amatista) */
  --accent-1: #a855f7;
  --accent-2: #22d3ee;
  --accent-3: #84ff5c;
  --glow-rgb: 168, 85, 247;
  --flame-rgb: 34, 211, 238;

  /* Stage scale */
  --imp-scale: 0.78;
}

body[data-variant="ascua"] {
  --accent-1: #f97316;
  --accent-2: #facc15;
  --accent-3: #ef4444;
  --glow-rgb: 249, 115, 22;
  --flame-rgb: 250, 204, 21;
}

body[data-variant="obsidiana"] {
  --accent-1: #3b82f6;
  --accent-2: #38bdf8;
  --accent-3: #67e8f9;
  --glow-rgb: 59, 130, 246;
  --flame-rgb: 56, 189, 248;
}

body[data-variant="esmeralda"] {
  --accent-1: #10b981;
  --accent-2: #a3e635;
  --accent-3: #5eead4;
  --glow-rgb: 16, 185, 129;
  --flame-rgb: 163, 230, 53;
}

body[data-variant="rubi"] {
  --accent-1: #ec4899;
  --accent-2: #fb7185;
  --accent-3: #fde047;
  --glow-rgb: 236, 72, 153;
  --flame-rgb: 244, 114, 182;
}

body[data-stage="bebe"] { --imp-scale: 0.76; }
body[data-stage="cachorro"] { --imp-scale: 0.88; }
body[data-stage="joven"] { --imp-scale: 1.0; }
body[data-stage="adulto"] { --imp-scale: 1.12; }

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #040308;
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  user-select: none;
}

#app-shell {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  max-height: 920px;
  margin: 0 auto;
  background: var(--bg-deep);
  overflow: hidden;
  box-shadow: 0 0 80px rgba(var(--glow-rgb), 0.22), 0 0 0 1px rgba(216, 178, 110, 0.16);
}

@media (min-width: 500px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 30%, #150d26 0%, #050309 70%);
  }
  #app-shell {
    height: min(94dvh, 880px);
    border-radius: 34px;
  }
}

/* Ambient Background */
.ambient-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(65px);
  opacity: 0.35;
  transition: background 0.8s ease;
}

.glow-primary {
  width: 340px;
  height: 340px;
  top: -70px;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(var(--glow-rgb), 0.75), transparent 70%);
}

.glow-secondary {
  width: 260px;
  height: 260px;
  bottom: 80px;
  right: -60px;
  background: radial-gradient(circle, rgba(var(--flame-rgb), 0.45), transparent 70%);
}

.tarot-frame-lines {
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(216, 178, 110, 0.14);
  border-radius: 26px;
}

#imp-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 22;
  pointer-events: none;
}

#fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 26;
  pointer-events: none;
}

body.play-mode #app-shell {
  cursor: crosshair;
}

/* Paper Prank Canvas (faceted 3D crumple & side push) */
.paper-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: none;
}

/* Completely hide the real underlying reading screen during paper pranks (zero ghost underneath!) */
body.prank-active .content-viewport,
body.prank-active .orbital-menu-layer {
  visibility: hidden !important;
  opacity: 0 !important;
}

.reading-card.returning {
  animation: pageRestoreUnfurl 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Body Parts Customizer */
.parts-card {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
}

.parts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.parts-header .section-mini-title {
  margin-bottom: 0;
}

.part-group {
  margin-bottom: 8px;
}

.part-group:last-child {
  margin-bottom: 0;
}

.part-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.part-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.part-pill {
  padding: 5px 9px;
  border-radius: 99px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.part-pill.active {
  border-color: var(--gold);
  background: rgba(var(--glow-rgb), 0.3);
  color: #fff6df;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.color-swatch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 99px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.color-swatch::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--sw);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
}

.color-swatch.active {
  border-color: var(--gold);
  background: rgba(var(--glow-rgb), 0.28);
  color: #fff6df;
}

/* Frequency selector in Caracter tab */
.freq-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
}

.freq-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.freq-btn {
  padding: 8px 6px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.freq-btn.active {
  border-color: var(--gold);
  background: rgba(216, 178, 110, 0.2);
  color: #fff6df;
}

.freq-desc {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.streak-imp-glow {
  width: 78px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 240, 210, 0.9), rgba(var(--flame-rgb), 0.72) 45%, rgba(var(--glow-rgb), 0.25) 75%, transparent);
  filter: blur(5px);
}

.btn-listo {
  background: linear-gradient(135deg, #facc15, #f97316);
  color: #12091c;
  border: none;
  padding: 8px 16px;
  font-weight: 800;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.98);
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   SCENE 1: HATCH SCREEN (PIEDRA DE CARBÓN)
   ========================================================================== */
#hatch-screen {
  padding: 28px 22px 26px;
  justify-content: space-between;
  align-items: center;
  text-align: center;
}

.tarot-roman {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--gold);
  text-transform: uppercase;
  opacity: 0.88;
}

.brand-title {
  margin: 6px 0 2px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 500;
  letter-spacing: 0.08em;
  background: linear-gradient(180deg, #fff5dc 0%, #d8b26e 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.coal-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
}

.coal-aura {
  position: absolute;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.38) 0%, rgba(168, 85, 247, 0.22) 48%, transparent 72%);
  filter: blur(22px);
  animation: pulseAura 3.2s ease-in-out infinite;
  pointer-events: none;
}

.coal-button {
  position: relative;
  width: 230px;
  height: 230px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s ease;
}

.coal-button:active {
  transform: scale(0.94);
}

.coal-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: lighten;
  filter: drop-shadow(0 0 18px rgba(249, 115, 22, 0.45));
  animation: floatSlow 4.2s ease-in-out infinite;
}

.coal-button.shake {
  animation: coalShake 0.36s ease;
}

.coal-crack-flash {
  position: absolute;
  inset: 25%;
  border-radius: 50%;
  background: radial-gradient(circle, #fff8dc 0%, rgba(249, 115, 22, 0.7) 45%, transparent 75%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.coal-progress {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.coal-progress .pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  background: rgba(216, 178, 110, 0.1);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.coal-progress .pip.lit {
  background: #ffb347;
  box-shadow: 0 0 12px #ff8c00;
}

.hatch-hint {
  max-width: 290px;
  margin: 18px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Variant Picker */
.variant-picker {
  width: 100%;
  background: rgba(15, 10, 26, 0.9);
  border: 1px solid var(--border-gold);
  border-radius: 22px;
  padding: 18px 16px;
  backdrop-filter: blur(12px);
  animation: fadeUp 0.45s ease;
}

.picker-eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.picker-title {
  margin: 4px 0 14px;
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 500;
}

.variant-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.variant-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, transform 0.2s;
}

.variant-card.selected {
  border-color: var(--gold);
  background: rgba(216, 178, 110, 0.12);
  transform: translateY(-2px);
}

.variant-thumb {
  width: 84px;
  height: 84px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  margin-bottom: 8px;
}

.variant-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  mix-blend-mode: lighten;
}

.variant-card strong {
  font-size: 14px;
  margin-bottom: 2px;
}

.variant-card span {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.name-input-wrap {
  display: block;
  text-align: left;
  margin-bottom: 14px;
}

.name-input-wrap span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.name-input-wrap input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
}

.name-input-wrap input:focus {
  border-color: var(--gold);
}

.btn-primary {
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #090612;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(var(--glow-rgb), 0.35);
  transition: transform 0.15s ease, filter 0.2s ease;
}

.btn-primary:active {
  transform: scale(0.97);
}

/* ==========================================================================
   SCENE 2: MAIN INTERACTIVE STAGE
   ========================================================================== */
.top-hud {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 6px;
}

.hud-identity {
  display: flex;
  flex-direction: column;
}

.hud-name {
  font-family: Georgia, serif;
  font-size: 17px;
  color: #fff4d9;
  letter-spacing: 0.04em;
}

.hud-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.hud-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.icon-btn.cloud-connected {
  border-color: rgba(52, 211, 153, 0.65);
  background: rgba(16, 185, 129, 0.14);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.25);
}

.stats-strip {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 4px 18px 8px;
}

.stat-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 5px 8px;
}

.stat-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-bar {
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.45s ease;
}

.fill-ember { background: linear-gradient(90deg, #f97316, #facc15); }
.fill-bond { background: linear-gradient(90deg, #c084fc, #f472b6); }
.fill-mood { background: linear-gradient(90deg, #22d3ee, #84ff5c); }

/* ==========================================================================
   ROTATING ORBITAL MENU (BEHIND THE DIABLILLO)
   ========================================================================== */
.orbital-menu-layer {
  position: absolute;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
  width: 268px;
  height: 268px;
  z-index: 8; /* Behind Imp (z-20) */
  pointer-events: auto;
}

.orbital-wheel {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.72s cubic-bezier(0.22, 1, 0.36, 1);
  transform: rotate(var(--wheel-rot, 0deg));
}

.orbital-ring-decor {
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  border: 1px dashed rgba(216, 178, 110, 0.32);
  box-shadow: inset 0 0 35px rgba(var(--glow-rgb), 0.14);
}

.orbital-node {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68px;
  height: 44px;
  margin: -22px 0 0 -34px;
  border-radius: 99px;
  border: 1px solid rgba(216, 178, 110, 0.3);
  background: rgba(15, 10, 26, 0.85);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  cursor: pointer;
  transform: rotate(var(--angle)) translateY(-112px) rotate(calc(-1 * var(--angle) - var(--wheel-rot, 0deg)));
  transition: border-color 0.3s, color 0.3s, background 0.3s, box-shadow 0.3s;
}

.orbital-node.active {
  border-color: var(--gold);
  color: #fff6df;
  background: rgba(35, 22, 58, 0.94);
  box-shadow: 0 0 18px rgba(var(--glow-rgb), 0.48);
}

.node-icon { font-size: 13px; }

/* ==========================================================================
   FOREGROUND DIABLILLO LAYER (IN FRONT OF MENU)
   ========================================================================== */
.imp-stage {
  position: absolute;
  top: 98px;
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  height: 240px;
  z-index: 20; /* Always in foreground over the orbital menu */
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: top 0.55s cubic-bezier(0.22, 1, 0.36, 1), transform 0.55s ease;
}

body.imp-sitting .imp-stage {
  top: 295px;
}

.imp-actor {
  position: relative;
  width: 216px;
  height: 216px;
  pointer-events: auto;
  cursor: grab;
  transform: scale(var(--imp-scale)) translate(var(--imp-x, 0px), var(--imp-y, 0px)) rotate(var(--imp-tilt, 0deg));
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.imp-actor:active {
  cursor: grabbing;
}

.imp-aura {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--glow-rgb), 0.42) 0%, rgba(var(--flame-rgb), 0.16) 50%, transparent 72%);
  filter: blur(18px);
  animation: pulseAura 3.5s ease-in-out infinite;
  pointer-events: none;
}

#imp-sprite {
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: lighten;
  animation: impBreathe 3.8s ease-in-out infinite;
  filter: drop-shadow(0 0 14px rgba(var(--glow-rgb), 0.4));
  pointer-events: none;
}

.imp-actor.happy #imp-sprite {
  animation: impHop 0.55s ease;
}

.imp-actor.purr #imp-sprite {
  filter: drop-shadow(0 0 24px rgba(var(--flame-rgb), 0.85));
}

.imp-reaction-badge {
  position: absolute;
  top: 118px;
  right: 18px;
  z-index: 40;
  padding: 6px 12px;
  border-radius: 99px;
  background: rgba(15, 10, 26, 0.92);
  border: 1px solid var(--gold);
  font-size: 12px;
  color: #fff6df;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  animation: fadeUp 0.25s ease;
}

/* ==========================================================================
   SCROLLABLE CONTENT SPACE (BELOW/INDEPENDENT OF IMP)
   ========================================================================== */
.content-viewport {
  position: relative;
  z-index: 14;
  flex: 1;
  margin-top: 238px;
  padding: 8px 16px 76px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.content-viewport::-webkit-scrollbar {
  width: 4px;
}
.content-viewport::-webkit-scrollbar-thumb {
  background: rgba(216, 178, 110, 0.28);
  border-radius: 99px;
}

.tab-panel {
  display: none;
  animation: fadeUp 0.35s ease;
}

.tab-panel.active {
  display: block;
}

.panel-header {
  margin-bottom: 12px;
}

.panel-header h2 {
  margin: 0 0 4px;
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 500;
  color: #fff4da;
}

.panel-desc, .imp-speech {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
}

.imp-speech {
  font-style: italic;
  color: #dfd0f6;
}

/* Care Cards */
.care-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.action-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: transform 0.16s ease, border-color 0.25s ease;
}

.action-card:active {
  transform: scale(0.96);
}

.action-card:hover {
  border-color: var(--border-gold);
}

.action-emoji {
  font-size: 20px;
  margin-bottom: 6px;
}

.action-card strong {
  font-size: 13.5px;
  margin-bottom: 2px;
}

.action-card small {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Commands */
.command-box {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 12px;
}

.section-mini-title {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
  margin-bottom: 8px;
}

.command-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  padding: 6px 10px;
  border-radius: 99px;
  border: 1px solid rgba(216, 178, 110, 0.28);
  background: rgba(255, 255, 255, 0.04);
  color: #efe4ff;
  font-size: 12px;
  cursor: pointer;
}

.chip:active {
  background: rgba(var(--glow-rgb), 0.25);
}

.command-form {
  display: flex;
  gap: 6px;
}

.command-form input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.btn-small {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-gold);
  background: rgba(216, 178, 110, 0.18);
  color: #fff4da;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ==========================================================================
   READING MODE (GRIMORIO) + DRAG & SCORCH EFFECTS
   ========================================================================== */
.reading-card {
  position: relative;
  z-index: 12;
  background: rgba(16, 11, 27, 0.86);
  border: 1px solid var(--border-gold);
  border-radius: 18px;
  padding: 14px;
  backdrop-filter: blur(8px);
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.4s ease;
}

.reading-card.dragged-away {
  transform: translateX(52%) rotate(5deg);
  box-shadow: -16px 14px 40px rgba(0, 0, 0, 0.65);
}

.reading-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.reading-card-header h2 {
  margin: 2px 0 0;
  font-family: Georgia, serif;
  font-size: 17px;
  color: #fff3d6;
}

.btn-restore {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid #facc15;
  background: rgba(250, 204, 21, 0.2);
  color: #fff8dc;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.reading-scroll {
  max-height: 215px;
  overflow-y: auto;
  padding-right: 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14.5px;
  line-height: 1.65;
  color: #e9dff6;
}

.reading-scroll p {
  margin: 0 0 12px;
}

.scorched-word {
  color: #2f1f1a;
  background: linear-gradient(180deg, rgba(249, 115, 22, 0.55), rgba(124, 45, 18, 0.72));
  text-shadow: 0 0 8px #ff6b00;
  border-radius: 4px;
  padding: 0 3px;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.5);
  transition: all 0.5s ease;
}

.reading-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.reading-status {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-ghost-xs {
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--gold);
  font-size: 11px;
  cursor: pointer;
}

/* Behind-text streak (< 1 second) */
.behind-text-streak {
  position: absolute;
  top: 70px;
  left: -140px;
  width: 130px;
  height: 130px;
  z-index: 9; /* Behind reading card text */
  pointer-events: none;
  display: flex;
  align-items: center;
}

.behind-text-streak img {
  width: 110px;
  height: 110px;
  object-fit: contain;
  mix-blend-mode: screen;
  opacity: 0.78;
  filter: blur(1px) brightness(1.3);
}

.behind-text-streak .streak-wake {
  position: absolute;
  right: 40px;
  width: 180px;
  height: 44px;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, rgba(240, 224, 255, 0.55), rgba(var(--flame-rgb), 0.75));
  filter: blur(10px);
}

.behind-text-streak.running {
  animation: streakDash 0.75s cubic-bezier(0.18, 0.89, 0.32, 1) forwards;
}

/* ==========================================================================
   CHARACTER & STAGES TAB
   ========================================================================== */
.stage-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.stage-btn {
  padding: 9px 4px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stage-btn strong { font-size: 12px; }
.stage-btn span { font-size: 10px; color: var(--text-muted); }

.stage-btn.active {
  border-color: var(--gold);
  background: rgba(216, 178, 110, 0.16);
}

.traits-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 12px;
}

.trait-row {
  display: grid;
  grid-template-columns: 116px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #e6dcf5;
}

.trait-track {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.trait-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  transition: width 0.45s ease;
}

.trait-summary {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--gold);
  line-height: 1.4;
}

/* ==========================================================================
   MISCHIEF LAB TAB
   ========================================================================== */
.mischief-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mischief-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 11px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.mischief-btn:hover { border-color: var(--gold); }
.mischief-btn:active { transform: scale(0.96); }
.mischief-btn strong { font-size: 12.5px; margin-bottom: 3px; }
.mischief-btn small { font-size: 10.5px; color: var(--text-muted); line-height: 1.3; }

/* ==========================================================================
   BOTTOM NAV
   ========================================================================== */
.bottom-nav {
  position: absolute;
  bottom: 12px;
  left: 14px;
  right: 14px;
  z-index: 35;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(12, 8, 22, 0.92);
  border: 1px solid var(--border-gold);
  backdrop-filter: blur(12px);
}

.nav-pill {
  border: none;
  border-radius: 12px;
  padding: 8px 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.25s, color 0.25s;
}

.nav-pill.active {
  background: rgba(var(--glow-rgb), 0.28);
  color: #fff6df;
}

/* ==========================================================================
   GLASS OVERLAYS (TAPS, KISS, PEEK)
   ========================================================================== */
.glass-overlay {
  position: absolute;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  overflow: hidden;
}

.glass-paw {
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.45);
  opacity: 0;
  filter: drop-shadow(0 0 22px rgba(var(--flame-rgb), 0.75));
}

.glass-paw.tapping {
  animation: pawTapGlass 1.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.glass-ripple {
  position: absolute;
  top: 45%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.75);
  opacity: 0;
}

.glass-paw.tapping .r1 { animation: glassRipple 0.6s ease-out 0.42s 1; }
.glass-paw.tapping .r2 { animation: glassRipple 0.6s ease-out 0.96s 1; }

.glass-kiss {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  opacity: 0;
  filter: drop-shadow(0 0 24px rgba(192, 132, 252, 0.9));
}

.glass-kiss.kissing {
  animation: kissPrintFade 7.5s ease-out forwards;
}

.glass-peek {
  position: absolute;
  top: 48%;
  right: -135px;
  width: 150px;
  height: 150px;
  transform: rotate(-18deg);
  transition: right 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.glass-peek.visible {
  right: -46px;
}

.glass-peek img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: lighten;
}

.play-banner {
  position: absolute;
  top: 64px;
  left: 16px;
  right: 16px;
  z-index: 90;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(15, 10, 26, 0.96);
  border: 1px solid var(--gold);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  font-size: 12.5px;
  color: #fff4d8;
}

/* ==========================================================================
   KEYFRAMES
   ========================================================================== */
@keyframes pulseAura {
  0%, 100% { transform: scale(0.95); opacity: 0.72; }
  50% { transform: scale(1.08); opacity: 1; }
}

@keyframes floatSlow {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-9px); }
}

@keyframes impBreathe {
  0%, 100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-7px) scale(1.025); }
}

@keyframes impHop {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-22px) scale(1.08) rotate(-4deg); }
  70% { transform: translateY(4px) scale(0.96) rotate(3deg); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes coalShake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-8px) rotate(-4deg); }
  40% { transform: translateX(8px) rotate(4deg); }
  60% { transform: translateX(-6px) rotate(-2deg); }
  80% { transform: translateX(6px) rotate(2deg); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes streakDash {
  0% { transform: translateX(0) scaleX(1.1); opacity: 0; }
  15% { opacity: 0.95; }
  85% { opacity: 0.85; }
  100% { transform: translateX(580px) scaleX(1.25); opacity: 0; }
}

@keyframes pawTapGlass {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.42); }
  18%  { opacity: 0.96; transform: translate(-50%, -50%) scale(1.24); }
  26%  { opacity: 1; transform: translate(-50%, -50%) scale(1.38); }
  38%  { opacity: 0.9; transform: translate(-50%, -50%) scale(0.98); }
  50%  { opacity: 1; transform: translate(-50%, -50%) scale(1.44); }
  65%  { opacity: 0.88; transform: translate(-50%, -50%) scale(1.06); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
}

@keyframes glassRipple {
  0% { transform: scale(0.4); opacity: 0.95; }
  100% { transform: scale(5.4); opacity: 0; }
}

@keyframes kissPrintFade {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.55); }
  8%   { opacity: 1; transform: translate(-50%, -50%) scale(1.18); }
  15%  { opacity: 0.96; transform: translate(-50%, -50%) scale(1.08); }
  74%  { opacity: 0.74; transform: translate(-50%, -50%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.12); }
}

@keyframes paperCrumpleThrow {
  0% {
    transform: translate(0, 0) scale(1, 1) rotate(0deg) skew(0deg);
    border-radius: 18px;
    filter: brightness(1);
    opacity: 1;
  }
  18% {
    transform: translate(0, -8px) scale(0.84, 0.78) rotate(-5deg) skew(6deg, -4deg);
    border-radius: 26px;
    filter: brightness(1.12) contrast(1.15);
  }
  38% {
    transform: translate(8px, -18px) scale(0.52, 0.48) rotate(14deg) skew(-10deg, 8deg);
    border-radius: 42%;
    filter: brightness(1.2) contrast(1.3);
  }
  58% {
    transform: translate(-12px, -24px) scale(0.28, 0.28) rotate(-28deg) skew(8deg, -6deg);
    border-radius: 48%;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.8), inset 0 0 22px rgba(249, 115, 22, 0.55);
    opacity: 1;
  }
  100% {
    transform: translate(290px, -210px) scale(0.18, 0.18) rotate(520deg);
    border-radius: 50%;
    opacity: 0;
  }
}

@keyframes paperRollOut {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
  16% {
    transform: translate(24px, -6px) rotate(6deg) scale(0.98);
  }
  42% {
    transform: translate(115px, 14px) rotate(36deg) scale(0.92);
    opacity: 0.96;
  }
  75% {
    transform: translate(275px, 60px) rotate(140deg) scale(0.82);
    opacity: 0.85;
  }
  100% {
    transform: translate(430px, 110px) rotate(260deg) scale(0.72);
    opacity: 0;
  }
}

@keyframes pageRestoreUnfurl {
  0% { opacity: 0; transform: scale(0.94) translateY(8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
