/* ========================================
   DON'T YOU REMEMBER?
   Playing card deck edition
   ======================================== */

:root {
    --bg-deep: #1a1d22;
    --bg-dark: #232830;
    --mirror-base: #2a2f38;
    --mirror-highlight: #3a4048;
    --mirror-shadow: #15181d;
    --cream: #e8ddd0;
    --cream-soft: #d4c5b3;
    --gold: #c4a265;
    --gold-dim: #8a7245;
    --gold-bright: #d4b878;
    --purple-deep: #2a1530;
    --purple-mid: #1a1a1a;
    --purple-ink: #0a0a0a;
    --card-purple: #3a1f3f;
    --card-cream: #ede0c8;
    --card-cream-light: #f5ebd8;
    --white-soft: #f0ebe4;
    --text-secondary: #b0a598;
    --text-dim: #7a7268;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }

body {
    color: var(--cream);
    font-family: 'Crimson Text', Georgia, serif;
    line-height: 1.7;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    height: 100dvh;
    /* Just the glass image with a soft darkening overlay for readability */
    background:
        linear-gradient(180deg, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.4) 100%),
        url('background.png') center/cover no-repeat;
    background-attachment: fixed;
}

/* subtle darkening vignette on top */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(ellipse at 50% 100%, rgba(0, 0, 0, 0.25) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 0%, rgba(0, 0, 0, 0.18) 0%, transparent 50%);
}

/* ---- NAME GATE ---- */

.name-gate {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    opacity: 1;
    transition: opacity 1.2s ease;
}

.name-gate.closing {
    opacity: 0;
    pointer-events: none;
}

.name-stage {
    text-align: center;
    max-width: 500px;
    animation: stage-in 1s ease forwards;
}

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

.name-whisper {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    font-style: italic;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.name-form {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.name-input {
    width: 100%;
    max-width: 360px;
    font-family: 'Nanum Myeongjo', Georgia, serif;
    font-size: clamp(1.5rem, 4vw, 2rem);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--gold-dim);
    color: var(--white-soft);
    text-align: center;
    padding: 0.4rem 0.2rem;
    outline: none;
    transition: border-color 0.3s ease;
    caret-color: var(--gold);
}

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

.name-input.error {
    animation: name-shake 0.45s cubic-bezier(.36,.07,.19,.97);
    border-bottom-color: #c4a265;
}

@keyframes name-shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(3px); }
    30%, 50%, 70% { transform: translateX(-6px); }
    40%, 60% { transform: translateX(6px); }
}

.name-error {
    font-family: 'Crimson Text', Georgia, serif;
    font-style: italic;
    font-size: 0.95rem;
    color: var(--gold);
    opacity: 0;
    height: 1rem;
    margin: 0;
    transition: opacity 0.4s ease;
    text-align: center;
    letter-spacing: 0.03em;
}

.name-error.visible {
    opacity: 0.85;
}

.name-submit {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 1rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold);
    background: transparent;
    border: 1px solid var(--gold-dim);
    padding: 0.7rem 2.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-style: italic;
}

.name-submit:hover {
    background: rgba(196, 162, 101, 0.1);
    border-color: var(--gold);
    letter-spacing: 0.3em;
}

