/* ==========================================================================
   FANTASY DESIGN SYSTEM & TOKENS
   ========================================================================== */

:root {
    /* Default Mystic Palette (Cosmic/Arcane) */
    --bg-darkest: #0a0813;
    --bg-dark: #120e25;
    --bg-card: rgba(22, 17, 43, 0.65);
    
    --primary-color: #7b2cbf;
    --primary-glow: rgba(123, 44, 191, 0.6);
    --secondary-color: #3c096c;
    
    --accent-color: #ffd700; /* Gold */
    --accent-glow: rgba(255, 215, 0, 0.4);
    
    --text-primary: #f8f7ff;
    --text-secondary: #c9c5e8;
    --text-muted: #827baf;
    
    --border-color: rgba(255, 215, 0, 0.25);
    --border-hover: rgba(255, 215, 0, 0.6);
    
    --box-shadow-glow: 0 0 20px var(--primary-glow);
    --transition-speed: 0.35s;
    --font-heading: 'Cinzel', serif;
    --font-fancy: 'Cinzel Decorative', serif;
    --font-body: 'Lora', serif;
}

/* Fire Theme (Element: Fire) */
.theme-fire {
    --bg-darkest: #110505;
    --bg-dark: #220b0b;
    --bg-card: rgba(43, 15, 15, 0.65);
    --primary-color: #d90429;
    --primary-glow: rgba(217, 4, 41, 0.6);
    --secondary-color: #ef233c;
    --accent-color: #ffb703;
    --accent-glow: rgba(255, 183, 3, 0.4);
    --text-primary: #fff0f0;
    --text-secondary: #fcd5d5;
    --border-color: rgba(255, 183, 3, 0.25);
    --border-hover: rgba(255, 183, 3, 0.65);
    --box-shadow-glow: 0 0 25px rgba(217, 4, 41, 0.5);
}

/* Water Theme (Element: Water) */
.theme-water {
    --bg-darkest: #030a16;
    --bg-dark: #07172f;
    --bg-card: rgba(10, 31, 61, 0.65);
    --primary-color: #0077b6;
    --primary-glow: rgba(0, 119, 182, 0.6);
    --secondary-color: #03045e;
    --accent-color: #90e0ef;
    --accent-glow: rgba(144, 224, 239, 0.4);
    --text-primary: #f0faff;
    --text-secondary: #d0eef7;
    --border-color: rgba(144, 224, 239, 0.3);
    --border-hover: rgba(144, 224, 239, 0.7);
    --box-shadow-glow: 0 0 25px rgba(0, 119, 182, 0.5);
}

/* Wind Theme (Element: Wind) */
.theme-wind {
    --bg-darkest: #040e0a;
    --bg-dark: #0d231a;
    --bg-card: rgba(13, 40, 29, 0.65);
    --primary-color: #2a9d8f;
    --primary-glow: rgba(42, 157, 143, 0.6);
    --secondary-color: #1a6b61;
    --accent-color: #a7f3d0;
    --accent-glow: rgba(167, 243, 208, 0.4);
    --text-primary: #f0fdf4;
    --text-secondary: #c6f6d5;
    --border-color: rgba(167, 243, 208, 0.3);
    --border-hover: rgba(167, 243, 208, 0.7);
    --box-shadow-glow: 0 0 25px rgba(42, 157, 143, 0.5);
}

/* Earth Theme (Element: Earth) */
.theme-earth {
    --bg-darkest: #0e0714;
    --bg-dark: #200f2b;
    --bg-card: rgba(36, 17, 49, 0.65);
    --primary-color: #9d4edd;
    --primary-glow: rgba(157, 78, 221, 0.6);
    --secondary-color: #5a189a;
    --accent-color: #e0aaff;
    --accent-glow: rgba(224, 170, 255, 0.4);
    --text-primary: #faf5ff;
    --text-secondary: #ebd9fc;
    --border-color: rgba(224, 170, 255, 0.3);
    --border-hover: rgba(224, 170, 255, 0.7);
    --box-shadow-glow: 0 0 25px rgba(157, 78, 221, 0.5);
}

