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

:root {
    /* Night-sky & mystic indigo palette */
    --bg-abyss: #070412;
    --bg-midnight: #0d0820;
    --mystical-deep: #120b28;
    --mystical-purple: #26164a;
    --mystical-light: #4d3380;
    --nebula-indigo: rgba(68, 45, 130, 0.34);
    --nebula-plum: rgba(112, 46, 118, 0.22);

    /* Antique gold foil palette */
    --gold-primary: #d4af37;
    --gold-light: #f6e7bd;
    --gold-bright: #ffe694;
    --gold-dark: #7d5b12;
    --gold-gradient: linear-gradient(135deg, #9c741b 0%, #e3c25b 32%, #fff1bf 50%, #d4af37 72%, #8a6314 100%);
    --gold-line-gradient: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.85), rgba(255, 241, 191, 0.95), rgba(212, 175, 55, 0.85), transparent);

    /* Parchment & leather */
    --paper-cream: #f6efe0;
    --paper-aged: #e5d7be;
    --paper-edge: #cbb999;
    --leather-dark: #160a0d;
    --leather-mid: #281316;
    --leather-light: #3d1d22;
    --text-dark: #2a1710;

    /* Glows & shadows */
    --shadow-mystical: rgba(8, 4, 20, 0.72);
    --glow-gold: rgba(212, 175, 55, 0.38);
    --glow-gold-strong: rgba(255, 230, 148, 0.55);

    /* Typography */
    --font-serif: 'Noto Serif SC', 'Songti SC', serif;
    --font-display: 'Cinzel', 'Times New Roman', serif;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-serif);
    background-color: var(--bg-midnight);
    background-image:
        radial-gradient(ellipse 80% 60% at 50% 45%, rgba(62, 37, 112, 0.36) 0%, transparent 65%),
        radial-gradient(circle at 18% 22%, var(--nebula-indigo) 0%, transparent 45%),
        radial-gradient(circle at 82% 78%, var(--nebula-plum) 0%, transparent 48%),
        radial-gradient(circle at 50% 50%, transparent 42%, rgba(4, 2, 10, 0.82) 100%),
        linear-gradient(160deg, var(--bg-abyss) 0%, var(--bg-midnight) 48%, #150c2e 100%);
    color: var(--paper-cream);
    -webkit-font-smoothing: antialiased;
    user-select: none;
}

/* Subtle vignette overlay */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(circle at 50% 50%, transparent 55%, rgba(4, 2, 10, 0.65) 100%);
}

/* ============================================================
   Loading Screen
   ============================================================ */
#loading-screen {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 50% 45%, rgba(56, 33, 104, 0.45) 0%, transparent 55%),
        linear-gradient(180deg, var(--bg-abyss) 0%, var(--bg-midnight) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    transition: opacity 0.9s ease-out;
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    padding: 2rem;
}

.mystical-symbol {
    font-size: 4.2rem;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 1.75rem;
    filter: drop-shadow(0 0 18px var(--glow-gold));
    animation: pulse-glow 2.2s ease-in-out infinite;
}

.loading-content h2 {
    font-family: var(--font-serif);
    font-weight: 300;
    font-size: 1.35rem;
    color: var(--gold-light);
    margin-bottom: 1.8rem;
    letter-spacing: 0.28em;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

.loading-bar {
    width: 220px;
    height: 2px;
    background: rgba(212, 175, 55, 0.16);
    margin: 0 auto;
    border-radius: 999px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.loading-progress {
    width: 0%;
    height: 100%;
    border-radius: 999px;
    background: var(--gold-gradient);
    box-shadow: 0 0 12px var(--glow-gold-strong);
    animation: loading-progress 2s ease-out forwards;
}

@keyframes loading-progress {
    to { width: 100%; }
}

@keyframes pulse-glow {
    0%, 100% {
        opacity: 0.72;
        transform: scale(1);
        filter: drop-shadow(0 0 14px var(--glow-gold));
    }
    50% {
        opacity: 1;
        transform: scale(1.08);
        filter: drop-shadow(0 0 28px var(--glow-gold-strong));
    }
}

/* ============================================================
   Three.js Canvas Background
   ============================================================ */
#canvas-container {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

#canvas-container canvas {
    display: block;
}

/* ============================================================
   CSS 3D Book
   ============================================================ */
#book-scene {
    position: fixed;
    top: 52%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    perspective: 2200px;
    width: 300px;
    height: 400px;
}

