/* ═══════════════════════════════════════════════════════════
   FABLETIDE - fabletide design system
   ═══════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────── */
:root {
    --purple-deep: #1a0a3c;
    --purple-mid: #2d1060;
    --purple-soft: #4a1f8c;
    --blue-deep: #0a1628;
    --blue-mid: #0d2550;
    --gold: #f5c842;
    --gold-soft: #fde98a;
    --coral: #ff6b6b;
    --teal: #00d4aa;
    --teal-dark: #00a882;
    --white: #ffffff;
    --off-white: #f0eaff;
    --text-light: #c9b8ff;
    --text-muted: #8870bb;
    --card-bg: rgba(255, 255, 255, 0.06);
    --card-border: rgba(255, 255, 255, 0.12);
    --nav-h: 68px;
    --border-radius: 14px;
    --border-radius-large: 22px;
    --transition-speed: 0.25s;
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
/* Hide the page scrollbar globally so layout never shifts horizontally
   when content height changes (e.g. switching between Plans and Credits
   in the in-app pricing screen). Scroll still works via wheel, touch,
   and keyboard. */
html, body { scrollbar-width: none; -ms-overflow-style: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; width: 0; height: 0; }
body {
    font-family: 'Nunito', sans-serif;
    background: var(--purple-deep);
    color: var(--white);
    overflow-x: hidden;
    min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
ul { list-style: none; }
.hidden, .sq-hidden { display: none !important; }

/* ── Animations ─────────────────────────────────────────── */
@keyframes fadeIn       { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInDown   { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInUp     { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes twinkle      { 0% { opacity: 0.25; } 100% { opacity: 0.65; } }
@keyframes spin         { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes bookFloat    { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes sparkleFloat { 0%, 100% { transform: translateY(0) scale(1); opacity: 0.95; } 50% { transform: translateY(-4px) scale(1.08); opacity: 0.55; } }
@keyframes bounce       { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ── Stars background ───────────────────────────────────── */
.stars { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.star { position: absolute; border-radius: 50%; background: white; animation: twinkle 7s infinite alternate; }

/* ═══════════════════════════════════════════════════════════
   SITE NAV
   ═══════════════════════════════════════════════════════════ */
.site-nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 200;
    height: var(--nav-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 2rem;
    background: rgba(26, 10, 60, 0.85);
    backdrop-filter: blur(14px);
}

.nav-logo { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; flex-shrink: 0; }
.nav-logo-icon { font-size: 1.5rem; }
.nav-logo-text {
    font-family: 'Fredoka One', cursive; font-size: 1.6rem;
    background: linear-gradient(135deg, var(--gold), var(--teal));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.nav-logged-out { display: flex; align-items: center; gap: 1.2rem; }
.nav-link {
    color: var(--text-light); font-weight: 700; font-size: 0.9rem;
    cursor: pointer; transition: color var(--transition-speed);
    background: none; border: none; padding: 0;
}
.nav-link:hover { color: var(--white); }

.btn-nav-outline {
    padding: 0.45rem 1.2rem; border-radius: 50px;
    background: transparent; border: 2px solid var(--teal);
    color: var(--teal); font-weight: 800; font-size: 0.85rem;
    transition: all var(--transition-speed);
}
.btn-nav-outline:hover { background: var(--teal); color: var(--purple-deep); }

.btn-nav-gold {
    padding: 0.45rem 1.2rem; border-radius: 50px;
    background: linear-gradient(135deg, var(--gold), #f0a800);
    color: var(--purple-deep); font-weight: 800; font-size: 0.85rem;
    border: none; transition: all var(--transition-speed);
}
.btn-nav-gold:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(245, 200, 66, 0.4); }

.btn-nav-tour {
    padding: 0.45rem 0.9rem; border-radius: 50px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--card-border);
    color: var(--text-light); font-weight: 700; font-size: 0.82rem;
    cursor: pointer; transition: all var(--transition-speed);
    display: inline-flex; align-items: center; gap: 0.35rem;
}
.btn-nav-tour:hover { background: rgba(0, 212, 170, 0.16); color: var(--white); border-color: var(--teal); }

.demo-banner {
    /* Absolute-centered against the fixed nav so the logo on the left
       doesn't push the banner off-axis (space-between would otherwise
       shove it to the right). */
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    display: flex; align-items: center; justify-content: center;
    gap: 10px; flex-wrap: wrap;
    background: rgba(245, 200, 66, 0.12); border: 1px solid rgba(245, 200, 66, 0.3);
    border-radius: 10px; padding: 6px 14px;
    font-size: 0.85rem; color: var(--gold); font-weight: 600;
    max-width: calc(100% - 4rem);
}
.demo-banner.hidden { display: none !important; }
.demo-banner-msg { font-weight: 400; color: var(--text-light); }
.demo-upgrade-link, .demo-back-link {
    background: none; border: none; color: var(--teal);
    font-family: inherit; font-size: inherit; font-weight: 600; cursor: pointer;
    transition: color var(--transition-speed);
}
.demo-upgrade-link:hover, .demo-back-link:hover { color: var(--white); }

.user-badge {
    display: flex; align-items: center; gap: 1.2rem;
    animation: fadeIn 0.3s ease-out;
}
.user-badge.hidden { display: none !important; }
.user-badge-info { display: none; }
.user-badge-name { font-size: 0.9rem; font-weight: 800; color: var(--white); white-space: nowrap; }
.user-badge-tier { font-size: 0.72rem; color: var(--teal); font-weight: 700; white-space: nowrap; }
.user-badge-stories {
    background: none; border: none; color: var(--text-light);
    font-weight: 700; font-size: 0.85rem; white-space: nowrap;
    transition: color var(--transition-speed);
}
.user-badge-stories:hover { color: var(--white); }
.user-badge-right { display: flex; align-items: center; gap: 1.2rem; }
.main-nav-btn {
    background: none; border: none; color: var(--text-light);
    font-weight: 700; font-size: 0.85rem; white-space: nowrap;
    transition: color var(--transition-speed);
}
.main-nav-btn:hover { color: var(--white); }
.main-nav-btn.hidden { display: none !important; }
.user-badge-logout {
    padding: 0.45rem 1.2rem; border-radius: 50px;
    background: transparent; border: 2px solid var(--text-muted);
    color: var(--text-muted); font-weight: 800; font-size: 0.85rem;
    white-space: nowrap; transition: all var(--transition-speed);
}
.user-badge-logout:hover { border-color: var(--coral); color: var(--coral); }

.hamburger-btn {
    display: none; align-items: center; justify-content: center;
    background: transparent; border: 1px solid var(--card-border);
    border-radius: 8px; color: var(--white); width: 34px; height: 34px;
    font-size: 1rem; transition: background var(--transition-speed);
}
.hamburger-btn:hover { background: rgba(255, 255, 255, 0.08); }

.mobile-nav-menu {
    position: absolute; top: var(--nav-h); right: 0; left: 0;
    background: rgba(26, 10, 60, 0.97); backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--card-border); padding: 0.5rem 0; z-index: 201;
}
.mobile-nav-menu.hidden { display: none !important; }
.mobile-nav-item {
    display: block; width: 100%; padding: 12px 20px;
    background: transparent; border: none; color: var(--text-light);
    font-size: 0.95rem; font-weight: 700; text-align: left;
    transition: background var(--transition-speed);
}
.mobile-nav-item:hover { background: rgba(255, 255, 255, 0.06); color: var(--white); }
.mobile-nav-item.hidden { display: none !important; }
.mobile-nav-logout { color: var(--text-muted); font-weight: 600; }

/* ═══════════════════════════════════════════════════════════
   AUTH LANDING PAGE
   ═══════════════════════════════════════════════════════════ */
.auth-landing {
    padding-top: calc(var(--nav-h) + 3rem);
    position: relative;
    background: radial-gradient(ellipse at 50% 0%, var(--purple-mid) 0%, var(--purple-deep) 60%);
}
.auth-landing.hidden { display: none !important; }

.landing-hero { text-align: center; padding: 0 1.5rem 3rem; position: relative; z-index: 1; }
.hero-tag {
    display: inline-block;
    background: rgba(245, 200, 66, 0.12); border: 1px solid rgba(245, 200, 66, 0.4);
    color: var(--gold); padding: 0.3rem 0.9rem; border-radius: 50px;
    font-size: 0.82rem; font-weight: 800; margin-bottom: 1.2rem; letter-spacing: 0.04em;
}
.hero-title {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(2.4rem, 5.5vw, 4.2rem); line-height: 1.1; margin-bottom: 1rem;
}
.hero-title span {
    background: linear-gradient(135deg, var(--gold), var(--teal));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-sub { font-size: 1.05rem; color: var(--text-light); max-width: 540px; margin: 0 auto; line-height: 1.7; }

.auth-row {
    display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap;
    width: 100%; max-width: 780px; margin: 0 auto;
    padding: 0 1rem; position: relative; z-index: 1;
}

/* Redeem-from-email context banner. Shown above .auth-row when a credit
   code is stashed (typically from clicking the CTA in a gift email). */
.auth-redeem-banner {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    width: 100%;
    max-width: 780px;
    margin: 0 auto 1.25rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(245, 197, 24, 0.18), rgba(245, 197, 24, 0.08));
    border: 1px solid rgba(245, 197, 24, 0.4);
    border-radius: 14px;
    position: relative;
    z-index: 1;
}
.auth-redeem-banner-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
}
.auth-redeem-banner-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    line-height: 1.4;
}
.auth-redeem-banner-text strong {
    color: var(--gold);
    font-size: 1rem;
}
.auth-redeem-banner-text span {
    color: var(--text-light);
    font-size: 0.9rem;
}
.auth-redeem-banner.hidden { display: none; }
.auth-card {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 22px; padding: 2rem 1.8rem;
    flex: 1; min-width: 290px; max-width: 360px;
    backdrop-filter: blur(10px);
}
.auth-card-title { font-family: 'Fredoka One', cursive; font-size: 1.25rem; color: var(--gold); margin-bottom: 1.2rem; }

#loginCard .auth-form-panel { display: none; }
#loginCard .auth-form-panel.active { display: block; }
#signupCard .auth-form-panel { display: block; }

.auth-field { margin-bottom: 0.75rem; }
.auth-field label {
    display: block; font-size: 0.75rem; font-weight: 800;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.3rem;
}
.auth-input {
    width: 100%; padding: 0.65rem 0.9rem;
    border-radius: 10px; border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.07); color: var(--white);
    font-family: 'Nunito', sans-serif; font-size: 0.9rem;
    outline: none; transition: border var(--transition-speed);
}
.auth-input:focus { border-color: var(--teal); }
.auth-input::placeholder { color: var(--text-muted); }
.auth-field-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; display: block; line-height: 1.4; }
.auth-field-hint strong { color: var(--text-light); }
.auth-reset-title { font-family: 'Fredoka One', cursive; font-size: 1.1rem; color: var(--gold-soft); margin-bottom: 1rem; }
.auth-forgot-desc { font-size: 0.85rem; color: var(--text-light); margin-bottom: 1rem; line-height: 1.5; }

.auth-submit-btn {
    width: 100%; padding: 0.75rem; border-radius: 50px;
    background: linear-gradient(135deg, var(--teal), var(--teal-dark));
    color: var(--purple-deep); font-weight: 800; font-size: 0.95rem;
    border: none; margin-top: 0.3rem; transition: all var(--transition-speed);
}
.auth-submit-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 212, 170, 0.4); }
.auth-submit-btn:disabled { opacity: 0.6; transform: none; cursor: not-allowed; }

.auth-forgot-link { text-align: center; margin-top: 0.75rem; }
.auth-text-btn {
    background: none; border: none; color: var(--teal);
    font-size: 0.82rem; font-weight: 700; cursor: pointer;
    transition: color var(--transition-speed);
}
.auth-text-btn:hover { color: var(--white); }

.auth-error { color: var(--coral); font-size: 0.82rem; font-weight: 700; min-height: 1.2em; margin: 0.3rem 0; }
.auth-success { color: var(--teal); font-size: 0.82rem; font-weight: 700; min-height: 1.2em; margin: 0.3rem 0; }
.auth-free-note { text-align: center; font-size: 0.78rem; color: var(--text-muted); margin-top: 0.75rem; }
.auth-tabs.hidden { display: none !important; }

.auth-bottom { text-align: center; padding: 1.5rem 1rem 0; position: relative; z-index: 1; }
.auth-divider {
    display: flex; align-items: center; gap: 1rem;
    max-width: 300px; margin: 0 auto 1rem;
    color: var(--text-muted); font-size: 0.82rem; font-weight: 700;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--card-border); }
.auth-demo-btn {
    background: var(--card-bg); border: 1px solid var(--card-border);
    color: var(--text-light); padding: 0.65rem 1.8rem; border-radius: 50px;
    font-weight: 700; font-size: 0.9rem; transition: all var(--transition-speed);
}
.auth-demo-btn:hover { border-color: var(--teal); color: var(--white); }
.auth-demo-note { font-size: 0.78rem; color: var(--text-muted); }
.auth-pricing-link { margin-top: 0.75rem; }

/* ── Paid signup screen ─────────────────────────────────── */
.paid-signup-header { text-align: center; padding: 0 1.5rem 1.5rem; position: relative; z-index: 1; }
.paid-signup-back {
    display: inline-block; margin-bottom: 1.2rem;
    color: var(--teal); font-size: 0.9rem; font-weight: 700;
}
.paid-signup-title {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.2; margin-bottom: 0.5rem;
}
.paid-signup-title span {
    background: linear-gradient(135deg, var(--gold), var(--teal));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.paid-signup-sub { color: var(--text-light); font-size: 0.95rem; }
.paid-signup-notice {
    display: flex; gap: 1rem; align-items: flex-start;
    max-width: 720px; margin: 0 auto 2rem;
    background: rgba(245, 200, 66, 0.08); border: 1px solid rgba(245, 200, 66, 0.4);
    border-radius: 16px; padding: 1rem 1.2rem; position: relative; z-index: 1;
}
.paid-signup-notice-icon { font-size: 1.6rem; line-height: 1; flex-shrink: 0; }
.paid-signup-notice strong { color: var(--gold); font-size: 0.95rem; display: block; margin-bottom: 0.25rem; }
.paid-signup-notice p { font-size: 0.85rem; color: var(--text-light); line-height: 1.5; margin: 0; }
.paid-signup-notice p strong { display: inline; color: var(--gold-soft); font-size: inherit; margin: 0; }

.paid-signup-plan-card .pricing-toggle-row { margin: 1rem 0 1.2rem; }

.custom-select { position: relative; }
.custom-select-trigger {
    display: flex; justify-content: space-between; align-items: center;
    width: 100%; padding: 0.65rem 0.9rem;
    border-radius: 10px; border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.07); color: var(--white);
    font-family: 'Nunito', sans-serif; font-size: 0.9rem; font-weight: 700;
    text-align: left; cursor: pointer;
    transition: border var(--transition-speed);
}
.custom-select-trigger:hover, .custom-select-trigger:focus,
.custom-select.open .custom-select-trigger { border-color: var(--teal); outline: none; }
.custom-select-arrow { color: var(--teal); font-size: 0.9rem; transition: transform var(--transition-speed); }
.custom-select.open .custom-select-arrow { transform: rotate(180deg); }
.custom-select-options {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--purple-mid); border: 1.5px solid var(--teal);
    border-radius: 10px; padding: 0.3rem;
    z-index: 50;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(0, 212, 170, 0.18);
}
.custom-select-options[hidden] { display: none; }
.custom-select-option {
    display: flex; align-items: center; gap: 0.55rem;
    width: 100%; text-align: left;
    background: transparent; border: none; color: var(--text-light);
    padding: 0.6rem 0.85rem; font-size: 0.9rem; font-weight: 600;
    border-radius: 6px; cursor: pointer;
    transition: background var(--transition-speed), color var(--transition-speed);
}
.custom-select-option:hover, .custom-select-option:focus { background: rgba(0, 212, 170, 0.14); color: var(--white); outline: none; }
.custom-select-emoji { font-size: 1.05rem; line-height: 1; }
.paid-signup-summary {
    margin-top: 1rem; padding: 1rem; border-radius: 14px;
    background: rgba(255, 255, 255, 0.04); border: 1px solid var(--card-border);
}
.paid-signup-summary-name { font-family: 'Fredoka One', cursive; font-size: 1.1rem; color: var(--gold-soft); margin-bottom: 0.2rem; }
.paid-signup-summary-price { font-family: 'Fredoka One', cursive; font-size: 1.4rem; color: var(--white); margin-bottom: 0.4rem; }
.paid-signup-summary-desc { font-size: 0.85rem; color: var(--text-light); margin-bottom: 0.6rem; line-height: 1.5; }
.paid-signup-summary-features { list-style: none; padding: 0; margin: 0; }
.paid-signup-summary-features li {
    font-size: 0.82rem; color: var(--text-light); padding: 0.22rem 0;
    display: flex; gap: 0.5rem; align-items: flex-start;
}
.paid-signup-summary-features li::before {
    content: '✦'; color: var(--teal); font-size: 0.7rem; margin-top: 3px; flex-shrink: 0;
}
.paid-signup-toggle.hidden { display: none; }
.custom-select-option.option-locked {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: auto; /* keep tooltip / hover hint */
}
.custom-select-option.option-locked::after {
    content: '🔒';
    margin-left: auto;
    font-size: 0.8rem;
}
.custom-select-option.option-locked:hover,
.custom-select-option.option-locked:focus {
    background: transparent;
    color: var(--text-light);
}
.paid-signup-gated-banner { margin-top: 0; }
.paid-signup-trial-badge {
    display: block;
    margin: 1rem 0 0;
    padding: 0.55rem 0.85rem;
    border-radius: 999px;
    background: var(--teal-dark);
    color: var(--purple-deep);
    font-family: 'Fredoka One', cursive;
    font-size: 0.95rem;
    text-align: center;
    letter-spacing: 0.2px;
}
.paid-signup-summary-trial-note {
    color: var(--gold-soft);
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0.7rem 0 0;
    padding: 0.6rem 0.75rem;
    background: rgba(245, 200, 66, 0.08);
    border-left: 3px solid var(--gold);
    border-radius: 4px;
}

