/* ==========================================================================
   AETHERIA II: THE WHISPERING SPIRES — VISUAL SYSTEM & CORE STYLES
   Dark-Romantasy Interactive RPG Journal PWA (Exact Architectural Parity with Book 1)
   Palette: Rose Gold (#e0a899), Velvet Crimson (#881337) & Imperial Gold (#c9a227)
   ========================================================================== */

/* --- Custom Properties / Design Tokens --- */
:root {
  --bg: #0a0a0f;
  --bg-card: rgba(16, 14, 24, 0.92);
  --bg-card-solid: #12101a;
  --bg-overlay: linear-gradient(180deg, rgba(10, 8, 15, 0.45) 0%, rgba(10, 8, 15, 0.90) 100%);
  
  /* Gold & Rose Gold Accents */
  --gold: #c9a227;
  --gold-light: #e5c358;
  --gold-dim: rgba(201, 162, 39, 0.25);
  --gold-glow: rgba(201, 162, 39, 0.65);
  --border-gold: rgba(201, 162, 39, 0.35);

  --rose-gold: #e0a899;
  --rose-gold-light: #f5d0c5;
  --rose-gold-dark: #b7796a;
  --rose-gold-border: rgba(224, 168, 153, 0.45);
  --rose-gold-glow: rgba(224, 168, 153, 0.65);

  /* Crimson & Velvet */
  --crimson: #881337;
  --crimson-deep: #4c0519;
  --crimson-glow: rgba(136, 19, 55, 0.7);
  --blood: #7a1f2b;
  --blood-glow: rgba(122, 31, 43, 0.7);

  /* Ivory Text */
  --ivory: #f5ede8;
  --ivory-muted: rgba(245, 237, 232, 0.74);

  /* Character Affinities */
  --julian: #5c1f2e;
  --julian-glow: rgba(92, 31, 46, 0.7);
  --kaelen: #3a4a5c;
  --kaelen-glow: rgba(58, 74, 92, 0.7);
  --lyra: #8fb3c9;
  --lyra-glow: rgba(143, 179, 201, 0.7);
  --morvath: #991b1b;
  --morvath-glow: rgba(153, 27, 27, 0.75);

  /* Typography */
  --font-display: 'Cinzel', serif;
  --font-body: 'EB Garamond', 'Crimson Text', serif;

  --transition-screen: opacity 400ms ease;
  --transition-meter: width 600ms cubic-bezier(0.4, 0, 0.2, 1);
  --safe-top: env(safe-area-inset-top, 16px);
  --safe-bottom: env(safe-area-inset-bottom, 20px);
}

/* --- Base & Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100%;
  background-color: var(--bg);
  color: var(--ivory);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* --- Ember Particle Canvas --- */
#ember-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

/* --- Background Image Layer --- */
.bg-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: opacity 800ms ease-in-out, filter 800ms ease;
  opacity: 0.34;
  filter: brightness(0.68) contrast(1.15);
  pointer-events: none;
}

