/* Original artwork, spread layouts, export preview, and basic rendering primitives. */

:root {
    --bg-primary: #0d0c14;
    --bg-secondary: rgba(22, 20, 32, 0.88);
    --bg-card: #1c192b;
    --bg-bot: #231f36;
    --bg-input: rgba(18, 16, 26, 0.94);
    --text-primary: #ede8f5;
    --text-secondary: #b8b0c8;
    --text-muted: #857c98;
    --accent-gold: #e5c158;
    --accent-primary: #b388ff;
    --accent-secondary: #8c54ff;
    --border-color: rgba(179, 136, 255, 0.18);
    --border-glow: rgba(179, 136, 255, 0.35);
    --card-back: linear-gradient(135deg, #372957 0%, #1c1533 100%);
    --card-front: linear-gradient(135deg, #2a243d 0%, #1e192c 100%);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

[data-theme="light"] {
    --bg-primary: #f6f5fb;
    --bg-secondary: rgba(255, 255, 255, 0.94);
    --bg-card: #eceaf4;
    --bg-bot: #e2dfef;
    --bg-input: rgba(255, 255, 255, 0.96);
    --text-primary: #211c2e;
    --text-secondary: #4a4458;
    --text-muted: #79718a;
    --accent-gold: #b3820a;
    --accent-primary: #7c4dff;
    --accent-secondary: #651fff;
    --border-color: rgba(124, 77, 255, 0.18);
    --border-glow: rgba(124, 77, 255, 0.35);
    --card-back: linear-gradient(135deg, #d8d0ee 0%, #bdb3db 100%);
    --card-front: linear-gradient(135deg, #ffffff 0%, #f0edfa 100%);
    --shadow: 0 8px 32px rgba(90, 70, 130, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Cormorant Garamond', serif;
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 50% 0%, rgba(179, 136, 255, 0.15) 0%, transparent 55%),
        radial-gradient(circle at 100% 100%, rgba(102, 126, 234, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 0% 100%, rgba(229, 193, 88, 0.05) 0%, transparent 45%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-size: 18px;
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ==========================================================
   Social Share Card Generator & Talisman Export
   ========================================================== */
.social-export-dialog {
    border: none;
    background: transparent;
    padding: 0;
    max-width: 1040px;
    width: 96vw;
    max-height: 96vh;
    margin: auto;
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.9), 0 0 40px rgba(212, 175, 55, 0.3);
    outline: none;
}

.social-export-container {
    background: var(--bg-primary);
    border: 1px solid var(--accent-gold);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 92vh;
}

.social-export-body {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: var(--bg-primary);
}

.social-export-sidebar {
    padding: 20px 22px 22px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: rgba(13, 10, 24, 0.4);
    overflow-y: auto;
    min-height: 0;
}

.social-control-section {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.social-control-label {
    font-family: 'Cinzel', serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--accent-gold);
}

.social-control-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin: -2px 0 2px;
    line-height: 1.4;
}

/* Format pills */
.format-toggle-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.format-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 9px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: 'Cinzel', serif;
    font-size: 12px;
    letter-spacing: 0.4px;
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.format-btn svg { flex-shrink: 0; }

.format-btn small {
    display: block;
    font-family: 'Cormorant Garamond', serif;
    font-size: 12.5px;
    color: var(--text-muted);
    letter-spacing: 0;
    font-weight: 400;
    margin-top: 1px;
}

.format-btn:hover {
    border-color: rgba(212, 175, 55, 0.5);
    color: var(--text-primary);
}

.format-btn.active {
    background: rgba(212, 175, 55, 0.14);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    font-weight: 700;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

.format-btn.active small { color: rgba(212, 175, 55, 0.8); }

/* Quote candidates */
.quote-option-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.quote-option {
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px 8px 30px;
    position: relative;
    font-family: 'Cormorant Garamond', serif;
    font-size: 14.5px;
    line-height: 1.35;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: block;
    width: 100%;
}

.quote-option-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.quote-option::before {
    content: '✦';
    position: absolute;
    left: 11px;
    top: 9px;
    font-size: 10px;
    color: var(--text-muted);
}

.quote-option:hover {
    border-color: rgba(212, 175, 55, 0.5);
    color: var(--text-primary);
}

.quote-option.active {
    background: rgba(212, 175, 55, 0.12);
    border-color: var(--accent-gold);
    color: var(--text-primary);
}

.quote-option.active::before { color: var(--accent-gold); }

.social-quote-input {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 10px 12px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 15px;
    line-height: 1.45;
    resize: vertical;
    min-height: 78px;
}

.social-quote-input:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.25);
}

.social-quote-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.2px;
}

.social-quote-meta .is-long { color: #e0a86b; }

.social-export-actions-panel {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 4px;
}

.social-primary-btn {
    width: 100%;
    background: linear-gradient(135deg, #d4af37 0%, #aa8420 100%);
    color: #0b0914;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.35);
    transition: all 0.2s;
}

.social-primary-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.5);
}

.social-primary-btn:disabled,
.social-secondary-btn:disabled {
    opacity: 0.55;
    cursor: progress;
    transform: none;
}

.social-secondary-btn {
    width: 100%;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.social-secondary-btn:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.social-share-feedback {
    min-height: 18px;
    font-size: 12.5px;
    color: var(--accent-gold);
    text-align: center;
    padding: 2px 0;
    transition: opacity 0.2s ease;
}

/* Live preview (the preview image IS the export, scaled down) */
.social-preview-wrapper {
    padding: 22px 24px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: radial-gradient(circle at 50% 42%, rgba(26, 18, 46, 0.75) 0%, rgba(8, 6, 15, 0.98) 100%);
    overflow: hidden;
    min-height: 0;
}

.talisman-preview-frame {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    background: #080612;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.08);
    flex: 0 1 auto;
    min-height: 0;
}

.talisman-preview-frame.format-story {
    height: min(calc(92vh - 200px), 720px);
    aspect-ratio: 9 / 16;
}

.talisman-preview-frame.format-post {
    width: min(calc(92vh - 200px), 520px, 100%);
    aspect-ratio: 1 / 1;
}

.talisman-preview-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    transition: opacity 0.25s ease;
}

.talisman-preview-frame.is-rendering .talisman-preview-img { opacity: 0.4; }
.talisman-preview-frame.is-empty .talisman-preview-img { opacity: 0; }

.talisman-preview-status {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-family: 'Cinzel', serif;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent-gold);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.talisman-preview-frame.is-rendering .talisman-preview-status,
.talisman-preview-frame.is-empty .talisman-preview-status { opacity: 1; }

.talisman-preview-status .spin {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(212, 175, 55, 0.25);
    border-top-color: var(--accent-gold);
    animation: talismanSpin 0.9s linear infinite;
}

@keyframes talismanSpin { to { transform: rotate(360deg); } }

.talisman-preview-caption {
    font-family: 'Cinzel', serif;
    font-size: 10.5px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--text-muted);
    display: flex;
    gap: 14px;
    align-items: center;
    white-space: nowrap;
}

.talisman-preview-caption span + span::before {
    content: '·';
    margin-right: 14px;
    color: var(--border-color);
}

/* Altar hint: the "rotate device" nudge only makes sense on phones */
.hint-rotate { display: none; }

@media (max-width: 640px) {
    .hint-rotate { display: inline; }
}

@media (max-width: 800px) {
    .social-export-dialog {
        width: 100vw;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
    .social-export-container {
        max-height: 100vh;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    .social-export-body {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }
    .social-preview-wrapper {
        order: 1;
        flex: 0 0 auto;
        padding: 16px 14px 12px;
    }
    .social-export-sidebar {
        order: 2;
        border-right: none;
        border-top: 1px solid var(--border-color);
        padding: 16px 16px 26px;
        overflow: visible;
        gap: 18px;
    }
    .social-export-actions-panel { margin-top: 2px; }
    .talisman-preview-frame.format-story { height: min(58vh, 520px); }
    .talisman-preview-frame.format-post { width: min(88vw, 58vh); }
}
/* Active Consultation Reading Display Stage */
.active-reading-stage {
    display: none;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.4s ease-out;
}

/* Minimized Top Bar to Start New Consultation */
.reading-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.reading-badge {
    font-family: 'Cinzel', serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 8px;
}

.new-consult-btn {
    background: transparent;
    border: 1px solid var(--accent-primary);
    border-radius: 20px;
    padding: 6px 14px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-primary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.new-consult-btn:hover {
    background: var(--accent-primary);
    color: #ffffff;
    box-shadow: 0 0 12px var(--border-glow);
}

/* The Centered Visual Stage */
.visual-stage-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    min-height: 280px;
    position: relative;
    transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

/* -------------------------------------------------------------------------
   THEME 1: TAROT — Aged Dark Walnut & Mahogany Altar Table
   ------------------------------------------------------------------------- */
.visual-stage-card.stage-theme-tarot {
    background: 
        /* Warm amber candlelight glow radiating from center */
        radial-gradient(ellipse at 50% 45%, rgba(245, 195, 95, 0.16) 0%, rgba(160, 90, 30, 0.1) 35%, rgba(24, 15, 12, 0.94) 75%, #0e0806 100%),
        /* Subtle aged wood plank grain */
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.28) 0px, rgba(0, 0, 0, 0.28) 2px, transparent 2px, transparent 22px),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.012) 0px, rgba(255, 255, 255, 0.012) 1px, transparent 1px, transparent 80px),
        linear-gradient(180deg, #1c110a 0%, #120905 100%);
    border: 2px solid rgba(212, 160, 60, 0.35);
    box-shadow: 
        inset 0 0 80px rgba(0, 0, 0, 0.88),
        inset 0 1px 1px rgba(255, 220, 140, 0.25),
        0 16px 44px rgba(0, 0, 0, 0.75);
    overflow: hidden;
}

.visual-stage-card.stage-theme-tarot::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(212, 160, 60, 0.22);
    border-radius: calc(var(--radius-lg) - 6px);
    pointer-events: none;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.visual-stage-card.stage-theme-tarot::after {
    content: '❖';
    position: absolute;
    top: 12px;
    left: 14px;
    font-size: 13px;
    color: rgba(229, 193, 88, 0.45);
    text-shadow: 0 0 6px rgba(229, 193, 88, 0.3);
    pointer-events: none;
}

/* -------------------------------------------------------------------------
   THEME 2: RUNES — Sacred Norse Woven Altar Cloth
   ------------------------------------------------------------------------- */
.visual-stage-card.stage-theme-runes {
    background: 
        /* Starlit twilight center ambiance */
        radial-gradient(ellipse at 50% 50%, rgba(46, 70, 95, 0.25) 0%, rgba(18, 26, 36, 0.75) 45%, rgba(11, 14, 20, 0.96) 80%, #080a0e 100%),
        /* Dense Nordic linen cross-weave texture */
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0px, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 3px),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0px, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 3px),
        #0e131a;
    border: 2px dashed rgba(140, 185, 230, 0.32);
    box-shadow: 
        inset 0 0 85px rgba(4, 7, 12, 0.92),
        inset 0 0 24px rgba(78, 140, 210, 0.12),
        0 16px 44px rgba(0, 0, 0, 0.75);
    overflow: hidden;
}

.visual-stage-card.stage-theme-runes::before {
    content: '';
    position: absolute;
    inset: 7px;
    border: 1px dotted rgba(140, 185, 230, 0.22);
    border-radius: calc(var(--radius-lg) - 5px);
    pointer-events: none;
}

/* -------------------------------------------------------------------------
   THEME 3: I CHING — Imperial Cinnabar & Polished Ebony Lacquer Altar Board
   ------------------------------------------------------------------------- */
.visual-stage-card.stage-theme-iching {
    background: 
        /* High-gloss lacquer reflective specular light */
        linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.015) 30%, transparent 60%),
        /* Imperial Cinnabar center aura with deep ebony fade */
        radial-gradient(ellipse at 50% 40%, rgba(186, 32, 38, 0.28) 0%, rgba(105, 14, 18, 0.2) 40%, rgba(18, 10, 12, 0.96) 80%, #0b0607 100%),
        /* Subtle wood grain beneath lacquer */
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.2) 0px, rgba(0, 0, 0, 0.2) 2px, transparent 2px, transparent 12px),
        #0d0708;
    border: 2px solid rgba(229, 193, 88, 0.5);
    outline: 1px solid rgba(186, 32, 38, 0.5);
    outline-offset: -7px;
    box-shadow: 
        inset 0 0 75px rgba(0, 0, 0, 0.92),
        inset 0 0 35px rgba(186, 32, 38, 0.25),
        0 16px 48px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

.visual-stage-card.stage-theme-iching::before {
    content: '';
    position: absolute;
    inset: 12px;
    border: 1px dashed rgba(229, 193, 88, 0.28);
    border-radius: calc(var(--radius-lg) - 8px);
    pointer-events: none;
}

/* Clean Centered Tarot Grids & Ceremonial Spreads */
.tarot-stage-grid {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.tarot-stage-grid.layout-single {
    display: flex;
    justify-content: center;
    align-items: center;
}

.tarot-stage-grid.layout-single .tarot-card-wrapper {
    width: clamp(120px, 34vw, 165px);
    height: calc(clamp(120px, 34vw, 165px) * 1.68);
}

/* 3-Card Triad (Past, Present, Future - Never wraps into vertical) */
.tarot-stage-grid.layout-3-card,
.tarot-row.layout-3-card {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: clamp(8px, 2.5vw, 20px);
    flex-wrap: nowrap;
    width: 100%;
}

.tarot-stage-grid.layout-3-card .tarot-card-wrapper,
.tarot-row.layout-3-card .tarot-card-wrapper {
    width: clamp(75px, 26vw, 118px);
    height: calc(clamp(75px, 26vw, 118px) * 1.68);
    flex-shrink: 0;
}

/* 5-Card Cross Altar */
.tarot-stage-grid.layout-5-card {
    display: grid;
    grid-template-columns: repeat(3, auto);
    grid-template-rows: repeat(3, auto);
    gap: clamp(6px, 2vw, 16px);
    justify-items: center;
    align-items: center;
    max-width: 560px;
    margin: 0 auto;
}

.tarot-stage-grid.layout-5-card .tarot-card-wrapper[data-pos-idx="1"] { grid-column: 2; grid-row: 1; } /* Challenge / Crown */
.tarot-stage-grid.layout-5-card .tarot-card-wrapper[data-pos-idx="2"] { grid-column: 1; grid-row: 2; } /* Past */
.tarot-stage-grid.layout-5-card .tarot-card-wrapper[data-pos-idx="0"] { grid-column: 2; grid-row: 2; } /* Present */
.tarot-stage-grid.layout-5-card .tarot-card-wrapper[data-pos-idx="3"] { grid-column: 3; grid-row: 2; } /* Future */
.tarot-stage-grid.layout-5-card .tarot-card-wrapper[data-pos-idx="4"] { grid-column: 2; grid-row: 3; } /* Outcome */

.tarot-stage-grid.layout-5-card .tarot-card-wrapper {
    width: clamp(60px, 20vw, 105px);
    height: calc(clamp(60px, 20vw, 105px) * 1.68);
}

/* Authentic 10-Card Celtic Cross Formation */
.celtic-cross-altar {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: clamp(10px, 3.5vw, 36px);
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 4px;
}

.celtic-cross-circle {
    display: grid;
    grid-template-columns: repeat(3, auto);
    grid-template-rows: repeat(3, auto);
    gap: clamp(6px, 1.8vw, 14px);
    align-items: center;
    justify-items: center;
}

.celtic-pos-above { grid-column: 2; grid-row: 1; }
.celtic-pos-past { grid-column: 1; grid-row: 2; }
.celtic-center-stack { 
    grid-column: 2; 
    grid-row: 2; 
    position: relative; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    width: clamp(48px, 12vw, 84px);
    height: calc(clamp(48px, 12vw, 84px) * 1.68);
}
.celtic-center-stack .celtic-card-present {
    position: absolute;
    inset: 0;
    z-index: 1;
}
.celtic-center-stack .celtic-card-challenge {
    position: absolute;
    inset: 0;
    z-index: 2;
    transform: rotate(90deg) scale(0.94);
    transition: transform 0.25s ease, z-index 0.25s ease;
}
.celtic-center-stack .celtic-card-challenge:hover {
    transform: rotate(90deg) scale(1.08) translateY(-10px);
    z-index: 12;
}
.celtic-pos-future { grid-column: 3; grid-row: 2; }
.celtic-pos-below { grid-column: 2; grid-row: 3; }

.celtic-staff {
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 1.5vw, 12px);
    align-items: center;
    justify-content: center;
}

.celtic-cross-altar .tarot-card-wrapper {
    width: clamp(44px, 12vw, 76px);
    height: calc(clamp(44px, 12vw, 76px) * 1.68);
}

.tarot-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(8px, 2vw, 16px);
    flex-wrap: nowrap;
    width: 100%;
}

