/* ========================================
   CSS CUSTOM PROPERTIES - THEME VARIABLES
   ======================================== */

/* Default Theme: Autumn */
html,
:root {
    /* Background colors */
    --bg-gradient-start: #105610 !important;
    --bg-gradient-end: #a94610 !important;
    --container-bg: rgba(255, 255, 255, 0.95) !important;
    --result-gradient-start: #e8762e !important;
    --result-gradient-end: #d96619 !important;

    /* Text colors */
    --heading-primary: #7a2a1f !important;
    --heading-secondary: #5a1010 !important;
    --heading-tertiary: #5d4e37 !important;
    --text-primary: #555 !important;
    --text-secondary: #666 !important;
    --text-light: #999 !important;
    --text-white: white !important;

    /* Accent colors */
    --accent-primary: #4a7c3c !important;
    --accent-primary-dark: #2d5016 !important;
    --accent-secondary: #5a7a47 !important;
    --accent-tertiary: #7a6952 !important;

    /* Button colors */
    --button-gradient-start: #4a7c3c !important;
    --button-gradient-end: #2d5016 !important;
    --button-shadow: rgba(74, 124, 60, 0.4) !important;

    /* Border colors */
    --border-light: #eee !important;
    --border-medium: #ddd !important;
    --border-accent: #5a7a47 !important;

    /* Background variations */
    --bg-light: #f9f9f9 !important;
    --bg-white: white !important;
    --bg-hover: #f0f5ef !important;

    /* Error colors */
    --error-bg: #ffebee !important;
    --error-border: #ef5350 !important;
    --error-text: #c62828 !important;

    /* Fate die */
    --fate-die-bg: #611 !important;

    /* Scrollbar colors */
    --scrollbar-track: #f1f1f1 !important;
    --scrollbar-thumb: #5a7a47 !important;
    --scrollbar-thumb-hover: #4a6a37 !important;

    /* Shadows */
    --shadow-primary: rgba(0, 0, 0, 0.3) !important;
    --shadow-secondary: rgba(0, 0, 0, 0.2) !important;

    /* Close button */
    --close-btn-bg: rgba(122, 42, 31, 0.1) !important;
    --close-btn-bg-hover: rgba(122, 42, 31, 0.2) !important;
    --close-btn-color: #7a2a1f !important;

    /* Link container hover gradient */
    --link-hover-gradient-start: rgba(74, 124, 60, 0.03) !important;
    --link-hover-gradient-end: rgba(45, 80, 22, 0.03) !important;

    /* History */
    --history-border-shadow: rgba(90, 122, 71, 0.15) !important;

    /* Result text shadow */
    --result-text-shadow: rgba(0, 0, 0, 0.2) !important;
}

/* Light Theme */
html.light-theme,
html.light-theme:root,
body.light-theme {
    --bg-gradient-start: #f5f5f5 !important;
    --bg-gradient-end: #e0e0e0 !important;
    --container-bg: rgba(255, 255, 255, 0.98) !important;
    --result-gradient-start: #FF9800 !important;
    --result-gradient-end: #F57C00 !important;

    --heading-primary: #333 !important;
    --heading-secondary: #444 !important;
    --heading-tertiary: #555 !important;
    --text-primary: #444 !important;
    --text-secondary: #666 !important;

    --accent-primary: #2196F3 !important;
    --accent-primary-dark: #1976D2 !important;
    --accent-secondary: #1e88e5 !important;
    --accent-tertiary: #90a4ae !important;

    --button-gradient-start: #2196F3 !important;
    --button-gradient-end: #1976D2 !important;
    --button-shadow: rgba(33, 150, 243, 0.4) !important;

    --border-accent: #1e88e5 !important;

    --bg-hover: #e3f2fd !important;

    --fate-die-bg: #1976D2 !important;

    --scrollbar-thumb: #2196F3 !important;
    --scrollbar-thumb-hover: #1976D2 !important;

    --close-btn-bg: rgba(33, 33, 33, 0.08) !important;
    --close-btn-bg-hover: rgba(33, 33, 33, 0.15) !important;
    --close-btn-color: #333 !important;

    --link-hover-gradient-start: rgba(33, 150, 243, 0.03) !important;
    --link-hover-gradient-end: rgba(25, 118, 210, 0.03) !important;

    --history-border-shadow: rgba(33, 150, 243, 0.15) !important;
}