.bg-spires {
  background-image: var(--bg-overlay), url('assets/img/spires-campus.jpg'), radial-gradient(circle at 50% 20%, #1e1828 0%, #0a0a0f 80%);
}
.bg-observatory {
  background-image: var(--bg-overlay), url('assets/img/astral-observatory.jpg'), radial-gradient(circle at 50% 20%, #19142b 0%, #0a0a0f 80%);
}
.bg-conservatory {
  background-image: var(--bg-overlay), url('assets/img/poison-conservatory.jpg'), radial-gradient(circle at 50% 40%, #12241a 0%, #0a0a0f 85%);
}
.bg-cloisters {
  background-image: var(--bg-overlay), url('assets/img/dueling-cloisters.jpg'), radial-gradient(circle at 50% 40%, #291016 0%, #0a0a0f 85%);
}
.bg-reliquary {
  background-image: var(--bg-overlay), url('assets/img/sunken-reliquary.jpg'), radial-gradient(circle at 50% 50%, #0e1a22 0%, #0a0a0f 85%);
}
.bg-gala {
  background-image: var(--bg-overlay), url('assets/img/masquerade-ball.jpg'), radial-gradient(circle at 50% 30%, #22142a 0%, #0a0a0f 80%);
}
.bg-burning {
  background-image: var(--bg-overlay), url('assets/img/burning-spires.jpg'), radial-gradient(circle at 50% 30%, #301416 0%, #0a0a0f 80%);
}

/* --- Top Utility Bar (Audio & Install) --- */
.top-controls {
  position: fixed;
  top: var(--safe-top);
  right: 16px;
  z-index: 30;
  display: flex;
  gap: 12px;
  align-items: center;
}

.icon-btn {
  background: rgba(16, 14, 24, 0.88);
  border: 1px solid var(--border-gold);
  color: var(--gold);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: transform 150ms ease, border-color 200ms ease, box-shadow 200ms ease;
}

.icon-btn:hover, .icon-btn:focus-visible {
  transform: scale(1.05);
  border-color: var(--rose-gold);
  color: var(--rose-gold-light);
  box-shadow: 0 0 10px var(--rose-gold-glow);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* --- Progressive HUD --- */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(180deg, rgba(10, 8, 15, 0.98) 0%, rgba(10, 8, 15, 0.88) 80%, transparent 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 25;
  padding: calc(var(--safe-top) + 4px) 16px 12px;
  border-bottom: 1px solid rgba(224, 168, 153, 0.2);
  display: none;
  flex-direction: column;
  gap: 8px;
}

#hud.active {
  display: flex;
}

.hud-player-info {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--gold-light);
  text-transform: uppercase;
  padding-right: 52px; /* keep clear of the fixed audio toggle in .top-controls */
  row-gap: 2px;
  column-gap: 10px;
}

.hud-player-info span {
  min-width: 0;
}

@media (min-width: 420px) {
  .hud-player-info { font-size: 0.82rem; flex-wrap: nowrap; }
}

.hud-meters-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 14px;
}

@media (min-width: 600px) {
  .hud-meters-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.meter-wrapper {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.meter-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-family: var(--font-display);
  color: var(--ivory-muted);
  letter-spacing: 0.05em;
}

.meter-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

.meter-bar {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  transition: var(--transition-meter);
}

.meter-astral .meter-bar {
  background: linear-gradient(90deg, #c9a227, #f7df83);
  box-shadow: 0 0 8px var(--gold-dim);
}
.meter-astral.danger .meter-bar {
  background: linear-gradient(90deg, #881337, #e11d48);
  box-shadow: 0 0 10px var(--crimson-glow);
}
.meter-reputation .meter-bar {
  background: linear-gradient(90deg, #b7796a, #f5d0c5);
  box-shadow: 0 0 8px var(--rose-gold-glow);
}
.meter-morvath .meter-bar {
  background: linear-gradient(90deg, #991b1b, #ef4444);
  box-shadow: 0 0 8px var(--morvath-glow);
}
.meter-julian .meter-bar {
  background: linear-gradient(90deg, var(--julian), #a83654);
  box-shadow: 0 0 8px var(--julian-glow);
}
.meter-kaelen .meter-bar {
  background: linear-gradient(90deg, var(--kaelen), #627e9e);
  box-shadow: 0 0 8px var(--kaelen-glow);
}
.meter-lyra .meter-bar {
  background: linear-gradient(90deg, var(--lyra), #d0e7f7);
  box-shadow: 0 0 8px var(--lyra-glow);
}

/* Unlock Glow Pulse */
.pulse-glow-gold {
  animation: pulseGold 1.2s ease-in-out 3;
}
.pulse-glow-silver {
  animation: pulseSilver 1.2s ease-in-out 3;
}

@keyframes pulseGold {
  0%, 100% {
    box-shadow: 0 0 4px rgba(224, 168, 153, 0.2);
    border-color: rgba(224, 168, 153, 0.4);
  }
  50% {
    box-shadow: 0 0 18px var(--rose-gold-glow), 0 0 28px rgba(136, 19, 55, 0.5);
    border-color: var(--rose-gold);
  }
}

@keyframes pulseSilver {
  0%, 100% {
    box-shadow: 0 0 4px rgba(143, 179, 201, 0.2);
    border-color: rgba(143, 179, 201, 0.4);
  }
  50% {
    box-shadow: 0 0 18px var(--lyra-glow), 0 0 28px rgba(143, 179, 201, 0.5);
    border-color: var(--lyra);
  }
}

/* --- Screen Container & State Machine --- */
#app {
  position: relative;
  z-index: 10;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: calc(var(--safe-top) + 20px) 16px calc(var(--safe-bottom) + 40px);
}

body.has-hud-active #app {
  /* All 3 bond meters (Julian/Kaelen/Lyra) unlock together right after the
     companion is chosen, so the HUD is routinely 3 rows tall (2-col grid)
     on phones — not just astral/composure/morvath. Undersizing this padding
     let the fixed HUD visually and functionally cover the top of every
     screen beneath it (e.g. the map hub's Sector 1 pin became unclickable).
     --hud-live-height is measured and kept in sync by game.js; the 200px
     literal is only the fallback for the instant before that first runs. */
  padding-top: calc(var(--safe-top) + var(--hud-live-height, 200px) + 20px);
}

.screen {
  opacity: 0;
  transition: var(--transition-screen);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  max-width: 680px;
  margin: auto auto;
  padding: 10px 0 24px;
}

.screen.active {
  display: flex;
  opacity: 1;
}

.screen.hidden {
  display: none !important;
  opacity: 0 !important;
}

/* Card Panel Container */
.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.8), inset 0 0 24px rgba(224, 168, 153, 0.05);
  padding: 28px 20px;
  width: 100%;
  position: relative;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

@media (min-width: 520px) {
  .card-panel {
    padding: 36px 30px;
  }
}

.card-panel::before, .card-panel::after {
  content: '❖';
  position: absolute;
  color: var(--rose-gold);
  font-size: 11px;
  opacity: 0.6;
}
.card-panel::before { top: 8px; left: 10px; }
.card-panel::after { bottom: 8px; right: 10px; }

/* --- Scenic Illustration Banners --- */
.scene-banner-frame {
  width: 100%;
  height: 200px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(224, 168, 153, 0.4);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7), inset 0 0 20px rgba(0, 0, 0, 0.8);
  margin-bottom: 20px;
  cursor: zoom-in;
}

@media (min-width: 520px) {
  .scene-banner-frame {
    height: 240px;
  }
}

.scene-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: brightness(0.9) contrast(1.1);
  transition: transform 600ms ease;
}

.scene-banner-frame:hover .scene-banner-img {
  transform: scale(1.03);
}

.scene-banner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, rgba(10, 8, 15, 0.15) 0%, rgba(10, 8, 15, 0.7) 100%);
  pointer-events: none;
}

/* --- Solo RPG Character Encounter Cards --- */
.character-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(18, 14, 26, 0.85);
  border: 1px solid rgba(224, 168, 153, 0.3);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

@media (min-width: 520px) {
  .character-card {
    flex-direction: row;
    align-items: center;
    padding: 18px;
  }
}

.character-portrait-frame {
  width: 120px;
  height: 160px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--rose-gold);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7), 0 0 10px var(--rose-gold-glow);
  margin: 0 auto;
  cursor: zoom-in;
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.character-portrait-frame:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 20px var(--rose-gold-glow);
}

.character-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 400ms ease;
}

.character-card:hover .character-portrait-img {
  transform: scale(1.05);
}

.character-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.character-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--rose-gold-light);
  letter-spacing: 0.06em;
}

.character-title {
  font-size: 0.84rem;
  font-family: var(--font-display);
  color: var(--ivory-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.character-quote {
  font-style: italic;
  font-size: 0.98rem;
  color: var(--ivory);
  line-height: 1.5;
  border-left: 2px solid var(--rose-gold);
  padding-left: 10px;
  margin-top: 4px;
}

/* Character Specific Border Glows */
.card-julian { border-color: rgba(92, 31, 46, 0.8); }
.card-julian .character-portrait-frame { border-color: var(--julian); box-shadow: 0 0 14px var(--julian-glow); }
.card-kaelen { border-color: rgba(58, 74, 92, 0.8); }
.card-kaelen .character-portrait-frame { border-color: var(--kaelen); box-shadow: 0 0 14px var(--kaelen-glow); }
.card-lyra { border-color: rgba(143, 179, 201, 0.8); }
.card-lyra .character-portrait-frame { border-color: var(--lyra); box-shadow: 0 0 14px var(--lyra-glow); }
.card-morvath { border-color: rgba(153, 27, 27, 0.8); }
.card-morvath .character-portrait-frame { border-color: var(--morvath); box-shadow: 0 0 14px var(--morvath-glow); }

/* --- Protagonist Avatar Selection Grid --- */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  margin: 16px 0 20px;
}

@media (min-width: 540px) {
  .avatar-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.avatar-card {
  background: rgba(14, 13, 20, 0.85);
  border: 1px solid rgba(224, 168, 153, 0.25);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  transition: all 200ms ease;
}

.avatar-card:hover {
  border-color: var(--rose-gold);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6), 0 0 12px var(--rose-gold-glow);
}

.avatar-card.selected {
  border-color: var(--rose-gold-light);
  background: rgba(36, 28, 42, 0.95);
  box-shadow: 0 0 18px var(--rose-gold-glow);
  transform: scale(1.02);
}

.avatar-card-frame {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(224, 168, 153, 0.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.avatar-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 300ms ease;
}

.avatar-card:hover .avatar-card-img {
  transform: scale(1.05);
}

.avatar-card-name {
  font-family: var(--font-display);
  font-size: 0.82rem;
  color: var(--rose-gold-light);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.avatar-card-tag {
  font-size: 0.74rem;
  color: var(--ivory-muted);
}

.avatar-zoom-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(10, 8, 15, 0.78);
  border: 1px solid var(--border-gold);
  border-radius: 50%;
  color: var(--rose-gold-light);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: all 180ms ease;
}

.avatar-zoom-btn:hover { background: rgba(224, 168, 153, 0.25); border-color: var(--rose-gold); }

/* Selected Avatar Preview (Step 4 & Grimoire) */
.selected-avatar-frame {
  width: 140px;
  height: 186px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--rose-gold);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7), 0 0 16px var(--rose-gold-glow);
  margin: 0 auto 16px;
  cursor: zoom-in;
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.selected-avatar-frame:hover {
  transform: scale(1.03);
  box-shadow: 0 0 20px var(--rose-gold-glow);
}

.selected-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

/* --- Fullscreen Image Lightbox Modal --- */
.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 250ms ease;
}

.lightbox-modal.active {
  display: flex;
  opacity: 1;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 5, 10, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.lightbox-container {
  position: relative;
  z-index: 2;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: lightboxPop 250ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes lightboxPop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.lightbox-frame {
  border: 1px solid var(--rose-gold);
  box-shadow: 0 0 35px rgba(224, 168, 153, 0.35), 0 24px 60px rgba(0, 0, 0, 0.95);
  border-radius: 8px;
  overflow: hidden;
  background: #0e0d16;
  display: flex;
  flex-direction: column;
}

.lightbox-frame img {
  max-width: min(88vw, 680px);
  max-height: 72vh;
  object-fit: contain;
  display: block;
}

.lightbox-caption {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--rose-gold-light);
  text-align: center;
  padding: 12px 18px;
  background: rgba(16, 14, 24, 0.98);
  border-top: 1px solid rgba(224, 168, 153, 0.25);
  letter-spacing: 0.04em;
}

.lightbox-close-btn {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 36px;
  height: 36px;
  background: var(--rose-gold);
  color: #0a080f;
  border: 1px solid #ffffff;
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  transition: transform 150ms ease, background 150ms ease;
}

.lightbox-close-btn:hover {
  transform: scale(1.12);
  background: var(--rose-gold-light);
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--rose-gold);
  text-align: center;
  letter-spacing: 0.08em;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  font-size: 2.1rem;
  line-height: 1.2;
  margin-bottom: 8px;
  text-shadow: 0 2px 14px rgba(224, 168, 153, 0.35);
}

h2 {
  font-size: 1.45rem;
  margin-bottom: 16px;
  color: var(--rose-gold-light);
}

h3 {
  font-size: 1.15rem;
  margin-bottom: 12px;
}

.subtitle {
  font-size: 0.92rem;
  letter-spacing: 0.18em;
  color: var(--ivory-muted);
  text-align: center;
  margin-bottom: 20px;
  text-transform: uppercase;
  font-family: var(--font-display);
}

p {
  margin-bottom: 16px;
  font-size: 1.06rem;
  color: var(--ivory);
}

.lead-text {
  font-size: 1.18rem;
  font-style: italic;
  text-align: center;
  line-height: 1.7;
  color: #f7f1ea;
  margin-bottom: 24px;
}

.divider {
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--rose-gold), transparent);
  margin: 18px auto;
}