/* 3D Tarot Card */
.tarot-card-wrapper {
    perspective: 1000px;
    width: clamp(52px, 16vw, 118px);
    height: calc(clamp(52px, 16vw, 118px) * 1.68);
    cursor: zoom-in;
    position: relative;
    transition: transform 0.22s cubic-bezier(0.2, 0, 0.2, 1);
    flex-shrink: 0;
}

.tarot-card-wrapper:hover {
    transform: translateY(-5px) scale(1.03);
}

.tarot-card-wrapper:hover .card-face {
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.55), 0 0 16px rgba(229, 193, 88, 0.35);
    border-color: #ffd700;
}

.tarot-card-wrapper::after {
    content: '🔍';
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    background: rgba(13, 12, 20, 0.85);
    border: 1px solid var(--accent-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.tarot-card-wrapper:hover::after {
    opacity: 1;
    transform: scale(1);
}

.tarot-card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.65s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.tarot-card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius-md);
    border: 2px solid var(--accent-gold);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
    user-select: none;
    overflow: hidden;
}

.card-back {
    background-color: #110e1e;
    background-image: url('/static/cards/tarot/card-back.webp');
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
}

.card-back::before {
    display: none;
}

.card-front {
    background: #0d0c14;
    transform: rotateY(180deg);
    text-align: center;
    padding: 0;
    position: relative;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: calc(var(--radius-md) - 2px);
}