/* Soft ambient ground shadow under the floating book */
#book-scene::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -44px;
    width: 280px;
    height: 36px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(4, 2, 12, 0.78) 0%, rgba(16, 9, 36, 0.35) 55%, transparent 78%);
    filter: blur(10px);
    pointer-events: none;
    animation: shadow-breathe 6s ease-in-out infinite;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

#book-scene:has(.book.open)::after {
    animation: none;
    opacity: 0.65;
    transform: translateX(-50%) scaleX(1.15);
}

.book {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transform: rotateX(8deg) rotateY(-10deg);
    transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
    cursor: pointer;
    animation: book-float 6s ease-in-out infinite;
}

.book:hover {
    transform: rotateX(5deg) rotateY(-5deg) translateY(-4px);
}

.book.open {
    animation: none;
    translate: 0 0;
    transform: rotateX(4deg) rotateY(-30deg);
}

@keyframes book-float {
    0%, 100% { translate: 0 0; }
    50% { translate: 0 -10px; }
}

@keyframes shadow-breathe {
    0%, 100% {
        opacity: 0.85;
        transform: translateX(-50%) scale(1);
    }
    50% {
        opacity: 0.55;
        transform: translateX(-50%) scale(0.92);
    }
}

/* ----- Cover Structure (two-sided) ----- */
.cover {
    position: absolute;
    width: 300px;
    height: 400px;
    transform-style: preserve-3d;
}

.cover .face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 4px 12px 12px 4px;
    overflow: hidden;
}

/* FRONT COVER */
.cover.front {
    transform-origin: left center;
    transform: translateZ(50px);
    transition: transform 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 10;
}

.cover.front .face.outside {
    background:
        radial-gradient(circle at 35% 28%, rgba(212, 175, 55, 0.12) 0%, transparent 55%),
        radial-gradient(circle at 75% 80%, rgba(0, 0, 0, 0.45) 0%, transparent 60%),
        linear-gradient(135deg, var(--leather-light) 0%, var(--leather-mid) 45%, var(--leather-dark) 100%);
    box-shadow:
        inset 0 1px 1px rgba(255, 241, 191, 0.14),
        inset -2px -2px 14px rgba(0, 0, 0, 0.6),
        12px 18px 36px rgba(4, 2, 12, 0.72),
        0 0 28px rgba(212, 175, 55, 0.08);
}

.cover.front .face.inside {
    transform: translateZ(1px) rotateY(180deg);
    background: linear-gradient(135deg, #271316 0%, #160a0d 100%);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.55);
}

.book.open .cover.front {
    transform: translateZ(50px) rotateY(-175deg);
}

/* BACK COVER */
.cover.back {
    transform: translateZ(-20px) rotateY(180deg);
    z-index: 1;
}

.cover.back .face.outside {
    background: linear-gradient(135deg, var(--leather-mid) 0%, var(--leather-dark) 100%);
    box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.65);
}

/* ----- Leather Texture Overlay ----- */
.leather-texture {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(rgba(255, 241, 191, 0.03) 1px, transparent 0),
        repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(0, 0, 0, 0.05) 2px, rgba(0, 0, 0, 0.05) 4px),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, 0.05) 2px, rgba(0, 0, 0, 0.05) 4px);
    background-size: 6px 6px, auto, auto;
    pointer-events: none;
}

/* ----- Spine (left edge) ----- */
.spine-visual {
    position: absolute;
    left: 0;
    top: 0;
    width: 18px;
    height: 100%;
    background: linear-gradient(
        90deg,
        #0a0406 0%,
        var(--leather-mid) 28%,
        #4a2328 50%,
        var(--leather-mid) 74%,
        #0b0507 100%
    );
    border-radius: 4px 0 0 4px;
    box-shadow:
        inset -3px 0 8px rgba(0, 0, 0, 0.65),
        2px 0 10px rgba(0, 0, 0, 0.45);
}

.spine-visual::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 8%;
    bottom: 8%;
    width: 2px;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 16px,
        rgba(227, 194, 91, 0.22) 16px,
        rgba(227, 194, 91, 0.22) 18px
    );
}