/* ── Features section ───────────────────────────────────── */
.landing-features {
    position: relative; padding: 5rem 2rem;
    background: linear-gradient(180deg, transparent 0%, var(--blue-deep) 100%);
    margin-top: 4rem;
}
.section-title { font-family: 'Fredoka One', cursive; font-size: 2.1rem; text-align: center; margin-bottom: 0.5rem; position: relative; z-index: 1; }
.section-sub { text-align: center; color: var(--text-light); font-size: 1rem; margin-bottom: 2.5rem; position: relative; z-index: 1; }
.features-grid {
    /* Flex (not grid) so the last row centres any leftover cards instead of
       leaving an empty grid cell on the right. Cards stay capped at 300px so
       the row never grows wider than the surrounding section. */
    display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch;
    gap: 1.2rem; max-width: 960px; margin: 0 auto; position: relative; z-index: 1;
}
.features-grid > .feature-card { flex: 1 1 240px; max-width: 300px; min-width: 0; }
@media (max-width: 899px) {
    /* Tablet/mobile: max 2 per row. flex-basis 240 + gap means at <500-ish px
       only one card fits per row, which is fine for narrow phones. */
    .features-grid > .feature-card { flex: 1 1 calc(50% - 0.6rem); max-width: calc(50% - 0.6rem); }
}
.feature-card {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 20px; padding: 1.6rem; text-align: center;
    transition: transform var(--transition-speed);
}
.feature-card:hover { transform: translateY(-4px); }
.feature-icon { font-size: 2.2rem; margin-bottom: 0.7rem; }
.feature-card h4 { font-family: 'Fredoka One', cursive; font-size: 1.05rem; color: var(--gold-soft); margin-bottom: 0.4rem; }
.feature-card p { font-size: 0.85rem; color: var(--text-light); line-height: 1.6; }

/* ── Landing pricing ────────────────────────────────────── */
.landing-pricing {
    position: relative; padding: 5rem 2rem 4rem;
    background:
        linear-gradient(180deg, var(--blue-deep) 0%, transparent 14%),
        radial-gradient(ellipse at 50% 100%, var(--purple-mid) 0%, var(--purple-deep) 70%);
}
.pricing-toggle-row { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin-bottom: 2.5rem; position: relative; z-index: 1; }
.payment-billing-toggle { margin: 0 0 1.4rem; }
.toggle-label-text { font-weight: 700; color: var(--text-light); font-size: 0.9rem; }
.toggle-label-text.active-label { color: var(--white); }
.pricing-toggle-switch {
    width: 50px; height: 26px; background: var(--purple-soft);
    border-radius: 50px; position: relative; cursor: pointer; transition: background 0.3s;
    border: none;
}
.pricing-toggle-switch.active { background: var(--teal-dark); }
.toggle-knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: white; border-radius: 50%; transition: left 0.3s; }
.pricing-toggle-switch.active .toggle-knob { left: 27px; }
.save-badge { background: rgba(0, 212, 170, 0.15); border: 1px solid var(--teal); color: var(--teal); padding: 0.2rem 0.65rem; border-radius: 50px; font-size: 0.75rem; font-weight: 800; }