/* Position badges size themselves to the card so long labels (e.g. "Present Situation")
   wrap onto two lines instead of being clipped by the card face */
.tarot-card-wrapper {
    container-type: inline-size;
}

.card-overlay-badge {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 10px);
    box-sizing: border-box;
    /* Near-opaque on purpose: a backdrop blur here cost a live compositing layer per card for no visible difference. */
    background: rgba(13, 12, 20, 0.88);
    border: 1px solid rgba(229, 193, 88, 0.45);
    border-radius: 12px;
    padding: 3px 8px;
    padding: 3px clamp(5px, 7cqw, 9px);
    font-size: 9px;
    font-size: clamp(6.5px, 9.5cqw, 10px);
    line-height: 1.2;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    letter-spacing: clamp(0.3px, 0.7cqw, 0.8px);
    color: var(--accent-gold);
    text-align: center;
    white-space: normal;
    overflow-wrap: normal;
    z-index: 3;
    pointer-events: none;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
}

.card-overlay-badge.top-badge {
    top: 6px;
}

/* Hide hover affordances and helper captions while the altar is photographed for export */
.visual-stage-card.is-capturing .altar-orientation-hint,
.visual-stage-card.is-capturing .tarot-card-wrapper::after {
    display: none !important;
}

/* The share-card compositor also drops the frame ornament and inner border, which
   otherwise leak into the crop when a spread reaches the altar's edge */