/* Runic Shimmer Effect */
@keyframes arcaneShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.arcane-shimmer-active {
  background: linear-gradient(90deg, var(--rose-gold-dark) 0%, var(--rose-gold-light) 35%, #fff 50%, var(--rose-gold) 65%, var(--rose-gold-dark) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: arcaneShimmer 4s ease-in-out infinite;
}

/* --- Buttons & Inputs --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 24px;
  font-family: var(--font-display);
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  color: #0b080f;
  background: linear-gradient(135deg, #f5d0c5 0%, #e0a899 50%, #b7796a 100%);
  border: 1px solid #ffe3dc;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), 0 0 12px var(--rose-gold-glow);
  transition: transform 150ms ease, box-shadow 200ms ease, filter 150ms ease;
  width: 100%;
  max-width: 380px;
  margin: 8px auto;
  font-weight: 700;
}

.btn:hover, .btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(224, 168, 153, 0.55);
  filter: brightness(1.08);
}

.btn:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: rgba(16, 14, 24, 0.85);
  color: var(--ivory);
  border: 1px solid rgba(224, 168, 153, 0.4);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.btn-secondary:hover, .btn-secondary:focus-visible {
  border-color: var(--rose-gold);
  color: var(--rose-gold-light);
  box-shadow: 0 0 15px var(--rose-gold-glow);
}

.btn-blood {
  background: linear-gradient(135deg, #a8233a 0%, var(--crimson) 100%);
  border-color: #e11d48;
  color: #fff;
}

.btn:disabled, .btn.disabled {
  opacity: 0.35 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  box-shadow: none !important;
  filter: grayscale(0.8) !important;
  transform: none !important;
}

/* Choice Buttons Stack */
.choices-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 18px;
}

.choice-btn {
  background: rgba(16, 14, 24, 0.92);
  border: 1px solid rgba(224, 168, 153, 0.3);
  border-radius: 6px;
  padding: 14px 18px;
  color: var(--ivory);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: all 180ms ease;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.choice-btn:hover, .choice-btn:focus-visible {
  border-color: var(--rose-gold);
  background: rgba(32, 24, 40, 0.95);
  transform: translateX(4px);
  box-shadow: 0 4px 16px rgba(224, 168, 153, 0.2);
}

.choice-title {
  font-family: var(--font-display);
  font-size: 0.92rem;
  color: var(--rose-gold-light);
  letter-spacing: 0.05em;
}

.choice-consequence {
  font-size: 0.85rem;
  color: var(--ivory-muted);
  font-style: italic;
}

.order-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-family: var(--font-display);
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(224, 168, 153, 0.15);
  border: 1px solid rgba(224, 168, 153, 0.4);
  color: var(--rose-gold-light);
  margin-bottom: 4px;
  width: fit-content;
}

/* Input Styles */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-bottom: 20px;
}

.input-label {
  font-family: var(--font-display);
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  color: var(--rose-gold-light);
  text-transform: uppercase;
}

.text-input, .select-input, .textarea-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  background: rgba(10, 8, 15, 0.85);
  border: 1px solid rgba(224, 168, 153, 0.4);
  border-radius: 4px;
  color: var(--ivory);
  font-family: var(--font-body);
  font-size: 1.05rem;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.text-input:focus, .select-input:focus, .textarea-input:focus {
  outline: none;
  border-color: var(--rose-gold);
  box-shadow: 0 0 12px var(--rose-gold-glow);
}

.textarea-input {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

/* Option Cards */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
  margin: 16px 0 24px;
}

