/* ==========================================================================
   THE SECRET OWL — LA STANZA DELLE NECESSITÀ
   Direzione artistica: Hogwarts notturna, oro antico, pergamena, ceralacca
   Mobile-first, accessibile, supporto temi delle 4 Case
   ========================================================================== */

:root {
  --bg-deep: #09070d;
  --bg-card: rgba(20, 15, 26, 0.88);
  --bg-card-solid: #16101d;
  --bg-elevated: rgba(31, 23, 40, 0.92);

  --gold: #d4af37;
  --gold-bright: #f2d98d;
  --gold-soft: rgba(212, 175, 55, 0.25);
  --gold-border: rgba(212, 175, 55, 0.42);

  --accent: #8c1d28;        /* Rosso ceralacca di default */
  --accent-glow: rgba(140, 29, 40, 0.45);
  --accent-light: #c94653;

  --text-main: #f3ead8;
  --text-muted: #c2b69f;
  --text-dim: #8f836e;

  --parchment-bg: #f4e8ce;
  --parchment-edge: #dfd0ac;
  --parchment-ink: #291c11;
  --parchment-ink-soft: #5c4632;

  --success: #5ea87a;
  --error: #c75b5b;

  --font-display: 'Cinzel', Georgia, 'Times New Roman', serif;
  --font-serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-magic: 0 18px 50px rgba(0, 0, 0, 0.65), 0 0 28px rgba(212, 175, 55, 0.08);
}

/* Temi opzionali delle 4 Case di Hogwarts */
body[data-theme="gryffindor"] {
  --accent: #8c1922;
  --accent-glow: rgba(160, 30, 42, 0.45);
  --accent-light: #d64550;
  --gold: #dfb141;
}

body[data-theme="hufflepuff"] {
  --accent: #9b7316;
  --accent-glow: rgba(224, 177, 52, 0.35);
  --accent-light: #e7be4e;
  --gold: #edc752;
}

body[data-theme="ravenclaw"] {
  --accent: #1c3d73;
  --accent-glow: rgba(42, 95, 178, 0.45);
  --accent-light: #5c8de0;
  --gold: #c9a46c;
}

body[data-theme="slytherin"] {
  --accent: #17543c;
  --accent-glow: rgba(34, 118, 84, 0.45);
  --accent-light: #4fa883;
  --gold: #c9d2cc;
  --gold-bright: #e6eeea;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% 0%, rgba(78, 48, 92, 0.28) 0%, transparent 55%),
    radial-gradient(circle at 85% 90%, var(--accent-glow) 0%, transparent 48%),
    linear-gradient(180deg, #0b0810 0%, #120d18 48%, #09070d 100%);
  color: var(--text-main);
  font-family: var(--font-serif);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#magic-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.vignette-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(4, 3, 7, 0.72) 100%);
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   TOP BAR
   ========================================================================== */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.1rem;
  background: rgba(11, 8, 16, 0.76);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(212, 175, 55, 0.16);
}

.top-bar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gold);
}

.owl-mini-icon {
  width: 24px;
  height: 24px;
}

.brand-text {
  font-family: var(--font-display);
  font-size: 0.88rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.top-bar-controls {
  display: flex;
  gap: 0.45rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 55, 0.28);
  background: rgba(25, 19, 34, 0.72);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.74rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  min-height: 36px;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  border-color: var(--gold);
  color: var(--gold-bright);
  outline: none;
}

.icon-btn[aria-pressed="false"] {
  opacity: 0.62;
}

/* ==========================================================================
   LAYOUT PRINCIPALE
   ========================================================================== */
.app-shell {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3.2rem;
}

.view {
  animation: fadeSlideIn 0.55s ease both;
}

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

/* ==========================================================================
   TIPOGRAFIA & ELEMENTI ORNAMENTALI
   ========================================================================== */
.eyebrow {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  text-align: center;
}