.visual-stage-card.is-capturing-bare::before,
.visual-stage-card.is-capturing-bare::after {
    display: none !important;
}

.card-art-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px;
    background: var(--card-front);
}

.card-position {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--accent-primary);
}

.card-icon {
    font-size: 38px;
    line-height: 1;
    margin: 4px 0;
    filter: drop-shadow(0 0 8px rgba(229, 193, 88, 0.3));
}

.card-name {
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.card-suit {
    font-size: 11px;
    color: var(--text-muted);
}

/* Card Zoom Lightbox Dialog */
dialog.card-zoom-dialog {
    border: none;
    background: transparent;
    padding: 0;
    margin: auto;
    max-width: 95vw;
    max-height: 95vh;
    overflow: visible;
    outline: none;
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.2, 0, 0.2, 1), display 0.28s allow-discrete, overlay 0.28s allow-discrete;
}

dialog.card-zoom-dialog[open] {
    opacity: 1;
    transform: scale(1);
}

@starting-style {
    dialog.card-zoom-dialog[open] {
        opacity: 0;
        transform: scale(0.92);
    }
}

dialog.card-zoom-dialog::backdrop {
    background-color: rgba(6, 4, 14, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    transition: background-color 0.28s ease, backdrop-filter 0.28s ease, display 0.28s allow-discrete, overlay 0.28s allow-discrete;
}

dialog.card-zoom-dialog[open]::backdrop {
    background-color: rgba(6, 4, 14, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

@starting-style {
    dialog.card-zoom-dialog[open]::backdrop {
        background-color: rgba(6, 4, 14, 0);
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
}

@media (prefers-reduced-motion: reduce) {
    dialog.card-zoom-dialog {
        transform: none;
        transition-duration: 0.1s;
    }
    dialog.card-zoom-dialog[open] {
        transform: none;
    }
}

.card-zoom-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 12px 24px;
    user-select: none;
}

.card-zoom-close {
    position: absolute;
    top: -12px;
    right: 0px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(26, 20, 42, 0.9);
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 20;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

.card-zoom-close:hover {
    background: var(--accent-gold);
    color: #120e1a;
    transform: scale(1.1);
}

.card-zoom-nav {
    position: absolute;
    top: 45%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(22, 17, 36, 0.88);
    border: 1px solid rgba(229, 193, 88, 0.5);
    color: var(--accent-gold);
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 15;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
}

.card-zoom-nav.prev {
    left: -32px;
}

.card-zoom-nav.next {
    right: -32px;
}

.card-zoom-nav:hover {
    background: var(--accent-gold);
    color: #120e1a;
    border-color: var(--accent-gold);
    transform: translateY(-50%) scale(1.12);
}

.card-zoom-stage {
    perspective: 1400px;
    width: min(390px, 82vw);
    height: min(520px, calc(82vw * 4 / 3), 66vh);
}

.card-zoom-card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.65s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.card-zoom-card.flipped {
    transform: rotateY(180deg);
}

.card-zoom-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 16px;
    border: 2px solid var(--accent-gold);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.85), 0 0 32px rgba(229, 193, 88, 0.25);
    overflow: hidden;
}

.card-zoom-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card-zoom-meta {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    max-width: 420px;
}

.zoom-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 12px;
    background: rgba(229, 193, 88, 0.12);
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    font-family: 'Cinzel', serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.zoom-title {
    font-family: 'Cinzel', serif;
    font-size: 22px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8), 0 0 20px rgba(229, 193, 88, 0.3);
    margin: 0;
    letter-spacing: 0.5px;
}

.zoom-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-wrap: wrap;
    justify-content: center;
}

.zoom-flip-btn {
    cursor: pointer;
    color: var(--accent-gold);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(229, 193, 88, 0.12);
    border: 1px solid rgba(229, 193, 88, 0.3);
    transition: all 0.2s ease;
}

.zoom-flip-btn:hover {
    background: rgba(229, 193, 88, 0.28);
    color: #fff;
    border-color: var(--accent-gold);
}

.zoom-sep {
    opacity: 0.4;
}

@media (max-width: 580px) {
    .card-zoom-nav.prev { left: -8px; }
    .card-zoom-nav.next { right: -8px; }
    .card-zoom-close { top: -8px; right: -8px; }
    .card-zoom-stage {
        width: min(300px, 80vw);
        height: min(400px, calc(80vw * 4 / 3), 60vh);
    }
}

[data-theme="light"] dialog.card-zoom-dialog[open]::backdrop {
    background-color: rgba(240, 238, 248, 0.85);
}

[data-theme="light"] .card-zoom-close,
[data-theme="light"] .card-zoom-nav {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(124, 77, 255, 0.3);
    color: var(--text-primary);
}

[data-theme="light"] .zoom-title {
    color: var(--text-primary);
    text-shadow: none;
}

/* ==========================================================================
   I CHING AUTHENTIC STACKED HEXAGRAMS & TRANSFORMATION ENGINE
   ========================================================================== */
.iching-stage-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    position: relative;
    z-index: 2;
}

.iching-board-header {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'Cinzel', serif;
    font-size: 13px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent-gold);
    opacity: 0.9;
}

.iching-board-header span {
    color: #e54d52;
    font-size: 15px;
}

/* Dual Hexagram Pillars Row */
.iching-pillars-row {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 24px;
    width: 100%;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .iching-pillars-row {
        flex-direction: column;
        align-items: center;
        gap: 18px;
    }
}