.yoink-big {
    font-family: 'Nanum Myeongjo', Georgia, serif;
    font-size: clamp(3.5rem, 10vw, 6rem);
    font-weight: 700;
    color: var(--white-soft);
    line-height: 1;
    text-shadow:
        0 0 30px rgba(220, 180, 110, 0.4),
        0 0 60px rgba(220, 180, 110, 0.2),
        0 4px 10px rgba(0, 0, 0, 0.6);
    margin-bottom: 1.5rem;
    animation: yoink-pop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.yoink-sub {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    font-style: italic;
    color: var(--cream-soft);
    line-height: 1.4;
    margin: 0;
    opacity: 0;
    animation: fade-up 0.8s ease 0.5s forwards;
}

.yoink-sub-2 {
    animation-delay: 1.2s;
}

/* Atmospheric candle-glow behind the yoink */
.name-yoink {
    position: relative;
}

.name-yoink::before {
    content: '';
    position: absolute;
    inset: -30vmin;
    background:
        radial-gradient(circle at 50% 50%, rgba(220, 160, 90, 0.22) 0%, rgba(180, 120, 70, 0.1) 30%, transparent 60%);
    z-index: -1;
    pointer-events: none;
    animation: candle-pulse 5s ease-in-out infinite;
}

.name-yoink::after {
    content: '';
    position: absolute;
    inset: -20vmin;
    background:
        radial-gradient(circle at 35% 40%, rgba(255, 220, 170, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 65% 55%, rgba(255, 200, 140, 0.06) 0%, transparent 45%);
    z-index: -1;
    pointer-events: none;
    animation: candle-pulse 7s ease-in-out infinite reverse;
}

@keyframes candle-pulse {
    0%, 100% {
        opacity: 0.7;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.08);
    }
}

@keyframes yoink-pop {
    0% { opacity: 0; transform: scale(0.4) rotate(-6deg); }
    60% { opacity: 1; transform: scale(1.08) rotate(2deg); }
    100% { opacity: 1; transform: scale(1) rotate(0); }
}

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

/* ---- DECK DEAL ANIMATION ---- */

.card.pre-deal {
    opacity: 0;
    pointer-events: none;
}

.card.dealing {
    animation: deal-in 0.7s cubic-bezier(0.25, 0.95, 0.35, 1.05) forwards;
}

@keyframes deal-in {
    from {
        opacity: 0;
        transform: translate(var(--deal-x, 0), var(--deal-y, 0)) rotate(var(--deal-rot, 0deg)) scale(0.4);
    }
    to {
        opacity: 1;
        transform: translate(0, 0) rotate(0) scale(1);
    }
}

.grain {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}


/* ---- FOGGED MIRROR ---- */

/* ---- BACKDROP ---- */

.backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 5, 0.82);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* ---- MAIN ---- */

main {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1.5rem;
    gap: 2rem;
    position: relative;
    z-index: 5;
    overflow: hidden;
}

/* ---- HERO ---- */

.hero-text { text-align: center; }

.title {
    font-family: 'Nanum Myeongjo', Georgia, serif;
    font-size: clamp(2rem, 5vw, 3.4rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--white-soft);
    margin-top: 0.8rem;
    /* Layered glow + depth shadow for cinematic feel */
    text-shadow:
        0 0 30px rgba(220, 180, 110, 0.35),
        0 0 60px rgba(220, 180, 110, 0.2),
        0 0 100px rgba(220, 180, 110, 0.12),
        0 3px 8px rgba(0, 0, 0, 0.6),
        0 10px 30px rgba(0, 0, 0, 0.4);
    animation: title-breathe 6s ease-in-out infinite;
}

/* Ghost-dissolve for the guest's name in the title.
   Starts visible inline; on .dissolving it blurs, drifts up, letters spread,
   and its width collapses so the rest of the title reflows cleanly. */
.name-dissolve {
    display: inline-block;
    white-space: nowrap;
    vertical-align: baseline;
    opacity: 1;
    filter: blur(0);
    letter-spacing: normal;
    transform: translateY(0);
    /* Fade/blur finish fast so text is invisible before width collapses.
       No overflow:hidden — that causes baseline shift in inline-block. */
    transition:
        opacity 800ms ease-out,
        filter 1100ms ease-out,
        letter-spacing 1100ms ease-out,
        transform 1100ms ease-out,
        max-width 1200ms cubic-bezier(0.4, 0, 0.2, 1) 900ms;
}

.name-dissolve.dissolving {
    max-width: 0 !important;
    opacity: 0;
    filter: blur(14px);
    letter-spacing: 0.35em;
    transform: translateY(-10px);
}