/* Dark Theme */
html.dark-theme,
html.dark-theme:root,
body.dark-theme {
    --bg-gradient-start: #1a1a1a !important;
    --bg-gradient-end: #2d2d2d !important;
    --container-bg: rgba(40, 40, 40, 0.95) !important;
    --result-gradient-start: #FFC107 !important;
    --result-gradient-end: #FFA000 !important;

    --heading-primary: #fff !important;
    --heading-secondary: #eee !important;
    --heading-tertiary: #ddd !important;
    --text-primary: #ccc !important;
    --text-secondary: #aaa !important;
    --text-light: #888 !important;

    --accent-primary: #4CAF50 !important;
    --accent-primary-dark: #388E3C !important;
    --accent-secondary: #66bb6a !important;
    --accent-tertiary: #757575 !important;

    --button-gradient-start: #4CAF50 !important;
    --button-gradient-end: #388E3C !important;
    --button-shadow: rgba(76, 175, 80, 0.4) !important;

    --border-light: #444 !important;
    --border-medium: #555 !important;
    --border-accent: #66bb6a !important;

    --bg-light: #2a2a2a !important;
    --bg-white: #333 !important;
    --bg-hover: #3a3a3a !important;

    --error-bg: #3d1f1f !important;
    --error-border: #c62828 !important;
    --error-text: #ef5350 !important;

    --fate-die-bg: #1b5e20 !important;

    --scrollbar-track: #2a2a2a !important;
    --scrollbar-thumb: #4CAF50 !important;
    --scrollbar-thumb-hover: #388E3C !important;

    --close-btn-bg: rgba(255, 255, 255, 0.1) !important;
    --close-btn-bg-hover: rgba(255, 255, 255, 0.15) !important;
    --close-btn-color: #fff !important;

    --link-hover-gradient-start: rgba(76, 175, 80, 0.05) !important;
    --link-hover-gradient-end: rgba(56, 142, 60, 0.05) !important;

    --history-border-shadow: rgba(76, 175, 80, 0.2) !important;
}

/* Winter Theme */
html.winter-theme,
html.winter-theme:root,
body.winter-theme {
    --bg-gradient-start: #e1f5fe !important;
    --bg-gradient-end: #42a5f5 !important;
    --container-bg: rgba(255, 255, 255, 0.97) !important;
    --result-gradient-start: #00bcd4 !important;
    --result-gradient-end: #0097a7 !important;

    --heading-primary: #1a237e !important;
    --heading-secondary: #283593 !important;
    --heading-tertiary: #3949ab !important;
    --text-primary: #333 !important;
    --text-secondary: #555 !important;

    --accent-primary: #5e35b1 !important;
    --accent-primary-dark: #4527a0 !important;
    --accent-secondary: #7e57c2 !important;
    --accent-tertiary: #00d4ff !important;

    --button-gradient-start: #5e35b1 !important;
    --button-gradient-end: #4527a0 !important;
    --button-shadow: rgba(94, 53, 177, 0.4) !important;

    --border-accent: #7e57c2 !important;

    --bg-hover: #e8eaf6 !important;

    --fate-die-bg: #283593 !important;

    --scrollbar-thumb: #5e35b1 !important;
    --scrollbar-thumb-hover: #4527a0 !important;

    --close-btn-bg: rgba(26, 35, 126, 0.08) !important;
    --close-btn-bg-hover: rgba(26, 35, 126, 0.15) !important;
    --close-btn-color: #1a237e !important;

    --link-hover-gradient-start: rgba(94, 53, 177, 0.03) !important;
    --link-hover-gradient-end: rgba(69, 39, 160, 0.03) !important;

    --history-border-shadow: rgba(94, 53, 177, 0.15) !important;
}

/* Seasonal Effects Animations */

/* Winter - Snowflakes falling with rotation */
@keyframes snowfall-0 {
    0% {
        transform: translateY(-50px) translateX(0) rotate(0deg);
    }
    100% {
        transform: translateY(100vh) translateX(var(--drift)) rotate(var(--rotation));
    }
}

@keyframes snowfall-1 {
    0% {
        transform: translateY(-50px) translateX(0) rotate(0deg);
    }
    50% {
        transform: translateY(50vh) translateX(calc(var(--drift) * 0.5)) rotate(calc(var(--rotation) * 0.5));
    }
    100% {
        transform: translateY(100vh) translateX(var(--drift)) rotate(var(--rotation));
    }
}