@media (min-width: 520px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.selection-card {
  background: rgba(14, 12, 20, 0.85);
  border: 1px solid rgba(224, 168, 153, 0.25);
  border-radius: 6px;
  padding: 16px;
  cursor: pointer;
  transition: all 200ms ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.selection-card:hover {
  border-color: var(--rose-gold);
  transform: translateY(-2px);
  background: rgba(26, 20, 32, 0.95);
}

.selection-card.selected {
  border-color: var(--rose-gold);
  background: rgba(40, 26, 42, 0.95);
  box-shadow: 0 0 16px var(--rose-gold-glow);
}

.selection-card .card-name {
  font-family: var(--font-display);
  font-size: 0.98rem;
  color: var(--rose-gold-light);
  letter-spacing: 0.05em;
}

.selection-card .card-desc {
  font-size: 0.88rem;
  color: var(--ivory-muted);
  line-height: 1.4;
}

/* --- Typewriter Container --- */
.typewriter-text {
  cursor: pointer;
  position: relative;
  user-select: none;
}

.tap-to-skip {
  display: block;
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--ivory-muted);
  margin-top: 10px;
  font-family: var(--font-display);
  opacity: 0.6;
}

/* --- Rose Ink Bleed & Typewriter Animations --- */
.rose-ink-char {
  display: inline-block;
  opacity: 0;
  animation: roseInkBleed 340ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity, filter, color;
}

@keyframes roseInkBleed {
  0% {
    opacity: 0;
    color: #fb7185;
    text-shadow: 0 0 10px #f43f5e, 0 0 18px rgba(244, 63, 94, 0.7);
    transform: translateY(2.5px) scale(1.08);
    filter: blur(1.8px);
  }
  45% {
    opacity: 0.95;
    color: #fda4af;
    text-shadow: 0 0 6px rgba(244, 63, 94, 0.4), 0 0 12px rgba(224, 168, 153, 0.6);
    transform: translateY(-0.5px) scale(1.02);
    filter: blur(0.4px);
  }
  100% {
    opacity: 1;
    color: var(--ivory);
    text-shadow: none;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

.rose-ink-shimmer {
  background: linear-gradient(90deg, #f43f5e 0%, #fda4af 25%, #fff 50%, #e0a899 75%, #f43f5e 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: roseInkShimmer 3.5s linear infinite;
}

@keyframes roseInkShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Common Minigame Feedback */
.minigame-feedback {
  font-family: var(--font-display);
  font-size: 0.98rem;
  letter-spacing: 0.06em;
  min-height: 28px;
  text-align: center;
  margin: 12px 0;
}

.feedback-success {
  color: #34d399;
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.6);
}

.feedback-fail {
  color: #f43f5e;
  text-shadow: 0 0 10px rgba(244, 63, 94, 0.6);
}

/* ==========================================================================
   MINIJUEGO 1 (CAPÍTULO 4): ALQUIMIA DE SANGRE ANÓMALA
   ========================================================================== */
.alch-workbench {
  width: 100%;
  background: rgba(14, 11, 18, 0.92);
  border: 1px solid var(--rose-gold-border);
  border-radius: 8px;
  padding: 20px;
  margin: 16px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}

.alch-vials-row {
  display: flex;
  justify-content: space-around;
  gap: 12px;
  margin-bottom: 20px;
}

.alch-vial-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.alch-tube {
  width: 42px;
  height: 120px;
  border: 2px solid rgba(224, 168, 153, 0.6);
  border-top: none;
  border-radius: 0 0 21px 21px;
  background: rgba(8, 6, 12, 0.85);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 12px rgba(0,0,0,0.9);
}

.alch-liquid {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  transition: height 300ms ease;
  border-radius: 0 0 19px 19px;
}

.alch-liquid.belladonna {
  background: linear-gradient(180deg, #a855f7, #6b21a8);
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.6);
}

.alch-liquid.phoenix {
  background: linear-gradient(180deg, #f43f5e, #9f1239);
  box-shadow: 0 0 14px rgba(244, 63, 94, 0.6);
}

.alch-liquid.mercury {
  background: linear-gradient(180deg, #38bdf8, #0369a1);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.6);
}

.alch-vial-name {
  font-family: var(--font-display);
  font-size: 0.72rem;
  color: var(--rose-gold-light);
  letter-spacing: 0.05em;
  text-align: center;
}

.alch-controls-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.alch-slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.alch-slider-label {
  font-size: 0.85rem;
  color: var(--ivory-muted);
  width: 110px;
}

.alch-range {
  flex: 1;
  accent-color: var(--rose-gold);
}

.alch-ph-box {
  margin: 18px 0 12px;
  background: rgba(10, 8, 14, 0.8);
  border: 1px solid rgba(224, 168, 153, 0.3);
  border-radius: 6px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.alch-ph-val {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: #34d399;
}

/* ==========================================================================
   MINIJUEGO 2 (CAPÍTULO 5): DUELO TÁCTICO DE CONTRAMAGIA
   ========================================================================== */
.duel-arena {
  width: 100%;
  max-width: 680px;
  margin: 20px auto;
  background: rgba(14, 11, 18, 0.94);
  border: 1px solid var(--rose-gold-border);
  border-radius: 8px;
  padding: 24px 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.7);
  text-align: center;
}

.duel-health-grid {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.duel-combatant-card {
  flex: 1;
  background: rgba(22, 14, 28, 0.85);
  border: 1px solid rgba(224, 168, 153, 0.3);
  border-radius: 6px;
  padding: 14px 12px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.duel-combatant-name {
  font-family: var(--font-display);
  font-size: 0.88rem;
  color: var(--rose-gold-light);
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  display: block;
}

.duel-hp-track {
  width: 100%;
  height: 12px;
  background: rgba(0,0,0,0.7);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(224, 168, 153, 0.35);
  margin-bottom: 6px;
}

.duel-hp-bar {
  height: 100%;
  transition: width 350ms ease;
}

.duel-hp-bar.bar-player {
  background: linear-gradient(90deg, #e11d48, #10b981);
}

.duel-hp-bar.bar-enemy {
  background: linear-gradient(90deg, #881337, #ef4444);
}

.duel-hp-txt {
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--ivory-muted);
}

.duel-dice-strip {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 20px 0;
}

.duel-die {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: radial-gradient(circle, #2a1624 20%, #120b15 100%);
  border: 2px solid var(--rose-gold);
  color: var(--rose-gold-light);
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.6);
  transition: transform 300ms ease, border-color 200ms ease;
}

.duel-die.rolling {
  animation: dieRollShake 500ms ease;
}

@keyframes dieRollShake {
  0% { transform: rotate(0deg) scale(0.9); }
  25% { transform: rotate(45deg) scale(1.1); }
  50% { transform: rotate(-30deg) scale(0.95); }
  75% { transform: rotate(15deg) scale(1.05); }
  100% { transform: rotate(0deg) scale(1); }
}

.duel-actions-strip {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 18px 0 10px;
}

/* ==========================================================================
   MINIJUEGO 3 (CAPÍTULO 6): GANZÚA ARCANA CONCÉNTRICA (RUNIC LOCKPICK)
   ========================================================================== */
.lock-stage {
  width: 100%;
  max-width: 680px;
  margin: 20px auto;
  background: rgba(14, 11, 18, 0.94);
  border: 1px solid var(--rose-gold-border);
  border-radius: 8px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.7);
}

.lock-rings-viewport {
  position: relative;
  width: 300px;
  height: 300px;
  margin: 26px auto;
  background: radial-gradient(circle, rgba(26, 16, 32, 0.95), rgba(10, 7, 14, 0.98));
  border-radius: 50%;
  border: 2px solid var(--rose-gold-border);
  box-shadow: inset 0 0 35px rgba(0,0,0,0.9), 0 8px 24px rgba(0,0,0,0.6);
  overflow: visible;
}

.lock-alignment-pin {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  color: #f43f5e;
  font-size: 1.4rem;
  z-index: 25;
  text-shadow: 0 0 10px #f43f5e, 0 0 20px rgba(244, 63, 94, 0.8);
  cursor: default;
  pointer-events: none;
}

.lock-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  border: 2px dashed rgba(224, 168, 153, 0.5);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  transition: transform 380ms cubic-bezier(0.2, 0.8, 0.2, 1), border-color 250ms ease, box-shadow 250ms ease;
}

.lock-ring-outer {
  width: 270px;
  height: 270px;
  margin: -135px 0 0 -135px;
  border-color: rgba(224, 168, 153, 0.65);
}

.lock-ring-mid {
  width: 190px;
  height: 190px;
  margin: -95px 0 0 -95px;
  border-color: rgba(244, 63, 94, 0.65);
}

.lock-ring-inner {
  width: 110px;
  height: 110px;
  margin: -55px 0 0 -55px;
  border-color: rgba(56, 189, 248, 0.65);
}

.lock-ring.aligned {
  border-style: solid;
  border-color: #34d399 !important;
  box-shadow: 0 0 18px rgba(52, 211, 153, 0.6);
}

.lock-glyph-notch {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #18111e;
  border: 2px solid var(--rose-gold);
  color: var(--rose-gold-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: bold;
  box-shadow: 0 0 8px rgba(224, 168, 153, 0.6);
  z-index: 10;
  transition: all 250ms ease;
}

.lock-ring.aligned .lock-glyph-notch {
  background: #064e3b;
  border-color: #34d399;
  color: #a7f3d0;
  box-shadow: 0 0 14px #34d399;
}

.lock-center-sigil {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.8rem;
  color: var(--rose-gold);
  text-shadow: 0 0 14px rgba(224, 168, 153, 0.8);
  z-index: 5;
  pointer-events: none;
}

.lock-controls-grid {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  max-width: 520px;
  margin: 18px 0 10px;
}

.lock-rotate-btn {
  flex: 1;
  min-width: 140px;
  padding: 10px 14px;
}

.lock-resonance-meter-box {
  width: 100%;
  max-width: 440px;
  margin-top: 14px;
}

/* ==========================================================================
   MINIJUEGO 4 (CAPÍTULO 7): BAILE DE MÁSCARAS (VALS DE ENGAÑO)
   ========================================================================== */
.waltz-ballroom {
  width: 100%;
  max-width: 680px;
  margin: 20px auto;
  background: rgba(14, 11, 18, 0.94);
  border: 1px solid var(--rose-gold-border);
  border-radius: 8px;
  padding: 24px 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.7);
}

.waltz-meters-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.waltz-cards-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.waltz-card-btn {
  background: rgba(20, 15, 27, 0.88);
  border: 1px solid rgba(224, 168, 153, 0.3);
  border-radius: 6px;
  padding: 14px 18px;
  color: var(--ivory);
  cursor: pointer;
  text-align: left;
  transition: all 220ms ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.waltz-card-btn:hover:not(:disabled) {
  border-color: var(--rose-gold);
  background: rgba(36, 22, 44, 0.95);
  transform: translateX(4px);
}

/* ==========================================================================
   MINIJUEGO 5 (CAPÍTULO 10): SOBRECARGA RÚNICA ARMÓNICA
   ========================================================================== */
.overload-chamber {
  width: 100%;
  max-width: 680px;
  margin: 20px auto;
  background: rgba(14, 11, 18, 0.94);
  border: 1px solid var(--rose-gold-border);
  border-radius: 8px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.7);
}

.harmonic-stage {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 18px 0;
}

.harmonic-wave-container {
  width: 100%;
  max-width: 480px;
  height: 64px;
  background: rgba(8, 6, 12, 0.92);
  border: 1px solid var(--rose-gold-border);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.85);
}

.harmonic-sweet-spot {
  position: absolute;
  top: 0;
  left: 40%;
  width: 20%;
  height: 100%;
  background: rgba(244, 63, 94, 0.28);
  border-left: 2px solid #f43f5e;
  border-right: 2px solid #f43f5e;
  box-shadow: 0 0 18px rgba(244, 63, 94, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.sweet-spot-tag {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: #fda4af;
  font-weight: bold;
}

.harmonic-needle {
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: #ffffff;
  box-shadow: 0 0 12px #fff, 0 0 18px #f43f5e;
  z-index: 10;
  pointer-events: none;
}

/* ==========================================================================
   CENTERED, EXPANDED JOURNAL PARCHMENT CONTAINER
   ========================================================================== */
.journal-entry-container {
  max-width: 780px;
  margin: 38px auto;
  padding: 34px 30px;
  background: radial-gradient(circle at top, rgba(28, 18, 34, 0.96), rgba(14, 9, 18, 0.98));
  border: 1px solid var(--rose-gold-border);
  border-top: 3px solid var(--rose-gold);
  border-bottom: 3px solid var(--rose-gold);
  border-radius: 8px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.8), inset 0 0 30px rgba(224, 168, 153, 0.05);
  text-align: center;
  position: relative;
}

.journal-entry-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  color: var(--rose-gold-light);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.journal-prompt-desc {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.12rem;
  font-style: italic;
  color: var(--ivory);
  line-height: 1.75;
  max-width: 660px;
  margin: 12px auto 22px auto;
  text-align: center;
}

.grimoire-textarea {
  width: 100%;
  min-height: 220px;
  padding: 18px 22px;
  background: rgba(8, 6, 12, 0.9);
  border: 1px solid rgba(224, 168, 153, 0.35);
  border-radius: 6px;
  color: var(--ivory);
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.15rem;
  line-height: 1.8;
  resize: vertical;
  box-sizing: border-box;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.85);
  transition: border-color 250ms ease, box-shadow 250ms ease;
  margin-bottom: 22px;
  text-align: left;
}

.grimoire-textarea:focus {
  outline: none;
  border-color: var(--rose-gold);
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.85), 0 0 20px rgba(224, 168, 153, 0.4);
}

.seal-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  align-items: center;
  margin-top: 14px;
}

.seal-word-input {
  max-width: 250px;
  text-align: center;
  text-transform: uppercase;
  font-family: monospace;
  letter-spacing: 2px;
  font-size: 0.95rem;
}

/* ==========================================================================
   BOOK III: ORACLE CORE CONTINUITY ON ETSY
   ========================================================================== */
.book3-continuity-box {
  margin-top: 28px;
  padding: 26px 24px;
  background: rgba(26, 16, 32, 0.9);
  border: 1px solid var(--rose-gold-border);
  border-top: 3px solid #8b5cf6;
  border-radius: 8px;
  max-width: 580px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

.book3-coming-soon-badge {
  display: inline-block;
  padding: 5px 14px;
  background: rgba(139, 92, 246, 0.25);
  border: 1px solid #8b5cf6;
  border-radius: 20px;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: #c4b5fd;
  text-transform: uppercase;
  margin-bottom: 12px;
  font-weight: 700;
}

/* --- Grimoire Antique Format --- */
.grimoire-book {
  background: #120e18;
  border: 2px solid var(--rose-gold);
  border-radius: 8px;
  padding: 36px 24px;
  position: relative;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.9), inset 0 0 35px rgba(224, 168, 153, 0.08);
  width: 100%;
}

.grimoire-header-ornament {
  text-align: center;
  font-size: 1.4rem;
  color: var(--rose-gold);
  margin-bottom: 12px;
}

.grimoire-entry {
  background: rgba(18, 14, 26, 0.7);
  border-left: 3px solid var(--rose-gold);
  padding: 16px 20px;
  margin: 20px 0;
  border-radius: 0 6px 6px 0;
}


.grimoire-entry-num {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--rose-gold-light);
  letter-spacing: 0.1em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.grimoire-entry-content {
  font-size: 1.05rem;
  font-style: italic;
  color: var(--ivory);
  line-height: 1.6;
}

.grimoire-quoted-line {
  display: block;
  margin-top: 8px;
  padding: 8px 14px;
  background: rgba(224, 168, 153, 0.12);
  border-left: 2px solid var(--rose-gold);
  font-size: 0.92rem;
  color: var(--rose-gold-light);
  font-style: normal;
  border-radius: 0 4px 4px 0;
}

/* Stat Radar/Bar Summary */
.stat-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 24px 0;
}

@media (min-width: 520px) {
  .stat-summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.stat-pill {
  background: rgba(14, 12, 20, 0.85);
  border: 1px solid rgba(224, 168, 153, 0.3);
  border-radius: 6px;
  padding: 12px;
  text-align: center;
}

.stat-pill-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--ivory-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-pill-value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--rose-gold-light);
  margin-top: 4px;
}

/* Sequel Teaser Rune */
.sequel-box {
  margin-top: 32px;
  text-align: center;
  padding: 24px 16px;
  border-top: 1px solid rgba(224, 168, 153, 0.25);
}

.sequel-rune {
  font-size: 2.2rem;
  color: var(--rose-gold);
  animation: pulseRune 2.5s infinite ease-in-out;
  display: inline-block;
  margin-bottom: 8px;
}

@keyframes pulseRune {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 6px var(--rose-gold-glow));
  }
  50% {
    transform: scale(1.15);
    filter: drop-shadow(0 0 16px var(--rose-gold-light));
  }
}