.pricing-cards-grid {
    /* Flex (not grid) so the in-app upgrade flow, which can render fewer
       than 4 cards, stays centred instead of leaving empty grid columns
       on the right. Cards are capped at 290px so a single rendered card
       does not balloon to full container width. */
    display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch;
    gap: 1.2rem; max-width: 1200px; margin: 0 auto 3rem; position: relative; z-index: 1;
}
.pricing-cards-grid > .sq-pricing-card { flex: 1 1 240px; max-width: 290px; min-width: 0; }
.sq-pricing-card {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 22px; padding: 1.8rem 1.4rem; position: relative;
    transition: transform var(--transition-speed);
    display: flex; flex-direction: column;
}
.sq-pricing-card:hover { transform: translateY(-4px); }
.sq-popular { border-color: var(--gold); background: rgba(245, 200, 66, 0.06); }
.sq-popular-badge, .sq-trial-badge, .sq-legend-badge {
    position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
    padding: 0.18rem 0.9rem; border-radius: 50px; font-size: 0.75rem; font-weight: 900; white-space: nowrap;
}
.sq-popular-badge { background: linear-gradient(135deg, var(--gold), #f0a800); color: var(--purple-deep); }
.sq-trial-badge { background: var(--teal-dark); color: var(--purple-deep); font-size: 0.72rem; }
.sq-legend-badge { background: var(--coral); color: white; font-size: 0.72rem; }
.sq-plan-emoji { font-size: 2rem; margin-bottom: 0.5rem; }
.sq-plan-name { font-family: 'Fredoka One', cursive; font-size: 1.2rem; margin-bottom: 0.3rem; }
/* Price + suffix stay on a single line. Font sizes are sized so even the
   widest combination ($24.99 + "/ month, billed annually") fits inside the
   ~245px content area of a 290px-wide card. */
.sq-plan-price { font-family: 'Fredoka One', cursive; font-size: 1.65rem; line-height: 1.1; margin-bottom: 0.25rem; white-space: nowrap; }
.sq-plan-price span { font-family: 'Nunito', sans-serif; font-size: 0.7rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.sq-plan-desc { font-size: 0.8rem; color: var(--text-light); margin-bottom: 1rem; line-height: 1.5; }
.sq-plan-features { margin-bottom: 1.4rem; flex: 1; }
.sq-plan-features li { font-size: 0.82rem; padding: 0.28rem 0; color: var(--text-light); display: flex; gap: 0.5rem; align-items: flex-start; }
.sq-plan-features li::before { content: '✦'; color: var(--teal); font-size: 0.65rem; margin-top: 3px; flex-shrink: 0; }
.sq-plan-btn { width: 100%; padding: 0.7rem; border-radius: 50px; font-weight: 800; font-size: 0.88rem; border: none; transition: all var(--transition-speed); margin-top: auto; }
.sq-plan-btn:hover { transform: translateY(-2px); }
.sq-plan-btn-outline { background: transparent; border: 2px solid var(--card-border); color: var(--text-light); }
.sq-plan-btn-outline:hover { border-color: var(--teal); color: var(--teal); }
.sq-plan-btn-teal { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: var(--purple-deep); }
.sq-plan-btn-teal:hover { box-shadow: 0 5px 18px rgba(0, 212, 170, 0.4); }
.sq-plan-btn-gold { background: linear-gradient(135deg, var(--gold), #f0a800); color: var(--purple-deep); }
.sq-plan-btn-gold:hover { box-shadow: 0 5px 18px rgba(245, 200, 66, 0.4); }
.sq-plan-btn-coral { background: linear-gradient(135deg, var(--coral), #e04040); color: white; }
.sq-plan-btn-coral:hover { box-shadow: 0 5px 18px rgba(255, 107, 107, 0.4); }

.sq-credits-section { max-width: 760px; margin: 0 auto; position: relative; z-index: 1; }
.sq-credits-title { font-family: 'Fredoka One', cursive; font-size: 1.4rem; text-align: center; margin-bottom: 0.4rem; }
.sq-credits-sub { text-align: center; color: var(--text-light); font-size: 0.88rem; margin-bottom: 1.2rem; }
.sq-credits-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 0.9rem; padding-top: 0.75rem; }
.sq-credit-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 18px; padding: 1.2rem 0.9rem; text-align: center; transition: all var(--transition-speed); }
.sq-credit-card:hover { border-color: var(--coral); transform: translateY(-3px); }
.sq-credit-best { border-color: var(--coral); background: rgba(255, 107, 107, 0.07); position: relative; overflow: visible; }
.sq-credit-best-badge { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, var(--coral), #e04040); color: white; padding: 0.18rem 0.6rem; border-radius: 50px; font-size: 0.72rem; font-weight: 900; white-space: nowrap; }
.sq-credit-count { font-family: 'Fredoka One', cursive; font-size: 1.8rem; color: var(--gold); }
.sq-credit-label { font-size: 0.8rem; color: var(--text-light); margin-bottom: 0.4rem; }
.sq-credit-price { font-size: 1rem; font-weight: 800; }
.sq-credit-buy-btn { margin-top: 0.9rem; padding: 0.55rem 0.9rem; font-size: 0.82rem; }
.sq-credit-per { font-size: 0.7rem; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   APP CONTAINER
   ═══════════════════════════════════════════════════════════ */
.app-container {
    max-width: 1100px; margin: 0 auto;
    padding: calc(var(--nav-h) + 24px) 20px 20px;
    display: flex; flex-direction: column;
}
/* Widen the container only while the in-app pricing screen is active so
   the four plan cards always sit on a single row (never 3+1). Other
   sections keep the standard 1100px width. The credits panel inherits
   this width too, so toggling between Plans and Credits does not shift. */
.app-container:has(#pricingSection.active) { max-width: min(1340px, calc(100vw - 40px)); }
.app-container.hidden { display: none !important; }
.main-content { flex: 1; display: flex; flex-direction: column; }
.form-section {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: var(--border-radius-large); padding: 2rem;
    display: none; animation: fadeIn 0.35s ease-out;
}
.form-section.active { display: block; }
.form-section h2 { font-family: 'Fredoka One', cursive; font-size: 1.7rem; color: var(--gold-soft); text-align: center; margin-bottom: 0.5rem; }
.section-description { text-align: center; color: var(--text-light); font-size: 1rem; margin-bottom: 1.5rem; }

/* ── Home Section ───────────────────────────────────────── */
.home-container { padding: 1rem 0; }
.welcome-hero { text-align: center; margin-bottom: 2.5rem; }
.welcome-hero h2 { font-family: 'Fredoka One', cursive; font-size: 2.2rem; margin-bottom: 0.4rem; }
.welcome-hero h2 span { color: var(--gold); }
.welcome-sub { color: var(--text-light); font-size: 1rem; }
.welcome-tier { margin-top: 0.3rem; font-size: 0.95rem; color: var(--text-light); }
.welcome-tier-badge { color: var(--teal); font-weight: 900; }

#homeSection {
    background: radial-gradient(ellipse at 50% 0%, var(--purple-mid) 0%, var(--purple-deep) 60%);
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    margin-top: calc(-1 * (var(--nav-h) + 24px));
}
.home-container { padding: calc(var(--nav-h) + 3.5rem) 1.5rem 3rem; display: flex; flex-direction: column; align-items: center; position: relative; z-index: 1; }
.home-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; max-width: 500px; width: 100%; margin: 0 auto 2.5rem; }
#homeNewStoryCard { grid-column: 1 / -1; padding: 2rem 1.4rem; }
#homeNewStoryCard .action-icon { font-size: 3rem; }
#homeNewStoryCard h4 { font-size: 1.3rem; }
.action-card {
    background: var(--card-bg); border: 1px solid var(--card-border);
    border-radius: 18px; padding: 1.6rem 1.4rem; text-align: center;
    cursor: pointer; transition: all var(--transition-speed); min-width: 150px;
    color: var(--white);
}
.action-card:hover { transform: translateY(-4px); border-color: var(--teal); }
.action-icon { font-size: 2.4rem; margin-bottom: 0.5rem; }
.action-card h4 { font-family: 'Fredoka One', cursive; font-size: 1rem; color: var(--gold-soft); }
.action-card p { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; }

.home-shelf-section { margin-bottom: 2rem; }
.shelf-title { font-family: 'Fredoka One', cursive; font-size: 1.2rem; color: var(--gold-soft); margin-bottom: 0.8rem; }
.story-shelf { display: flex; gap: 0.9rem; overflow-x: auto; padding-bottom: 0.75rem; }
.story-shelf::-webkit-scrollbar { height: 4px; }
.story-shelf::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius: 2px; }
.story-shelf::-webkit-scrollbar-thumb { background: var(--purple-soft); border-radius: 2px; }
.story-thumb { flex-shrink: 0; width: 150px; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; overflow: hidden; cursor: pointer; transition: transform var(--transition-speed); }
.story-thumb:hover { transform: scale(1.04); }
.story-thumb-img { width: 100%; height: 90px; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; }
.story-thumb-info { padding: 0.6rem; }
.story-thumb-info h5 { font-size: 0.82rem; font-weight: 800; margin-bottom: 0.15rem; }
.story-thumb-info p { font-size: 0.72rem; color: var(--text-muted); }

.char-shelf { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.char-chip { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 50px; padding: 0.4rem 1rem 0.4rem 0.5rem; display: flex; align-items: center; gap: 0.5rem; cursor: pointer; transition: all var(--transition-speed); }
.char-chip:hover { border-color: var(--gold); }
.char-avatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.char-chip span { font-size: 0.85rem; font-weight: 700; }

/* ── Step Indicator ─────────────────────────────────────── */
.step-indicator { display: flex; align-items: center; justify-content: center; padding: 1rem 0 0.5rem; }
.step { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.step-number { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; border: 2px solid var(--card-border); color: var(--text-muted); background: var(--card-bg); transition: all var(--transition-speed); }
.step.active .step-number { border-color: var(--teal); color: var(--teal); background: rgba(0,212,170,0.1); }
.step.completed .step-number { border-color: var(--gold); background: var(--gold); color: var(--purple-deep); }
.step-label { font-size: 0.7rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.step.active .step-label { color: var(--teal); }
.step-line { flex: 1; max-width: 50px; height: 2px; background: var(--card-border); border-radius: 2px; margin: 0 4px 20px; }
.step-line.completed { background: var(--gold); }

/* ── Step 1 ─────────────────────────────────────────────── */
.character-count-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1rem; max-width: 600px; margin: 0 auto; }
.character-tile { background: var(--card-bg); border: 2px solid var(--card-border); border-radius: 18px; padding: 1.5rem 1rem; text-align: center; cursor: pointer; transition: all var(--transition-speed); display: flex; flex-direction: column; align-items: center; gap: 0.5rem; color: var(--white); }
.character-tile:hover { border-color: var(--teal); transform: translateY(-3px); }
.character-tile.selected { border-color: var(--gold); background: rgba(245,200,66,0.07); }
.tile-number { font-family: 'Fredoka One', cursive; font-size: 2.5rem; color: var(--gold); line-height: 1; }
.tile-label { font-size: 0.85rem; color: var(--text-light); font-weight: 700; }
.step1-quota-hint { text-align: center; color: var(--coral); font-size: 0.85rem; margin-bottom: 1rem; font-weight: 700; }

/* ── Step 2: Character forms ────────────────────────────── */
.character-forms { margin-bottom: 1.5rem; }
.character-form { background: rgba(255,255,255,0.04); border: 1px solid var(--card-border); border-radius: var(--border-radius); padding: 1.2rem; margin-bottom: 1rem; }
.character-form h3 { font-family: 'Fredoka One', cursive; font-size: 1rem; color: var(--gold-soft); margin-bottom: 0.8rem; }
.form-group { margin-bottom: 0.75rem; }
.form-group label { display: block; font-size: 0.75rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.3rem; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.6rem 0.85rem; border-radius: 10px; border: 1px solid var(--card-border); background: rgba(255,255,255,0.07); color: var(--white); font-family: 'Nunito', sans-serif; font-size: 0.9rem; outline: none; transition: border var(--transition-speed); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--teal); }
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-muted); }
.form-group select option { background: var(--purple-mid); }
.char-photo-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.char-photo-btn { padding: 0.35rem 0.75rem; border-radius: 8px; font-size: 0.8rem; font-weight: 700; border: 1px solid var(--card-border); background: rgba(255,255,255,0.06); color: var(--text-light); cursor: pointer; transition: all var(--transition-speed); }
.char-photo-btn:hover, .char-photo-btn.active { border-color: var(--teal); color: var(--teal); }
.char-photo-preview { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid var(--card-border); }

/* ── Saved character picker ─────────────────────────────── */
.char-use-saved-btn { display: flex; align-items: center; gap: 0.4rem; padding: 0.4rem 1rem; border-radius: 50px; background: rgba(245,200,66,0.1); border: 1px solid rgba(245,200,66,0.3); color: var(--gold); font-size: 0.82rem; font-weight: 700; cursor: pointer; margin-bottom: 0.75rem; transition: all var(--transition-speed); font-family: 'Nunito', sans-serif; }
.char-use-saved-btn:hover { background: rgba(245,200,66,0.18); border-color: var(--gold); }
.char-saved-picker { background: rgba(255,255,255,0.04); border: 1px solid var(--card-border); border-radius: 14px; padding: 0.8rem; margin-bottom: 0.75rem; }
.char-saved-picker.hidden { display: none !important; }
.char-saved-list { display: flex; flex-direction: column; gap: 0.4rem; }
.char-saved-option { display: flex; align-items: center; gap: 0.75rem; width: 100%; padding: 0.5rem 0.75rem; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px; color: var(--white); cursor: pointer; text-align: left; transition: all var(--transition-speed); font-family: 'Nunito', sans-serif; }
.char-saved-option:hover { border-color: var(--teal); background: rgba(0,212,170,0.06); }
.char-saved-option.selected { border-color: var(--gold); background: rgba(245,200,66,0.07); }
.char-saved-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; background: rgba(245,200,66,0.15); border: 1px solid rgba(245,200,66,0.3); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.char-saved-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.char-saved-avatar-initial { font-size: 1rem; font-weight: 800; color: var(--gold); }
.char-saved-info { display: flex; flex-direction: column; gap: 2px; }
.char-saved-info strong { font-size: 0.85rem; font-weight: 800; color: var(--white); }
.char-saved-info span { font-size: 0.74rem; color: var(--text-muted); line-height: 1.3; }
.char-save-row { display: flex; align-items: center; justify-content: space-between; margin-top: 0.5rem; flex-wrap: wrap; gap: 0.3rem; }
.char-save-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--text-light); cursor: pointer; }
.char-save-label input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--teal); cursor: pointer; }
.char-save-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ── Step 3: Location ───────────────────────────────────── */
.custom-location-container { max-width: 500px; margin: 0 auto; }
.custom-location-label { font-size: 0.82rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.5rem; }
.custom-location-input { width: 100%; padding: 0.75rem 1.1rem; border-radius: 50px; border: 2px solid var(--card-border); background: rgba(255,255,255,0.07); color: var(--white); font-family: 'Nunito', sans-serif; font-size: 0.95rem; outline: none; transition: border var(--transition-speed); }
.custom-location-input:focus { border-color: var(--gold); }
.custom-location-input::placeholder { color: var(--text-muted); }

.location-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; max-width: 900px; margin: 0 auto 1.5rem; }
.location-tile { background: var(--card-bg); border: 2px solid var(--card-border); border-radius: 18px; padding: 1.4rem 1rem; text-align: center; cursor: pointer; transition: all var(--transition-speed); color: var(--white); }
.location-tile:hover { border-color: var(--purple-soft); transform: translateY(-3px); }
.location-tile.selected { border-color: var(--gold); background: rgba(245,200,66,0.07); }
.location-tile .location-emoji { font-size: 2.5rem; margin-bottom: 0.5rem; display: block; }
.location-tile h4 { font-family: 'Fredoka One', cursive; font-size: 0.95rem; margin-bottom: 0.2rem; }
.location-tile p { font-size: 0.77rem; color: var(--text-muted); }