@keyframes snowfall-2 {
    0% {
        transform: translateY(-50px) translateX(0) rotate(0deg);
    }
    33% {
        transform: translateY(33vh) translateX(calc(var(--drift) * -0.3)) rotate(calc(var(--rotation) * 0.33));
    }
    66% {
        transform: translateY(66vh) translateX(calc(var(--drift) * 0.6)) rotate(calc(var(--rotation) * 0.66));
    }
    100% {
        transform: translateY(100vh) translateX(var(--drift)) rotate(var(--rotation));
    }
}

/* Autumn - Leaves swaying back and forth */
@keyframes leaffall-0 {
    0% {
        transform: translateY(-50px) translateX(0) rotate(0deg);
    }
    25% {
        transform: translateY(25vh) translateX(var(--sway)) rotate(calc(var(--rotation) * 0.25));
    }
    50% {
        transform: translateY(50vh) translateX(0) rotate(calc(var(--rotation) * 0.5));
    }
    75% {
        transform: translateY(75vh) translateX(calc(var(--sway) * -1)) rotate(calc(var(--rotation) * 0.75));
    }
    100% {
        transform: translateY(100vh) translateX(0) rotate(var(--rotation));
    }
}

@keyframes leaffall-1 {
    0% {
        transform: translateY(-50px) translateX(0) rotate(0deg);
    }
    20% {
        transform: translateY(20vh) translateX(calc(var(--sway) * -0.5)) rotate(calc(var(--rotation) * 0.2));
    }
    40% {
        transform: translateY(40vh) translateX(var(--sway)) rotate(calc(var(--rotation) * 0.4));
    }
    60% {
        transform: translateY(60vh) translateX(calc(var(--sway) * -0.8)) rotate(calc(var(--rotation) * 0.6));
    }
    80% {
        transform: translateY(80vh) translateX(calc(var(--sway) * 0.6)) rotate(calc(var(--rotation) * 0.8));
    }
    100% {
        transform: translateY(100vh) translateX(0) rotate(var(--rotation));
    }
}

/* Spring - Rain falling straight down */
@keyframes rainfall {
    0% {
        transform: translateY(-50px);
    }
    100% {
        transform: translateY(100vh);
    }
}

/* Stars - Twinkling stars (opacity only) */
@keyframes startwinkle-0 {
    0%, 100% {
        opacity: var(--opacity);
    }
    50% {
        opacity: calc(var(--opacity) * 0.3);
    }
}

@keyframes startwinkle-1 {
    0%, 100% {
        opacity: var(--opacity);
    }
    30% {
        opacity: calc(var(--opacity) * 0.5);
    }
    70% {
        opacity: var(--opacity);
    }
}

@keyframes startwinkle-2 {
    0%, 100% {
        opacity: var(--opacity);
    }
    25% {
        opacity: calc(var(--opacity) * 0.2);
    }
    50% {
        opacity: calc(var(--opacity) * 0.6);
    }
    75% {
        opacity: calc(var(--opacity) * 0.4);
    }
}

.seasonal-effect {
    will-change: transform;
}

/* Spring Theme */
html.spring-theme,
html.spring-theme:root,
body.spring-theme {
    --bg-gradient-start: #e8f5e9 !important;
    --bg-gradient-end: #4caf50 !important;
    --container-bg: rgba(255, 255, 255, 0.97) !important;
    --result-gradient-start: #ec407a !important;
    --result-gradient-end: #d81b60 !important;

    --heading-primary: #2e7d32 !important;
    --heading-secondary: #388e3c !important;
    --heading-tertiary: #43a047 !important;
    --text-primary: #424242 !important;
    --text-secondary: #616161 !important;

    --accent-primary: #66bb6a !important;
    --accent-primary-dark: #43a047 !important;
    --accent-secondary: #81c784 !important;
    --accent-tertiary: #ffd700 !important;

    --button-gradient-start: #66bb6a !important;
    --button-gradient-end: #43a047 !important;
    --button-shadow: rgba(102, 187, 106, 0.4) !important;

    --border-accent: #81c784 !important;

    --bg-hover: #f1f8e9 !important;

    --fate-die-bg: #388e3c !important;

    --scrollbar-thumb: #66bb6a !important;
    --scrollbar-thumb-hover: #43a047 !important;

    --close-btn-bg: rgba(46, 125, 50, 0.08) !important;
    --close-btn-bg-hover: rgba(46, 125, 50, 0.15) !important;
    --close-btn-color: #2e7d32 !important;

    --link-hover-gradient-start: rgba(102, 187, 106, 0.05) !important;
    --link-hover-gradient-end: rgba(67, 160, 71, 0.05) !important;

    --history-border-shadow: rgba(102, 187, 106, 0.15) !important;
}