/* Reduced-motion: still dissolve (so title ends clean), but no blur/drift/spread */
.name-dissolve.reduced-motion.dissolving {
    filter: blur(0) !important;
    letter-spacing: normal !important;
    transform: none !important;
}

@keyframes title-breathe {
    0%, 100% {
        text-shadow:
            0 0 30px rgba(220, 180, 110, 0.35),
            0 0 60px rgba(220, 180, 110, 0.2),
            0 0 100px rgba(220, 180, 110, 0.12),
            0 3px 8px rgba(0, 0, 0, 0.6),
            0 10px 30px rgba(0, 0, 0, 0.4);
    }
    50% {
        text-shadow:
            0 0 40px rgba(220, 180, 110, 0.5),
            0 0 80px rgba(220, 180, 110, 0.3),
            0 0 130px rgba(220, 180, 110, 0.18),
            0 3px 8px rgba(0, 0, 0, 0.6),
            0 10px 30px rgba(0, 0, 0, 0.4);
    }
}

.whisper {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: clamp(0.9rem, 1.6vw, 1.05rem);
    font-weight: 400;
    font-style: italic;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    margin-bottom: 0.2rem;
    line-height: 1.3;
}

/* ---- DECK ---- */

.deck {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    align-content: flex-start;
    gap: 1.2rem;
    /* 5 per row so 9 cards lay out as 5+4, fitting on one viewport */
    max-width: calc(170px * 5 + 1.2rem * 4 + 2rem);
    width: 100%;
}

/* ---- CARD ---- */

.card {
    width: 170px;
    min-width: 170px;
    max-width: 170px;
    height: 238px;
    min-height: 238px;
    max-height: 238px;
    cursor: pointer;
    transition: transform 0.4s ease, z-index 0s linear 0.4s;
    position: relative;
    perspective: 2000px;
    flex: 0 0 170px;
    /* Faster tap response + disable double-tap-zoom on cards */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Hover lift ONLY on real pointer devices (mouse) — prevents sticky hover on touch */
@media (hover: hover) and (pointer: fine) {
    .card:hover {
        transform: translateY(-8px) rotate(-0.3deg);
    }

    .card:hover .card-face {
        box-shadow:
            0 40px 70px -12px rgba(0, 0, 0, 0.9),
            0 22px 40px -8px rgba(0, 0, 0, 0.65),
            0 10px 20px -4px rgba(0, 0, 0, 0.5),
            0 3px 6px rgba(0, 0, 0, 0.4),
            inset 0 1px 0 rgba(255, 248, 230, 0.55),
            inset 0 -1px 1px rgba(0, 0, 0, 0.1),
            inset 0 0 0 1px rgba(196, 162, 101, 0.45);
    }

    /* Prevent sibling cards from lifting on hover while any card is flipped */
    body:has(.card.flipped) .card:not(.flipped):hover {
        transform: none;
    }
}

body:has(.card.flipped) .card:not(.flipped) {
    pointer-events: none;
}

.card.flipped {
    z-index: 200;
    min-width: 0;
    max-width: 90vw;
    min-height: 0;
    max-height: 85vh;
    transition:
        top 900ms cubic-bezier(0.4, 0.1, 0.2, 1),
        left 900ms cubic-bezier(0.4, 0.1, 0.2, 1),
        width 900ms cubic-bezier(0.4, 0.1, 0.2, 1),
        height 900ms cubic-bezier(0.4, 0.1, 0.2, 1);
}

.card.flipped:hover {
    transform: none;
}

/* Ghost placeholder keeps grid slot while card is fixed */
.card-placeholder {
    width: 170px;
    min-width: 170px;
    max-width: 170px;
    height: 238px;
    visibility: hidden;
    flex: 0 0 170px;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Firefox fix: explicit transform keeps the element in 3D rendering
       context so backface-visibility: hidden works reliably. */
    transform: rotateY(0deg);
    border-radius: 11px;
    overflow: hidden;
    box-shadow:
        /* Soft deep shadow (card resting on surface) */
        0 30px 60px -12px rgba(0, 0, 0, 0.85),
        0 18px 36px -8px rgba(0, 0, 0, 0.65),
        0 8px 16px -4px rgba(0, 0, 0, 0.5),
        /* Close contact shadow */
        0 2px 4px rgba(0, 0, 0, 0.45),
        /* Inner top highlight */
        inset 0 1px 0 rgba(255, 248, 230, 0.55),
        /* Inner bottom shadow */
        inset 0 -1px 1px rgba(0, 0, 0, 0.12),
        /* Gold frame */
        inset 0 0 0 1px rgba(196, 162, 101, 0.35);
}

/* Paper noise texture injected into card backgrounds */

.card.flipped .card-face {
    box-shadow:
        /* Dramatic shadow when flipped and centered */
        0 50px 100px -10px rgba(0, 0, 0, 0.9),
        0 25px 50px -8px rgba(0, 0, 0, 0.7),
        0 10px 20px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 248, 230, 0.6),
        inset 0 -1px 1px rgba(0, 0, 0, 0.12),
        inset 0 0 0 1px rgba(196, 162, 101, 0.45);
}