/* ── Step 4: Genre ──────────────────────────────────────── */
.genre-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; max-width: 800px; margin: 0 auto 1.5rem; }
.genre-tile { border: 2px solid transparent; border-radius: 18px; padding: 1.3rem 1rem; text-align: center; cursor: pointer; transition: all var(--transition-speed); color: var(--white); font-weight: 700; font-size: 0.95rem; text-shadow: 0 1px 4px rgba(0,0,0,0.5); background: var(--card-bg); opacity: 0.85; }
.genre-tile:hover { transform: translateY(-3px); opacity: 1; filter: brightness(1.08); }
.genre-tile.selected { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,0.25); opacity: 1; }
.genre-tile .genre-emoji { font-size: 2.2rem; margin-bottom: 0.4rem; display: block; }
.genre-tile .genre-name { display: block; font-family: 'Fredoka One', cursive; font-size: 1rem; }
.genre-tile[data-genre="Adventure"] { background: linear-gradient(135deg, #C0622A, #F08030); }
.genre-tile[data-genre="Fantasy"]   { background: linear-gradient(135deg, #6A35B5, #A855F7); }
.genre-tile[data-genre="Funny"]     { background: linear-gradient(135deg, #E07800, #F5C518); color: #1a0a00; text-shadow: none; }
.genre-tile[data-genre="Mystery"]   { background: linear-gradient(135deg, #2C3E6A, #4A6FA5); }
.genre-tile[data-genre="Spooky"]    { background: linear-gradient(135deg, #2A5E2A, #52A852); }
.genre-tile[data-genre="Magical"]   { background: linear-gradient(135deg, #D63088, #F472B6, #A855F7); }

/* ── Step 4: Save-my-media toggles ──────────────────────── */
.media-save-options {
    max-width: 600px;
    margin: 0 auto 1rem;
    padding: 1rem 1.25rem;
    background: rgba(255,217,61,0.08);
    border: 1px solid rgba(255,217,61,0.3);
    border-radius: 12px;
}
.media-save-title { font-family: 'Fredoka One', cursive; font-size: 1rem; color: var(--gold-soft); margin: 0 0 0.3rem; text-align: center; }
.media-save-sub   { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 0.7rem; text-align: center; line-height: 1.4; }
.media-save-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.8rem;
    background: rgba(0,0,0,0.18);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-light);
    font-size: 0.9rem;
    transition: all var(--transition-speed);
}
.media-save-toggle + .media-save-toggle { margin-top: 0.45rem; }
.media-save-toggle:hover { border-color: rgba(255,217,61,0.4); color: var(--white); }
.media-save-toggle input { accent-color: var(--gold); width: 1.05rem; height: 1.05rem; flex-shrink: 0; }
.media-save-emoji { display: inline-block; margin-right: 0.25rem; }

/* ── Nav buttons ────────────────────────────────────────── */
.navigation-buttons { display: flex; justify-content: center; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; }
.nav-btn { padding: 0.7rem 1.8rem; border-radius: 50px; font-weight: 800; font-size: 0.95rem; border: none; transition: all var(--transition-speed); display: inline-flex; align-items: center; gap: 0.4rem; }
.btn-icon { font-size: 0.9rem; }
.back-btn { background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-light); }
.back-btn:hover { border-color: var(--teal); color: var(--white); }
.next-btn { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: var(--purple-deep); }
.next-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(0,212,170,0.4); }
.start-btn { background: linear-gradient(135deg, var(--gold), #f0a800); color: var(--purple-deep); }
.start-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(245,200,66,0.4); }
.restart-btn { background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-light); }
.restart-btn:hover { border-color: var(--coral); color: var(--coral); }
.download-btn { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: var(--purple-deep); }
.download-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(0,212,170,0.35); }
.start-again-btn { background: linear-gradient(135deg, var(--gold), #f0a800); color: var(--purple-deep); }
.home-start-btn { background: linear-gradient(135deg, var(--gold), #f0a800); color: var(--purple-deep); }
.nav-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

/* ── Loading ────────────────────────────────────────────── */
#loadingSection { position: relative; overflow: hidden; }
.loading-container { text-align: center; padding: 3rem 1rem; position: relative; z-index: 1; }
.story-loading-animation { margin-bottom: 2rem; }
.magic-book { position: relative; width: 90px; height: 75px; margin: 0 auto; }
.book-cover { width: 90px; height: 75px; background: linear-gradient(135deg, var(--purple-soft), var(--teal-dark)); border-radius: 8px 14px 14px 8px; box-shadow: 0 6px 20px rgba(0,212,170,0.25); animation: bookFloat 9s ease-in-out infinite; }
.book-cover::before { content: '📖'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 2.2rem; }
.sparkles { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); width: 130px; display: flex; justify-content: space-around; }
.sparkles span { font-size: 1.1rem; animation: sparkleFloat 9s ease-in-out infinite; }
.sparkles span:nth-child(2) { animation-delay: 1.8s; }
.sparkles span:nth-child(3) { animation-delay: 3.6s; }
.sparkles span:nth-child(4) { animation-delay: 5.4s; }
.sparkles span:nth-child(5) { animation-delay: 7.2s; }
.loading-title { font-family: 'Fredoka One', cursive; font-size: 1.6rem; color: var(--gold-soft); margin-bottom: 0.5rem; }
.loading-text { color: var(--text-light); font-size: 0.95rem; margin-bottom: 1.5rem; }
.loading-steps { display: flex; flex-direction: column; gap: 0.5rem; max-width: 280px; margin: 0 auto; }
.loading-step { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1rem; border-radius: 10px; background: var(--card-bg); border: 1px solid var(--card-border); font-size: 0.88rem; color: var(--text-muted); transition: all var(--transition-speed); }
.loading-step.active { border-color: var(--teal); color: var(--teal); background: rgba(0,212,170,0.07); }
.step-icon { font-size: 1.1rem; }

/* ── Active Story ───────────────────────────────────────── */
.active-story-container { text-align: center; padding: 3rem 1rem; }
.active-story-icon { font-size: 4rem; margin-bottom: 1rem; animation: bookFloat 6s ease-in-out infinite; }
.active-story-message { color: var(--text-light); font-size: 1rem; margin-bottom: 1.5rem; }
.active-story-buttons { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; }

/* ── Story Section ──────────────────────────────────────── */
.story-display { padding: 0; }
.story-header { text-align: center; margin-bottom: 1.5rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--card-border); }
.story-title { font-family: 'Fredoka One', cursive; font-size: 1.7rem; color: var(--gold-soft); margin-bottom: 0.4rem; }
.episode-title { color: var(--teal); font-size: 0.95rem; font-weight: 700; }

.story-columns { width: 100%; display: grid; grid-template-columns: 1fr 520px; grid-template-rows: auto auto; grid-template-areas: "text image" "text choices"; gap: 18px 24px; }
.story-col-text { grid-area: text; min-height: 200px; overflow-y: auto; background: rgba(255,255,255,0.03); border: 1px solid var(--card-border); border-radius: var(--border-radius); padding: 1.4rem; scrollbar-width: thin; scrollbar-color: var(--purple-soft) transparent; }
.story-col-text::-webkit-scrollbar { width: 5px; }
.story-col-text::-webkit-scrollbar-thumb { background: var(--purple-soft); border-radius: 3px; }
.story-col-image { grid-area: image; border-radius: var(--border-radius-large); overflow: hidden; align-self: start; }
.story-col-choices { grid-area: choices; align-self: start; }

.story-image-container { position: relative; width: 100%; }
.story-image { width: 100%; height: auto; display: block; border-radius: var(--border-radius-large) var(--border-radius-large) 0 0; }
.image-loading-overlay { position: absolute; inset: 0; background: var(--card-bg); display: flex; align-items: center; justify-content: center; border-radius: var(--border-radius-large); }
.image-loading-overlay.hidden { display: none !important; }
.image-spinner { width: 44px; height: 44px; border: 3px solid rgba(255,255,255,0.1); border-top-color: var(--teal); border-radius: 50%; animation: spin 1s linear infinite; }
.story-text { font-size: 1.05rem; line-height: 1.8; color: var(--off-white); white-space: pre-wrap; text-align: justify; }

.audio-bar { width: 100%; background: rgba(255,255,255,0.05); border-top: 1px solid var(--card-border); display: flex; flex-direction: column; border-radius: 0 0 var(--border-radius-large) var(--border-radius-large); }
.audio-bar.hidden { display: none !important; }
.audio-bar-progress { height: 5px; background: rgba(255,255,255,0.1); width: 100%; cursor: pointer; transition: height 0.15s; }
.audio-bar-progress:hover { height: 8px; }
.audio-bar-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width 0.1s linear; }
.audio-bar-controls { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 6px 14px; }
.audio-bar-play { width: 34px; height: 34px; border-radius: 50%; border: none; background: linear-gradient(135deg, var(--teal), var(--teal-dark)); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition-speed); }
.audio-bar-play:hover { transform: scale(1.1); box-shadow: 0 3px 12px rgba(0,212,170,0.4); }
.audio-bar-play.playing { background: linear-gradient(135deg, var(--gold), #f0a800); }
.audio-bar-restart { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--card-border); background: transparent; color: var(--text-light); cursor: pointer; font-size: 0.85rem; display: flex; align-items: center; justify-content: center; transition: all var(--transition-speed); }
.audio-bar-restart:hover { border-color: var(--teal); color: var(--teal); }

.choices-title { font-family: 'Fredoka One', cursive; font-size: 1rem; color: var(--gold-soft); margin-bottom: 0.75rem; text-align: center; }
.choices-container { display: flex; flex-direction: column; gap: 0.75rem; }
.choice-btn { width: 100%; padding: 0.9rem 1.2rem; background: var(--card-bg); border: 2px solid var(--card-border); border-radius: 14px; color: var(--white); font-family: 'Nunito', sans-serif; font-size: 0.92rem; font-weight: 700; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 0.8rem; opacity: 0; pointer-events: none; transition: opacity 0.7s ease-out, border-color var(--transition-speed), background var(--transition-speed), transform var(--transition-speed); }
.choice-btn.is-revealed { opacity: 1; pointer-events: auto; }
.choice-btn:hover { border-color: var(--teal); background: rgba(0,212,170,0.07); transform: translateX(4px); }
.choice-number { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,0.1); display: flex; align-items: center; justify-content: center; font-size: 0.78rem; flex-shrink: 0; font-family: 'Fredoka One', cursive; }
.choice-text { flex: 1; }
.pre-reveal { opacity: 0; pointer-events: none; transition: opacity 0.7s ease; }
.pre-reveal.revealed { opacity: 1; pointer-events: auto; }

/* ── Finale ─────────────────────────────────────────────── */
.finale-columns { width: 100%; display: grid; grid-template-columns: 1fr 520px; grid-template-areas: "text image"; gap: 18px 24px; align-items: start; }
.finale-col-text { grid-area: text; background: rgba(255,255,255,0.03); border: 1px solid var(--card-border); border-radius: var(--border-radius); padding: 1.4rem; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--purple-soft) transparent; max-height: min(72vh, 580px); }
.finale-col-text::-webkit-scrollbar { width: 5px; }
.finale-col-text::-webkit-scrollbar-thumb { background: var(--purple-soft); border-radius: 3px; }
.finale-col-image { grid-area: image; align-self: start; }
.finale-the-end { font-family: 'Fredoka One', cursive; font-size: 2rem; color: var(--gold); font-style: italic; margin: 1rem 0 0.5rem; }
.finale-congrats { color: var(--teal); font-size: 0.95rem; font-weight: 700; margin-bottom: 1rem; line-height: 1.5; }
.finale-image-container { position: relative; width: 100%; border-radius: var(--border-radius-large); overflow: hidden; box-shadow: 0 6px 24px rgba(0,0,0,0.4); }
.finale-image { width: 100%; height: auto; display: block; }
.finale-overlay { position: absolute; top: 16px; right: 16px; }
.finale-crown { font-size: 2.5rem; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.3)); animation: bounce 2s ease-in-out infinite; }
.finale-text-container { padding: 0 0 1rem 1rem; margin-bottom: 1rem; border-left: 3px solid var(--teal); }
.finale-story-text { font-size: 1.05rem; line-height: 1.8; color: var(--off-white); white-space: pre-wrap; text-align: justify; }
.finale-buttons { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }

/* ── Error ──────────────────────────────────────────────── */
.error-container { text-align: center; padding: 3rem 1rem; }
.error-icon { font-size: 4.5rem; margin-bottom: 1rem; }
.error-text { color: var(--coral); font-size: 1rem; margin-bottom: 1.5rem; }

/* ═══════════════════════════════════════════════════════════
   IN-APP PRICING
   ═══════════════════════════════════════════════════════════ */
.pricing-header { text-align: center; margin-bottom: 1.5rem; }
.pricing-header h2 { font-family: 'Fredoka One', cursive; font-size: 1.8rem; color: var(--gold-soft); }
.pricing-subheading { color: var(--text-light); font-size: 0.9rem; margin-top: 0.4rem; line-height: 1.6; max-width: 600px; margin-left: auto; margin-right: auto; }
.pricing-tabs { display: flex; gap: 0.5rem; justify-content: center; margin-bottom: 1.5rem; }
.pricing-tab { padding: 0.5rem 1.4rem; border-radius: 50px; background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-light); font-weight: 800; font-size: 0.88rem; transition: all var(--transition-speed); }
.pricing-tab.active { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: var(--purple-deep); border-color: transparent; }
.pricing-tab-panel.hidden { display: none !important; }
.pricing-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin-bottom: 1rem; align-items: stretch; }
.pricing-grid > .pricing-card { flex: 1 1 240px; max-width: 290px; min-width: 0; }
.pricing-tagline { font-size: 0.8rem; color: var(--text-light); margin: 0.5rem 0 0; line-height: 1.45; }
.pricing-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 20px; padding: 1.6rem 1.3rem; position: relative; transition: transform var(--transition-speed); display: flex; flex-direction: column; }
.pricing-card:hover { transform: translateY(-3px); }
.pricing-card-popular { border-color: var(--gold); background: rgba(245,200,66,0.05); }
.pricing-card-legend { border-color: var(--coral); background: rgba(255,107,107,0.05); }
.pricing-popular-badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, var(--gold), #f0a800); color: var(--purple-deep); padding: 0.15rem 0.85rem; border-radius: 50px; font-size: 0.72rem; font-weight: 900; white-space: nowrap; }
.pricing-trial-badge { background: var(--teal-dark) !important; color: var(--purple-deep) !important; }
.pricing-legend-badge { background: var(--coral) !important; color: var(--white) !important; }
.pricing-card-top { text-align: center; margin-bottom: 1rem; }
.pricing-emoji { font-size: 2rem; margin-bottom: 0.4rem; }
.pricing-tier-name { font-family: 'Fredoka One', cursive; font-size: 1.2rem; margin-bottom: 0.3rem; }
.pricing-price { font-family: 'Fredoka One', cursive; font-size: 1.9rem; color: var(--gold); }
.pricing-period { font-family: 'Nunito', sans-serif; font-size: 0.82rem; color: var(--text-muted); font-weight: 600; }
.pricing-price-note { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }
.pricing-features { margin-bottom: 1.2rem; flex: 1; }
.pricing-features li { font-size: 0.82rem; padding: 0.25rem 0; color: var(--text-light); display: flex; gap: 0.5rem; align-items: flex-start; }
.feat-check { color: var(--teal); flex-shrink: 0; font-weight: 800; }
.feat-muted { color: var(--text-muted); flex-shrink: 0; }
.pricing-cta-btn { width: 100%; padding: 0.65rem; border-radius: 50px; font-weight: 800; font-size: 0.85rem; border: none; transition: all var(--transition-speed); margin-top: auto; }
.pricing-cta-btn:hover { transform: translateY(-2px); }
.pricing-cta-free { background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-light); }
.pricing-cta-free:hover { border-color: var(--teal); color: var(--teal); }
.pricing-cta-paid { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: var(--purple-deep); }
.pricing-cta-paid:hover { box-shadow: 0 4px 15px rgba(0,212,170,0.35); }
.pricing-cta-legend { background: linear-gradient(135deg, var(--gold), #f0a800); color: var(--purple-deep); }
.pricing-cta-legend:hover { box-shadow: 0 4px 15px rgba(245,200,66,0.35); }
.pricing-footer-note { background: rgba(255,255,255,0.03); border: 1px solid var(--card-border); border-radius: 12px; padding: 0.75rem 1rem; text-align: center; font-size: 0.82rem; color: var(--text-muted); margin-top: 1rem; }
.credits-intro { margin-bottom: 1.5rem; }
.credits-intro-line { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.88rem; color: var(--text-light); margin-bottom: 0.4rem; }
/* Credit packs follow the same row rules as the plan cards: never 3+1.
   Flex with justify-content centre keeps any subset (1, 2, 3, or 4 cards)
   centred horizontally; the mobile media query below forces 1-col. */
.credit-pack-grid { display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: 0.9rem; }
.credit-pack-grid > .credit-pack-card { flex: 1 1 180px; max-width: 240px; min-width: 0; }
.credit-pack-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 18px; padding: 1.4rem 1rem; text-align: center; transition: all var(--transition-speed); position: relative; display: flex; flex-direction: column; }
.credit-pack-card:hover { transform: translateY(-3px); border-color: var(--teal); }
.credit-pack-best { border-color: var(--coral); background: rgba(255,107,107,0.06); overflow: visible; }
.credit-pack-best-badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, var(--coral), #e04040); color: white; padding: 0.15rem 0.7rem; border-radius: 50px; font-size: 0.7rem; font-weight: 800; white-space: nowrap; }
.credit-pack-count { font-family: 'Fredoka One', cursive; font-size: 2rem; color: var(--gold); }
.credit-pack-label { font-size: 0.82rem; color: var(--text-light); margin-bottom: 0.4rem; }
.credit-pack-price { font-size: 1.1rem; font-weight: 800; margin-bottom: 0.6rem; }
.pricing-back-row { text-align: center; margin-top: 1.5rem; }
.pricing-back-btn { background: none; border: none; color: var(--teal); font-weight: 700; font-size: 0.9rem; cursor: pointer; transition: color var(--transition-speed); }
.pricing-back-btn:hover { color: var(--white); }

/* ═══════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(10, 5, 30, 0.85); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.hidden { display: none !important; }
.modal-card { background: var(--purple-mid); border: 1px solid var(--card-border); border-radius: var(--border-radius-large); padding: 2.5rem 2rem; max-width: 420px; width: 100%; text-align: center; position: relative; animation: fadeInUp 0.3s ease-out; }
.paywall-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.modal-card h2 { font-family: 'Fredoka One', cursive; font-size: 1.6rem; color: var(--gold-soft); margin-bottom: 0.6rem; }
.paywall-text { color: var(--text-light); font-size: 0.9rem; line-height: 1.6; margin-bottom: 0.8rem; }
.paywall-buttons { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1rem; }
.paywall-login-link { background: none; border: none; color: var(--text-muted); font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: color var(--transition-speed); }
.paywall-login-link:hover { color: var(--text-light); }
.upgrade-cta-btn { width: 100%; padding: 0.75rem; border-radius: 50px; background: linear-gradient(135deg, var(--gold), #f0a800); color: var(--purple-deep); font-weight: 800; font-size: 0.95rem; border: none; transition: all var(--transition-speed); }
.upgrade-cta-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(245,200,66,0.4); }
.modal-close-btn { position: absolute; top: 1rem; right: 1rem; background: rgba(255,255,255,0.08); border: none; border-radius: 50%; width: 28px; height: 28px; color: var(--text-muted); font-size: 0.8rem; cursor: pointer; transition: all var(--transition-speed); display: flex; align-items: center; justify-content: center; }
.modal-close-btn:hover { background: rgba(255,255,255,0.15); color: var(--white); }
.modal-title { font-family: 'Fredoka One', cursive; font-size: 1.4rem; color: var(--gold-soft); margin-bottom: 0.5rem; }
.upgrade-overlay-meta { font-size: 0.82rem !important; color: var(--text-muted) !important; }
.upgrade-tiers { margin: 0.75rem 0; }
.save-chars-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.75rem 0; max-height: 220px; overflow-y: auto; }
.save-chars-slot-count { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.5rem; }

/* ═══════════════════════════════════════════════════════════
   PARENT DASHBOARD
   ═══════════════════════════════════════════════════════════ */
.fullscreen-overlay { position: fixed; inset: 0; z-index: 400; background: var(--purple-deep); overflow-y: auto; display: flex; align-items: flex-start; justify-content: center; padding: 2rem 1rem; }
.fullscreen-overlay.hidden { display: none !important; }
.fullscreen-overlay--dashboard { background: linear-gradient(180deg, var(--blue-deep) 0%, var(--purple-deep) 100%); }
.dashboard-fs-close { position: fixed; top: 1.2rem; right: max(1rem, calc(50% - 480px - 1rem)); background: rgba(255,255,255,0.08); border: none; border-radius: 50%; width: 36px; height: 36px; color: var(--text-light); font-size: 1rem; cursor: pointer; transition: all var(--transition-speed); z-index: 401; display: flex; align-items: center; justify-content: center; }
.dashboard-fs-close:hover { background: rgba(255,255,255,0.15); color: var(--white); }
.dashboard-fs-content { width: 100%; max-width: 960px; padding-top: 1rem; }
.dashboard-panel.hidden { display: none !important; }
.dashboard-title { font-family: 'Fredoka One', cursive; font-size: 2rem; color: var(--gold-soft); margin-bottom: 0.5rem; }
.dashboard-subtitle { color: var(--text-light); font-size: 0.9rem; margin-bottom: 1.2rem; }
.dashboard-btn-row { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.dashboard-stats-grid { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.dashboard-stat-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; padding: 1.2rem 1.4rem; flex: 1; min-width: 140px; text-align: center; }
.dashboard-stat-value { font-family: 'Fredoka One', cursive; font-size: 1.8rem; color: var(--gold); }
.dashboard-stat-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.dashboard-section { margin-bottom: 1.5rem; }
.dashboard-section-title { font-family: 'Fredoka One', cursive; font-size: 1.2rem; color: var(--gold-soft); margin-bottom: 0.75rem; }
.dashboard-row { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 0; border-bottom: 1px solid var(--card-border); font-size: 0.88rem; }
.dashboard-row:last-child { border-bottom: none; }
.dashboard-row-label { color: var(--text-muted); }
.dashboard-row-value { font-weight: 700; }
.age-bands { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; }
.age-band { flex: 1; min-width: 110px; border: 2px solid var(--card-border); border-radius: 14px; padding: 0.9rem 0.7rem; text-align: center; cursor: pointer; transition: all 0.25s; }
.age-band:hover { border-color: var(--purple-soft); }
.age-band.selected { border-color: var(--teal); background: rgba(0,212,170,0.07); }
.age-band.default-band { border-color: var(--gold); background: rgba(245,200,66,0.05); }
.default-label { display: inline-block; background: rgba(245,200,66,0.15); border: 1px solid rgba(245,200,66,0.4); color: var(--gold); padding: 0.12rem 0.55rem; border-radius: 50px; font-size: 0.67rem; font-weight: 800; margin-bottom: 0.25rem; }
.band-emoji { font-size: 1.6rem; margin-bottom: 0.3rem; }
.band-range { font-family: 'Fredoka One', cursive; font-size: 0.9rem; margin-bottom: 0.15rem; }
.band-desc { font-size: 0.7rem; color: var(--text-muted); line-height: 1.3; }
.age-band.selected .band-desc { color: var(--text-light); }
.parental-control-row { display: flex; align-items: center; justify-content: space-between; padding: 0.65rem 0; border-bottom: 1px solid var(--card-border); gap: 1rem; }
.parental-control-row:last-child { border-bottom: none; }
.pc-label { font-size: 0.88rem; font-weight: 700; }
.pc-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.1rem; }
.pc-toggle { display: flex; align-items: center; gap: 0.5rem; background: rgba(0,212,170,0.1); border: 1px solid var(--teal); border-radius: 50px; padding: 0.3rem 0.75rem; font-size: 0.8rem; font-weight: 800; color: var(--teal); cursor: pointer; transition: all var(--transition-speed); }
.pc-toggle.off { background: rgba(255,107,107,0.1); border-color: var(--coral); color: var(--coral); }
.parent-override-msg { color: var(--text-light); font-size: 0.95rem; margin-bottom: 1rem; text-align: center; line-height: 1.6; max-width: 400px; }

/* ═══════════════════════════════════════════════════════════
   LIBRARY PANEL
   ═══════════════════════════════════════════════════════════ */
.library-panel { position: fixed; top: 0; left: 0; bottom: 0; z-index: 250; width: min(420px, 100vw); background: var(--purple-mid); border-right: 1px solid var(--card-border); overflow-y: auto; transition: transform 0.3s ease; }
.library-panel.hidden { transform: translateX(-100%); display: block !important; }
.library-panel-inner { padding: 1.5rem; padding-top: calc(var(--nav-h) + 1rem); }
.library-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.library-panel-header h2 { font-family: 'Fredoka One', cursive; font-size: 1.3rem; color: var(--gold-soft); }
.library-close-btn { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; transition: color var(--transition-speed); }
.library-close-btn:hover { color: var(--white); }
.library-tier-badge { font-size: 0.78rem; color: var(--teal); font-weight: 700; margin-bottom: 0.25rem; }
.library-monthly-badge { color: var(--gold) !important; }

.library-credits-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem;
    margin: 0.5rem 0 1rem;
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    background: rgba(245, 200, 66, 0.08);
    border: 1px solid rgba(245, 200, 66, 0.3);
    font-size: 0.85rem;
}
.library-credits-row.hidden { display: none !important; }
.library-credits-label { color: var(--gold); font-weight: 700; }
.library-credits-label strong { color: var(--gold-soft); font-variant-numeric: tabular-nums; }
.library-credits-icon { font-size: 1rem; }
.library-credits-note { color: var(--text-muted); font-size: 0.78rem; font-weight: 500; margin-left: 0.25rem; }
.library-credits-buy-btn {
    background: linear-gradient(135deg, var(--gold), var(--gold-soft));
    color: var(--purple-deep);
    border: none; border-radius: 50px;
    padding: 0.4rem 0.9rem;
    font-weight: 800; font-size: 0.78rem;
    cursor: pointer; transition: transform var(--transition-speed);
    white-space: nowrap;
}
.library-credits-buy-btn:hover { transform: translateY(-1px); }