.display-title {
  margin: 0.25rem 0 0.85rem;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 5.2vw, 2.55rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--gold-bright);
  text-shadow: 0 2px 18px rgba(212, 175, 55, 0.28);
}

.lead-text {
  margin: 0 auto 1.4rem;
  max-width: 58ch;
  font-size: 1.15rem;
  color: var(--text-muted);
  text-align: center;
}

.gold-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  margin: 1.2rem 0;
  color: var(--gold);
}

.gold-divider.compact {
  margin: 0.9rem 0;
}

.gold-divider::before,
.gold-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  max-width: 110px;
  background: linear-gradient(90deg, transparent, var(--gold-border), transparent);
}

.badge-pill {
  display: inline-block;
  padding: 0.28rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--gold-border);
  background: rgba(212, 175, 55, 0.09);
  color: var(--gold-bright);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge-pill.gold {
  background: rgba(212, 175, 55, 0.16);
}

/* ==========================================================================
   SCHERMATA INTRO & CONTO ALLA ROVESCIA
   ========================================================================== */
.dispatch-card,
.parchment-card.dark-framed {
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-lg);
  padding: 0.65rem;
  box-shadow: var(--shadow-magic);
  backdrop-filter: blur(8px);
}

.dispatch-border {
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: calc(var(--radius-lg) - 6px);
  padding: 1.75rem 1.25rem 1.5rem;
  text-align: center;
}

.parchment-card.dark-framed {
  padding: 2rem 1.4rem;
  text-align: center;
}

.crest-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 0.8rem;
  color: var(--gold);
}

.crest-svg {
  width: 82px;
  height: 82px;
  filter: drop-shadow(0 0 12px rgba(212, 175, 55, 0.25));
}

.ministry-header {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.department-sub {
  margin: 0.25rem 0 0;
  font-size: 0.98rem;
  font-style: italic;
  color: var(--text-muted);
}

.dispatch-body {
  margin: 1.15rem auto 1.65rem;
  max-width: 56ch;
  text-align: left;
  font-size: 1.16rem;
  color: var(--text-main);
}

.dispatch-body p {
  margin: 0 0 0.9rem;
}

.dispatch-body p:first-child {
  font-style: italic;
  color: var(--gold-bright);
  font-size: 1.24rem;
}

.protocol-footer {
  margin: 1.5rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Countdown */
.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  max-width: 420px;
  margin: 1.5rem auto;
}

.time-box {
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 0.35rem;
}

.time-box span {
  display: block;
  font-family: var(--font-display);
  font-size: 1.65rem;
  color: var(--gold-bright);
}

.time-box small {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ==========================================================================
   BOTTONI MAGICI
   ========================================================================== */
.wax-seal-cta-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.btn-primary-magic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-height: 50px;
  padding: 0.82rem 1.75rem;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: linear-gradient(135deg, var(--accent) 0%, #5b1119 100%);
  color: #fff6e4;
  font-family: var(--font-display);
  font-size: 0.94rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 18px var(--accent-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn-primary-magic:hover,
.btn-primary-magic:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55), 0 0 26px rgba(212, 175, 55, 0.35);
  filter: brightness(1.08);
  outline: none;
}

.btn-primary-magic:active {
  transform: translateY(0);
}

.wax-dot {
  color: var(--gold-bright);
  font-size: 0.95rem;
}

.btn-secondary-magic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  border: 1px solid var(--gold-border);
  background: rgba(212, 175, 55, 0.1);
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-secondary-magic:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold);
}

.btn-ghost-magic {
  background: transparent;
  border: 1px solid rgba(212, 175, 55, 0.28);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.48rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  cursor: pointer;
  min-height: 40px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.btn-ghost-magic:hover {
  color: var(--gold-bright);
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.08);
}

/* ==========================================================================
   SCHERMATA GIOCO (5 PROVE)
   ========================================================================== */
.rune-progress {
  margin-bottom: 1.15rem;
}

.rune-track {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.45rem;
}