/* ==========================================================================
   GLOBAL RESET & BASIC STYLE
   ========================================================================== */

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

body {
    background-color: var(--bg-darkest);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* WebGL / Canvas Background */
.magic-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
}

/* ==========================================================================
   PRELOADER SCREEN
   ========================================================================== */

.preloader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #07050d;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease, visibility 0.8s;
}

.preloader-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
}

.preloader-content {
    text-align: center;
    max-width: 450px;
    padding: 20px;
}

.loading-rune {
    margin-bottom: 25px;
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

.preloader-content h2 {
    font-family: var(--font-heading);
    color: var(--accent-color);
    font-size: 1.6rem;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.preloader-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ==========================================================================
   TYPOGRAPHY & TITLE
   ========================================================================== */

.astrolabe-container {
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 30px 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 30px;
    position: relative;
    z-index: 10;
}

.celestial-header {
    text-align: center;
    position: relative;
    padding-bottom: 15px;
}

.celestial-header::after {
    content: '';
    display: block;
    width: 180px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
    margin: 15px auto 0 auto;
    filter: drop-shadow(0 0 3px var(--accent-glow));
}

.fantasy-title {
    font-family: var(--font-fancy);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 0 0 15px var(--accent-glow), 0 0 30px rgba(0, 0, 0, 0.5);
    letter-spacing: 3px;
    line-height: 1.3;
}

.subtitle {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    letter-spacing: 5px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: 5px;
}

/* Audio Control */
.audio-control-wrapper {
    margin-top: 15px;
    display: flex;
    justify-content: center;
}

.audio-btn {
    background: rgba(22, 17, 43, 0.4);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 0.75rem;
    letter-spacing: 2px;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-speed) ease;
}

.audio-btn:hover {
    border-color: var(--border-hover);
    color: var(--accent-color);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
    transform: translateY(-2px);
}

.audio-icon {
    width: 16px;
    height: 16px;
}

.audio-icon.hidden {
    display: none;
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */

.main-content-layout {
    display: grid;
    grid-template-columns: 350px 1fr 350px;
    gap: 30px;
    align-items: stretch;
}

@media (max-width: 1200px) {
    .main-content-layout {
        grid-template-columns: 1fr 1fr;
    }
    .divination-stage {
        grid-column: 1 / -1;
        order: -1;
        margin-bottom: 20px;
    }
}

@media (max-width: 768px) {
    .main-content-layout {
        grid-template-columns: 1fr;
    }
    .fantasy-title {
        font-size: 1.6rem;
    }
    .astrolabe-container {
        padding: 15px 10px;
    }
}

/* ==========================================================================
   GLASSMORPHIC CARDS
   ========================================================================== */

.magic-card {
    background-color: var(--bg-card);
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    overflow: hidden;
}

.magic-card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 15px rgba(255, 215, 0, 0.1);
}

/* Corner decorative borders */
.card-border {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.card-border::before, .card-border::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 1px solid var(--accent-color);
    opacity: 0.4;
    transition: opacity var(--transition-speed);
}

.magic-card:hover .card-border::before,
.magic-card:hover .card-border::after {
    opacity: 0.9;
}

/* Top-Left Corner */
.card-border::before {
    top: 10px;
    left: 10px;
    border-right: none;
    border-bottom: none;
}

/* Bottom-Right Corner */
.card-border::after {
    bottom: 10px;
    right: 10px;
    border-left: none;
    border-top: none;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 14px;
    margin-bottom: 20px;
}

.card-header h2 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.decorative-icon {
    filter: drop-shadow(0 0 5px var(--accent-glow));
}

.card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ==========================================================================
   INPUTS & BUTTONS PORTAL
   ========================================================================== */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--accent-color);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: 700;
}

.magical-input {
    background-color: rgba(8, 6, 18, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition-speed) ease;
}

.magical-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.15), inset 0 0 5px rgba(255, 215, 0, 0.05);
}

select.magical-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffd700' width='18' height='18'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px;
}