/* --- Tripartite Legacy Additions --- */
.legacy-detected-box {
  background: rgba(30, 20, 36, 0.85);
  border: 1px solid var(--rose-gold);
  border-radius: 6px;
  padding: 16px;
  margin: 16px 0;
  text-align: center;
}

.legacy-detected-box p {
  font-size: 0.96rem;
  margin-bottom: 12px;
}

/* --- The wax sigil picker --- */
.sigil-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0 20px;
}
.sigil-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 14px 8px;
  background: rgba(14, 12, 20, 0.85);
  border: 1px solid rgba(224, 168, 153, 0.25);
  border-radius: 6px;
  cursor: pointer;
  color: var(--ivory-muted);
  font-family: var(--font-body);
  transition: all 200ms ease;
}
.sigil-card:hover { border-color: var(--rose-gold); transform: translateY(-2px); }
.sigil-card.selected {
  border-color: var(--rose-gold-light);
  background: rgba(224, 168, 153, 0.14);
  box-shadow: 0 0 18px var(--rose-gold-glow);
}
.sigil-mark { font-size: 1.7rem; line-height: 1; }
.sigil-maris { color: #8fc4dd; }
.sigil-zephyr { color: #b6b0c9; }
.sigil-lyra { color: var(--lyra); }
.sigil-name {
  font-size: 0.78rem;
  line-height: 1.25;
  text-align: center;
  color: var(--ivory-muted);
}
.sigil-who {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--rose-gold);
}
@media (max-width: 419px) {
  .sigil-grid { grid-template-columns: 1fr; }
  .sigil-card { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 14px; }
  .sigil-name { text-align: left; flex: 1; }
}

/* --- Sealed lines --- */
.seal-field { margin-top: 18px; }
.seal-input {
  border-color: rgba(224, 168, 153, 0.55);
  background: rgba(24, 16, 20, 0.75);
  font-style: italic;
}
.seal-word {
  max-width: 220px;
  text-align: center;
  font-style: normal;
  font-family: var(--font-display);
  letter-spacing: 0.18em;
  text-transform: lowercase;
}
.seal-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--ivory-muted);
  opacity: 0.8;
  line-height: 1.45;
}
.field-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ivory-muted);
  opacity: 0.75;
  font-size: 0.82rem;
}

.btn-ghost {
  display: block;
  margin: 4px auto 0;
  padding: 8px 16px;
  min-height: 40px;
  background: none;
  border: 1px dashed rgba(224, 168, 153, 0.4);
  border-radius: 4px;
  color: var(--ivory-muted);
  font-family: var(--font-display);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 180ms ease;
}
.btn-ghost:hover { border-color: var(--rose-gold); color: var(--rose-gold-light); }
.card-panel.short-mode .textarea-input,
.card-panel.short-mode .sigil-grid + .input-label { display: none; }
.card-panel.short-mode .textarea-input + .seal-field { margin-top: 8px; }