.rune-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.22rem;
  padding: 0.48rem 0.2rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(212, 175, 55, 0.16);
  background: rgba(18, 13, 24, 0.65);
  color: var(--text-dim);
  transition: all 0.25s ease;
}

.rune-node.active {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.14);
  color: var(--gold-bright);
  box-shadow: 0 0 16px rgba(212, 175, 55, 0.18);
}

.rune-node.solved {
  border-color: rgba(94, 168, 122, 0.55);
  background: rgba(94, 168, 122, 0.12);
  color: #a9e4be;
}

.rune-num {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
}

.rune-label {
  font-family: var(--font-ui);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  white-space: nowrap;
}

.trial-card {
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.2rem;
  box-shadow: var(--shadow-magic);
  backdrop-filter: blur(8px);
}

.trial-meta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.trial-step-tag {
  font-family: var(--font-display);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.trial-location {
  font-family: var(--font-ui);
  font-size: 0.76rem;
  color: var(--text-dim);
}

.trial-title {
  margin: 0 0 0.7rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 4.4vw, 1.85rem);
  color: var(--gold-bright);
}

.trial-story {
  margin: 0 0 0.9rem;
  font-size: 1.14rem;
  font-style: italic;
  color: var(--text-muted);
}

.trial-prompt {
  margin: 0 0 1.1rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Interazioni: Case di Hogwarts */
.houses-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.house-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(212, 175, 55, 0.28);
  background: rgba(28, 21, 36, 0.78);
  color: var(--text-main);
  cursor: pointer;
  text-align: center;
  transition: transform 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.house-card:hover,
.house-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--gold);
  background: rgba(42, 31, 52, 0.92);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.38);
  outline: none;
}

.house-card.wrong-shake {
  animation: shake 0.38s ease;
  border-color: var(--error);
}

.house-card.correct-glow {
  border-color: var(--success);
  background: rgba(94, 168, 122, 0.16);
}

.house-emblem {
  width: 36px;
  height: 36px;
  color: var(--gold);
}

.house-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--gold-bright);
}

.house-motto {
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* Interazioni: Input Incantesimo / Indovinello */
.spell-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.magic-input {
  width: 100%;
  min-height: 50px;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--gold-border);
  background: rgba(11, 8, 16, 0.78);
  color: var(--text-main);
  font-family: var(--font-serif);
  font-size: 1.2rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.magic-input:focus {
  outline: none;
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18);
}

.lumos-flash {
  animation: lumosBurst 0.9s ease;
}

@keyframes lumosBurst {
  0% { box-shadow: 0 0 0 rgba(242, 217, 141, 0); }
  35% { box-shadow: 0 0 70px 18px rgba(242, 217, 141, 0.75); }
  100% { box-shadow: var(--shadow-magic); }
}

/* Interazioni: Pozione (Calderone) */
.cauldron-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(212, 175, 55, 0.3);
  background: radial-gradient(circle at 50% 70%, rgba(212, 175, 55, 0.14), rgba(14, 10, 20, 0.75));
}

.cauldron-svg {
  width: 72px;
  height: 72px;
  color: var(--gold);
  transition: transform 0.3s ease;
}

.cauldron-box.brewing .cauldron-svg {
  transform: scale(1.08);
  filter: drop-shadow(0 0 18px rgba(242, 217, 141, 0.65));
}

.cauldron-status {
  margin: 0.45rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--gold-bright);
}

.ingredients-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.ingredient-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 0.78rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(212, 175, 55, 0.25);
  background: rgba(25, 19, 34, 0.78);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.ingredient-btn:hover {
  border-color: var(--gold);
}

.ingredient-btn.selected {
  border-color: var(--gold-bright);
  background: rgba(212, 175, 55, 0.18);
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.2);
}

.ingredient-title {
  font-family: var(--font-display);
  font-size: 0.88rem;
  color: var(--gold-bright);
}