/* Summer Theme */
html.summer-theme,
html.summer-theme:root,
body.summer-theme {
    --bg-gradient-start: #fff3e0 !important;
    --bg-gradient-end: #ff9800 !important;
    --container-bg: rgba(255, 255, 255, 0.97) !important;
    --result-gradient-start: #42a5f5 !important;
    --result-gradient-end: #1e88e5 !important;

    --heading-primary: #e65100 !important;
    --heading-secondary: #ef6c00 !important;
    --heading-tertiary: #f57c00 !important;
    --text-primary: #424242 !important;
    --text-secondary: #616161 !important;

    --accent-primary: #ffa726 !important;
    --accent-primary-dark: #f57c00 !important;
    --accent-secondary: #ffb74d !important;
    --accent-tertiary: #ff6b6b !important;

    --button-gradient-start: #ffa726 !important;
    --button-gradient-end: #f57c00 !important;
    --button-shadow: rgba(255, 167, 38, 0.4) !important;

    --border-accent: #ffb74d !important;

    --bg-hover: #fff8e1 !important;

    --fate-die-bg: #f57c00 !important;

    --scrollbar-thumb: #ffa726 !important;
    --scrollbar-thumb-hover: #f57c00 !important;

    --close-btn-bg: rgba(230, 81, 0, 0.08) !important;
    --close-btn-bg-hover: rgba(230, 81, 0, 0.15) !important;
    --close-btn-color: #e65100 !important;

    --link-hover-gradient-start: rgba(255, 167, 38, 0.05) !important;
    --link-hover-gradient-end: rgba(245, 124, 0, 0.05) !important;

    --history-border-shadow: rgba(255, 167, 38, 0.15) !important;
}

/* Stars Theme */
html.stars-theme,
html.stars-theme:root,
body.stars-theme {
    --bg-gradient-start: #0a0e27 !important;
    --bg-gradient-end: #4a148c !important;
    --container-bg: rgba(30, 20, 50, 0.92) !important;
    --result-gradient-start: #5b21b6 !important;
    --result-gradient-end: #4c1d95 !important;

    --heading-primary: #e0e7ff !important;
    --heading-secondary: #c7d2fe !important;
    --heading-tertiary: #a5b4fc !important;
    --text-primary: #d1d5db !important;
    --text-secondary: #9ca3af !important;
    --text-light: #6b7280 !important;

    --accent-primary: #818cf8 !important;
    --accent-primary-dark: #6366f1 !important;
    --accent-secondary: #a5b4fc !important;
    --accent-tertiary: #fbbf24 !important;

    --button-gradient-start: #818cf8 !important;
    --button-gradient-end: #6366f1 !important;
    --button-shadow: rgba(129, 140, 248, 0.5) !important;

    --border-light: #4b5563 !important;
    --border-medium: #6b7280 !important;
    --border-accent: #a5b4fc !important;

    --bg-light: #1f2937 !important;
    --bg-white: #374151 !important;
    --bg-hover: #4b5563 !important;

    --error-bg: #3d1f3d !important;
    --error-border: #c62828 !important;
    --error-text: #ef5350 !important;

    --fate-die-bg: #4f46e5 !important;

    --scrollbar-track: #1f2937 !important;
    --scrollbar-thumb: #818cf8 !important;
    --scrollbar-thumb-hover: #6366f1 !important;

    --close-btn-bg: rgba(129, 140, 248, 0.1) !important;
    --close-btn-bg-hover: rgba(129, 140, 248, 0.2) !important;
    --close-btn-color: #e0e7ff !important;

    --link-hover-gradient-start: rgba(129, 140, 248, 0.05) !important;
    --link-hover-gradient-end: rgba(99, 102, 241, 0.05) !important;

    --history-border-shadow: rgba(129, 140, 248, 0.2) !important;

    --result-text-shadow: rgba(0, 0, 0, 0.4) !important;
}

/* Stars theme: top-to-bottom gradient instead of diagonal */
html.stars-theme body {
    background: linear-gradient(180deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%) !important;
}