select.magical-input option {
    background-color: var(--bg-dark);
    color: var(--text-primary);
}

/* Element Selector Grid */
.element-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.element-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-speed) ease;
}

.element-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--border-color);
}

.element-btn.active {
    border-color: var(--accent-color);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.05), var(--primary-glow));
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.1);
}

.elem-icon {
    font-size: 1.3rem;
}

.elem-name {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 700;
}

.element-btn.active .elem-name {
    color: var(--accent-color);
}

/* Divination Modes List */
.divination-modes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-speed) ease;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.mode-btn.active {
    border-color: var(--accent-color);
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.03), rgba(123, 44, 191, 0.2));
    box-shadow: 0 0 10px rgba(123, 44, 191, 0.1);
}

.mode-title {
    font-family: var(--font-heading);
    color: var(--accent-color);
    font-size: 0.85rem;
    letter-spacing: 1px;
    font-weight: 700;
}

.mode-desc {
    font-family: var(--font-body);
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 2px;
}

/* Collapsible parameters */
.custom-params {
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    padding-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.3s ease;
    max-height: 200px;
    opacity: 1;
}

.custom-params.hidden {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    margin: 0;
    border-top: none;
    pointer-events: none;
    overflow: hidden;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.form-group-sub {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group-sub label {
    font-size: 0.7rem;
    letter-spacing: 1px;
}

.min-input {
    width: 100%;
    padding: 8px;
    font-size: 0.85rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.checkbox-row input[type="checkbox"] {
    accent-color: var(--accent-color);
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.checkbox-row label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
}

/* ==========================================================================
   CENTER STAGE & CRYSTAL BALL ALTAR
   ========================================================================== */

.divination-stage {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 40px 0;
}

/* Background Runic Circles Rotation */
.runic-circle-outer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 480px;
    height: 480px;
    z-index: 1;
    pointer-events: none;
    opacity: 0.45;
    filter: blur(0.3px);
}

@media (max-width: 500px) {
    .runic-circle-outer {
        width: 320px;
        height: 320px;
    }
}

.rune-glyphs {
    font-family: var(--font-heading);
    fill: var(--accent-color);
    font-size: 8px;
    letter-spacing: 4px;
    opacity: 0.6;
}

/* Rotation Classes */
.rotate-cw {
    animation: rotCW 40s linear infinite;
    transform-origin: center;
}

.rotate-ccw {
    animation: rotCCW 30s linear infinite;
    transform-origin: center;
}

@keyframes rotCW {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

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

/* Crystal Ball and Altar */
.crystal-ball-container {
    position: relative;
    z-index: 10;
    width: 300px;
    height: 350px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 25px;
}

.crystal-ball-aura {
    position: absolute;
    top: 15px;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary-color) 0%, transparent 70%);
    filter: blur(10px);
    opacity: 0.6;
    animation: pulseAura 4s ease-in-out infinite alternate;
    z-index: 1;
}

@keyframes pulseAura {
    0% { transform: scale(0.95); opacity: 0.4; }
    100% { transform: scale(1.05); opacity: 0.8; }
}

.crystal-ball-highlight {
    position: absolute;
    top: 40px;
    left: 65px;
    width: 40px;
    height: 25px;
    background: radial-gradient(ellipse, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 80%);
    border-radius: 50%;
    transform: rotate(-30deg);
    z-index: 15;
    pointer-events: none;
}

.crystal-ball {
    position: absolute;
    top: 15px;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 120%, rgba(10, 8, 19, 0.9) 0%, rgba(57, 36, 103, 0.3) 60%, rgba(255, 255, 255, 0.1) 100%);
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), inset 0 0 40px rgba(255, 255, 255, 0.05), inset 0 -30px 40px rgba(123, 44, 191, 0.3), 0 0 20px var(--primary-glow);
    z-index: 10;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: box-shadow var(--transition-speed) ease, border-color var(--transition-speed) ease;
    animation: floatBall 6s ease-in-out infinite;
}

.crystal-ball:hover {
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 45px rgba(0, 0, 0, 0.9), inset 0 0 50px rgba(255, 255, 255, 0.1), inset 0 -30px 50px rgba(123, 44, 191, 0.5), 0 0 35px var(--primary-glow);
}