/* ----- Gold Borders ----- */
.gold-outer-border {
    position: absolute;
    inset: 12px 12px 12px 24px;
    border: 1.5px solid rgba(212, 175, 55, 0.72);
    border-radius: 2px 8px 8px 2px;
    box-shadow:
        inset 0 0 0 1px rgba(246, 231, 189, 0.14),
        0 0 10px rgba(212, 175, 55, 0.14);
    pointer-events: none;
}

.gold-inner-border {
    position: absolute;
    inset: 20px 20px 20px 32px;
    border: 1px solid rgba(212, 175, 55, 0.36);
    border-radius: 1px 5px 5px 1px;
    pointer-events: none;
}

/* ----- Corner Ornaments ----- */
.corner {
    position: absolute;
    width: 24px;
    height: 24px;
    pointer-events: none;
}

.corner::before,
.corner::after {
    content: '';
    position: absolute;
    background: var(--gold-gradient);
    box-shadow: 0 0 6px rgba(212, 175, 55, 0.35);
}

.corner.tl { top: 15px; left: 27px; }
.corner.tl::before { top: 0; left: 0; width: 18px; height: 2px; }
.corner.tl::after  { top: 0; left: 0; width: 2px; height: 18px; }

.corner.tr { top: 15px; right: 15px; }
.corner.tr::before { top: 0; right: 0; width: 18px; height: 2px; }
.corner.tr::after  { top: 0; right: 0; width: 2px; height: 18px; }

.corner.bl { bottom: 15px; left: 27px; }
.corner.bl::before { bottom: 0; left: 0; width: 18px; height: 2px; }
.corner.bl::after  { bottom: 0; left: 0; width: 2px; height: 18px; }

.corner.br { bottom: 15px; right: 15px; }
.corner.br::before { bottom: 0; right: 0; width: 18px; height: 2px; }
.corner.br::after  { bottom: 0; right: 0; width: 2px; height: 18px; }

/* ----- Center Ornament ----- */
.center-ornament {
    position: absolute;
    top: 35%;
    left: 52%;
    transform: translate(-50%, -50%);
    width: 88px;
    height: 88px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.magic-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1.5px solid rgba(227, 194, 91, 0.78);
    box-shadow:
        0 0 18px rgba(212, 175, 55, 0.18),
        inset 0 0 14px rgba(212, 175, 55, 0.12);
    animation: spin-slow 24s linear infinite;
}

.magic-ring::before {
    content: '';
    position: absolute;
    inset: 11px;
    border-radius: 50%;
    border: 1px dashed rgba(246, 231, 189, 0.55);
    animation: spin-slow 14s linear infinite reverse;
}

.magic-core {
    font-size: 2rem;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.45));
    animation: pulse-glow 3.4s ease-in-out infinite;
}

@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ----- Gold-foil Title on Cover ----- */
.book-title-area {
    position: absolute;
    top: 63%;
    left: 52%;
    transform: translateX(-50%);
    width: 72%;
    text-align: center;
    pointer-events: none;
}

.book-title-area h1 {
    font-family: var(--font-serif);
    font-size: 1.48rem;
    font-weight: 700;
    letter-spacing: 0.34em;
    padding-left: 0.34em;
    margin: 0.55rem 0 0.45rem;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.85)) drop-shadow(0 0 10px rgba(212, 175, 55, 0.25));
}

.title-line {
    width: 84px;
    height: 1px;
    background: var(--gold-line-gradient);
    margin: 0 auto;
    opacity: 0.85;
}

.subtitle-en {
    display: block;
    margin-top: 0.35rem;
    font-family: var(--font-display);
    font-size: 0.58rem;
    letter-spacing: 0.24em;
    color: var(--gold-light);
    opacity: 0.72;
    text-transform: uppercase;
}

/* ----- Inside Face (left page when open) ----- */
.face.inside .inner-paper {
    position: absolute;
    inset: 14px 14px 14px 24px;
    background: linear-gradient(135deg, var(--paper-aged) 0%, var(--paper-cream) 100%);
    border-radius: 2px 5px 5px 2px;
    box-shadow: inset -6px 0 18px rgba(92, 68, 16, 0.14);
    overflow: hidden;
}