.step1-credit-usage {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 50px;
    background: rgba(245, 200, 66, 0.15);
    border: 1px solid rgba(245, 200, 66, 0.4);
    color: var(--gold);
    font-size: 0.8rem; font-weight: 700;
    line-height: 1.3;
    vertical-align: middle;
}
.step1-hint-stories { margin-bottom: 0.45rem; }
.step1-hint-credits { margin-bottom: 0.3rem; }
.step1-hint-credits-desc {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.4;
}
.library-panel-toggle { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.library-toggle-btn { padding: 0.35rem 0.85rem; border-radius: 50px; background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-muted); font-size: 0.8rem; font-weight: 700; transition: all var(--transition-speed); }
.library-toggle-btn.active { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: var(--purple-deep); border-color: transparent; }
.library-toggle-btn.hidden { display: none !important; }
.library-stories-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.75rem; }
.library-story-item { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px; padding: 0.75rem; cursor: pointer; transition: all var(--transition-speed); }
.library-story-item:hover { border-color: var(--teal); }
.library-story-title { font-weight: 800; font-size: 0.88rem; margin-bottom: 0.2rem; }
.library-story-meta { font-size: 0.74rem; color: var(--text-muted); }
.library-view-all-btn { background: none; border: none; color: var(--teal); font-size: 0.85rem; font-weight: 700; cursor: pointer; width: 100%; text-align: center; padding: 0.5rem; transition: color var(--transition-speed); }
.library-view-all-btn:hover { color: var(--white); }
.library-new-btn { width: 100%; padding: 0.75rem; border-radius: 50px; margin-top: 1rem; background: linear-gradient(135deg, var(--gold), #f0a800); color: var(--purple-deep); font-weight: 800; font-size: 0.9rem; border: none; transition: all var(--transition-speed); }
.library-new-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(245,200,66,0.35); }
.my-characters-section { margin-top: 0.5rem; }
.my-characters-section.hidden { display: none !important; }
.my-characters-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.my-characters-header h3 { font-family: 'Fredoka One', cursive; font-size: 1.05rem; color: var(--gold-soft); }
.char-slot-count { font-size: 0.75rem; color: var(--text-muted); font-weight: 700; }
.my-characters-list { display: flex; flex-direction: column; gap: 0.5rem; }
.library-backdrop { position: fixed; inset: 0; z-index: 249; background: rgba(10,5,30,0.6); }
.library-backdrop.hidden { display: none !important; }

/* ── Library Page ───────────────────────────────────────── */
.library-page { position: fixed; inset: 0; z-index: 260; background: var(--purple-deep); overflow-y: auto; }
.library-page.hidden { display: none !important; }
.library-page-inner { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem; padding-top: calc(var(--nav-h) + 1.5rem); }
.library-page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.library-page-header h2 { font-family: 'Fredoka One', cursive; font-size: 1.5rem; color: var(--gold-soft); }
.library-page-filters { display: flex; gap: 0.5rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.library-filter-btn { padding: 0.4rem 1rem; border-radius: 50px; background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-muted); font-size: 0.85rem; font-weight: 700; transition: all var(--transition-speed); }
.library-filter-btn.active { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: var(--purple-deep); border-color: transparent; }
.library-page-stories { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }

/* ── Story Cards (library panel + library page) ─────────────── */
.story-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; padding: 0.9rem 1rem; transition: border-color var(--transition-speed); }
.story-card:hover { border-color: var(--teal); }
.story-card.expiring-soon { border-color: var(--coral); }
.story-card-title { font-weight: 800; font-size: 0.92rem; margin-bottom: 0.35rem; color: var(--white); }
.story-card-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; font-size: 0.74rem; color: var(--text-muted); margin-bottom: 0.6rem; }
.story-card-branch-chip { display: inline-flex; align-items: center; gap: 0.25rem; background: rgba(0,212,170,0.12); border: 1px solid rgba(0,212,170,0.4); color: var(--teal); padding: 0.1rem 0.5rem; border-radius: 50px; font-size: 0.68rem; font-weight: 800; }
.story-card.is-branch { background: rgba(0,212,170,0.04); }

/* ── Story card with Part 1 image background (.has-thumb) ──────
   Adds a full-card dimmed image layer behind the existing card content.
   When data-thumb-url is empty (old stories, demo), .has-thumb is not
   set so none of these rules apply and the gradient placeholder shows. */
.story-card.has-thumb { position: relative; overflow: hidden; isolation: isolate; }
.story-card-bg {
    position: absolute; inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 320ms ease;
    z-index: 0;
    pointer-events: none;
}
.story-card.thumb-loaded .story-card-bg { opacity: 1; }
.story-card.has-thumb::before {
    content: '';
    position: absolute; inset: 0;
    z-index: 1;
    pointer-events: none;
    /* Option A - even-dim wash. Visual review may swap this rule for a
       gradient (Option B) or filter+lighter overlay (Option C). */
    background: rgba(15, 10, 40, 0.62);
}
.story-card-body { position: relative; z-index: 2; }
.story-card-try-branch-btn { background: none; border: none; color: var(--teal); font: inherit; font-size: 0.78rem; cursor: pointer; padding: 0.2rem 0; margin-top: 0.2rem; text-decoration: none; display: inline-flex; align-items: center; gap: 0.3rem; }
.story-card-try-branch-btn:hover { color: var(--white); }
.story-card-try-branch-icon { text-decoration: none; }
.story-card-try-branch-text { text-decoration: underline; }