/* Gothic Theme */
html.gothic-theme,
html.gothic-theme:root,
body.gothic-theme {
    --bg-gradient-start: #1a0a1a !important;
    --bg-gradient-end: #2d1a2d !important;
    --container-bg: rgba(20, 10, 20, 0.85) !important;
    --result-gradient-start: #6a0dad !important;
    --result-gradient-end: #4a0a7a !important;

    --heading-primary: #d8b4e2 !important;
    --heading-secondary: #c299d8 !important;
    --heading-tertiary: #b088c5 !important;
    --text-primary: #d4c5d8 !important;
    --text-secondary: #b8a5bc !important;
    --text-light: #8a7a8e !important;
    --text-white: #f0e8f0 !important;

    --accent-primary: #8b4789 !important;
    --accent-primary-dark: #6a2c68 !important;
    --accent-secondary: #9d5b9b !important;
    --accent-tertiary: #7a4477 !important;

    --button-gradient-start: #8b4789 !important;
    --button-gradient-end: #6a2c68 !important;
    --button-shadow: rgba(139, 71, 137, 0.5) !important;

    --border-light: #3d2a3d !important;
    --border-medium: #4d3a4d !important;
    --border-accent: #9d5b9b !important;

    --bg-light: #2a1a2a !important;
    --bg-white: #3a2a3a !important;
    --bg-hover: #4a3a4a !important;

    --error-bg: #3d1a2a !important;
    --error-border: #a82255 !important;
    --error-text: #ef5589 !important;

    --fate-die-bg: #000000 !important;

    --scrollbar-track: #2a1a2a !important;
    --scrollbar-thumb: #8b4789 !important;
    --scrollbar-thumb-hover: #6a2c68 !important;

    --close-btn-bg: rgba(139, 71, 137, 0.15) !important;
    --close-btn-bg-hover: rgba(139, 71, 137, 0.25) !important;
    --close-btn-color: #d8b4e2 !important;

    --link-hover-gradient-start: rgba(139, 71, 137, 0.08) !important;
    --link-hover-gradient-end: rgba(106, 44, 104, 0.08) !important;

    --history-border-shadow: rgba(139, 71, 137, 0.25) !important;

    --result-text-shadow: rgba(0, 0, 0, 0.5) !important;
}

/* Gothic theme: use background image */
html.gothic-theme body {
    background: url('img/Background/gotham.png') center center / cover no-repeat fixed !important;
}

/* Gothic theme: dice styling with black background and yellow text */
html.gothic-theme .fate-die {
    background-color: #000000 !important;
    color: #FFD700 !important;
}

html.gothic-theme .die {
    background-color: #000000 !important;
    color: #FFD700 !important;
    border-color: #FFD700 !important;
}

/* Gothic theme: make dice highlights more distinct */
html.gothic-theme .die-highlight-high {
    border: 3px solid #00FF00 !important;
    box-shadow: 0 0 10px #00FF00, 0 2px 4px var(--shadow-primary) !important;
}

html.gothic-theme .die-highlight-low {
    border: 3px solid #FF4500 !important;
    box-shadow: 0 0 10px #FF4500, 0 2px 4px var(--shadow-primary) !important;
}

/* Cthulhu Theme */
html.cthulhu-theme,
html.cthulhu-theme:root,
body.cthulhu-theme {
    --bg-gradient-start: #0a0a0a !important;
    --bg-gradient-end: #1a1a2e !important;
    --container-bg: rgba(15, 15, 20, 0.88) !important;
    --result-gradient-start: #4a0e4e !important;
    --result-gradient-end: #2a0a3a !important;

    --heading-primary: #7fb069 !important;
    --heading-secondary: #6a9b5e !important;
    --heading-tertiary: #b388eb !important;
    --text-primary: #c4d8c4 !important;
    --text-secondary: #a0b8a0 !important;
    --text-light: #788878 !important;
    --text-white: #e8f5e8 !important;

    --accent-primary: #3fb57a !important;
    --accent-primary-dark: #2e7d52 !important;
    --accent-secondary: #4fc98a !important;
    --accent-tertiary: #8e4ec6 !important;

    --button-gradient-start: #3fb57a !important;
    --button-gradient-end: #2e7d52 !important;
    --button-shadow: rgba(63, 181, 122, 0.5) !important;

    --border-light: #2a2a3a !important;
    --border-medium: #3a3a4a !important;
    --border-accent: #4fc98a !important;

    --bg-light: #1a1a2a !important;
    --bg-white: #252535 !important;
    --bg-hover: #353545 !important;

    --error-bg: #2a1a1f !important;
    --error-border: #c62852 !important;
    --error-text: #ef5577 !important;

    --fate-die-bg: #1a4d2e !important;

    --scrollbar-track: #1a1a2a !important;
    --scrollbar-thumb: #3fb57a !important;
    --scrollbar-thumb-hover: #2e7d52 !important;

    --close-btn-bg: rgba(63, 181, 122, 0.15) !important;
    --close-btn-bg-hover: rgba(63, 181, 122, 0.25) !important;
    --close-btn-color: #7fb069 !important;

    --link-hover-gradient-start: rgba(63, 181, 122, 0.08) !important;
    --link-hover-gradient-end: rgba(46, 125, 82, 0.08) !important;

    --history-border-shadow: rgba(63, 181, 122, 0.25) !important;

    --result-text-shadow: rgba(0, 0, 0, 0.6) !important;
}