/* Hexagram Pillar Card */
.hex-pillar {
    background: rgba(18, 12, 14, 0.76);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(229, 193, 88, 0.35);
    border-radius: 16px;
    padding: 22px 24px;
    min-width: 290px;
    max-width: 360px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65), inset 0 0 16px rgba(186, 32, 38, 0.15);
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.hex-pillar:hover {
    border-color: rgba(229, 193, 88, 0.65);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.75), 0 0 20px rgba(229, 193, 88, 0.2);
    transform: translateY(-2px);
}

.hex-pillar.primary {
    border-color: rgba(229, 193, 88, 0.45);
}

.hex-pillar.transformed {
    border-color: rgba(186, 32, 38, 0.55);
    background: rgba(24, 12, 14, 0.8);
}

/* Pillar Role Badge (本卦 / 之卦) */
.hex-pillar-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 4px 14px;
    border-radius: 20px;
    background: rgba(229, 193, 88, 0.15);
    color: var(--accent-gold);
    border: 1px solid rgba(229, 193, 88, 0.35);
    display: flex;
    align-items: center;
    gap: 6px;
}

.hex-pillar.transformed .hex-pillar-badge {
    background: rgba(186, 32, 38, 0.25);
    color: #ff9498;
    border-color: rgba(186, 32, 38, 0.5);
}

/* Pillar Title & Chinese Typography */
.hex-pillar-head {
    text-align: center;
}

.hex-pillar-name {
    font-family: 'Cinzel', serif;
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.25;
}

.hex-pillar-chinese {
    font-family: 'Cinzel', serif, "STSong", "Songti SC", "SimSun";
    font-size: 16px;
    color: var(--accent-gold);
    margin-top: 4px;
}

/* Trigram Decomposition Badges (Upper & Lower Bagua) */
.hex-trigrams-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11px;
    color: var(--text-secondary);
}

.trigram-chip {
    display: flex;
    align-items: center;
    gap: 5px;
}

.trigram-chip .tg-sym {
    font-size: 15px;
    color: var(--accent-gold);
}

.trigram-chip .tg-label {
    font-weight: 600;
}

.trigram-divider {
    color: rgba(255, 255, 255, 0.25);
    font-size: 10px;
    text-transform: uppercase;
}

/* 6-Line Stacked Hexagram Engine */
.hex-lines-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    padding: 12px 10px;
    background: rgba(8, 5, 6, 0.65);
    border-radius: 12px;
    border: 1px solid rgba(229, 193, 88, 0.18);
}

/* Hexagram Line Row */
.hex-line-row {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 18px;
    position: relative;
}

.hex-line-num {
    font-size: 10px;
    font-family: monospace;
    color: var(--text-muted);
    width: 18px;
    text-align: right;
    flex-shrink: 0;
}

/* Bar Container */
.hex-line-bar {
    flex: 1;
    height: 12px;
    display: flex;
    align-items: center;
    position: relative;
    border-radius: 3px;
    transition: all 0.25s ease;
}

/* Solid Yang Bar (7 or 9) */
.hex-line-bar.solid {
    background: linear-gradient(90deg, #b88628 0%, #ffd700 50%, #b88628 100%);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6), 0 0 8px rgba(229, 193, 88, 0.25);
    border-radius: 3px;
}

/* Broken Yin Bar (6 or 8) */
.hex-line-bar.broken {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    background: transparent;
}

.hex-line-bar.broken .bar-segment {
    flex: 1;
    height: 100%;
    background: linear-gradient(90deg, #a67922 0%, #e6be55 50%, #a67922 100%);
    border-radius: 3px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6), 0 0 6px rgba(229, 193, 88, 0.2);
}

/* Moving / Changing Line Styles (Old Yang 9, Old Yin 6) */
.hex-line-row.changing .hex-line-bar.solid {
    background: linear-gradient(90deg, #e54d52 0%, #ffc83b 50%, #e54d52 100%);
    box-shadow: 0 0 14px rgba(255, 90, 95, 0.7), 0 0 6px rgba(255, 215, 0, 0.8);
    animation: hexPulse 2.2s ease-in-out infinite;
}

.hex-line-row.changing .hex-line-bar.broken .bar-segment {
    background: linear-gradient(90deg, #c42f34 0%, #ff7377 50%, #c42f34 100%);
    box-shadow: 0 0 12px rgba(255, 90, 95, 0.7), 0 0 6px rgba(255, 120, 120, 0.7);
    animation: hexPulse 2.2s ease-in-out infinite;
}

@keyframes hexPulse {
    0%, 100% {
        filter: brightness(1) drop-shadow(0 0 3px rgba(229, 77, 82, 0.5));
    }
    50% {
        filter: brightness(1.3) drop-shadow(0 0 10px rgba(255, 190, 60, 0.9));
    }
}

/* Changing Line Indicator Pill */
.hex-changing-tag {
    font-size: 11px;
    font-weight: 700;
    width: 22px;
    height: 18px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hex-changing-tag.old-yang {
    color: #ffd700;
    background: rgba(229, 77, 82, 0.28);
    border: 1px solid rgba(229, 77, 82, 0.55);
    box-shadow: 0 0 8px rgba(229, 77, 82, 0.45);
}

.hex-changing-tag.old-yin {
    color: #ff9999;
    background: rgba(186, 32, 38, 0.28);
    border: 1px solid rgba(186, 32, 38, 0.55);
    box-shadow: 0 0 8px rgba(186, 32, 38, 0.45);
}

.hex-changing-tag.static {
    opacity: 0.18;
    color: var(--text-muted);
}

.hex-changing-tag.transformed-indicator {
    color: #ffc83b;
    background: rgba(229, 193, 88, 0.15);
    border: 1px solid rgba(229, 193, 88, 0.35);
    font-size: 10px;
}

/* Hex Pillar Meaning Footer */
.hex-pillar-footer {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 10px;
    width: 100%;
}

.hex-pillar-footer em {
    color: #ffffff;
    font-style: normal;
    font-weight: 600;
}

/* Transformation Bridge (between Primary and Transformed Hexagrams) */
.iching-transform-bridge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    min-width: 110px;
}

.bridge-arrow-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(186, 32, 38, 0.4) 0%, rgba(20, 10, 12, 0.8) 100%);
    border: 1px solid rgba(229, 193, 88, 0.4);
    box-shadow: 0 0 16px rgba(186, 32, 38, 0.4);
    animation: bridgeFlow 2s ease-in-out infinite;
}

@keyframes bridgeFlow {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 12px rgba(186, 32, 38, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 22px rgba(229, 193, 88, 0.6);
    }
}

.bridge-arrow {
    font-size: 20px;
    color: var(--accent-gold);
}

.bridge-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--accent-gold);
    text-align: center;
}