/* Branch picker modal */
.branch-picker-card { max-width: 760px; text-align: left; padding: 2.4rem 2rem; }
.branch-picker-card h2 { text-align: center; font-size: 1.85rem; }
.branch-picker-card .paywall-text { text-align: center; font-size: 1rem; line-height: 1.45; margin-bottom: 1.2rem; }
.branch-picker-card .paywall-icon { text-align: center; font-size: 2.6rem; }
.branch-picker-step { display: none; }
.branch-picker-step.branch-step-active { display: block; }
.branch-picker-error { color: var(--coral); font-size: 0.92rem; text-align: center; margin: 0.5rem 0; }
.branch-picker-error.hidden { display: none; }
.branch-where-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 0.6rem; }
.branch-where-card { background: rgba(255,255,255,0.04); border: 2px solid var(--card-border); border-radius: 16px; padding: 1.3rem 1rem; text-align: center; cursor: pointer; transition: all var(--transition-speed); color: var(--text-light); }
.branch-where-card:hover { border-color: var(--teal); background: rgba(0,212,170,0.06); transform: translateY(-2px); }
.branch-where-num { font-family: 'Fredoka One', cursive; font-size: 2.2rem; color: var(--gold); line-height: 1; }
.branch-where-label { font-weight: 800; font-size: 1.1rem; color: var(--white); margin: 0.35rem 0 0.5rem; }
.branch-where-hint { font-size: 0.92rem; color: var(--text-light); line-height: 1.4; font-style: italic; }
.branch-picker-instruction { font-size: 1rem; color: var(--text-light); text-align: center; margin-bottom: 0.9rem; }
.branch-choice-list { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.8rem; }
.branch-choice-btn { width: 100%; padding: 0.95rem 1.1rem; background: var(--card-bg); border: 2px solid var(--card-border); border-radius: 14px; color: var(--white); font-family: 'Nunito', sans-serif; font-size: 1rem; font-weight: 700; text-align: left; cursor: pointer; transition: all var(--transition-speed); display: flex; align-items: center; gap: 0.75rem; }
.branch-choice-btn:hover:not(.is-original) { border-color: var(--teal); background: rgba(0,212,170,0.06); }
.branch-choice-btn.is-original { opacity: 0.55; cursor: not-allowed; border-style: dashed; }
.branch-choice-num { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,0.1); display: flex; align-items: center; justify-content: center; font-size: 0.88rem; flex-shrink: 0; font-family: 'Fredoka One', cursive; }
.branch-original-tag { font-size: 0.78rem; color: var(--text-muted); font-style: italic; margin-left: auto; flex-shrink: 0; white-space: nowrap; }
.branch-picker-back-row { text-align: center; margin-top: 0.6rem; font-size: 0.94rem; }
.story-card-part { font-weight: 700; color: var(--teal); }
.story-card-expiration.expiring { color: var(--coral); font-weight: 700; }
.story-card-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.story-card-resume-btn { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: var(--purple-deep); font-weight: 800; font-size: 0.78rem; border: none; border-radius: 50px; padding: 0.35rem 0.75rem; cursor: pointer; transition: all var(--transition-speed); }
.story-card-resume-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0,212,170,0.3); }
.story-card-part-btn { padding: 0.3rem 0.6rem; font-size: 0.74rem; }
.story-card-keep-btn { background: linear-gradient(135deg, var(--gold), #f0a800); color: var(--purple-deep); font-weight: 800; font-size: 0.76rem; border: none; border-radius: 50px; padding: 0.3rem 0.7rem; cursor: pointer; transition: all var(--transition-speed); }
.story-card-keep-btn:hover { transform: translateY(-1px); }
.story-card-download-btn, .story-card-delete-btn { background: none; border: 1px solid var(--teal); border-radius: 8px; color: var(--teal); font-size: 0.85rem; padding: 0.3rem 0.5rem; cursor: pointer; transition: all var(--transition-speed); }
.story-card-download-btn:hover { background: rgba(0,212,170,0.12); }
.story-card-delete-btn:hover { color: var(--coral); border-color: var(--coral); background: rgba(255,107,107,0.12); }
.library-empty { text-align: center; color: var(--text-muted); font-size: 0.88rem; padding: 1.5rem 0.5rem; }
.library-empty-fullpage { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 0.6rem; min-height: 60vh; padding: 2rem 1rem; font-size: 1rem; }
.library-empty-fullpage p { margin: 0; white-space: nowrap; }
@media (max-width: 720px) { .library-empty-fullpage p { white-space: normal; } }
.first-tour-overlay { position: fixed; inset: 0; z-index: 4000; background: rgba(13, 12, 32, 0.78); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 1rem; animation: firstTourFade 0.25s ease; }
@keyframes firstTourFade { from { opacity: 0; } to { opacity: 1; } }
.first-tour-card { max-width: 420px; width: 100%; background: var(--purple-mid); border: 2px solid var(--teal); border-radius: 18px; padding: 2rem 1.5rem; text-align: center; box-shadow: 0 24px 48px rgba(0,0,0,0.5); }
.first-tour-icon { font-size: 2.6rem; margin-bottom: 0.4rem; }
.first-tour-title { font-family: 'Fredoka One', cursive; color: var(--gold-soft); font-size: 1.3rem; margin: 0 0 0.5rem; }
.first-tour-text { color: var(--text-light); font-size: 0.95rem; line-height: 1.5; margin: 0 0 1.5rem; }
.first-tour-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.first-tour-btn { border: none; cursor: pointer; font-family: inherit; border-radius: 50px; padding: 0.65rem 1.2rem; font-weight: 700; font-size: 0.92rem; transition: transform var(--transition-speed), background var(--transition-speed); }
.first-tour-btn-primary { background: var(--teal); color: var(--white); }
.first-tour-btn-primary:hover { background: var(--teal-dark); transform: translateY(-1px); }
.first-tour-btn-secondary { background: transparent; color: var(--text-muted); border: 1px solid var(--card-border); }
.first-tour-btn-secondary:hover { color: var(--text-light); border-color: var(--text-muted); }

/* Meta items get a subtle dark pill on .has-thumb cards so the
   teal/muted/coral text stays legible against any image - light or
   dark - without changing the look of gradient-only fallback cards. */
.story-card.has-thumb .story-card-part,
.story-card.has-thumb .story-card-expiration,
.story-card.has-thumb .story-card-date {
    background: rgba(0, 0, 0, 0.5);
    padding: 0.1rem 0.5rem;
    border-radius: 50px;
}

/* ── Character Cards (library panel) ───────────────────────── */
.char-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; padding: 0.75rem; display: flex; align-items: flex-start; gap: 0.75rem; flex-wrap: wrap; }
.char-card-avatar { flex-shrink: 0; }
.char-avatar-placeholder { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--teal-dark), var(--teal)); color: var(--purple-deep); display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 1rem; font-family: 'Fredoka One', cursive; }
.char-avatar-img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.char-card-info { flex: 1; min-width: 0; }
.char-card-name { display: block; font-weight: 800; font-size: 0.88rem; color: var(--white); }
.char-card-desc { display: block; font-size: 0.76rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.char-card-actions { display: flex; gap: 0.3rem; margin-left: auto; }
.char-edit-btn, .char-delete-btn { background: none; border: 1px solid var(--card-border); border-radius: 8px; color: var(--text-muted); font-size: 0.85rem; padding: 0.25rem 0.45rem; cursor: pointer; transition: all var(--transition-speed); }
.char-edit-btn:hover { color: var(--gold); border-color: var(--gold); }
.char-delete-btn:hover { color: var(--coral); border-color: var(--coral); }
.char-edit-form { width: 100%; flex-basis: 100%; padding-top: 0.5rem; }
.char-edit-name-display { font-weight: 800; font-size: 0.88rem; color: var(--gold-soft); margin-bottom: 0.4rem; }
.char-empty-state { text-align: center; color: var(--text-muted); font-size: 0.82rem; padding: 1rem 0; }

/* ── Character form (step 2 inputs) ─────────────────────── */
.character-form-item { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; padding: 1.2rem 1.4rem; display: flex; flex-direction: column; gap: 0.75rem; animation: slideIn 0.3s ease-out; }
.character-form-header { display: flex; align-items: center; gap: 0.6rem; font-family: 'Fredoka One', cursive; font-size: 1rem; color: var(--gold-soft); margin-bottom: 0.25rem; }
.character-form-group { display: flex; flex-direction: column; gap: 0.75rem; }
.character-field { display: flex; flex-direction: column; gap: 0.3rem; }
.character-label { font-size: 0.75rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.character-input, .character-textarea { width: 100%; padding: 0.6rem 0.85rem; border-radius: 10px; border: 1px solid var(--card-border); background: rgba(255,255,255,0.07); color: var(--white); font-family: 'Nunito', sans-serif; font-size: 0.9rem; outline: none; transition: border var(--transition-speed); }
.character-input:focus, .character-textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,212,170,0.12); }
.character-input::placeholder, .character-textarea::placeholder { color: var(--text-muted); }
.character-textarea { min-height: 80px; resize: vertical; }