/* Cthulhu theme: use background image */
html.cthulhu-theme body {
    background: url('img/Background/cthulhu.png') center center / cover no-repeat fixed !important;
}

/* Cthulhu theme: dice styling with dark background and eldritch green text */
html.cthulhu-theme .fate-die {
    background-color: #0a0a0a !important;
    color: #7fb069 !important;
    border: 2px solid #3fb57a !important;
    box-shadow: 0 0 8px rgba(63, 181, 122, 0.3) !important;
}

html.cthulhu-theme .die {
    background-color: #0a0a0a !important;
    color: #7fb069 !important;
    border: 2px solid #3fb57a !important;
    box-shadow: 0 0 8px rgba(63, 181, 122, 0.3) !important;
}

/* Cthulhu theme: make dice highlights more distinct with purple and green */
html.cthulhu-theme .die-highlight-high {
    border: 3px solid #7fb069 !important;
    box-shadow: 0 0 12px #7fb069, 0 2px 4px var(--shadow-primary) !important;
}

html.cthulhu-theme .die-highlight-low {
    border: 3px solid #b388eb !important;
    box-shadow: 0 0 12px #b388eb, 0 2px 4px var(--shadow-primary) !important;
}

/* ========================================
   GLOBAL STYLES
   ======================================== */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 40px 20px;
}

.container {
    background: var(--container-bg);
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 20px 60px var(--shadow-primary);
    position: relative;
    z-index: 1;
}

.header {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.header-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.theme-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 5px;
}

.theme-selector-wrapper label {
    font-size: 0.9em;
    white-space: nowrap;
}

.theme-selector {
    padding: 8px 10px;
    font-size: 0.9em;
    border: 2px solid var(--border-medium);
    border-radius: 6px;
    background: var(--bg-white);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.theme-selector:hover {
    border-color: var(--accent-secondary);
}

.theme-selector:focus {
    outline: none;
    border-color: var(--accent-secondary);
}

h1 {
    text-align: center;
    color: var(--heading-primary);
    margin: 0;
    font-size: 2.5em;
}

.close-button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--close-btn-bg);
    color: var(--close-btn-color);
    text-decoration: none;
    border-radius: 50%;
    font-size: 1.5em;
    font-weight: bold;
    transition: all 0.3s ease;
    line-height: 1;
}

.close-button:hover {
    background: var(--close-btn-bg-hover);
    transform: scale(1.1);
}

.close-button:active {
    transform: scale(0.95);
}

h2 {
    color: var(--heading-secondary);
    margin-bottom: 15px;
    font-size: 1.2em;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    align-items: stretch;
}

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

.control-group-inline {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.drop-control {
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
}

.radio-label input[type="radio"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.drop-control input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.drop-control input[type="text"] {
    width: 60px;
    min-width: 60px;
}

.drop-control select {
    width: auto;
    min-width: 100px;
}

.drop-control span {
    color: var(--text-primary);
    font-weight: 600;
}

label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1em;
    white-space: nowrap;
}

.dice-label {
    display: inline-block;
    width: 140px;
}

.mode-label {
    display: inline-flex;
    width: 160px;
}

.dropdown-aligned {
    width: 120px;	
}

select, input[type="text"] {
    padding: 12px;
    font-size: 1em;
    border: 2px solid var(--border-medium);
    border-radius: 8px;
    background: var(--bg-white);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.3s ease;
}

select:hover, input[type="text"]:hover {
    border-color: var(--accent-secondary);
}

select:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-secondary);
}

input[type="text"] {
    cursor: text;
    min-width: 120px;
}