.bridge-lines-list {
    font-size: 11px;
    color: #ff9999;
    background: rgba(186, 32, 38, 0.25);
    border-radius: 12px;
    padding: 2px 10px;
    border: 1px solid rgba(186, 32, 38, 0.45);
}

/* 3 Ancient Bronze Coins Tray */
.iching-coins-tray {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: rgba(12, 8, 9, 0.65);
    border: 1px solid rgba(229, 193, 88, 0.22);
    border-radius: 14px;
}

.coins-tray-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(229, 193, 88, 0.75);
    font-weight: 600;
}

.coins-row {
    display: flex;
    align-items: center;
    gap: 18px;
}

/* Ancient Bronze Coin: Round with Square Hole & Inscribed Han Characters */
.ancient-bronze-coin {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: 
        radial-gradient(circle at 35% 30%, #d4a755 0%, #997026 35%, #593f14 75%, #2a1c07 100%);
    border: 2px solid #5a4016;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.65),
        inset 0 1px 2px rgba(255, 230, 150, 0.45),
        inset 0 -2px 4px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: default;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.ancient-bronze-coin:hover {
    transform: translateY(-3px) rotate(8deg);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.75), inset 0 1px 2px rgba(255, 230, 150, 0.6);
}

/* The Center Square Cutout */
.coin-center-hole {
    width: 15px;
    height: 15px;
    background: #0d0809;
    border: 1.5px solid #4a3411;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 1px rgba(255, 215, 0, 0.3);
    position: relative;
    z-index: 2;
}

/* Decorative Han/Zhou Characters on Coin */
.coin-glyph {
    position: absolute;
    font-size: 8px;
    font-family: "STSong", "Songti SC", "SimSun", serif;
    font-weight: 700;
    color: rgba(255, 225, 140, 0.7);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    line-height: 1;
}

.coin-glyph.top { top: 3px; left: 50%; transform: translateX(-50%); }
.coin-glyph.bottom { bottom: 3px; left: 50%; transform: translateX(-50%); }
.coin-glyph.left { left: 3px; top: 50%; transform: translateY(-50%); }
.coin-glyph.right { right: 3px; top: 50%; transform: translateY(-50%); }

/* Runes Altar Casting Mat & Physical Stone Relics */
.rune-casting-mat {
    position: relative;
    width: 100%;
    max-width: 780px;
    min-height: 240px;
    padding: 44px 28px 28px 28px;
    border-radius: 48px;
    background: 
        radial-gradient(ellipse at 50% 40%, #252033 0%, #151120 70%, #0c0a13 100%);
    border: 1.5px solid rgba(229, 193, 88, 0.3);
    box-shadow: 
        inset 0 0 50px rgba(0, 0, 0, 0.9),
        inset 0 0 100px rgba(138, 92, 246, 0.08),
        0 16px 36px rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 32px;
    flex-wrap: wrap;
}

.rune-casting-mat::before {
    content: '';
    position: absolute;
    inset: 10px;
    border-radius: 40px;
    border: 1px dashed rgba(229, 193, 88, 0.25);
    pointer-events: none;
}

.rune-casting-mat-header {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(229, 193, 88, 0.55);
    font-family: 'Cinzel', serif;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
}

/* Standalone Physical Stone Artifact */
.rune-stone-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    cursor: zoom-in;
    position: relative;
    user-select: none;
    z-index: 2;
    perspective: 800px;
}

.rune-artifact-img {
    width: 140px;
    height: 140px;
    object-fit: contain;
    display: block;
    background: transparent !important;
    filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.85)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6));
    transition: transform 0.12s ease-out, filter 0.28s ease;
    transform-style: preserve-3d;
    will-change: transform, filter;
}

.rune-stone-wrapper:hover .rune-artifact-img {
    filter: drop-shadow(0 24px 32px rgba(0, 0, 0, 0.96)) drop-shadow(0 0 24px rgba(229, 193, 88, 0.5));
}

/* Physical Organic Pebble Fallback (Authentic Rounded River Stone - NO CARDS!) */
.rune-stone-pebble {
    width: 136px;
    height: 124px;
    border-radius: 47% 53% 54% 46% / 52% 48% 52% 48%;
    background: radial-gradient(circle at 35% 30%, #3a3646 0%, #201e29 55%, #121118 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 
        inset 2px 3px 5px rgba(255, 255, 255, 0.12),
        inset -3px -4px 8px rgba(0, 0, 0, 0.8),
        0 16px 22px rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.12s ease-out, box-shadow 0.28s ease;
    transform-style: preserve-3d;
    will-change: transform;
}

.rune-stone-wrapper:hover .rune-stone-pebble {
    box-shadow: 
        inset 2px 3px 6px rgba(255, 255, 255, 0.18),
        inset -3px -4px 10px rgba(0, 0, 0, 0.85),
        0 22px 30px rgba(0, 0, 0, 0.95),
        0 0 20px rgba(229, 193, 88, 0.35);
}

.pebble-glyph {
    font-size: 52px;
    font-family: 'Cinzel', serif, 'Segoe UI Historic';
    line-height: 1;
    user-select: none;
    color: #ffe69c;
    text-shadow: 
        0 0 14px rgba(229, 193, 88, 0.85),
        0 0 28px rgba(229, 193, 88, 0.4),
        1px 2px 3px rgba(0, 0, 0, 0.95);
}

.pebble-glyph.frost {
    color: #d4f4ff;
    text-shadow: 
        0 0 14px rgba(56, 189, 248, 0.9),
        0 0 28px rgba(56, 189, 248, 0.45),
        1px 2px 3px rgba(0, 0, 0, 0.95);
}

.pebble-glyph.amethyst {
    color: #f5e8ff;
    text-shadow: 
        0 0 14px rgba(192, 132, 252, 0.9),
        0 0 28px rgba(192, 132, 252, 0.45),
        1px 2px 3px rgba(0, 0, 0, 0.95);
}

.rune-stone-meta {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.rune-pos-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 2px 10px;
    border-radius: 12px;
    background: rgba(229, 193, 88, 0.12);
    border: 1px solid rgba(229, 193, 88, 0.4);
    color: var(--accent-gold);
}

.rune-name-label {
    font-family: 'Cinzel', serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.rune-meaning-label {
    font-size: 12px;
    color: var(--text-muted);
    max-width: 140px;
    line-height: 1.25;
    text-align: center;
}

/* Specialized Ceremonial Rune Layouts (Geometric Grid Preserved on All Screens) */
.rune-casting-mat.layout-single {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 240px;
}

.rune-casting-mat.layout-single .rune-artifact-img {
    width: clamp(120px, 34vw, 170px);
    height: clamp(120px, 34vw, 170px);
    filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.95)) drop-shadow(0 0 28px rgba(229, 193, 88, 0.45));
}