/* ---- CARD FRONT ---- */

.card-front {
    background:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='sparkle'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 0.95  0 0 0 1.5 -0.5'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23sparkle)'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 300 300' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='3'/%3E%3CfeColorMatrix values='0 0 0 0 0.2  0 0 0 0 0.15  0 0 0 0 0.1  0 0 0 0.45 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
        radial-gradient(ellipse at 25% 15%, rgba(255, 248, 225, 0.75) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 95%, rgba(140, 115, 85, 0.35) 0%, transparent 60%),
        linear-gradient(135deg, #f5ebd5 0%, #ecdfc5 55%, #d8c8aa 100%);
    /* Grain tiles scale with card so they stay visually stable during resize */
    background-size: 200px 200px, 160px 160px, auto, auto, auto;
    background-repeat: repeat, repeat, no-repeat, no-repeat, no-repeat;
    color: var(--purple-ink);
    padding: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    inset: 0;
    container-type: inline-size;
}

.card-front::before {
    content: '';
    position: absolute;
    inset: 0.5rem;
    border: 1.5px solid var(--gold-dim);
    border-radius: 4px;
    pointer-events: none;
}

.card-front::after {
    content: '';
    position: absolute;
    inset: 0.75rem;
    border: 0.5px solid var(--gold-dim);
    border-radius: 3px;
    pointer-events: none;
    opacity: 0.6;
}

.corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    font-family: 'Crimson Text', Georgia, serif;
    mix-blend-mode: multiply;
    opacity: 0.88;
}

/* px values are fallback for browsers without container query support (old Samsung Internet) */
.corner.tl { top: 17px; top: 12cqi; left: 17px; left: 12cqi; }
.corner.br { bottom: 17px; bottom: 12cqi; right: 17px; right: 12cqi; transform: rotate(180deg); }

.corner .letter {
    font-size: 20px;
    font-size: 14cqi;
    font-weight: 600;
    color: var(--purple-ink);
    letter-spacing: -0.02em;
    line-height: 1;
}

.corner .suit {
    font-size: 14px;
    font-size: 10cqi;
    color: var(--purple-ink);
    margin-top: 1px;
    margin-top: 0.8cqi;
    line-height: 1;
    font-variant-emoji: text;
}

/* Force suits to render as text (not iOS emoji) */
.suit, .big-suit {
    font-variant-emoji: text;
    -webkit-font-feature-settings: "liga" 0;
}