.inner-lines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 26px,
        rgba(125, 91, 18, 0.06) 26px,
        rgba(125, 91, 18, 0.06) 27px
    );
}

.inner-decorations {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 36px;
    color: var(--gold-dark);
    opacity: 0.28;
    font-size: 1rem;
}

.inner-decorations .deco {
    display: block;
}

/* ----- Page Block (thickness when closed) ----- */
.page-block {
    position: absolute;
    width: 290px;
    height: 390px;
    top: 5px;
    left: 5px;
    transform: translateZ(0);
    transform-style: preserve-3d;
    z-index: 5;
    pointer-events: none;
}

.sheet {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, var(--paper-edge) 0%, var(--paper-cream) 5%, var(--paper-cream) 95%, #c7b594 100%);
    border-radius: 2px 7px 7px 2px;
    box-shadow: inset -1px 0 2px rgba(0, 0, 0, 0.1);
    transform: translateZ(var(--z));
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transition-delay: var(--delay);
    transform-origin: left center;
}

.sheet::after {
    content: '';
    position: absolute;
    right: 0;
    top: 2px;
    bottom: 2px;
    width: 2.5px;
    background: linear-gradient(
        to bottom,
        var(--gold-dark),
        var(--gold-primary),
        var(--gold-light),
        var(--gold-primary),
        var(--gold-dark)
    );
    border-radius: 0 6px 6px 0;
    opacity: 0.72;
}

.book.open .sheet {
    transform: translateZ(var(--z)) rotateY(var(--angle));
}

/* ----- Right Page (answer) ----- */
.right-page {
    position: absolute;
    width: 290px;
    height: 390px;
    top: 5px;
    left: 5px;
    transform: translateZ(48px);
    transform-style: preserve-3d;
    z-index: 8;
    opacity: 0;
    transition: opacity 0.5s ease 0.3s;
    pointer-events: none;
}

.book.open .right-page {
    opacity: 1;
    pointer-events: auto;
}

.right-page .paper {
    position: relative;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 50% 45%, rgba(255, 252, 242, 0.6) 0%, transparent 70%),
        linear-gradient(135deg, var(--paper-aged) 0%, var(--paper-cream) 22%, var(--paper-cream) 78%, #ddd0b7 100%);
    border-radius: 2px 7px 7px 2px;
    box-shadow:
        inset 10px 0 22px rgba(92, 68, 16, 0.14),
        inset 0 0 26px rgba(125, 91, 18, 0.1);
    padding: 30px 24px;
    overflow: hidden;
}

.paper-lines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 25px,
        rgba(125, 91, 18, 0.065) 25px,
        rgba(125, 91, 18, 0.065) 26px
    );
    pointer-events: none;
}

/* Answer content inside right page */
.answer-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-dark);
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.7s ease 0.5s;
}

.book.open .answer-wrap {
    opacity: 1;
    transform: translateY(0);
}

.answer-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
    color: var(--gold-dark);
    letter-spacing: 0.18em;
    margin-bottom: 0.7rem;
}

.answer-header .sigil {
    font-size: 0.9rem;
    opacity: 0.68;
}

.answer-header .chapter {
    font-weight: 500;
}

.divider {
    width: 62%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-dark), var(--gold-primary), var(--gold-dark), transparent);
    margin: 0.75rem 0;
    opacity: 0.75;
}

.answer-paragraph {
    font-family: var(--font-serif);
    font-size: 1.18rem;
    line-height: 2;
    letter-spacing: 0.09em;
    font-weight: 500;
    min-height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    color: #2b1810;
}

.footer-mark {
    margin-top: 0.75rem;
    font-size: 1.25rem;
    color: var(--gold-dark);
    opacity: 0.45;
}

/* ============================================================
   UI Overlay
   ============================================================ */
#ui-overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 1.5rem 2.4rem;
}

#ui-overlay > * {
    pointer-events: auto;
}

/* Header */
.main-header {
    text-align: center;
    margin-top: 0.5rem;
    animation: fade-in-down 1.2s ease-out;
}