.ingredient-desc {
  font-size: 0.94rem;
  color: var(--text-muted);
}

/* Interazioni: Mappa del Malandrino */
.marauder-parchment {
  background: linear-gradient(160deg, #efe1be 0%, #e4d1a3 100%);
  color: var(--parchment-ink);
  border-radius: var(--radius-md);
  border: 2px solid #b59457;
  padding: 1rem;
  margin-bottom: 0.95rem;
  position: relative;
  overflow: hidden;
}

.marauder-parchment-header {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  color: #6b2323;
  margin: 0 0 0.55rem;
}

.footsteps-preview {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  color: #7c2d2d;
  opacity: 0.65;
  margin-bottom: 0.6rem;
}

.word-tiles-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  margin-top: 0.55rem;
}

.word-tile {
  padding: 0.42rem 0.78rem;
  border-radius: 8px;
  border: 1px solid #9d7d43;
  background: rgba(255, 250, 236, 0.85);
  color: #2f1f11;
  font-family: var(--font-serif);
  font-size: 1.04rem;
  cursor: pointer;
  min-height: 38px;
  transition: transform 0.15s, background 0.15s;
}

.word-tile:hover {
  transform: translateY(-1px);
  background: #fffdf5;
}

.word-tile.used {
  opacity: 0.4;
}

.tile-helper-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.55rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--parchment-ink-soft);
}

.link-btn-small {
  background: none;
  border: none;
  color: #7c1c24;
  text-decoration: underline;
  font-family: var(--font-ui);
  font-size: 0.74rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

/* Feedback & Hints */
.trial-feedback {
  margin-top: 0.9rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 1.02rem;
}

.trial-feedback.error {
  background: rgba(199, 91, 91, 0.14);
  border: 1px solid rgba(199, 91, 91, 0.42);
  color: #f4bebe;
}

.trial-utility-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
}

.hint-counter {
  font-family: var(--font-ui);
  font-size: 0.74rem;
  color: var(--text-dim);
}

.hint-box {
  margin-top: 0.7rem;
  padding: 0.78rem 1rem;
  border-left: 3px solid var(--gold);
  background: rgba(212, 175, 55, 0.08);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 1.02rem;
  color: var(--gold-bright);
}

/* Pannello Ricompensa */
.reward-panel {
  margin-top: 1.2rem;
  padding: 1.3rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--gold);
  background: radial-gradient(circle at 50% 0%, rgba(212, 175, 55, 0.2), rgba(18, 13, 25, 0.92));
  text-align: center;
  animation: fadeSlideIn 0.45s ease both;
}

.reward-label {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.reward-word {
  margin: 0.3rem 0 0.65rem;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 5vw, 2rem);
  letter-spacing: 0.18em;
  color: var(--gold-bright);
  text-shadow: 0 0 18px rgba(242, 217, 141, 0.45);
}

.reward-story {
  margin: 0 auto 1.15rem;
  max-width: 52ch;
  font-size: 1.08rem;
  color: var(--text-main);
}

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

/* ==========================================================================
   SCHERMATA 3: PORTE GOTICHE DELLA STANZA DELLE NECESSITÀ
   ========================================================================== */
.gate-stage {
  position: relative;
  min-height: 520px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gold-border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: #0d0a12;
  box-shadow: var(--shadow-magic);
}

.gothic-doors-frame {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
  z-index: 1;
}

.door-panel {
  flex: 1;
  background:
    repeating-linear-gradient(90deg, rgba(212, 175, 55, 0.04) 0 2px, transparent 2px 32px),
    linear-gradient(180deg, #1b1423 0%, #100c16 100%);
  border-right: 2px solid rgba(212, 175, 55, 0.32);
  position: relative;
  transition: transform 1.25s cubic-bezier(0.65, 0, 0.35, 1);
}

.door-right {
  border-right: none;
  border-left: 2px solid rgba(212, 175, 55, 0.32);
}

.door-arch-detail {
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(212, 175, 55, 0.18);
  border-radius: 120px 120px 0 0;
}

.door-light-spill {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(245, 221, 146, 0.9), rgba(212, 175, 55, 0.25) 45%, transparent 72%);
  opacity: 0;
  transition: opacity 0.9s ease;
}