/* Odd cards (1,3,5,7,9) are purple: time, wardrobe, mystery, contribute, safety */
.card[data-topic="time"] .corner .letter,
.card[data-topic="time"] .corner .suit,
.card[data-topic="time"] .big-suit,
.card[data-topic="wardrobe"] .corner .letter,
.card[data-topic="wardrobe"] .corner .suit,
.card[data-topic="wardrobe"] .big-suit,
.card[data-topic="mystery"] .corner .letter,
.card[data-topic="mystery"] .corner .suit,
.card[data-topic="mystery"] .big-suit,
.card[data-topic="contribute"] .corner .letter,
.card[data-topic="contribute"] .corner .suit,
.card[data-topic="contribute"] .big-suit,
.card[data-topic="safety"] .corner .letter,
.card[data-topic="safety"] .corner .suit,
.card[data-topic="safety"] .big-suit {
    color: var(--card-purple);
}

.center-art {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    text-align: center;
    padding: 0 3px;
    padding: 0 2cqi;
    max-width: 100%;
    mix-blend-mode: multiply;
    opacity: 0.92;
}

.flourish-top,
.flourish-bot {
    display: none;
}

.big-suit {
    font-size: 58px;
    font-size: 42cqi;
    color: var(--purple-ink);
    line-height: 1;
    margin: 0;
}

.big-spade { font-size: 62px; font-size: 46cqi; }