.title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.title-main {
    font-family: var(--font-serif);
    font-size: clamp(2.1rem, 4.5vw, 3.1rem);
    font-weight: 700;
    letter-spacing: 0.32em;
    padding-left: 0.32em;
    background: linear-gradient(110deg, #b58924 0%, #f6e7bd 26%, #d4af37 48%, #fff4cc 62%, #b58924 100%);
    background-size: 220% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 22px rgba(212, 175, 55, 0.3)) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.7));
    animation: gold-shimmer 7s ease-in-out infinite;
}

@keyframes gold-shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.title-sub {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gold-light);
    letter-spacing: 0.42em;
    padding-left: 0.42em;
    text-transform: uppercase;
    opacity: 0.76;
}

.subtitle {
    margin-top: 0.85rem;
    font-size: 0.96rem;
    font-weight: 300;
    color: rgba(235, 224, 202, 0.8);
    letter-spacing: 0.16em;
    max-width: 90vw;
    word-break: keep-all;
    text-wrap: balance;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.65);
}

/* ============================================================
   Answer Glassmorphism Overlay Card
   ============================================================ */
.answer-display {
    position: absolute;
    top: 52%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    text-align: center;
    opacity: 1;
    transition: opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1), transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 20;
    cursor: pointer;
}

.answer-display.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.88);
    pointer-events: none;
}

.answer-frame {
    position: relative;
    min-width: 340px;
    max-width: min(500px, 88vw);
    padding: 2.6rem 3.4rem;
    border-radius: 18px;
    background: linear-gradient(155deg, rgba(28, 16, 56, 0.82) 0%, rgba(12, 7, 28, 0.9) 100%);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border: 1px solid rgba(212, 175, 55, 0.45);
    box-shadow:
        0 24px 64px rgba(3, 1, 10, 0.78),
        0 0 48px rgba(212, 175, 55, 0.14),
        inset 0 1px 0 rgba(255, 241, 191, 0.18),
        inset 0 0 36px rgba(212, 175, 55, 0.05);
}

.answer-frame::before,
.answer-frame::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 1.5px solid rgba(246, 231, 189, 0.72);
    pointer-events: none;
}

.answer-frame::before {
    top: 12px;
    left: 12px;
    border-right: none;
    border-bottom: none;
    border-top-left-radius: 6px;
}

.answer-frame::after {
    bottom: 12px;
    right: 12px;
    border-left: none;
    border-top: none;
    border-bottom-right-radius: 6px;
}

.answer-decoration {
    height: 1px;
    background: var(--gold-line-gradient);
    margin: 1.15rem auto;
    width: 75%;
    opacity: 0.85;
}

.answer-text {
    font-family: var(--font-serif);
    font-size: 1.55rem;
    font-weight: 500;
    color: var(--paper-cream);
    line-height: 1.95;
    letter-spacing: 0.1em;
    min-height: 108px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
}

.answer-number {
    margin-top: 1.15rem;
    font-size: 0.84rem;
    color: var(--gold-light);
    letter-spacing: 0.24em;
    opacity: 0.75;
}

/* ============================================================
   Controls & Buttons
   ============================================================ */
.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    margin-bottom: 1.2rem;
    animation: fade-in-up 1.2s ease-out 0.35s both;
}

.btn-mystical {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 500;
    padding: 0.88rem 2.2rem;
    border-radius: 999px;
    border: 1.5px solid transparent;
    background:
        linear-gradient(135deg, rgba(36, 20, 68, 0.92), rgba(17, 10, 38, 0.96)) padding-box,
        var(--gold-gradient) border-box;
    color: var(--gold-light);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease, color 0.3s ease;
    letter-spacing: 0.16em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    box-shadow:
        0 8px 24px rgba(4, 2, 12, 0.55),
        0 0 18px rgba(212, 175, 55, 0.14);
}

.btn-mystical::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--gold-gradient);
    opacity: 0;
    transition: opacity 0.35s ease;
    z-index: -1;
}

.btn-mystical:hover::before {
    opacity: 1;
}

.btn-mystical:hover {
    color: var(--bg-abyss);
    transform: translateY(-2px);
    box-shadow:
        0 12px 28px rgba(4, 2, 12, 0.65),
        0 0 28px var(--glow-gold);
}

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

.btn-mystical:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 3px rgba(13, 8, 32, 0.9),
        0 0 0 5px var(--gold-bright),
        0 0 24px var(--glow-gold);
}