.gate-stage.opening .door-left {
  transform: translateX(-102%);
}

.gate-stage.opening .door-right {
  transform: translateX(102%);
}

.gate-stage.opening .door-light-spill {
  opacity: 1;
}

.gate-stage.opening .gate-content {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.gate-content {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 540px;
}

.collected-runes {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.2rem 0 1.8rem;
}

.collected-rune-chip {
  padding: 0.35rem 0.78rem;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: rgba(212, 175, 55, 0.14);
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}

.wax-seal-trigger {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.seal-ring {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 158px;
  height: 158px;
  border-radius: 50%;
  border: 2px dashed var(--gold);
  padding: 10px;
  animation: slowPulse 3s ease-in-out infinite;
}

.seal-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-light), var(--accent) 62%, #4a0c12 100%);
  border: 2px solid var(--gold-bright);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.45), 0 0 30px var(--accent-glow);
  color: #fff5df;
  padding: 0.75rem;
  transition: transform 0.25s ease;
}

.wax-seal-trigger:hover .seal-inner {
  transform: scale(1.06);
}

.seal-glyph {
  font-size: 1.65rem;
  color: var(--gold-bright);
  margin-bottom: 0.25rem;
}

.seal-cta {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.25;
}

@keyframes slowPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.25); }
  50% { box-shadow: 0 0 28px 6px rgba(212, 175, 55, 0.35); }
}

/* ==========================================================================
   SCHERMATA 4: ARCHIVIO PERGAMENE
   ========================================================================== */
.archive-header {
  text-align: center;
  margin-bottom: 1.6rem;
}

.archive-stats {
  display: inline-block;
  padding: 0.32rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 55, 0.28);
  background: rgba(20, 15, 26, 0.72);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--gold-bright);
}

.featured-letter-section {
  margin-bottom: 2rem;
}

.birthday-banner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
  padding: 1.35rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gold);
  background:
    radial-gradient(circle at 100% 0%, rgba(212, 175, 55, 0.22), transparent 55%),
    linear-gradient(135deg, rgba(35, 24, 43, 0.95), rgba(20, 14, 27, 0.95));
  color: var(--text-main);
  cursor: pointer;
  box-shadow: var(--shadow-magic);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.birthday-banner:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.65), 0 0 24px rgba(212, 175, 55, 0.24);
}

.birthday-title {
  margin: 0.5rem 0 0.25rem;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 3.8vw, 1.55rem);
  color: var(--gold-bright);
}

.birthday-preview {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text-muted);
}

.wax-seal-emblem {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-light), var(--accent) 70%, #4d0d13);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--gold-bright);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.section-heading-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.section-subtitle {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
}

.gold-line {
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, var(--gold-border), transparent);
}

.scrolls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

.scroll-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  width: 100%;
  text-align: left;
  padding: 1.15rem 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(212, 175, 55, 0.3);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.scroll-card:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  background: var(--bg-elevated);
}

.scroll-card.opened {
  border-color: rgba(212, 175, 55, 0.55);
}

.scroll-info {
  min-width: 0;
}

.scroll-spell {
  margin: 0 0 0.2rem;
  font-family: var(--font-display);
  font-size: 1.16rem;
  color: var(--gold-bright);
}

.scroll-when {
  margin: 0 0 0.35rem;
  font-size: 1.02rem;
  font-style: italic;
  color: var(--text-muted);
}