.error-message {
    background: var(--error-bg);
    border: 2px solid var(--error-border);
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 20px;
    color: var(--error-text);
    font-weight: 500;
}

.roll-button {
    padding: 15px 30px;
    font-size: 1.2em;
    font-weight: bold;
    color: var(--text-white);
    background: linear-gradient(135deg, var(--button-gradient-start) 0%, var(--button-gradient-end) 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.3s ease;
}

.roll-button:hover {
    box-shadow: 0 5px 15px var(--button-shadow);
}

.roll-button:active {
    transform: scale(0.98);
}

.result-display {
    background: linear-gradient(135deg, var(--result-gradient-start) 0%, var(--result-gradient-end) 100%);
    border-radius: 15px;
    padding: 40px;
    margin: 0 auto 30px auto;
    max-width: 500px;
    text-align: center;
}

.current-result {
    font-size: 4em;
    font-weight: bold;
    color: var(--text-white);
    text-shadow: 0 2px 4px var(--result-text-shadow);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.success-result {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--text-white);
    text-shadow: 0 2px 4px var(--result-text-shadow);
    margin-bottom: 8px;
}

.sum-result {
    font-size: 2.25em;
    font-weight: 600;
    color: var(--text-white);
    text-shadow: 0 2px 4px var(--result-text-shadow);
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-bottom: 8px;
}

.rolls-result {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--text-white);
    text-shadow: 0 1px 2px var(--result-text-shadow);
}

.discarded-result {
    font-size: 1.5em;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 0 1px 2px var(--result-text-shadow);
    font-style: italic;
}

.dice-display {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.fate-die {
    width: 50px;
    height: 50px;
    background-color: var(--fate-die-bg);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4em;
    font-weight: bold;
    color: var(--text-white);
    box-shadow: 0 2px 4px var(--shadow-primary);
    padding-left: 2px;
    padding-bottom: 14px;
}

.history-section {
    border-top: 2px solid var(--border-light);
    padding-top: 20px;
}

.roll-history {
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: var(--bg-light);
    border-radius: 10px;
}

.history-entry {
    padding: 10px 15px;
    background: var(--bg-white);
    border-left: 4px solid var(--border-accent);
    margin-bottom: 10px;
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 0.95em;
    transition: all 0.2s ease;
    cursor: pointer;
}

.history-entry:hover {
    background: var(--bg-hover);
    border: 2px solid var(--border-accent);
    border-left: 4px solid var(--border-accent);
    box-shadow: 0 2px 8px var(--history-border-shadow);
}

.history-entry:last-child {
    margin-bottom: 0;
}

/* Scrollbar styling */
.roll-history::-webkit-scrollbar {
    width: 8px;
}

.roll-history::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 10px;
}

.roll-history::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
}

.roll-history::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Link containers for index page */
.link-container {
    display: block;
    border: 3px solid var(--accent-tertiary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    background: var(--bg-white);
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: text;
}

.link-container:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px var(--shadow-primary);
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, var(--link-hover-gradient-start) 0%, var(--link-hover-gradient-end) 100%);
}

.link-container:active {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px var(--shadow-secondary);
}

.link-container h2 {
    color: var(--accent-primary);
    margin-bottom: 10px;
    font-size: 1.3em;
}

.link-container:hover h2 {
    color: var(--accent-primary-dark);
}

.link-container p {
    color: var(--text-secondary);
    margin-top: 10px;
    line-height: 1.6;
}

/* Section styling */
.section {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid var(--border-light);
}

.section h2 {
    color: var(--heading-tertiary);
    margin-bottom: 15px;
}

.section p, .section ul {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 10px;
}

.section ul {
    list-style-position: inside;
    padding-left: 20px;
}

.section a {
    color: var(--accent-primary);
    text-decoration: none;
}

.section a:hover {
    color: var(--accent-primary-dark);
    text-decoration: underline;
}

.footer-text {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid var(--border-light);
    text-align: center;
    color: var(--text-light);
    font-size: 0.9em;
    line-style: italic;
}

/* Footer */
.footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid var(--border-light);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.footer .oddturnip-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    padding: 8px 15px;
    background: var(--bg-white);
    border: 2px solid var(--border-medium);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
}

.footer .oddturnip-link:hover {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--button-shadow);
}

.footer .oddturnip-link img {
    height: 24px;
    width: auto;
}