/* ── Dashboard stat rings ────────────────────────────────── */
.dashboard-rings { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin: 0.75rem 0 1.25rem; }
.stat-ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.stat-ring-label {
    font-size: 0.9rem; opacity: 0.8;
    line-height: 1.3;
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    white-space: nowrap;
}
.stat-ring-value { font-size: 1.1rem; font-weight: 700; }
.stat-ring-subtitle {
    font-size: 0.72rem; opacity: 0.55; text-align: center;
    max-width: 170px; line-height: 1.4; margin-top: 0.1rem;
}
.stat-info-btn { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.4); background: transparent; color: rgba(255,255,255,0.6); font-size: 0.65rem; font-weight: 700; cursor: pointer; padding: 0; line-height: 1; flex-shrink: 0; transition: border-color 0.15s, color 0.15s; }
.stat-info-btn:hover, .stat-info-btn:focus { border-color: rgba(255,255,255,0.9); color: #fff; outline: none; }
.stat-popover { position: fixed; z-index: 9999; background: #1a1228; border: 1px solid rgba(255,255,255,0.15); border-radius: 10px; padding: 12px 36px 12px 14px; max-width: 240px; font-size: 0.82rem; line-height: 1.45; color: rgba(255,255,255,0.9); box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.stat-popover.hidden { display: none; }
.stat-popover-text { margin: 0; }
.stat-popover-close { position: absolute; top: 8px; right: 8px; background: none; border: none; color: rgba(255,255,255,0.6); font-size: 1rem; cursor: pointer; padding: 0; line-height: 1; }
.stat-popover-close:hover { color: #fff; }
@media (max-width: 600px) { .stat-popover { position: fixed; bottom: 0; left: 0; right: 0; top: auto; max-width: none; border-radius: 16px 16px 0 0; padding: 20px 20px 28px; } }
.recommendation-card { border-radius: 0.75rem; padding: 0.85rem 1rem; font-size: 0.88rem; line-height: 1.45; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12); }
.recommendation-card.rec-upgrade { border-color: rgba(255,160,50,0.5); }
.recommendation-card.hidden { display: none !important; }

/* ── Parental controls ───────────────────────────────────── */
.pc-age-tiles { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.age-tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1 1 calc(33% - 8px); min-width: 80px; padding: 16px 10px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.06); cursor: pointer; transition: all 0.2s; color: #fff; font-family: inherit; }
.age-tile:hover { background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.30); }
.age-tile.selected { background: rgba(119,88,255,0.20); border-color: #7758ff; }
.age-tile::after { content: '✓'; position: absolute; bottom: 6px; right: 8px; width: 16px; height: 16px; background: #7758ff; border-radius: 50%; font-size: 0.65rem; font-weight: 700; color: #fff; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s; }
.age-tile.selected::after { opacity: 1; }
.age-tile-emoji { font-size: 1.6rem; margin-bottom: 6px; display: block; }
.age-tile-name { font-size: 0.78rem; font-weight: 700; text-align: center; line-height: 1.2; }
.pc-section { margin-bottom: 20px; }
.pc-section-title { font-size: 0.95rem; font-weight: 700; margin: 0 0 4px; }
.pc-hint { font-size: 0.8rem; color: rgba(255,255,255,0.5); margin: 0 0 10px; }
.pc-genres-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pc-genre-check-wrap { display: contents; }
.pc-genre-check-wrap input[type="checkbox"] { display: none; }
.pc-genre-btn { display: flex; align-items: center; justify-content: center; padding: 14px 8px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; font-weight: 700; font-size: 0.85rem; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.6); transition: all 0.2s; opacity: 0.5; }
.pc-genre-btn:hover { opacity: 0.8; filter: brightness(1.1); }
.pc-genre-check-wrap input:checked + .pc-genre-btn { opacity: 1; border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,0.25); }
.pc-genre-btn[data-genre="Adventure"] { background: linear-gradient(135deg, #C0622A, #F08030); }
.pc-genre-btn[data-genre="Fantasy"]   { background: linear-gradient(135deg, #6A35B5, #A855F7); }
.pc-genre-btn[data-genre="Funny"]     { background: linear-gradient(135deg, #E07800, #F5C518); }
.pc-genre-btn[data-genre="Mystery"]   { background: linear-gradient(135deg, #2C3E6A, #4A6FA5); }
.pc-genre-btn[data-genre="Spooky"]    { background: linear-gradient(135deg, #2A5E2A, #52A852); }
.pc-genre-btn[data-genre="Magical"]   { background: linear-gradient(135deg, #D63088, #F472B6, #A855F7); }
.pc-number-input { width: 80px; padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.08); color: #fff; }
.pc-time-fields { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 6px; }
.pc-time-fields label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.pc-time-fields input[type="time"] { padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.08); color: #fff; }
.pc-time-fields input[type="time"]::-webkit-calendar-picker-indicator { filter: brightness(0) invert(1); cursor: pointer; opacity: 0.8; }
.pc-timezone-display { font-size: 0.8rem; color: rgba(255,255,255,0.45); margin: 2px 0 0; }
.pc-save-status { font-size: 0.85rem; margin-bottom: 8px; }
.pc-save-ok { color: #7cd67c; }
.pc-save-err { color: #e07c7c; }
/* ── Dashboard sidebar layout ────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: 280px 1fr; gap: 1.5rem; align-items: stretch; }
.dash-sidebar { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 20px; overflow-y: auto; display: flex; flex-direction: column; position: sticky; top: 1rem; align-self: flex-start; }
.dash-sidebar-nav { display: flex; flex-direction: column; }
.dash-mobile-toggle { display: none; }
.dash-sidebar-header { padding: 1.2rem 1.4rem; border-bottom: 1px solid var(--card-border); }
.dash-user-avatar { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, var(--teal-dark), var(--teal)); color: var(--purple-deep); display: flex; align-items: center; justify-content: center; font-family: 'Fredoka One', cursive; font-size: 1.2rem; font-weight: 900; margin-bottom: 0.6rem; }
.dash-user-name { font-family: 'Fredoka One', cursive; font-size: 1.05rem; color: var(--white); }
.dash-user-plan { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.1rem; }
.dash-user-credits { font-size: 0.78rem; color: var(--gold); margin-top: 0.15rem; font-weight: 700; }
.dash-nav-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1.4rem; cursor: pointer; font-weight: 700; font-size: 0.88rem; color: var(--text-light); transition: all 0.2s; border-left: 3px solid transparent; }
.dash-nav-item:hover { background: rgba(255,255,255,0.04); color: var(--white); }
.dash-nav-item.active { background: rgba(0,212,170,0.08); color: var(--teal); border-left-color: var(--teal); }
.dash-nav-item .icon { font-size: 1.1rem; width: 22px; text-align: center; }
.dash-nav-logout { color: var(--coral) !important; border-top: 1px solid var(--card-border); margin-top: 0.25rem; }
.dash-nav-logout:hover { background: rgba(255,107,107,0.08) !important; color: var(--coral) !important; }
@media (max-width: 700px) {
    .dash-grid { grid-template-columns: 1fr; }
    .dash-sidebar { position: static; overflow: visible; }
    .dash-sidebar-header {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
        align-items: center;
        column-gap: 0.75rem;
        padding: 0.85rem 1rem;
    }
    .dash-sidebar-header .dash-user-avatar { margin: 0; grid-row: 1 / span 2; }
    .dash-sidebar-header .dash-user-name { margin: 0; font-size: 0.95rem; }
    .dash-sidebar-header .dash-user-plan { margin: 0; font-size: 0.75rem; }
    .dash-sidebar-header .dash-user-credits { grid-column: 3; grid-row: 1 / span 2; align-self: center; margin: 0; white-space: nowrap; }
    .dash-mobile-toggle {
        display: flex; align-items: center; justify-content: space-between;
        width: 100%; padding: 0.85rem 1.4rem;
        background: rgba(255,255,255,0.04);
        border: none; border-top: 1px solid var(--card-border);
        color: var(--white); font-family: inherit; font-weight: 700; font-size: 0.92rem;
        cursor: pointer; transition: background 0.2s;
        text-align: left;
    }
    .dash-mobile-toggle:hover { background: rgba(255,255,255,0.08); }
    .dash-mobile-toggle-icon { font-size: 1.1rem; line-height: 1; color: var(--teal); }
    .dash-sidebar-nav { display: none; border-top: 1px solid var(--card-border); }
    .dash-sidebar.nav-open .dash-sidebar-nav { display: flex; }
}
.dash-panel { display: flex; flex-direction: column; gap: 1.2rem; height: 100%; box-sizing: border-box; }
.dash-panel-section { display: flex; flex-direction: column; gap: 1.2rem; }
#dashPanelSubscription { flex: 1; justify-content: space-between; gap: 0.5rem; }
.dash-panel-section.hidden { display: none !important; }
.dash-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 20px; padding: 1.6rem; width: 100%; box-sizing: border-box; }
.dash-card-title { font-family: 'Fredoka One', cursive; font-size: 1.1rem; color: var(--gold-soft); margin-bottom: 0.25rem; }
.dash-card-sub { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 1.2rem; }

/* ── Dash action buttons ─────────────────────────────────── */
.dash-action-btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.65rem 1.2rem; border-radius: 50px; font-weight: 800; font-size: 0.85rem; cursor: pointer; transition: all var(--transition-speed); border: none; font-family: 'Nunito', sans-serif; }
.dash-action-gold { background: linear-gradient(135deg, var(--gold), #f0a800); color: var(--purple-deep); }
.dash-action-gold:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(245,200,66,0.35); }
.dash-action-teal { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: var(--purple-deep); }
.dash-action-teal:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,212,170,0.3); }
.dash-action-coral-outline { background: transparent; border: 2px solid var(--coral); color: var(--coral); }
.dash-action-coral-outline:hover { background: rgba(255,107,107,0.1); }
.sub-action-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.2rem; }

/* ── Subscription rows ───────────────────────────────────── */
.sub-row { display: flex; align-items: center; justify-content: space-between; padding: 0.65rem 0; border-bottom: 1px solid var(--card-border); font-size: 0.88rem; }
.sub-row:last-of-type { border-bottom: none; }
.sub-row-label { color: var(--text-muted); }
.sub-row-value { font-weight: 700; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.sub-badge { font-size: 0.67rem; font-weight: 800; padding: 0.1rem 0.5rem; border-radius: 50px; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.sub-badge.active { background: rgba(0,212,170,0.15); color: var(--teal); border: 1px solid rgba(0,212,170,0.3); }
.sub-badge.never-expire { background: rgba(245,200,66,0.12); color: var(--gold); border: 1px solid rgba(245,200,66,0.3); }

/* ── Age band cards ──────────────────────────────────────── */
.dash-alert-banner { background: rgba(245,200,66,0.08); border: 1px solid rgba(245,200,66,0.3); border-radius: 12px; padding: 0.75rem 1rem; font-size: 0.84rem; color: var(--text-light); display: flex; align-items: flex-start; gap: 0.6rem; line-height: 1.45; }
.dash-upgrade-banner { background: rgba(245,131,179,0.1); border: 1px solid rgba(245,131,179,0.35); border-radius: 12px; padding: 0.75rem 1rem; font-size: 0.88rem; color: var(--text-light); display: flex; align-items: flex-start; gap: 0.6rem; line-height: 1.45; margin-bottom: 1rem; }
.dash-alert-icon { flex-shrink: 0; }
.pc-locked .dash-card { opacity: 0.55; }
.pc-locked .age-band-card { cursor: not-allowed; }
.pc-locked button:not(.stat-info-btn), .pc-locked input { cursor: not-allowed; }
.age-bands-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin: 1rem 0; }
.age-band-card { position: relative; border: 2px solid var(--card-border); border-radius: 14px; padding: 1.1rem 0.9rem; text-align: center; cursor: pointer; transition: all 0.25s; background: rgba(255,255,255,0.03); display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.age-band-card:hover { border-color: var(--teal); background: rgba(0,212,170,0.05); }
.age-band-card.selected { border-color: var(--teal); background: rgba(0,212,170,0.08); }
.age-band-card.is-default { border-color: var(--gold-soft); background: rgba(245,200,66,0.04); }
.age-band-card.is-default.selected { border-color: var(--gold); background: rgba(245,200,66,0.1); }
.age-band-default-label { background: rgba(245,200,66,0.15); border: 1px solid rgba(245,200,66,0.4); color: var(--gold); padding: 0.1rem 0.5rem; border-radius: 50px; font-size: 0.63rem; font-weight: 800; margin-bottom: 0.2rem; text-transform: uppercase; letter-spacing: 0.04em; }
.age-band-emoji { font-size: 1.8rem; }
.age-band-range { font-family: 'Fredoka One', cursive; font-size: 0.95rem; color: var(--white); }
.age-band-desc { font-size: 0.7rem; color: var(--text-muted); line-height: 1.3; margin-top: 0.1rem; }
.age-band-card.selected .age-band-desc { color: var(--text-light); }

/* ── Credits grid ────────────────────────────────────────── */
.sq-credits-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin: 1rem 0 1.2rem; }
.sq-credit-pack { position: relative; border: 2px solid var(--card-border); border-radius: 14px; padding: 1rem 0.75rem; text-align: center; cursor: pointer; transition: all 0.25s; background: rgba(255,255,255,0.03); display: flex; flex-direction: column; align-items: center; gap: 0.15rem; }
.sq-credit-pack:hover { border-color: var(--teal); background: rgba(0,212,170,0.05); }
.sq-credit-pack.selected { border-color: var(--teal); background: rgba(0,212,170,0.1); }
.sq-credit-pack.best-value { border-color: var(--gold); background: rgba(245,200,66,0.05); }
.sq-credit-pack.best-value.selected { background: rgba(245,200,66,0.12); }
.sq-credit-pack .sq-credit-best-badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, var(--gold), #f0a800); color: var(--purple-deep); font-size: 0.6rem; font-weight: 900; padding: 0.15rem 0.55rem; border-radius: 50px; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.03em; }
.sq-pack-amount { font-family: 'Fredoka One', cursive; font-size: 1.8rem; color: var(--gold); line-height: 1; }
.sq-pack-label { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; font-weight: 800; letter-spacing: 0.04em; margin-bottom: 0.35rem; }
.sq-pack-price { font-weight: 800; font-size: 0.95rem; color: var(--white); }
.sq-pack-per { font-size: 0.66rem; color: var(--text-muted); }
.credits-balance-display { font-family: 'Fredoka One', cursive; font-size: 4rem; color: var(--gold); line-height: 1; margin: 0.75rem 0 0.25rem; }
.credits-balance-label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }

/* ── Account form ────────────────────────────────────────── */
.account-form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; margin: 1rem 0 1.2rem; }
.account-form-field { display: flex; flex-direction: column; gap: 0.3rem; }
.account-form-label { font-size: 0.75rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.account-form-input { width: 100%; padding: 0.6rem 0.85rem; border-radius: 10px; border: 1px solid var(--card-border); background: rgba(255,255,255,0.07); color: var(--white); font-family: 'Nunito', sans-serif; font-size: 0.88rem; outline: none; transition: border var(--transition-speed); box-sizing: border-box; }
.account-form-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,212,170,0.12); }
.account-form-input::placeholder { color: var(--text-muted); }
.danger-zone-card { border-color: rgba(255,107,107,0.4) !important; }
.danger-zone-card .dash-card-title { color: var(--coral); margin-bottom: 1.1rem; }
.danger-zone-card .dash-card-sub:last-child { margin-bottom: 0; }
.danger-zone-warning {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.45);
    border-radius: 10px;
    padding: 0.75rem 0.95rem;
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-light);
}
.danger-zone-warning strong { color: var(--coral); }

/* ── Notification toggles ────────────────────────────────── */
.notif-row { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 0; border-bottom: 1px solid var(--card-border); gap: 1rem; }
.notif-row:last-of-type { border-bottom: none; }
.notif-row-info { flex: 1; }
.notif-label { font-weight: 700; font-size: 0.88rem; }
.notif-desc { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.1rem; }
.sq-toggle { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; cursor: pointer; }
.sq-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.sq-toggle-track { position: absolute; inset: 0; background: rgba(255,255,255,0.12); border-radius: 24px; transition: background 0.2s; }
.sq-toggle input:checked + .sq-toggle-track { background: var(--teal); }
.sq-toggle-track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.sq-toggle input:checked + .sq-toggle-track::after { transform: translateX(18px); }

/* ═══════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════ */
.footer { text-align: center; padding: 1.4rem 1rem 1.6rem; color: var(--text-muted); font-size: 0.82rem; position: relative; z-index: 1; }
.footer-tagline { margin-bottom: 0.35rem; }
.footer-meta { font-size: 0.78rem; color: var(--text-muted); display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; align-items: baseline; }
.footer-link { background: none; border: none; padding: 0; color: var(--teal); font: inherit; cursor: pointer; text-decoration: underline; }
.footer-link:hover { color: var(--white); }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .story-columns { grid-template-columns: 1fr; grid-template-areas: "image" "text" "choices"; }
    .finale-columns { grid-template-columns: 1fr; grid-template-areas: "image" "text"; }
}

@media (max-width: 700px) {
    :root { --nav-h: 58px; }
    .site-nav { padding: 0 1rem; }
    .nav-logo-text { font-size: 1.3rem; }
    .nav-link { display: none; }
    .btn-nav-tour { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
    .btn-nav-tour-label { display: none; }
    .user-badge { gap: 0.4rem; padding: 4px 8px; }
    .user-badge-right { display: none; }
    .hamburger-btn { display: flex; }
    .user-badge-info { display: none; }
    .user-badge-stories { font-size: 0.8rem; }
    .hero-title { font-size: 2rem; }
    .auth-row { flex-direction: column; align-items: center; }
    .auth-card { max-width: 100%; min-width: unset; }
    .home-actions { gap: 0.75rem; }
    .action-card { min-width: 120px; padding: 1.2rem 1rem; }
    .sq-credits-grid { grid-template-columns: repeat(2, 1fr); }
    .account-form-2col { grid-template-columns: 1fr; }
    .age-bands-grid { grid-template-columns: 1fr 1fr; }
    .form-section { padding: 1.2rem; }
    .character-count-grid { grid-template-columns: repeat(2, 1fr); }
    .location-grid, .genre-grid { grid-template-columns: repeat(2, 1fr); }
    .nav-logged-out { gap: 0.5rem; }
}

/* ── Pricing card responsive layout + mobile collapse ───────
   Desktop: 4-up enforced above (no auto-fit so the 4th never wraps).
   Tablet (<=899px): 2x2.
   Mobile (<=599px): 1-col, summary-only (icon, name, price, tagline);
   tap a card to expand its features + CTA. JS in app.js + pricing.html
   handles the single-active-card behaviour. */
/* Tablet wraps to 2-per-row naturally via flex-basis. No grid override needed. */
@media (max-width: 599px) {
    /* Mobile forces a single column. flex-basis 100% > 240px so wrap occurs
       per item even when two would otherwise fit at narrow phone widths. */
    .pricing-cards-grid > .sq-pricing-card,
    .pricing-grid > .pricing-card,
    .credit-pack-grid > .credit-pack-card { flex-basis: 100%; max-width: 100%; }
    [data-pricing-card] { cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform 0.15s ease; }
    [data-pricing-card]:active { transform: scale(0.985); }
    [data-pricing-card] .sq-plan-features,
    [data-pricing-card] .sq-plan-btn,
    [data-pricing-card] .pricing-features,
    [data-pricing-card] .pricing-cta-btn { display: none; }
    [data-pricing-card].expanded .sq-plan-features { display: block; }
    [data-pricing-card].expanded .sq-plan-btn { display: block; }
    [data-pricing-card].expanded .pricing-features { display: block; }
    [data-pricing-card].expanded .pricing-cta-btn { display: block; }
}

/* ── Accessibility ──────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ═══════════════════════════════════════════════════════════
   GUIDED TOUR
   ═══════════════════════════════════════════════════════════ */
/* During a tour run, hide the page scrollbar entirely. User-initiated
   scrolling is blocked by wheel/touchmove preventDefault on the backdrop
   layer in tour.js. scrollIntoView still works because the document
   remains nominally scrollable - this avoids the flicker that came from
   toggling overflow:hidden between steps. */
body.tour-scroll-locked              { scrollbar-width: none; -ms-overflow-style: none; }
body.tour-scroll-locked::-webkit-scrollbar { display: none; width: 0; height: 0; }

.tour-backdrop {
    /* Transparent layer used for click capture only. Visual dim comes from
       the spotlight's outset box-shadow so the focused element stays sharp
       (no backdrop-filter blur applied to the highlighted region). */
    position: fixed; inset: 0; z-index: 9000;
    background: transparent;
    pointer-events: auto;
}
.tour-spotlight {
    position: fixed; z-index: 9001;
    border-radius: 14px;
    box-shadow: 0 0 0 9999px rgba(10, 5, 30, 0.65), 0 0 0 3px var(--teal);
    pointer-events: none;
    /* Position is snapped (no transition) so the spotlight and tooltip
       arrive at their new step in lockstep. tour.js fades both out
       before re-positioning, then fades back in. */
    transition: opacity 0.18s ease;
}
.tour-tooltip {
    position: fixed; z-index: 9002;
    max-width: 360px;
    background: var(--purple-mid);
    border: 2px solid var(--teal);
    border-radius: 18px;
    padding: 1.1rem 1.2rem 1rem;
    color: var(--text-light);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    transition: opacity 0.18s ease;
}
.tour-spotlight.tour-hidden,
.tour-tooltip.tour-hidden { opacity: 0; pointer-events: none; }
.tour-tooltip-step {
    font-size: 0.72rem; font-weight: 800; color: var(--teal);
    text-transform: uppercase; letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
}
.tour-tooltip-title {
    font-family: 'Fredoka One', cursive;
    font-size: 1.15rem; color: var(--gold-soft);
    margin-bottom: 0.45rem; line-height: 1.25;
}
.tour-tooltip-body {
    font-size: 0.92rem; line-height: 1.5; color: var(--text-light);
    margin-bottom: 0.95rem;
}
.tour-tooltip-body strong { color: var(--white); font-weight: 800; }
.tour-tooltip-actions {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.6rem;
}
.tour-nav-btns { display: flex; gap: 0.5rem; }
.tour-skip-btn, .tour-prev-btn, .tour-next-btn {
    border: none; cursor: pointer; font-family: inherit;
    border-radius: 50px; padding: 0.5rem 0.95rem; font-weight: 700; font-size: 0.84rem;
    transition: all var(--transition-speed);
}
.tour-skip-btn {
    background: none; color: var(--text-muted); padding-left: 0.3rem;
}
.tour-skip-btn:hover { color: var(--coral); }
.tour-prev-btn {
    background: rgba(255, 255, 255, 0.08); color: var(--text-light);
}
.tour-prev-btn:hover { background: rgba(255, 255, 255, 0.16); }
.tour-next-btn {
    background: linear-gradient(135deg, var(--teal), var(--teal-dark));
    color: var(--purple-deep);
}
.tour-next-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,212,170,0.35); }

/* Mobile: shrink the tooltip and let tour.js anchor it to the bottom or
   top edge of the viewport so it never overlaps the spotlight. */
@media (max-width: 600px) {
    .tour-tooltip {
        max-width: calc(100vw - 20px);
        padding: 0.85rem 0.95rem 0.75rem;
        border-radius: 14px;
    }
    .tour-tooltip-title { font-size: 1rem; }
    .tour-tooltip-body  { font-size: 0.85rem; line-height: 1.45; margin-bottom: 0.75rem; }
    .tour-tooltip-step  { font-size: 0.68rem; margin-bottom: 0.2rem; }
    .tour-skip-btn,
    .tour-prev-btn,
    .tour-next-btn { padding: 0.45rem 0.8rem; font-size: 0.8rem; }
    .tour-tooltip-actions { gap: 0.4rem; }
    .tour-nav-btns { gap: 0.4rem; }
}

/* Tour-only thumbnail prepended to mock story cards in the library panel */
.story-card-mock-thumb {
    width: 100%; height: 64px;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.4rem;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

/* ═══════════════════════════════════════════════════════════
   Payment screen (PayPal-direct)
   ═══════════════════════════════════════════════════════════ */

#paymentSection .payment-wrap,
#paymentSuccessSection .payment-success-wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.5rem 0;
}

.payment-back {
    margin-bottom: 1rem;
    color: var(--text-muted);
}
.payment-back:hover { color: var(--gold); }

.payment-title {
    font-family: 'Fredoka One', cursive;
    color: var(--gold);
    font-size: 1.85rem;
    margin: 0 0 0.4rem;
}
.payment-sub {
    color: var(--text-muted);
    margin: 0 0 1.5rem;
}

.payment-mock-banner {
    background: rgba(245, 200, 66, 0.10);
    border: 1px solid rgba(245, 200, 66, 0.35);
    color: var(--gold-soft);
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.5;
}
.payment-mock-banner.hidden { display: none; }

.payment-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 720px) {
    .payment-grid { grid-template-columns: 1fr; }
}

.payment-summary-card,
.payment-action-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 1.5rem;
}
.payment-summary-card {
    display: flex;
    flex-direction: column;
}

.payment-summary-emoji { font-size: 2.4rem; line-height: 1; margin-bottom: 0.5rem; }
.payment-summary-name {
    font-family: 'Fredoka One', cursive;
    color: var(--white);
    font-size: 1.4rem;
    margin-bottom: 0.25rem;
}
.payment-summary-price {
    color: var(--gold);
    font-size: 1.6rem;
    font-weight: 700;
}
.payment-summary-billing {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}
.payment-summary-features {
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
    font-size: 0.92rem;
    color: var(--text-light);
}
.payment-summary-features li {
    padding: 0.3rem 0 0.3rem 1.4rem;
    position: relative;
}
.payment-summary-features li::before {
    content: "✓";
    color: var(--teal);
    position: absolute;
    left: 0;
    font-weight: 700;
}
.payment-summary-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: 1rem;
    border-top: 1px solid var(--card-border);
    color: var(--text-muted);
    font-size: 0.95rem;
}
.payment-summary-total strong {
    color: var(--gold);
    font-size: 1.4rem;
    font-weight: 700;
}
.payment-summary-tax-note {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin: 0.6rem 0 0;
}
.payment-summary-trial-note {
    color: var(--gold-soft);
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0.5rem 0 0;
    padding: 0.6rem 0.75rem;
    background: rgba(245, 200, 66, 0.08);
    border-left: 3px solid var(--gold);
    border-radius: 4px;
}

.payment-action-heading {
    font-family: 'Fredoka One', cursive;
    color: var(--gold-soft);
    font-size: 1.15rem;
    margin: 0 0 0.6rem;
}
.payment-action-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.55;
    margin: 0 0 1.25rem;
}

.payment-button-mount {
    min-height: 64px;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Credit-purchase intent toggle (self vs gift) + recipient input. Lives
   inside .payment-action-card, above the PayPal button mount, only when
   pendingPayment.kind === 'credits'. */
.payment-credit-options {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 1.1rem;
}
.payment-credit-options-heading {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-light);
}
.payment-credit-toggle {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    padding: 4px;
    align-self: flex-start;
}
.payment-credit-toggle-btn {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    font: inherit;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.payment-credit-toggle-btn:hover { color: var(--text-light); }
.payment-credit-toggle-btn.active {
    background: var(--gold);
    color: #1a1a2e;
}
.payment-credit-recipient {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.payment-credit-recipient label {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-light);
}
.payment-credit-recipient-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0;
}

/* Credit-pack selector: dropdown at the top of the payment summary card,
   visible only when kind=credits. Reuses the .custom-select styles. */
.payment-credit-selector {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--card-border);
    text-align: left;
}
.payment-credit-selector-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Guest checkout fields: buyer email + login/signup links. Visible
   only when an unauthenticated user is on the credits payment screen. */
.payment-guest-fields {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1.1rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--card-border);
}
.payment-guest-account-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}
.payment-guest-account-row .auth-text-btn {
    padding: 0;
    font-weight: 700;
    color: var(--gold);
}
.payment-guest-account-sep {
    color: var(--text-muted);
    opacity: 0.6;
}
.payment-guest-email-label {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-light);
}
.payment-guest-email-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0;
}