@keyframes floatBall {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-12px); }
    100% { transform: translateY(0px); }
}

/* Magic Canvas embedded in the Crystal Ball */
.ball-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* Divination results inside ball */
.divination-results {
    position: relative;
    z-index: 5;
    padding: 20px;
    width: 100%;
}

.mystical-prompt {
    font-family: var(--font-heading);
    color: var(--text-secondary);
    font-size: 0.9rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    animation: blinkText 2.5s infinite alternate;
}

@keyframes blinkText {
    0% { opacity: 0.4; text-shadow: 0 0 2px rgba(255,255,255,0.1); }
    100% { opacity: 0.9; text-shadow: 0 0 8px var(--primary-glow); }
}

.numbers-display {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
}

.magic-number {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--accent-color);
    font-size: 3.2rem;
    text-shadow: 0 0 15px var(--accent-glow), 0 0 30px var(--primary-glow);
    animation: popNumber 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
    display: inline-block;
}

/* Shrink text size if generating multiple numbers */
.numbers-display.small-numbers .magic-number {
    font-size: 1.8rem;
    text-shadow: 0 0 8px var(--accent-glow);
    background: rgba(0, 0, 0, 0.4);
    width: 42px;
    height: 42px;
    line-height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

@keyframes popNumber {
    0% { transform: scale(0) rotate(-15deg); opacity: 0; filter: blur(5px); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; filter: blur(0px); }
}

/* Crystal Ball Pedestal */
.crystal-ball-pedestal {
    position: absolute;
    bottom: 30px;
    z-index: 8;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.7));
}

.gem-pulse {
    animation: gemPulse 2s ease-in-out infinite alternate;
    transform-origin: center;
}

@keyframes gemPulse {
    0% { filter: drop-shadow(0 0 1px var(--accent-glow)); opacity: 0.6; }
    100% { filter: drop-shadow(0 0 8px var(--accent-glow)); opacity: 1; }
}

/* Divination Button */
.ritual-button {
    position: relative;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    border: 2px solid var(--accent-color);
    border-radius: 30px;
    padding: 16px 36px;
    color: var(--accent-color);
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    z-index: 10;
    outline: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 15px var(--primary-glow);
    transition: all var(--transition-speed) cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.ritual-button:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 6px 30px rgba(0,0,0,0.6), 0 0 25px var(--accent-color);
    color: var(--text-primary);
}

.ritual-button:active {
    transform: scale(0.98) translateY(0px);
}

/* Shiny hover overlay effect */
.btn-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: skewX(-25deg);
    transition: 0.75s;
}

.ritual-button:hover .btn-shine {
    left: 150%;
    transition: 0.75s;
}