/* The Three Norns (Horizontal Triad - NEVER wraps into vertical) */
.rune-casting-mat.layout-norns {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: clamp(8px, 2.8vw, 28px);
    flex-wrap: nowrap;
    width: 100%;
}

.rune-casting-mat.layout-norns .rune-stone-wrapper {
    flex: 1 1 0;
    max-width: 145px;
}

/* 5-Rune Wyrd Cross (Compass Cross Layout - STRICT 3x3 GRID) */
.rune-casting-mat.layout-five-cross {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto auto;
    gap: clamp(6px, 2vw, 16px);
    justify-items: center;
    align-items: center;
    max-width: 580px;
    margin: 0 auto;
    width: 100%;
}

.rune-casting-mat.layout-five-cross .rune-stone-wrapper[data-index="3"] {
    grid-column: 2;
    grid-row: 1; /* North */
}
.rune-casting-mat.layout-five-cross .rune-stone-wrapper[data-index="1"] {
    grid-column: 1;
    grid-row: 2; /* West */
}
.rune-casting-mat.layout-five-cross .rune-stone-wrapper[data-index="0"] {
    grid-column: 2;
    grid-row: 2; /* Center / Core */
}
.rune-casting-mat.layout-five-cross .rune-stone-wrapper[data-index="2"] {
    grid-column: 3;
    grid-row: 2; /* East */
}
.rune-casting-mat.layout-five-cross .rune-stone-wrapper[data-index="4"] {
    grid-column: 2;
    grid-row: 3; /* South */
}

.rune-casting-mat.layout-five-cross .rune-stone-wrapper {
    width: clamp(65px, 24vw, 120px);
}

/* The Hammer of Thor (Mjölnir T-shape Layout - STRICT 3x3 GRID) */
.rune-casting-mat.layout-thor-hammer {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto auto;
    gap: clamp(6px, 2vw, 16px);
    justify-items: center;
    align-items: center;
    max-width: 580px;
    margin: 0 auto;
    width: 100%;
}

.rune-casting-mat.layout-thor-hammer .rune-stone-wrapper[data-index="1"] {
    grid-column: 1;
    grid-row: 1; /* Left Wing */
}
.rune-casting-mat.layout-thor-hammer .rune-stone-wrapper[data-index="0"] {
    grid-column: 2;
    grid-row: 1; /* Striking Point */
}
.rune-casting-mat.layout-thor-hammer .rune-stone-wrapper[data-index="2"] {
    grid-column: 3;
    grid-row: 1; /* Right Wing */
}
.rune-casting-mat.layout-thor-hammer .rune-stone-wrapper[data-index="3"] {
    grid-column: 2;
    grid-row: 2; /* Shaft */
}
.rune-casting-mat.layout-thor-hammer .rune-stone-wrapper[data-index="4"] {
    grid-column: 2;
    grid-row: 3; /* Grip */
}

.rune-casting-mat.layout-thor-hammer .rune-stone-wrapper {
    width: clamp(65px, 24vw, 120px);
}

/* The Nine Worlds of Yggdrasil (Cosmic 3x3 Tree - STRICT 3x3 GRID) */
.rune-casting-mat.layout-nine-worlds {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, auto);
    gap: clamp(8px, 2vw, 18px) clamp(4px, 1.5vw, 12px);
    justify-items: center;
    align-items: start;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}

.rune-casting-mat.layout-nine-worlds .rune-stone-wrapper {
    width: clamp(52px, 22vw, 105px);
}

.rune-casting-mat.layout-nine-worlds .rune-artifact-img {
    width: clamp(52px, 16vw, 100px);
    height: clamp(52px, 16vw, 100px);
}

.rune-casting-mat.layout-nine-worlds .rune-stone-pebble {
    width: clamp(52px, 16vw, 96px);
    height: clamp(48px, 14vw, 88px);
}

.rune-casting-mat.layout-nine-worlds .pebble-glyph {
    font-size: clamp(22px, 6vw, 40px);
}

/* Mobile Adjustments: Stones scale proportionally, NEVER break pattern */
@media (max-width: 640px) {
    .rune-casting-mat {
        padding: 34px 8px 16px 8px;
        border-radius: 28px;
    }
    .rune-artifact-img {
        width: clamp(54px, 18vw, 88px);
        height: clamp(54px, 18vw, 88px);
    }
    .rune-stone-pebble {
        width: clamp(54px, 18vw, 84px);
        height: clamp(48px, 16vw, 76px);
    }
    .pebble-glyph {
        font-size: clamp(22px, 7vw, 36px);
    }
    .rune-pos-badge {
        font-size: 8px;
        padding: 1px 5px;
        max-width: 82px;
    }
    .rune-name-label {
        font-size: 11px;
    }
    .rune-meaning-label {
        font-size: 8.5px;
        line-height: 1.15;
        max-width: 80px;
    }
}

.altar-orientation-hint {
    width: 100%;
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.8px;
    color: var(--accent-gold);
    opacity: 0.85;
    font-family: 'Cinzel', serif;
    text-transform: uppercase;
    padding: 4px 8px;
    margin-top: 10px;
    user-select: none;
    display: block;
    line-height: 1.5;
}

/* Merkstave (Reversed Runes) Styling */
.rune-stone-wrapper.is-reversed .rune-artifact-img,
.rune-stone-wrapper.is-reversed .rune-stone-pebble {
    transform: rotate(180deg);
}