/* PayPal-only payment panel: replaces Smart Buttons for credit packs.
   Single Continue-to-PayPal button + a support-contact footnote below. */
.payment-paypal-only-panel {
    text-align: left;
}
.payment-paypal-only-text {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
    text-align: center;
}
.payment-paypal-only-text a {
    color: var(--gold);
    text-decoration: underline;
}
.payment-paypal-continue-btn {
    width: 100%;
    padding: 0.85rem 1.2rem;
    border-radius: 999px;
    border: 1px solid #FFC439;
    background: #FFC439;
    color: #003087;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
    transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.payment-paypal-continue-btn:hover {
    background: #F5BB2D;
    border-color: #F5BB2D;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(255, 196, 57, 0.45);
}
.payment-paypal-continue-btn:disabled {
    opacity: 0.7;
    cursor: progress;
    transform: none;
    box-shadow: none;
}
.payment-paypal-btn-label {
    font-weight: 600;
    color: #003087;
}
.payment-paypal-wordmark {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-style: italic;
    font-weight: 800;
    font-size: 1.12em;
    letter-spacing: -0.02em;
    line-height: 1;
}
.payment-paypal-wordmark-pay { color: #003087; }
.payment-paypal-wordmark-pal { color: #009cde; }

/* Guest account-creation CTA on the success screen. Shown only after
   a guest credit purchase, encouraging account creation post-payment. */
.payment-success-guest-cta {
    margin: 1.5rem auto 1rem;
    max-width: 420px;
    padding: 1.1rem 1.2rem 1.2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    text-align: center;
}
.payment-success-guest-title {
    margin: 0 0 0.4rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-light);
}
.payment-success-guest-sub {
    margin: 0 0 0.9rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.payment-success-guest-cta-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
}
.payment-success-guest-cta-btn,
.payment-success-guest-login-btn {
    margin: 0;
    flex: 1 1 200px;
}
.payment-success-guest-login-btn {
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
}
.payment-success-guest-login-btn:hover {
    background: rgba(245, 197, 24, 0.1);
}

/* Redeem-credit-code section. Reuses the auth-card visual treatment
   so a recipient who lands on /redeem?code=... feels at home. */
.redeem-wrap {
    max-width: 520px;
    margin: 0 auto;
    padding: 2rem 1.5rem 2.5rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    text-align: center;
    position: relative;
}
.redeem-back {
    position: absolute;
    top: 0.9rem;
    left: 0.9rem;
}
.redeem-icon {
    font-size: 2.4rem;
    margin: 0.4rem 0 0.5rem;
}
.redeem-title {
    margin: 0 0 0.5rem;
    color: var(--gold);
    font-family: 'Fredoka One', cursive;
    font-size: 1.7rem;
}
.redeem-sub {
    margin: 0 0 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}
.redeem-form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    text-align: left;
}
.redeem-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.redeem-code-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.15rem;
    letter-spacing: 0.08em;
    text-align: center;
    text-transform: uppercase;
}
.redeem-error {
    margin: 0;
    color: var(--coral);
    font-size: 0.88rem;
}
.redeem-success {
    margin: 0;
    color: var(--teal);
    font-size: 0.95rem;
    font-weight: 700;
}
.redeem-submit-btn {
    width: 100%;
    padding: 0.85rem 1.2rem;
    border-radius: 999px;
    border: 0;
    background: linear-gradient(135deg, var(--gold), #f0a800);
    color: var(--purple-deep);
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.redeem-submit-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(245, 200, 66, 0.4); }
.redeem-submit-btn:disabled { opacity: 0.6; cursor: progress; transform: none; box-shadow: none; }
.redeem-help {
    margin: 1.4rem 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
}
.redeem-help a { color: var(--gold); text-decoration: underline; }

/* Credit-code display on the success screen. Hidden by default; shown
   when capture_credit_order returns a code. */
.payment-success-code {
    margin: 1.5rem auto 1rem;
    max-width: 360px;
    padding: 1.25rem 1rem 1rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px dashed var(--gold-soft);
    border-radius: 14px;
    text-align: center;
}
.payment-success-code-label {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.payment-success-code-value {
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--gold);
    word-break: keep-all;
}
.payment-success-code-copy {
    margin-top: 0.75rem;
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    padding: 0.4rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.payment-success-code-copy:hover {
    background: var(--gold);
    color: #1a1a2e;
}
.payment-success-code-hint {
    margin: 0.75rem 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.payment-sdk-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem;
    color: var(--text-muted);
}
.payment-sdk-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: payment-sdk-spin 0.8s linear infinite;
}
@keyframes payment-sdk-spin { to { transform: rotate(360deg); } }
.payment-sdk-loading-text { margin: 0; font-size: 0.9rem; }

.payment-sdk-error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.payment-sdk-error-title {
    margin: 0;
    color: #fca5a5;
    font-weight: 700;
    font-size: 0.95rem;
}
.payment-sdk-error-text {
    margin: 0;
    color: var(--text-light);
    font-size: 0.85rem;
    line-height: 1.45;
}
.payment-sdk-error-text a { color: var(--teal); }
.payment-sdk-error-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.25rem;
}
.payment-sdk-retry-btn,
.payment-sdk-fallback-btn {
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
}
.payment-sdk-retry-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
}
.payment-sdk-retry-btn:hover { background: rgba(255, 255, 255, 0.18); }
.payment-sdk-fallback-btn {
    background: var(--teal);
    color: #fff;
}
.payment-sdk-fallback-btn:hover { background: var(--teal-dark); }

.payment-mock-btn {
    background: linear-gradient(135deg, #0070ba, #003087);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0.85rem 1.25rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.2s;
}
.payment-mock-btn:hover:not(:disabled) { transform: translateY(-1px); }
.payment-mock-btn:disabled { opacity: 0.7; cursor: progress; }

.payment-mock-spinner {
    display: inline-block;
    width: 0.95em; height: 0.95em;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    margin-right: 0.45em;
    animation: paymentSpin 0.75s linear infinite;
    vertical-align: -2px;
}
@keyframes paymentSpin { to { transform: rotate(360deg); } }

.payment-mock-note {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin: 0;
    font-style: italic;
}

.payment-error {
    background: rgba(255, 107, 107, 0.10);
    border: 1px solid rgba(255, 107, 107, 0.35);
    color: var(--coral);
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin: 0.75rem 0 0;
}
.payment-error.hidden { display: none; }
.payment-status {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0.75rem 0 0;
}
.payment-status.hidden { display: none; }

.payment-legal-note {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    line-height: 1.55;
    margin: 0.5rem 0 0;
}
.payment-legal-note a { color: var(--gold); }

/* Success screen */
.payment-success-wrap {
    text-align: center;
    padding: 2rem 1rem 3rem;
}
.payment-success-icon {
    font-size: 3.2rem;
    margin-bottom: 0.5rem;
}
.payment-success-title {
    font-family: 'Fredoka One', cursive;
    color: var(--gold);
    font-size: 2rem;
    margin: 0 0 0.5rem;
}
.payment-success-sub {
    color: var(--text-light);
    max-width: 520px;
    margin: 0 auto 1.5rem;
    line-height: 1.55;
}
.payment-success-features {
    list-style: none;
    padding: 0;
    max-width: 380px;
    margin: 0 auto 1.5rem;
    text-align: left;
    color: var(--text-light);
}
.payment-success-features li {
    padding: 0.3rem 0 0.3rem 1.6rem;
    position: relative;
}
.payment-success-features li::before {
    content: "✨";
    position: absolute;
    left: 0;
}
.payment-success-cta {
    background: linear-gradient(135deg, var(--gold), var(--gold-soft));
    color: var(--purple-deep);
    border: none;
    border-radius: 10px;
    padding: 0.9rem 1.75rem;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s;
}
.payment-success-cta:hover { transform: translateY(-1px); }
.payment-success-receipt-note {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin: 1.25rem 0 0;
}