/* Responsive design */
@media (max-width: 600px) {
    .container {
        padding: 25px;
    }

    h1 {
        font-size: 2em;
    }

    .current-result {
        font-size: 3em;
    }

    .close-button {
        width: 36px;
        height: 36px;
        font-size: 1.3em;
    }
}

/* ========================================
   PAGE-SPECIFIC STYLES
   ======================================== */

/* Statistics section (Fate & Blades pages) */
.statistics-section {
    margin: 20px auto;
    max-width: 800px;
}

.stats-toggle {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    margin-bottom: 10px;
}

.stats-toggle:hover {
    opacity: 0.7;
}

.info-icon {
    font-size: 1.2em;
    margin-right: 5px;
}

.stats-content {
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px auto;
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.stats-table th,
.stats-table td {
    padding: 8px 6px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.stats-table th {
    background-color: rgba(255, 255, 255, 0.1);
    font-weight: bold;
}

.stats-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.stats-table tbody td:first-child {
    text-align: left;
}

/* Blades page styles */
.outcome-text {
    font-size: 1.5em;
    font-weight: bold;
    margin-top: 10px;
    text-align: center;
    text-shadow:
        -1px -1px 0 #000,
         1px -1px 0 #000,
        -1px  1px 0 #000,
         1px  1px 0 #000,
        -2px -2px 0 #000,
         2px -2px 0 #000,
        -2px  2px 0 #000,
         2px  2px 0 #000;
}

.dice-display {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.die {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    font-weight: bold;
    background-color: var(--fate-die-bg);
    color: var(--text-white);
    border: 2px solid var(--border-medium);
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-primary);
}

.die-highlight-high {
    border: 3px solid #4CAF50;
}

.die-highlight-low {
    border: 3px solid #FFA500;
}

/* Tarot page styles */
.cards-container {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.card-position {
    flex: 1;
    min-width: 150px;
    text-align: center;
}

.card-label {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--heading-secondary);
    margin-bottom: 10px;
}

.card-display {
    background: transparent;
    border: none;
    padding: 20px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-size: 1em;
    color: var(--text-primary);
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.card-image {
    max-width: 150px;
    max-height: 250px;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.card-image.reversed {
    transform: rotate(180deg);
}

.card-name {
    font-size: 0.95em;
    color: var(--text-primary);
    font-weight: 600;
}

.card-display:hover .card-image {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.card-display:hover .card-image.reversed {
    transform: rotate(180deg) scale(1.05);
}

.history-hand {
    padding: 15px;
    background: var(--bg-white);
    border-left: 4px solid var(--border-accent);
    margin-bottom: 15px;
    border-radius: 5px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.history-hand:hover {
    background: var(--bg-hover);
    border: 2px solid var(--border-accent);
    border-left: 4px solid var(--border-accent);
    box-shadow: 0 2px 8px var(--history-border-shadow);
}

.history-hand-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 1em;
}

.history-hand ul {
    list-style-position: inside;
    color: var(--text-secondary);
    font-size: 0.95em;
    padding-left: 10px;
}

.history-hand li {
    margin: 5px 0;
}

/* Modal styles (Tarot) */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-white);
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideIn 0.3s ease;
}

.modal-close {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: var(--text-primary);
    cursor: pointer;
    border: none;
    background: none;
    padding: 5px 10px;
    line-height: 1;
    transition: all 0.2s ease;
}

.modal-close:hover {
    color: var(--accent-primary);
    transform: scale(1.2);
}

.modal-card-image {
    max-width: 250px;
    max-height: 400px;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin: 0 auto 20px;
    display: block;
}

.modal-card-image.reversed {
    transform: rotate(180deg);
}

.modal-card-name {
    color: var(--text-primary);
    font-size: 1.8em;
    font-weight: 700;
    margin-bottom: 15px;
    padding-right: 40px;
}

.modal-card-orientation {
    color: var(--accent-primary);
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 15px;
}

.modal-card-meaning {
    color: var(--text-secondary);
    font-size: 1.1em;
    line-height: 1.8;
}

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

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Tarot responsive styles */
@media (max-width: 600px) {
    .cards-container {
        flex-direction: column;
    }

    .card-position {
        min-width: 100%;
    }

    .card-image {
        max-width: 120px;
        max-height: 200px;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }

    .modal-card-image {
        max-width: 180px;
        max-height: 300px;
    }

    .modal-card-name {
        font-size: 1.4em;
    }

    .modal-card-meaning {
        font-size: 1em;
    }
}