.rune-stone-wrapper.is-reversed .rune-artifact-img {
    filter: drop-shadow(0 -16px 20px rgba(0, 0, 0, 0.85)) drop-shadow(0 0 16px rgba(244, 63, 94, 0.45));
}

.rune-stone-wrapper.is-reversed:hover .rune-artifact-img {
    filter: drop-shadow(0 -24px 32px rgba(0, 0, 0, 0.96)) drop-shadow(0 0 24px rgba(244, 63, 94, 0.7));
}

.rune-pos-badge.badge-merkstave {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.55);
    color: #fca5a5;
}

.rune-pos-badge.badge-upright {
    background: rgba(229, 193, 88, 0.12);
    border-color: rgba(229, 193, 88, 0.4);
    color: var(--accent-gold);
}

/* Numerology Display */
.number-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
}

.number-value {
    font-family: 'Cinzel', serif;
    font-size: 46px;
    font-weight: 700;
    color: var(--accent-gold);
    text-shadow: 0 0 20px rgba(229, 193, 88, 0.45);
}

/* Interpretation Text Card */
.interpretation-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 26px 24px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.seeker-inquiry-box {
    background: var(--bg-card);
    border-left: 3px solid var(--accent-primary);
    border-radius: 4px var(--radius-sm) var(--radius-sm) 4px;
    padding: 10px 16px;
    font-size: 16px;
    color: var(--text-secondary);
    font-style: italic;
}

.oracle-stream-text {
    font-size: 18px;
    line-height: 1.7;
    color: var(--text-primary);
    overflow-wrap: break-word;
    word-break: normal;
}

.oracle-stream-text h1, .oracle-stream-text h2, .oracle-stream-text h3 {
    font-family: 'Cinzel', serif;
    color: var(--accent-gold);
    margin: 20px 0 10px;
}

.oracle-stream-text hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color), var(--accent-gold), var(--border-color), transparent);
    margin: 28px 0;
    opacity: 0.65;
}

.oracle-stream-text blockquote {
    border-left: 3px solid var(--accent-gold);
    margin: 16px 0;
    padding: 10px 18px;
    background: rgba(229, 193, 88, 0.05);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
    color: var(--text-secondary);
}

/* Responsive Table Container & Styling */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: rgba(18, 14, 26, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.oracle-stream-text table {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
    margin: 0;
    font-size: 16px;
    background: transparent;
}

.oracle-stream-text thead {
    background: rgba(212, 175, 55, 0.1);
}

.oracle-stream-text th {
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--accent-gold);
    text-transform: uppercase;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    vertical-align: middle;
}

.oracle-stream-text th:first-child,
.oracle-stream-text td:first-child {
    white-space: nowrap;
    font-weight: 600;
}

.oracle-stream-text th:not(:last-child),
.oracle-stream-text td:not(:last-child) {
    border-right: 1px solid rgba(179, 136, 255, 0.1);
}

.oracle-stream-text td {
    padding: 12px 16px;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    vertical-align: top;
    border-bottom: 1px solid rgba(179, 136, 255, 0.08);
    word-break: normal;
}

.oracle-stream-text tbody tr:last-child td {
    border-bottom: none;
}

.oracle-stream-text tbody tr:hover td {
    background: rgba(179, 136, 255, 0.04);
}

/* Light mode table adjustments */
[data-theme="light"] .table-responsive {
    background: rgba(255, 255, 255, 0.75);
    border-color: rgba(124, 77, 255, 0.18);
    box-shadow: 0 4px 16px rgba(90, 70, 130, 0.08);
}

[data-theme="light"] .oracle-stream-text thead {
    background: rgba(179, 130, 10, 0.08);
}

[data-theme="light"] .oracle-stream-text th:not(:last-child),
[data-theme="light"] .oracle-stream-text td:not(:last-child) {
    border-right-color: rgba(124, 77, 255, 0.1);
}

[data-theme="light"] .oracle-stream-text td {
    border-bottom-color: rgba(124, 77, 255, 0.08);
}

[data-theme="light"] .oracle-stream-text tbody tr:hover td {
    background: rgba(124, 77, 255, 0.04);
}

.oracle-stream-text ul, .oracle-stream-text ol {
    padding-left: 20px;
    margin: 10px 0;
}

.oracle-stream-text p {
    margin-bottom: 12px;
}

.oracle-stream-text p:last-child {
    margin-bottom: 0;
}

.oracle-stream-text strong {
    color: var(--accent-primary);
}

/* Reading Footer Tools */
.reading-footer-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
}

.tool-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 6px 14px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 15px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.tool-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.primary-export-btn {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2) 0%, rgba(140, 84, 255, 0.22) 100%), var(--bg-card);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    font-weight: 600;
    box-shadow: 0 0 14px rgba(212, 175, 55, 0.25);
}

.primary-export-btn:hover {
    border-color: #fce79a;
    color: #ffffff;
    box-shadow: 0 0 22px rgba(212, 175, 55, 0.45);
    transform: translateY(-1px);
}

/* Thinking Indicator */
.thinking {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
    font-style: italic;
    font-size: 16px;
    padding: 16px;
}

.shuffle-animation {
    display: flex;
    gap: 5px;
}

.shuffle-card {
    width: 12px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 3px;
    animation: shufflePulse 1.2s infinite ease-in-out;
}

.shuffle-card:nth-child(2) { animation-delay: 0.2s; }
.shuffle-card:nth-child(3) { animation-delay: 0.4s; }

@keyframes shufflePulse {
    0%, 100% { transform: translateY(0) scale(1); opacity: 0.4; }
    50% { transform: translateY(-7px) scale(1.1); opacity: 1; }
}

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


/* Keep the tarot viewer steady while its contents float into place. */
#cardZoomDialog, #cardZoomDialog[open] { transform: none; }
@starting-style { #cardZoomDialog[open] { transform: none; } }

/* Keep the cloth empty before the shared toss; labels arrive after impact. */
.rune-stone-motion { position: relative; }
.rune-casting-mat.is-casting { overflow: hidden; }
.rune-casting-mat.is-casting .rune-stone-motion { opacity: 0; will-change: transform, opacity; }
.rune-stone-meta { transition: opacity .24s ease; }
.rune-casting-mat.is-casting .rune-stone-meta { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
    .rune-stone-meta { transition: none; }
}