.btn-label {
    position: relative;
    z-index: 2;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* Active Divination Animation state on button */
.ritual-button.casting {
    pointer-events: none;
    background: linear-gradient(135deg, #111 0%, #222 100%);
    border-color: var(--text-muted);
    color: var(--text-muted);
    box-shadow: none;
    animation: castingButton 1.5s infinite alternate;
}

@keyframes castingButton {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(0.97); opacity: 0.5; }
}

/* ==========================================================================
   SPELLBOOK HISTORY SCROLL
   ========================================================================== */

.history-panel {
    max-height: calc(100vh - 200px);
    min-height: 520px;
}

@media (max-width: 1200px) {
    .history-panel {
        max-height: 500px;
        min-height: auto;
    }
}

.history-scroll {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 8px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Vintage parchment scroll custom scrollbar */
.history-scroll::-webkit-scrollbar {
    width: 6px;
}

.history-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.history-scroll::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.history-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Empty State */
.empty-history {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
    padding: 40px 10px;
}

.dust-icon {
    font-size: 2.2rem;
    margin-bottom: 15px;
    filter: drop-shadow(0 0 5px var(--accent-glow));
    animation: floatBall 3s infinite ease-in-out;
}

.empty-history p {
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.history-hint {
    font-size: 0.75rem;
    font-style: italic;
    opacity: 0.7;
}

/* History Scroll Card Item */
.history-card {
    background: linear-gradient(135deg, rgba(30, 20, 50, 0.4) 0%, rgba(15, 10, 25, 0.6) 100%);
    border: 1px solid rgba(255, 215, 0, 0.15);
    border-radius: 10px;
    padding: 14px;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    animation: slideInScroll 0.4s ease forwards;
}

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

.history-card:hover {
    border-color: var(--accent-color);
    background: linear-gradient(135deg, rgba(50, 30, 80, 0.5) 0%, rgba(25, 15, 40, 0.7) 100%);
    box-shadow: 0 4px 15px rgba(0,0,0,0.4), 0 0 8px rgba(255, 215, 0, 0.1);
    transform: translateX(4px);
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.destiny-name {
    font-family: var(--font-heading);
    color: var(--accent-color);
    font-size: 0.85rem;
    font-weight: 700;
}

.destiny-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.history-card-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.destiny-nums-small {
    display: flex;
    gap: 6px;
}

.small-num-badge {
    background: rgba(123, 44, 191, 0.3);
    border: 1px solid rgba(123, 44, 191, 0.5);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.destiny-tags {
    display: flex;
    gap: 6px;
}

.destiny-tag {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 700;
}

.tag-zodiac {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
}

.tag-element {
    background-color: var(--primary-glow);
    color: var(--text-primary);
}

.history-actions {
    margin-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 12px;
}

.magical-btn-danger {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(217, 4, 41, 0.4);
    color: #ef233c;
    padding: 8px;
    border-radius: 6px;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.magical-btn-danger:hover {
    background: rgba(217, 4, 41, 0.15);
    border-color: #d90429;
    box-shadow: 0 0 10px rgba(217, 4, 41, 0.2);
}

/* ==========================================================================
   DESTINY MODAL CARD
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(6, 4, 10, 0.85);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
    transition: opacity var(--transition-speed) ease, visibility var(--transition-speed);
}

.modal-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-card {
    background: #150f2b url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cpath d='M40 0L42 38L80 40L42 42L40 80L38 42L0 40L38 38Z' fill='%23ffd700' fill-opacity='0.02'/%3E%3C/svg%3E");
    border: 2px solid var(--accent-color);
    border-radius: 20px;
    width: 100%;
    max-width: 480px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8), 0 0 35px var(--accent-glow);
    animation: zoomInModal 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes zoomInModal {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.close-modal {
    position: absolute;
    top: 12px;
    right: 18px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
}

.close-modal:hover {
    color: var(--accent-color);
}

.card-scroll-effect {
    padding: 35px 25px 25px 25px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.card-scroll-header h3 {
    font-family: var(--font-fancy);
    color: var(--accent-color);
    font-size: 1.4rem;
    letter-spacing: 2px;
}

.card-scroll-header p {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-top: 2px;
}

.destiny-visual {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 5px 0;
}

.destiny-zodiac-badge, .destiny-element-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 4px 14px;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.destiny-zodiac-badge {
    color: var(--text-primary);
}

.destiny-element-badge {
    color: var(--accent-color);
}

.destiny-numbers {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 10px 0;
}

.modal-num {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-glow);
}

/* Modal numbers badge sizing when details have multiple numbers */
.destiny-numbers.small-numbers .modal-num {
    font-size: 1.6rem;
    background: rgba(123, 44, 191, 0.2);
    border: 1px solid var(--accent-color);
    width: 45px;
    height: 45px;
    line-height: 43px;
    border-radius: 50%;
}

.destiny-description {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.25);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    max-width: 90%;
}

.destiny-footer {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.modal-actions {
    width: 100%;
    margin-top: 5px;
}

.save-card-btn {
    width: 100%;
    font-size: 0.9rem;
    padding: 12px 24px;
}

/* ==========================================================================
   PORTAL FOOTER
   ========================================================================== */

.portal-footer {
    text-align: center;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-family: var(--font-heading);
    font-size: 0.75rem;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
}