/* --- Warding Hour / Cut-In prose --- */
.warding-payoff {
  margin-top: 20px;
  padding: 18px 20px;
  border-left: 3px solid var(--rose-gold);
  background: rgba(224, 168, 153, 0.08);
  border-radius: 0 6px 6px 0;
  line-height: 1.7;
  animation: modalRise 400ms ease;
}
.warding-payoff p + p { margin-top: 12px; }

.collision-pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 560px) {
  .collision-pair { grid-template-columns: 1fr 1fr; }
}
.collision-half { margin: 0; }

.order-beat {
  margin: 14px 0 18px;
  padding: 12px 16px;
  border-left: 2px solid var(--rose-gold-border);
  background: rgba(224, 168, 153, 0.05);
  border-radius: 0 4px 4px 0;
  font-style: italic;
  color: var(--ivory-muted);
  font-size: 0.98rem;
  line-height: 1.6;
}
.order-beat-badge {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 8px;
  background: rgba(224, 168, 153, 0.2);
  border: 1px solid var(--rose-gold);
  border-radius: 3px;
  font-family: var(--font-display);
  font-style: normal;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rose-gold-light);
}

.gala-counter {
  margin: 4px 0 16px;
  font-family: var(--font-display);
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  color: var(--rose-gold-light);
  text-align: center;
}

.grimoire-seal-line {
  margin-top: 12px;
  padding: 10px 14px;
  border-left: 2px solid var(--rose-gold);
  background: rgba(224, 168, 153, 0.08);
  border-radius: 0 4px 4px 0;
  font-style: italic;
  color: var(--rose-gold-light);
  line-height: 1.6;
}
.grimoire-entry-blank {
  font-style: italic;
  opacity: 0.62;
}
.grimoire-sealword-wrap { text-align: center; margin: 18px 0 24px; }
.grimoire-sealword-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ivory-muted);
  margin-bottom: 8px;
}
.grimoire-sealword {
  display: inline-block;
  padding: 10px 28px;
  border: 1px solid var(--rose-gold);
  border-radius: 4px;
  background: rgba(224, 168, 153, 0.12);
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.22em;
  color: var(--rose-gold-light);
  text-transform: lowercase;
}
.grimoire-chronicle-list {
  margin: 6px 0 0 18px;
  padding: 0;
  line-height: 1.75;
}
.grimoire-chronicle-list li {
  color: var(--ivory-muted);
  font-size: 0.96rem;
  margin-bottom: 4px;
}

.grimoire-export {
  text-align: center;
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid var(--rose-gold-border);
}
.btn-export {
  font-size: 1rem;
  min-height: 56px;
  box-shadow: 0 6px 26px rgba(0, 0, 0, 0.7), 0 0 26px var(--rose-gold-glow);
}
.export-note {
  max-width: 420px;
  margin: 10px auto 18px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ivory-muted);
}
.grimoire-export-secondary {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.grimoire-export-secondary .btn {
  width: auto;
  flex: 1 1 190px;
  max-width: 260px;
  font-size: 0.78rem;
  margin: 0;
}

/* In-game modal */
.game-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 5, 10, 0.86);
  backdrop-filter: blur(3px);
}
.game-modal.active { display: flex; }

.game-modal-panel {
  width: 100%;
  max-width: 460px;
  background: var(--bg-card-solid);
  border: 1px solid var(--rose-gold-border);
  border-radius: 8px;
  padding: 26px 24px 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.85), 0 0 24px var(--rose-gold-glow);
  animation: modalRise 260ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes modalRise {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.game-modal-panel h3 {
  font-family: var(--font-display);
  color: var(--rose-gold-light);
  font-size: 1.2rem;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}
.game-modal-body {
  color: var(--ivory-muted);
  font-size: 1.02rem;
  line-height: 1.6;
  margin-bottom: 20px;
}
.game-modal-body strong { color: var(--ivory); }
.game-modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.game-modal-actions .btn {
  width: auto;
  min-width: 130px;
  margin: 0;
  flex: 1 1 130px;
}

/* Act V Trials */
.trial-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  margin-bottom: 22px;
}
.trial-stage {
  border-left: 3px solid rgba(224, 168, 153, 0.3);
  transition: border-color 300ms ease, background 300ms ease, transform 300ms ease;
}
.trial-verdict {
  font-size: 0.95rem;
  color: var(--ivory-muted);
  line-height: 1.55;
  margin-top: 4px;
}
.trial-stage.trial-active {
  border-left-color: var(--rose-gold-light);
  transform: translateX(4px);
  animation: trialPulse 900ms ease-in-out infinite;
}
@keyframes trialPulse {
  0%, 100% { box-shadow: 0 0 0 rgba(224, 168, 153, 0); }
  50% { box-shadow: 0 0 20px var(--rose-gold-glow); }
}
.trial-stage.trial-pass {
  border-left-color: #6fae7c;
  background: rgba(58, 110, 70, 0.14);
}
.trial-stage.trial-pass .stat-pill-label { color: #9fd3a8; }
.trial-stage.trial-fail {
  border-left-color: var(--crimson);
  background: rgba(136, 19, 55, 0.14);
}
.trial-stage.trial-fail .stat-pill-label { color: #d98d99; }

/* ==========================================================================
   INTERACTIVE ACADEMY CAMPUS MAP (WITH PHOTO & GLOWING PINS)
   ========================================================================== */
.map-card-panel {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
}

.map-header {
  text-align: center;
  margin-bottom: 20px;
}

.map-viewport {
  position: relative;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--rose-gold-border);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.75), 0 0 20px rgba(136, 19, 55, 0.25);
  background: #09060b;
}

.map-img {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  filter: contrast(1.04) brightness(0.98);
  transition: transform 300ms ease;
}

.map-pins-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* This layer fully covers the map image so pins can be positioned freely,
     but that also silently ate every click meant for the underlying
     .clickable-image (the map never opened in the lightbox). Let clicks pass
     through the empty layer to the image beneath; only the pins themselves
     opt back in below. */
  pointer-events: none;
}

.map-pin {
  position: absolute;
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  outline: none;
  border: none;
  background: transparent;
  padding: 0;
  transition: transform 200ms ease;
}

.map-pin:hover,
.map-pin.active {
  transform: translate(-50%, -50%) scale(1.18);
  z-index: 30;
}

.map-pin-beacon {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2e1525 0%, #120914 90%);
  border: 2px solid var(--rose-gold);
  box-shadow: 0 0 12px rgba(224, 168, 153, 0.55), 0 2px 6px rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rose-gold-light);
  font-size: 15px;
  transition: all 250ms ease;
}

.map-pin:hover .map-pin-beacon,
.map-pin.active .map-pin-beacon {
  border-color: #fff;
  color: #fff;
  background: radial-gradient(circle at 35% 35%, var(--crimson-core) 0%, #1a050d 90%);
  box-shadow: 0 0 22px rgba(224, 168, 153, 0.9), 0 0 10px rgba(136, 19, 55, 0.8);
}

.map-pin::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--rose-gold);
  transform: translate(-50%, -50%) scale(1);
  animation: mapPinPulse 2.2s infinite ease-out;
  pointer-events: none;
}

.map-pin.active::before {
  border-color: #fff;
  animation: mapPinPulse 1.4s infinite ease-out;
}

@keyframes mapPinPulse {
  0% {
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0.9;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.2);
    opacity: 0;
  }
}

.map-pin-tag {
  margin-top: 5px;
  background: rgba(14, 10, 18, 0.9);
  backdrop-filter: blur(4px);
  border: 1px solid var(--rose-gold-border);
  padding: 3px 8px;
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--ivory);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 10px rgba(0,0,0,0.6);
  transition: all 200ms ease;
}

.map-pin:hover .map-pin-tag,
.map-pin.active .map-pin-tag {
  background: rgba(136, 19, 55, 0.95);
  border-color: var(--rose-gold);
  color: #fff;
  box-shadow: 0 0 12px rgba(224, 168, 153, 0.4);
}