.scroll-status {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.scroll-card.opened .scroll-status {
  color: #a9e4be;
}

.scroll-seal-badge {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: radial-gradient(circle at 35% 30%, #9b2430, #661019);
  border: 1.5px solid var(--gold);
  color: var(--gold-bright);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.scroll-card.opened .scroll-seal-badge {
  background: rgba(212, 175, 55, 0.14);
  color: var(--gold);
}

/* Ottava Pergamena */
.eighth-section {
  margin-top: 1.65rem;
}

.eighth-card {
  width: 100%;
  text-align: left;
  padding: 1.3rem 1.2rem;
  border-radius: var(--radius-md);
  border: 1px dashed var(--gold-border);
  background: linear-gradient(135deg, rgba(16, 12, 22, 0.92), rgba(32, 24, 42, 0.78));
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.eighth-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.eighth-card.locked .scroll-seal-badge {
  background: #1b1724;
  border-color: rgba(212, 175, 55, 0.45);
}

.archive-footer {
  margin-top: 2.2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.footer-note {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.74rem;
  color: var(--text-dim);
}

/* ==========================================================================
   MODALE LETTURA PERGAMENA
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 4, 8, 0.84);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.25s ease;
}

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

.parchment-modal {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: 88dvh;
  overflow-y: auto;
  border-radius: var(--radius-md);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.85), 0 0 36px rgba(212, 175, 55, 0.2);
  animation: unrollScroll 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes unrollScroll {
  from { opacity: 0; transform: scaleY(0.88) translateY(16px); }
  to { opacity: 1; transform: scaleY(1) translateY(0); }
}

.parchment-sheet {
  background:
    radial-gradient(ellipse at top left, rgba(255, 251, 240, 0.8), transparent 60%),
    linear-gradient(180deg, var(--parchment-bg) 0%, #ede0c0 100%);
  color: var(--parchment-ink);
  border: 3px double #b69454;
  border-radius: var(--radius-md);
  padding: 2rem 1.45rem 1.7rem;
}

.modal-close-btn {
  position: sticky;
  top: 0.65rem;
  float: right;
  margin: 0.55rem 0.55rem -2.2rem 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(92, 70, 50, 0.35);
  background: rgba(244, 232, 206, 0.92);
  color: var(--parchment-ink);
  font-size: 1rem;
  cursor: pointer;
  z-index: 3;
}

.parchment-top-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  margin-bottom: 0.65rem;
  color: #8c5c22;
}

.ornament-line {
  height: 1px;
  width: 55px;
  background: linear-gradient(90deg, transparent, #a67c3b, transparent);
}

.ornament-glyph {
  font-size: 1.25rem;
}

.modal-when {
  margin: 0;
  text-align: center;
  font-style: italic;
  font-size: 1rem;
  color: var(--parchment-ink-soft);
}

.modal-title {
  margin: 0.25rem 0 1.25rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 4.5vw, 1.95rem);
  color: #6f1a22;
}

.modal-body {
  font-size: 1.18rem;
  line-height: 1.72;
  color: var(--parchment-ink);
}

.modal-body p {
  margin: 0 0 1rem;
}

.modal-signature {
  margin: 1.4rem 0 0;
  text-align: right;
  font-family: var(--font-display);
  font-size: 0.96rem;
  color: #6f1a22;
}

.modal-actions {
  margin-top: 1.5rem;
  text-align: center;
}

.btn-parchment-close {
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  border: 1px solid #8c5c22;
  background: rgba(140, 92, 34, 0.12);
  color: var(--parchment-ink);
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  min-height: 44px;
}

.btn-parchment-close:hover {
  background: rgba(140, 92, 34, 0.22);
}

/* ==========================================================================
   RESPONSIVE DESKTOP & REDUCED MOTION
   ========================================================================== */
@media (min-width: 640px) {
  .app-shell {
    padding: 2rem 1.5rem 4rem;
  }

  .dispatch-border {
    padding: 2.4rem 2.4rem 2rem;
  }

  .trial-card {
    padding: 2rem 2rem;
  }

  .ingredients-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .scrolls-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .parchment-sheet {
    padding: 2.5rem 2.6rem 2.1rem;
  }
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