.btn-mystical.secondary {
    background: rgba(18, 11, 40, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 175, 55, 0.34);
    color: rgba(235, 224, 202, 0.88);
    box-shadow: 0 6px 20px rgba(4, 2, 12, 0.45);
}

.btn-mystical.secondary::before {
    background: linear-gradient(135deg, rgba(77, 51, 128, 0.65), rgba(45, 27, 78, 0.78));
}

.btn-mystical.secondary:hover {
    color: var(--gold-light);
    border-color: rgba(246, 231, 189, 0.65);
    box-shadow:
        0 10px 24px rgba(4, 2, 12, 0.55),
        0 0 20px rgba(122, 86, 196, 0.32);
}

.btn-icon {
    font-size: 1.12rem;
    line-height: 1;
}

.btn-text {
    line-height: 1;
}

.instructions {
    position: absolute;
    bottom: 1rem;
    font-size: 0.78rem;
    color: rgba(214, 200, 235, 0.55);
    letter-spacing: 0.14em;
    animation: fade-in 1.8s ease-out 0.8s both;
    text-align: center;
    padding: 0 1rem;
}

/* ============================================================
   Floating Particles
   ============================================================ */
#particles-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 4;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--gold-primary);
    border-radius: 50%;
    opacity: 0;
    box-shadow: 0 0 8px rgba(246, 231, 189, 0.55);
    animation: float-particle 4s ease-in-out infinite;
}

@keyframes float-particle {
    0%   { opacity: 0; transform: translateY(100vh) scale(0); }
    12%  { opacity: 0.75; }
    88%  { opacity: 0.65; }
    100% { opacity: 0; transform: translateY(-10vh) scale(1); }
}

/* ============================================================
   Entrance Keyframes
   ============================================================ */
@keyframes fade-in-down {
    from { opacity: 0; transform: translateY(-22px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(22px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================================
   Responsive Breakpoints
   ============================================================ */
@media (max-width: 768px) {
    #ui-overlay {
        padding: 1.25rem 1rem 2rem;
    }

    #book-scene {
        top: 46%;
        transform: translate(-50%, -50%) scale(0.76);
    }

    .title-sub {
        font-size: 0.72rem;
        letter-spacing: 0.32em;
    }

    .subtitle {
        font-size: 0.86rem;
        margin-top: 0.6rem;
    }

    .answer-display {
        top: 46%;
    }

    .answer-frame {
        min-width: 0;
        width: 86vw;
        padding: 1.9rem 1.8rem;
    }

    .answer-text {
        font-size: 1.2rem;
        min-height: 82px;
        letter-spacing: 0.08em;
    }

    .controls {
        flex-wrap: wrap;
        gap: 0.75rem;
        margin-bottom: 0.9rem;
    }

    .btn-mystical {
        padding: 0.74rem 1.55rem;
        font-size: 0.92rem;
    }

    .instructions {
        bottom: 0.65rem;
        font-size: 0.72rem;
    }
}

@media (max-width: 420px) {
    #book-scene {
        top: 45%;
        transform: translate(-50%, -50%) scale(0.6);
    }

    .title-main {
        letter-spacing: 0.22em;
        padding-left: 0.22em;
    }

    .subtitle {
        font-size: 0.8rem;
        letter-spacing: 0.1em;
    }

    .answer-frame {
        width: 90vw;
        padding: 1.6rem 1.35rem;
        border-radius: 14px;
    }

    .answer-text {
        font-size: 1.08rem;
        min-height: 70px;
    }

    .controls {
        flex-direction: column;
        width: 100%;
    }

    .btn-mystical {
        width: min(240px, 76vw);
        padding: 0.72rem 1.2rem;
    }
}

/* ============================================================
   Reduced Motion Accessibility
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .mystical-symbol,
    .magic-ring,
    .magic-ring::before,
    .magic-core,
    .title-main,
    .book,
    #book-scene::after,
    .particle,
    .main-header,
    .controls,
    .instructions {
        animation: none !important;
    }

    .book,
    .cover.front,
    .sheet,
    .right-page,
    .answer-wrap,
    .answer-display,
    .btn-mystical,
    #loading-screen {
        transition-duration: 0.01ms !important;
        transition-delay: 0ms !important;
    }
}