/* Interactive Map Pin Statuses */
.map-pin.locked {
  filter: grayscale(1) opacity(0.42);
  cursor: not-allowed;
}

.map-pin.locked .map-pin-beacon {
  border-color: #555;
  background: #141218;
  color: #777;
  box-shadow: none;
}

.map-pin.locked::before {
  display: none !important;
}

.map-pin.visited .map-pin-beacon {
  border-color: #10b981;
  color: #34d399;
  background: radial-gradient(circle at 35% 35%, #064e3b 0%, #061c14 90%);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.5);
}

.map-pin.active-objective .map-pin-beacon {
  border-color: #fff;
  background: radial-gradient(circle at 35% 35%, var(--crimson-core) 0%, #1a050d 90%);
  box-shadow: 0 0 24px rgba(244, 63, 94, 0.95), 0 0 14px rgba(224, 168, 153, 0.9);
  animation: beaconAlert 1.5s infinite alternate;
}

@keyframes beaconAlert {
  0% { transform: scale(1); box-shadow: 0 0 14px rgba(244, 63, 94, 0.6); }
  100% { transform: scale(1.15); box-shadow: 0 0 28px rgba(244, 63, 94, 1), 0 0 16px rgba(224, 168, 153, 0.9); }
}

/* Dossier Card below map */
.map-dossier-card {
  margin-top: 24px;
  padding: 22px 24px;
  background: rgba(20, 13, 24, 0.9);
  border: 1px solid var(--rose-gold-border);
  border-left: 4px solid var(--rose-gold);
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  transition: border-color 300ms ease, box-shadow 300ms ease;
}

.dossier-focus-pulse {
  animation: dossierGlow 1.2s ease-out;
}

@keyframes dossierGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(224, 168, 153, 0.8), 0 6px 24px rgba(0,0,0,0.5);
    border-color: var(--rose-gold-light);
  }
  50% {
    box-shadow: 0 0 25px 6px rgba(224, 168, 153, 0.6), 0 6px 30px rgba(136, 19, 55, 0.7);
    border-color: #ffffff;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(224, 168, 153, 0), 0 6px 24px rgba(0,0,0,0.5);
    border-color: var(--rose-gold-border);
  }
}

.map-dossier-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.map-dossier-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--rose-gold-light);
  letter-spacing: 0.05em;
  margin: 0;
}

.map-dossier-sector {
  font-size: 0.82rem;
  color: var(--ivory-muted);
  font-family: var(--font-accent);
  font-style: italic;
  margin-top: 4px;
}

.map-dossier-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(136, 19, 55, 0.35);
  border: 1px solid rgba(224, 168, 153, 0.3);
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--rose-gold-light);
}

.map-dossier-lore {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ivory);
  margin-bottom: 16px;
}

.map-dossier-characters {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.map-char-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: rgba(14, 10, 18, 0.75);
  border: 1px solid rgba(224, 168, 153, 0.2);
  border-radius: 20px;
  font-size: 0.82rem;
  color: var(--ivory-muted);
}

.map-char-chip-img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--rose-gold);
}

.map-actions-bar {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .map-pin-tag {
    display: none;
  }
  .map-pin.active .map-pin-tag {
    display: block;
    position: absolute;
    bottom: -28px;
  }
  .map-pin-beacon {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }
  .map-pin::before {
    width: 28px;
    height: 28px;
  }
  .map-dossier-card {
    padding: 16px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  #ember-canvas { display: none !important; }
  .meter-bar { transition: none !important; }
  .dice-cube { transition: none !important; }
  .map-pin::before { animation: none !important; }
}

/* Print Styling */
@media print {
  body {
    background: #ffffff !important;
    color: #1a1a1a !important;
    font-size: 13pt;
  }
  #ember-canvas, .top-controls, #hud, .btn, .wax-seal-wrapper, .tap-to-skip, .bg-layer {
    display: none !important;
  }
  .screen {
    display: block !important;
    opacity: 1 !important;
    max-width: 100% !important;
    padding: 0 !important;
  }
  .card-panel, .grimoire-book {
    background: #ffffff !important;
    border: 1px solid #777777 !important;
    box-shadow: none !important;
    color: #1a1a1a !important;
    padding: 20px !important;
  }
  h1, h2, h3, .hud-player-info, .stat-pill-value {
    color: #881337 !important;
    text-shadow: none !important;
  }
  .grimoire-entry {
    background: #f7f7f7 !important;
    border-left: 3px solid #881337 !important;
    color: #1a1a1a !important;
  }
  .grimoire-quoted-line {
    background: #ebebeb !important;
    color: #333333 !important;
  }
  .stat-pill {
    background: #fafafa !important;
    border: 1px solid #ccc !important;
  }
  .character-card, .scene-banner-frame {
    border: 1px solid #999 !important;
    box-shadow: none !important;
  }
  .game-modal, .btn-ghost, .avatar-zoom-btn, .grimoire-export, .order-beat { display: none !important; }
  .grimoire-seal-line, .grimoire-sealword {
    background: #f2eee4 !important;
    color: #6d540f !important;
    border-color: #8c6d17 !important;
  }
  .grimoire-chronicle-list li { color: #333 !important; }
}

/* ==========================================================================
   PATCH BLOCK v2 — missing tokens, missing classes, new minigames,
   responsive tablet/desktop tiers, companion toggle, accessibility.
   ========================================================================== */

:root {
  --crimson-core: #ea5b6c;
  --font-accent: 'Crimson Text', serif;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Companion variant toggle: default-visible Julian branch, swapped by data-companion */
.comp-j { display: block; }
.comp-k { display: none; }
body[data-companion="kaelen"] .comp-j { display: none; }
body[data-companion="kaelen"] .comp-k { display: block; }
.character-card.comp-j, .character-card.comp-k { display: flex; }
body[data-companion="kaelen"] .character-card.comp-j { display: none; }
body:not([data-companion="kaelen"]) .character-card.comp-k { display: none; }
.typewriter-text.comp-j, .typewriter-text.comp-k { display: block; }
body[data-companion="kaelen"] .typewriter-text.comp-j { display: none; }
body:not([data-companion="kaelen"]) .typewriter-text.comp-k { display: none; }

/* Companion selection cards (prologue) */
/* Both pickers below crop their (820x1098, ~3:4) source portraits down to a
   near-square 1:1 frame. object-position is biased toward the top so the
   crop keeps the whole face + hair instead of the centered default, which
   on a tall portrait cuts across the eyes. Cards are sized generously (not
   a fixed px) so the face reads clearly on phones and gets genuinely
   bigger — not just "more columns" — on tablets. */
.companion-select-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.companion-select-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: var(--bg-card); border: 1px solid var(--rose-gold-border); border-radius: 12px;
  padding: 14px; cursor: pointer; min-height: 44px;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
  color: var(--ivory); font-family: var(--font-body);
}
.companion-select-card:hover, .companion-select-card:focus-visible {
  border-color: var(--rose-gold); transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.4); outline: none;
}
.companion-select-thumb {
  display: block; position: relative; width: 100%; padding-top: 100%; /* 1:1 square via the classic padding-box technique — more reliable across engines than aspect-ratio on a sized <img> */
  border-radius: 10px; overflow: hidden; border: 2px solid var(--rose-gold-border); margin-bottom: 10px;
}
.companion-select-thumb img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 14%;
}
.companion-select-name { font-family: var(--font-display); font-size: 1rem; color: var(--rose-gold-light); margin-bottom: 6px; }
.companion-select-desc { font-size: 0.85rem; color: var(--ivory-muted); line-height: 1.4; }

/* Avatar picker (screen-character) — 2x2 on phone AND tablet portrait so
   each card stays large; only goes to a single row of 4 once there is
   genuinely enough width (tablet landscape / desktop) to keep them big. */
.avatar-pick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 760px) { .avatar-pick-grid { grid-template-columns: repeat(4, 1fr); } }
.avatar-pick-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--bg-card); border: 2px solid var(--rose-gold-border); border-radius: 12px;
  padding: 12px; cursor: pointer; min-height: 44px;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}