.card-name {
    font-family: 'Crimson Text', Georgia, serif;
    font-style: italic;
    font-size: 15px;
    font-size: 10.5cqi;
    font-weight: 600;
    color: var(--purple-ink);
    letter-spacing: 0.06em;
    line-height: 1.15;
    margin-top: 6px;
    margin-top: 4cqi;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ---- CARD BACK ---- */

.card-back {
    background:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='sparkle'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' seed='9'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 0.95  0 0 0 0.95 -0.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23sparkle)'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 300 300' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0.2  0 0 0 0 0.15  0 0 0 0 0.1  0 0 0 0.3 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
        radial-gradient(ellipse at 25% 15%, rgba(255, 248, 225, 0.7) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 95%, rgba(140, 115, 85, 0.3) 0%, transparent 60%),
        linear-gradient(135deg, #f5ebd5 0%, #ecdfc5 55%, #d8c8aa 100%);
    background-size: 200px 200px, 160px 160px, auto, auto, auto;
    background-repeat: repeat, repeat, no-repeat, no-repeat, no-repeat;
    transform: rotateY(180deg);
    padding: 1.5rem 1rem;
    position: absolute;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    container-type: inline-size;
}

.card-back::before {
    content: '';
    position: absolute;
    inset: 0.6rem;
    border: 1px solid var(--gold-dim);
    border-radius: 4px;
    pointer-events: none;
    z-index: 1;
}

.back-content {
    color: var(--purple-ink);
    text-align: center;
    padding: 0.3rem 0.5rem;
    width: 100%;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-dim) transparent;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    opacity: 0;
    transition: opacity 300ms ease;
    mix-blend-mode: multiply;
}

/* Center content when it fits, scroll from top when overflows.
   justify-content:center works when content fits; if content overflows,
   safe-center alignment keeps the start accessible (prevents top clip). */
.back-content {
    justify-content: safe center;
}

/* Reveal — fade to full weathered opacity */
.card.revealed .back-content {
    opacity: 0.92;
}


.back-content::-webkit-scrollbar {
    width: 4px;
}
.back-content::-webkit-scrollbar-track {
    background: transparent;
}
.back-content::-webkit-scrollbar-thumb {
    background: var(--gold-dim);
    border-radius: 2px;
    opacity: 0.5;
}


.back-content h3 {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 1.3rem;
    font-weight: 600;
    font-style: italic;
    color: var(--purple-mid);
    margin: 0 0 0.5rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(138, 114, 69, 0.3);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.back-content p {
    font-size: 1.1rem;
    line-height: 1.4;
    margin: 0;
    color: var(--purple-ink);
    opacity: 0.92;
}

.back-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.back-content li {
    font-size: 1.05rem;
    line-height: 1.35;
    margin: 0;
    padding-left: 1rem;
    position: relative;
    color: var(--purple-ink);
    opacity: 0.92;
}

.back-content li::before {
    content: '◆';
    position: absolute;
    left: 0;
    color: var(--gold-dim);
    font-size: 0.65rem;
    top: 0.4rem;
}

.back-content p.accent {
    color: var(--gold-dim);
    font-style: italic;
    font-weight: 600;
}

.back-content .gold {
    color: var(--gold-dim);
}

.back-content p.plain-italic {
    font-style: italic;
    font-weight: 400;
    color: var(--purple-ink);
}

.back-content p.gold-italic {
    color: var(--gold-dim);
    font-style: italic;
    font-weight: 400;
}

.back-content .rule-sub {
    margin-top: 0.3rem;
    font-size: 0.92rem;
    line-height: 1.35;
    opacity: 0.72;
    color: var(--purple-ink);
}

.back-content .rule-sub + .rule-sub {
    margin-top: 0.15rem;
}

/* Italic sub-lines inside wardrobe list items — smaller + faded,
   matching the "dim" paragraph style used elsewhere. */
.back-content ol.rules-list > li > em {
    font-size: 0.92rem;
    color: var(--purple-ink);
    opacity: 0.6;
    font-style: italic;
    font-weight: 400;
}

.back-content p.key {
    font-weight: 700;
    color: var(--purple-ink);
    font-style: normal;
}

.back-content p.italic {
    font-style: italic;
    font-weight: 400;
    color: var(--purple-ink);
}

.back-content ol.rules-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: rule;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.back-content ol.rules-list li {
    counter-increment: rule;
    font-size: 1.1rem;
    line-height: 1.35;
    padding-left: 1.6rem;
    position: relative;
    color: var(--purple-ink);
    opacity: 0.92;
    text-align: left;
}

.back-content ol.rules-list li::before {
    content: counter(rule) ".";
    position: absolute;
    left: 0;
    font-weight: 700;
    color: var(--gold-dim);
}

.back-content p.dim {
    color: var(--purple-ink);
    opacity: 0.6;
    font-style: italic;
    font-size: 1rem;
}

.back-content p em {
    color: var(--gold-dim);
    font-style: italic;
    font-weight: 600;
}

/* ---- ANIMATIONS ---- */

.fade-in {
    opacity: 0;
    animation: fadeIn 1.2s ease forwards;
}

.delay-1 { animation-delay: 0.5s; }
.delay-2 { animation-delay: 1s; }
.delay-3 { animation-delay: 1.6s; }
.delay-4 { animation-delay: 2.6s; }

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

/* ---- RESPONSIVE ---- */

@media (max-height: 900px) {
    .card {
        width: 150px;
        min-width: 150px;
        max-width: 150px;
        height: 210px;
        min-height: 210px;
        max-height: 210px;
        flex: 0 0 150px;
    }
    .card-placeholder {
        width: 150px;
        min-width: 150px;
        max-width: 150px;
        height: 210px;
        min-height: 210px;
        max-height: 210px;
        flex: 0 0 150px;
    }
    .deck { max-width: calc(150px * 5 + 1.2rem * 4 + 2rem); }
}

@media (max-height: 780px) {
    .card {
        width: 135px;
        min-width: 135px;
        max-width: 135px;
        height: 189px;
        min-height: 189px;
        max-height: 189px;
        flex: 0 0 135px;
    }
    .card-placeholder {
        width: 135px;
        min-width: 135px;
        max-width: 135px;
        height: 189px;
        min-height: 189px;
        max-height: 189px;
        flex: 0 0 135px;
    }
    .deck { max-width: calc(135px * 5 + 1rem * 4 + 2rem); gap: 1rem; }
    main { gap: 1.5rem; padding: 1rem; }
    .title { font-size: clamp(1.8rem, 4vw, 2.6rem); }
}


@media (max-width: 768px) {
    /* Glass image on mobile — no color tint, just natural darkening */
    body {
        background:
            linear-gradient(180deg, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.4) 100%),
            url('background.png') center/cover no-repeat;
        background-attachment: fixed;
    }
    /* Lighter grain on mobile — small cards were too noisy */
    .card-front {
        background:
            url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='sparkle'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 0.95  0 0 0 0.7 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23sparkle)'/%3E%3C/svg%3E"),
            url("data:image/svg+xml,%3Csvg viewBox='0 0 300 300' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='3'/%3E%3CfeColorMatrix values='0 0 0 0 0.2  0 0 0 0 0.15  0 0 0 0 0.1  0 0 0 0.2 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
            radial-gradient(ellipse at 25% 15%, rgba(255, 248, 225, 0.75) 0%, transparent 55%),
            radial-gradient(ellipse at 85% 95%, rgba(140, 115, 85, 0.35) 0%, transparent 60%),
            linear-gradient(135deg, #f5ebd5 0%, #ecdfc5 55%, #d8c8aa 100%);
        background-size: 300px 300px, 220px 220px, auto, auto, auto;
        background-repeat: repeat, repeat, no-repeat, no-repeat, no-repeat;
    }
    .card-back {
        background:
            url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='sparkle'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' seed='9'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 0.95  0 0 0 0.55 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23sparkle)'/%3E%3C/svg%3E"),
            url("data:image/svg+xml,%3Csvg viewBox='0 0 300 300' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0.2  0 0 0 0 0.15  0 0 0 0 0.1  0 0 0 0.18 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
            radial-gradient(ellipse at 25% 15%, rgba(255, 248, 225, 0.7) 0%, transparent 55%),
            radial-gradient(ellipse at 85% 95%, rgba(140, 115, 85, 0.3) 0%, transparent 60%),
            linear-gradient(135deg, #f5ebd5 0%, #ecdfc5 55%, #d8c8aa 100%);
        background-size: 300px 300px, 220px 220px, auto, auto, auto;
        background-repeat: repeat, repeat, no-repeat, no-repeat, no-repeat;
    }
    body::before {
        background:
            repeating-linear-gradient(
                100deg,
                transparent 0px,
                transparent 220px,
                rgba(255, 255, 255, 0.012) 221px,
                rgba(255, 255, 255, 0.018) 240px,
                transparent 260px
            ),
            radial-gradient(ellipse at 50% 100%, rgba(0, 10, 5, 0.45) 0%, transparent 60%),
            radial-gradient(ellipse at 50% 0%, rgba(0, 10, 5, 0.25) 0%, transparent 50%);
    }
}

@media (max-width: 480px) {
    /* Allow vertical scroll on mobile since content > viewport */
    html, body {
        overflow-y: auto;
        height: auto;
        min-height: 100dvh;
    }
    body {
        overflow-x: hidden;
    }
    main {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
        padding: 1.5rem 0.5rem 2rem;
        gap: 1.2rem;
        /* Center vertically when content fits; when taller than viewport, it
           overflows and the page scrolls naturally. */
        justify-content: center;
    }
    .deck {
        gap: 0.5rem;
        max-width: calc(110px * 3 + 0.5rem * 2 + 1rem);
    }
    .card {
        width: 110px;
        min-width: 110px;
        max-width: 110px;
        height: 154px;
        min-height: 154px;
        max-height: 154px;
        flex: 0 0 110px;
    }
    .card-placeholder {
        width: 110px;
        min-width: 110px;
        max-width: 110px;
        height: 154px;
        min-height: 154px;
        max-height: 154px;
        flex: 0 0 110px;
    }
    /* Smaller hero on mobile — fit title on one line */
    .title {
        font-size: clamp(1.3rem, 6vw, 1.9rem);
        margin-top: 0.5rem;
        white-space: nowrap;
    }
    .title-break { display: none; }
    .whisper { font-size: 0.85rem; margin-bottom: 0.1rem; }
    /* cqi handles scaling — no rem overrides */
    .sound-toggle {
        width: 40px;
        height: 40px;
        bottom: 1rem;
        right: 1rem;
        font-size: 1.1rem;
    }
}