.avatar-pick-card:hover, .avatar-pick-card:focus-visible {
  border-color: var(--rose-gold); transform: translateY(-2px); outline: none;
}
.avatar-pick-card.selected {
  border-color: var(--rose-gold-light);
  box-shadow: 0 0 0 3px var(--rose-gold-glow), 0 6px 18px rgba(0,0,0,0.4);
}
.avatar-pick-thumb {
  display: block; position: relative; width: 100%; padding-top: 100%; /* 1:1 square, same reliable technique as .companion-select-thumb */
  border-radius: 8px; overflow: hidden;
}
.avatar-pick-thumb img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%;
}
.avatar-pick-name {
  font-family: var(--font-display); font-size: 0.85rem; color: var(--ivory-muted); text-align: center;
}
.avatar-pick-card.selected .avatar-pick-name { color: var(--rose-gold-light); }

@keyframes pulseAttn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224,168,153,0.6); }
  50% { box-shadow: 0 0 0 8px rgba(224,168,153,0); }
}
.pulse-attn { animation: pulseAttn 0.9s ease 2; border-radius: 10px; }

/* Alchemy minigame (Chapter 4) — matches the actual markup emitted */
.alch-tubes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 0; }
.alch-tube-card { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.alch-tube-glass {
  width: 44px; height: 120px; border: 2px solid var(--rose-gold-border);
  border-radius: 6px 6px 10px 10px; background: rgba(0,0,0,0.35);
  display: flex; align-items: flex-end; overflow: hidden; position: relative;
}
.alch-tube-fill { width: 100%; transition: height 200ms ease; }
.fill-belladonna { background: linear-gradient(180deg, #a78bfa, #6d28d9); }
.fill-phoenix { background: linear-gradient(180deg, #fb923c, #9a3412); }
.fill-mercury { background: linear-gradient(180deg, #94a3b8, #334155); }
.alch-label { font-size: 0.78rem; color: var(--ivory-muted); text-align: center; font-family: var(--font-display); }
.range-slider { width: 100%; accent-color: var(--rose-gold); min-height: 24px; }
.alch-readout { margin-top: 12px; text-align: center; }
.alch-ph-box { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.alch-ph-label { font-family: var(--font-display); color: var(--ivory-muted); font-size: 0.85rem; }
.alch-ph-value { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; color: var(--rose-gold-light); }
.alch-target-tag { font-size: 0.75rem; color: var(--ivory-muted); border: 1px solid var(--rose-gold-border); border-radius: 999px; padding: 2px 10px; }

/* Wax seal stamp */
.wax-seal-stamp {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--blood); color: var(--ivory); border-radius: 999px;
  padding: 6px 14px; font-family: var(--font-display); font-size: 0.82rem;
  letter-spacing: 0.08em; border: 1px solid var(--rose-gold-border);
}
.stamp-icon { font-size: 1rem; }
@keyframes stampPop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.stamp-pop-anim { animation: stampPop 500ms ease; }

/* Lightbox controls */
.lightbox-controls-bar { position: absolute; top: 16px; right: 16px; z-index: 100; display: flex; gap: 8px; }
.lightbox-ctrl-btn {
  width: 40px; height: 40px; min-width: 40px; border-radius: 50%;
  border: 1px solid var(--rose-gold-border); background: rgba(10,8,15,0.85);
  color: var(--ivory); font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-ctrl-btn:hover, .lightbox-ctrl-btn:focus-visible { border-color: var(--rose-gold); color: var(--rose-gold-light); outline: none; }
.lightbox-close-btn {
  width: 44px; height: 44px; min-width: 44px; border-radius: 50%;
  border: 1px solid var(--rose-gold-border); background: rgba(10,8,15,0.85);
  color: var(--ivory); font-size: 1.2rem; cursor: pointer;
}

/* Misc structural classes now present in markup */
.banner-caption { font-size: 0.88rem; font-style: italic; color: var(--rose-gold-light); text-align: center; margin: 6px 0 18px; }
.dialogue-cards-stack { display: flex; flex-direction: column; gap: 14px; margin: 20px 0; }
.choices-stack { display: flex; flex-direction: column; gap: 12px; margin: 22px 0; }
.chapter-navigation-bar { margin-top: 28px; text-align: center; }
.minigame-container { text-align: center; }
.minigame-header { margin-bottom: 14px; }
.minigame-title { font-family: var(--font-display); color: var(--rose-gold-light); font-size: 1.1rem; }
.minigame-subtitle { font-size: 0.85rem; color: var(--ivory-muted); margin-top: 4px; }
.btn-action { background: var(--crimson); border-color: var(--rose-gold); }
.meter-passion .meter-bar { background: linear-gradient(90deg, var(--rose-gold), var(--crimson)); }
.grimoire-entries-grid { text-align: left; max-width: 680px; margin: 0 auto 24px auto; }
.grimoire-portrait-badge { text-align: center; }
.grimoire-stat-bars { text-align: left; max-width: 580px; margin: 0 auto 24px auto; }
.grimoire-code-box {
  font-family: monospace; font-size: 1.2rem; letter-spacing: 2px; color: #f8fafc;
  background: rgba(0,0,0,0.6); border: 1px solid #8b5cf6; padding: 10px 14px; border-radius: 4px;
  display: inline-block; user-select: all; margin: 8px 0; max-width: 100%;
  overflow-wrap: break-word; word-break: break-word;
}
.notch-outer, .notch-mid, .notch-inner { font-size: 1rem; }
.overload-readout { text-align: left; }
.exam-round-box {
  background: rgba(0,0,0,0.3); border-left: 3px solid var(--morvath); border-radius: 6px;
  padding: 14px 16px; margin-bottom: 14px; text-align: left;
}
.exam-round-text { font-style: italic; color: var(--ivory); line-height: 1.5; }
.exam-actions-strip { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }

/* Ending verdict block (grimoire screen) */
.ending-verdict-box {
  max-width: 680px; margin: 0 auto 24px auto; padding: 20px;
  border: 1px solid var(--rose-gold); border-radius: 10px;
  background: linear-gradient(180deg, rgba(136,19,55,0.25), rgba(16,14,24,0.85));
}
.ending-verdict-badge { font-family: var(--font-display); color: var(--rose-gold-light); font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 8px; }
.ending-verdict-title { font-family: var(--font-display); font-size: 1.4rem; color: var(--ivory); margin-bottom: 10px; }
.ending-verdict-text { font-size: 0.95rem; color: var(--ivory-muted); line-height: 1.6; font-style: italic; }

/* Map pin: visible keyboard focus.
   NOTE: deliberately does NOT add padding/min-width/min-height to .map-pin
   itself — it is absolutely positioned + transform-centered on hand-tuned
   percentage coordinates that sit as close as ~11% apart, so inflating its
   own hit box collided adjacent pins' click targets into one another. */
.map-pin:focus-visible { outline: 2px solid var(--rose-gold-light); outline-offset: 3px; border-radius: 50%; }

/* Touch target minimums */
.btn-ghost { min-height: 44px; }
.minigame-feedback { min-height: 1.2em; }

/* ==========================================================================
   RESPONSIVE — TABLET & DESKTOP
   The base layout capped every screen at 680px regardless of viewport, so
   iPad and desktop rendered a narrow phone-width column on a wide canvas.
   These tiers widen the reading column progressively.
   ========================================================================== */
@media (min-width: 768px) {
  .screen { max-width: 760px; }
  .card-panel { padding: 40px 44px; }
  /* .companion-select-card img sizes itself via width:100%/aspect-ratio, so
     no fixed-px override is needed here — one used to fight the 1:1 crop. */
}

@media (min-width: 1024px) {
  .screen { max-width: 860px; }
  body { font-size: 19px; }
  .dialogue-cards-stack { flex-direction: row; flex-wrap: wrap; }
  .dialogue-cards-stack .character-card { flex: 1 1 320px; }
}

@media (min-width: 1280px) {
  .screen { max-width: 960px; }
}

.map-card-panel { max-width: 100%; }
@media (min-width: 1024px) {
  .map-card-panel { max-width: 900px; }
}
