/**
 * Core CSS for Occult Bookstore Text Adventure
 * Dark, atmospheric theme with good readability
 */

:root {
    /* Color palette */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #888888;

    /* Accent colors */
    --accent-gold: #d4af37;
    --accent-purple: #8a2be2;
    --accent-blue: #4682b4;
    --accent-green: #228b22;
    --accent-red: #dc143c;

    /* Status colors */
    --sanity-high: #90ee90;
    --sanity-medium: #ffd700;
    --sanity-low: #ffa500;
    --sanity-critical: #ff4500;

    /* Reputation colors */
    --rep-high: #32cd32;
    --rep-positive: #90ee90;
    --rep-neutral: #d3d3d3;
    --rep-negative: #ffa500;
    --rep-low: #ff6347;

    /* Layout */
    --sidebar-width: 300px;
    --header-height: 165px; /* Increased to accommodate stat bars wrapping */
    --padding: 20px;
    --border-radius: 8px;
    --shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Main layout */
#game-container {
    display: grid;
    grid-template-areas:
        "header header"
        "main sidebar";
    grid-template-columns: 1fr var(--sidebar-width);
    grid-template-rows: var(--header-height) 1fr;
    height: 100vh;
    max-height: 100vh;
}

/* Header */
#game-header {
    grid-area: header;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    padding: var(--padding);
    border-bottom: 2px solid var(--accent-purple);
    box-shadow: var(--shadow);
    position: relative; /* Contain absolutely positioned stat overlays */
}

#game-header h1 {
    color: var(--accent-gold);
    font-size: 2.2em;
    margin-bottom: 0.5em;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#game-stats {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
}

.stat-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: bold;
}

#day-value, #date-value, #moon-value {
    color: var(--accent-gold);
    font-weight: bold;
    min-width: 30px;
    text-align: center;
}

/* Numeric stat values */
.stat-value-numeric {
    color: var(--accent-gold);
    font-weight: bold;
    min-width: 30px;
    text-align: center;
    position: relative;
}

/* Stat bar containers */
.stats-bars {
    display: flex;
    gap: 15px;
    align-items: center;
}

.stat-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.stat-bar-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 120px;
}

.stat-bar-fill {
    height: 18px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 9px;
    overflow: hidden;
    flex: 1;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-bar-inner {
    height: 100%;
    border-radius: 9px;
    transition: width 0.4s ease;
    position: relative;
}

.health-bar-inner {
    background: linear-gradient(90deg, #c33, #e55);
    box-shadow: 0 0 8px rgba(204, 51, 51, 0.5);
}

.sanity-bar-inner {
    background: linear-gradient(90deg, #4a7fc3, #5a9fd3);
    box-shadow: 0 0 8px rgba(74, 127, 195, 0.5);
}

.stat-value-overlay {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-weight: bold;
    font-size: 0.85em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 1;
}

/* Sanity color coding for overlay text */
.sanity-high { color: var(--sanity-high) !important; }
.sanity-medium { color: var(--sanity-medium) !important; }
.sanity-low { color: var(--sanity-low) !important; }
.sanity-critical { color: var(--sanity-critical) !important; }

/* ========================================
   DAMAGE FEEDBACK - Floating Numbers & Shake
   ======================================== */

/* Floating damage/heal numbers */
.float-number {
    position: fixed;
    font-weight: bold;
    pointer-events: none;
    font-size: 20px;
    z-index: 2000;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    animation: float-classic 1.2s ease-out forwards;
}

.float-number.damage {
    color: #ff4444;
}

.float-number.heal {
    color: #44ff88;
}

.float-number.gold {
    color: #ffd700;
}

.float-number.knowledge {
    color: #4a9eff;
}

.float-number.critical {
    color: #ff2222;
    font-size: 28px;
    font-weight: bold;
}

/* Floating number animation - classic float up */
@keyframes float-classic {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-60px);
        opacity: 0;
    }
}

/* Screen shake animations */
@keyframes shake-medium {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50% { transform: translateX(-5px); }
    20%, 40% { transform: translateX(5px); }
}

@keyframes shake-heavy {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70% { transform: translateX(-7px); }
    20%, 40%, 60% { transform: translateX(7px); }
}

#game-main.shake-medium {
    animation: shake-medium 0.5s ease-in-out;
}

#game-main.shake-heavy {
    animation: shake-heavy 0.6s ease-in-out;
}

/* Main content area */
#game-main {
    grid-area: main;
    padding: var(--padding);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
}

#story-text {
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--accent-purple);
    box-shadow: var(--shadow);
    font-size: 1.1em;
    line-height: 1.7;
    min-height: 200px;
    white-space: pre-wrap;
    overflow-y: auto;
    /* max-height removed to prevent double scrollbar - parent #game-main handles scrolling */
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
}

/* Debug encounter name display */
.debug-encounter-name {
    position: absolute;
    top: 5px;
    right: 10px;
    font-size: 9pt;
    color: var(--text-muted);
    opacity: 0.6;
    font-family: monospace;
    line-height: 1.2;
    pointer-events: none;
    white-space: nowrap;
}

#story-text p {
    margin: 0.5em 0;
}

#story-text p:first-child {
    margin-top: 0;
}

#story-text p:last-child {
    margin-bottom: 0;
}

/* Intro screen styling */
.intro-first-line {
    font-family: 'Cinzel', 'Georgia', serif;
    font-size: 1.05em;
    font-weight: 600;
    color: var(--accent-gold);
    text-shadow:
        0 0 8px rgba(212, 175, 55, 0.4),
        -2px -2px 0 #0d3d0d,
        2px -2px 0 #0d3d0d,
        -2px 2px 0 #0d3d0d,
        2px 2px 0 #0d3d0d,
        -2px 0 0 #0d3d0d,
        2px 0 0 #0d3d0d,
        0 -2px 0 #0d3d0d,
        0 2px 0 #0d3d0d;
    margin-bottom: 1.5em;
    line-height: 1.6;
}

#choices-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Choice buttons */
.choice-button {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    color: var(--text-primary);
    border: 2px solid var(--accent-purple);
    padding: 15px 20px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1em;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: inherit;
    line-height: 1.4;
}

.choice-button .choice-detail {
    display: block;
    margin-top: 4px;
    font-size: 0.85rem;
    color: #cbd3dc;
}

/* Foresight effects preview - hidden by default */
.choice-effects-preview {
    font-size: 0.75rem;
    color: #b8860b;
    opacity: 0.9;
    display: none; /* Hidden by default */
}

/* Show foresight effects when foresight is active */
body.foresight-active .choice-effects-preview {
    display: inline;
}

.choice-button.choice-disabled,
.choice-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.choice-button:hover {
    background: linear-gradient(135deg, var(--accent-purple), var(--bg-tertiary));
    border-color: var(--accent-gold);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.choice-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.choice-number {
    background: var(--accent-gold);
    color: var(--bg-primary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
    flex-shrink: 0;
}

/* Sidebar */
#game-sidebar {
    grid-area: sidebar;
    background: var(--bg-secondary);
    padding: var(--padding);
    overflow-y: auto;
    border-left: 2px solid var(--accent-purple);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-section {
    background: var(--bg-tertiary);
    padding: 10px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(138, 43, 226, 0.3);
}

.sidebar-section h3 {
    color: var(--accent-gold);
    margin-bottom: 7px;
    text-align: center;
    border-bottom: 2px solid var(--accent-purple);
    padding-bottom: 4px;
}

/* Menu toggle icon styling */
#menu-toggle-icon,
#rep-toggle-icon {
    font-size: 0.8em;
    display: inline-block;
    transition: transform 0.2s ease;
    margin-left: 5px;
    color: var(--text-secondary);
}

#game-menu-header:hover #menu-toggle-icon,
#reputation-header:hover #rep-toggle-icon {
    color: var(--accent-gold);
}

/* Reputation grid */
.rep-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    font-size: 0.9em;
}

.rep-grid span:nth-child(odd) {
    color: var(--text-secondary);
}

.rep-grid span:nth-child(even) {
    font-weight: bold;
    text-align: center;
    min-width: 30px;
}

/* Reputation color coding */
.rep-high { color: var(--rep-high) !important; }
.rep-positive { color: var(--rep-positive) !important; }
.rep-neutral { color: var(--rep-neutral) !important; }
.rep-negative { color: var(--rep-negative) !important; }
.rep-low { color: var(--rep-low) !important; }

/* Threshold Tax Panel */
.threshold-tax-panel {
    background-color: #2a1a1a;
    border: 2px solid #5a3a3a;
    border-radius: var(--border-radius);
    padding: 15px;
}

.threshold-tax-panel h3 {
    color: #d4a574;
    font-size: 1.2em;
    margin: 0 0 10px 0;
    text-align: center;
    border-bottom: 2px solid #5a3a3a;
}

.tax-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tax-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95em;
}

.tax-label {
    color: #888;
    flex: 1;
}

.tax-unit {
    color: #666;
    font-size: 0.85em;
    margin-left: 5px;
}

/* Drain severity colors */
.drain-light {
    color: #88cc88;
}

.drain-moderate {
    color: #cccc66;
}

.drain-heavy {
    color: #cc8844;
}

.drain-critical {
    color: #cc4444;
    font-weight: bold;
}

/* Maintenance countdown colors */
.countdown-normal {
    color: #88cc88;
}

.countdown-warning {
    color: #cccc66;
}

.countdown-urgent {
    color: #cc4444;
    font-weight: bold;
}

/* Game menu buttons */
#game-sidebar button {
    background: linear-gradient(135deg, var(--accent-blue), var(--bg-tertiary));
    color: var(--text-primary);
    border: 1px solid var(--accent-blue);
    padding: 10px 12px; /* Reduced from 12px to 10px (about 17% reduction) */
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95em;
    font-family: inherit;
    margin-bottom: 8px;
    width: 100%;
}

#game-sidebar button:hover {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-blue));
    border-color: var(--accent-gold);
    transform: translateY(-1px);
}

#game-sidebar button:active {
    transform: translateY(0);
}

/* Menu button layout */
.menu-button-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.menu-button-full {
    width: 100%;
}

.menu-button-half {
    width: calc(50% - 4px); /* Account for gap */
    margin-bottom: 0 !important; /* Override individual button margin */
}

/* Loading states */
.loading {
    opacity: 0.6;
    cursor: wait !important;
    pointer-events: none;
}

.loading::after {
    content: " ⏳";
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--accent-green);
    color: white;
    padding: 15px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    z-index: 1000;
    font-weight: bold;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

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

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-purple);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-gold);
}

/* Focus states for accessibility */
button:focus,
.choice-button:focus {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

/* Story text fade transition (0.5s fade-out, then fade-in) */
#story-text {
    opacity: 1;
    transition: opacity 0.5s ease;
}

#story-text.is-hidden {
    opacity: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --text-primary: #ffffff;
        --bg-primary: #000000;
        --bg-secondary: #1a1a1a;
        --accent-gold: #ffff00;
    }
}

/* Save/Load Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    max-width: 600px;
    margin: 50px auto;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    color: var(--accent-gold);
    margin-bottom: 20px;
    text-align: center;
    border-bottom: 2px solid var(--accent-purple);
    padding-bottom: 10px;
}

.modal-text-secondary {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-top: 10px;
}

.modal-text-muted {
    font-size: 0.8em;
    color: var(--text-muted);
    margin: 5px 0;
    font-style: italic;
}

.modal-divider {
    margin: 20px 0;
    border: none;
    border-top: 1px solid var(--accent-purple);
    opacity: 0.3;
}

.modal-button {
    background: linear-gradient(135deg, var(--accent-blue), var(--bg-tertiary));
    color: var(--text-primary);
    border: 1px solid var(--accent-blue);
    padding: 8px 15px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95em;
    font-family: inherit;
    margin-left: 10px;
}

.modal-button:hover {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-blue));
    border-color: var(--accent-gold);
}

.modal-input {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 2px solid var(--accent-purple);
    padding: 8px;
    margin-left: 10px;
    text-transform: uppercase;
    border-radius: var(--border-radius);
    font-family: inherit;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.load-input-section {
    margin-bottom: 20px;
}

.saves-list {
    margin-top: 10px;
}

.modal-footer {
    text-align: right;
    margin-top: 30px;
}

/* Save code items */
.save-code-item {
    padding: 10px;
    border: 1px solid var(--accent-purple);
    margin-bottom: 10px;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-primary);
}

.save-code-text {
    font-family: monospace;
    font-size: 1.1em;
    font-weight: bold;
    color: var(--accent-gold);
}

.save-code-buttons {
    display: flex;
    gap: 5px;
}

.small-button {
    padding: 5px 10px !important;
    margin: 0 !important;
    font-size: 0.85em;
}

.remove-button {
    background: linear-gradient(135deg, var(--accent-red), #aa1122) !important;
    border-color: var(--accent-red) !important;
}

.remove-button:hover {
    background: linear-gradient(135deg, #ff4444, var(--accent-red)) !important;
}

/* Bonus save items */
.bonus-save-item {
    padding: 12px;
    border: 2px solid var(--accent-green);
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    margin-bottom: 10px;
    border-radius: var(--border-radius);
}

.bonus-save-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.bonus-save-code {
    font-family: monospace;
    font-size: 1.2em;
    font-weight: bold;
    color: var(--accent-gold);
}

.bonus-button {
    background: linear-gradient(135deg, var(--accent-green), #116622) !important;
    border-color: var(--accent-green) !important;
    margin: 0 !important;
}

.bonus-button:hover {
    background: linear-gradient(135deg, #44aa44, var(--accent-green)) !important;
}

.error-text {
    color: var(--accent-red) !important;
}

/* Loading indicator */
.loading-indicator {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 20px;
    font-size: 1.2em;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 2px solid var(--accent-purple);
    border-radius: var(--border-radius);
    z-index: 100;
    box-shadow: var(--shadow);
}

.loading-subtext {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* ========================================
   SPELL STYLING - Mystical & Glowing Effects
   ======================================== */

/* Import mystical font - fallback to serif if not available */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600&display=swap');

:root {
    /* Spell colors by power level */
    --spell-power-1: #7dd3fc; /* Light blue - basic words */
    --spell-power-2: #a78bfa; /* Purple - intermediate words */
    --spell-power-3: #fbbf24; /* Gold - advanced words */
    --spell-power-4: #f87171; /* Red/orange - master words */

    /* Spell glow intensities */
    --spell-glow-soft: 0 0 8px;
    --spell-glow-medium: 0 0 12px;
    --spell-glow-strong: 0 0 16px;
    --spell-glow-intense: 0 0 20px;
}

/* Base spell text styling */
.spell-word,
.spell-name {
    font-family: 'Cinzel', 'Georgia', serif;
    font-weight: 500;
    letter-spacing: 0.5px;
    position: relative;
    display: inline-block;
    transition: all 0.3s ease;
}

/* Spell words by power level */
.spell-word.power-1 {
    color: var(--spell-power-1);
    text-shadow: var(--spell-glow-soft) var(--spell-power-1);
    font-size: 1.05em;
}

.spell-word.power-2 {
    color: var(--spell-power-2);
    text-shadow: var(--spell-glow-medium) var(--spell-power-2);
    font-size: 1.1em;
}

.spell-word.power-3 {
    color: var(--spell-power-3);
    text-shadow: var(--spell-glow-strong) var(--spell-power-3);
    font-size: 1.15em;
}

.spell-word.power-4 {
    color: var(--spell-power-4);
    text-shadow: var(--spell-glow-intense) var(--spell-power-4);
    font-size: 1.2em;
}

/* Named spells get special treatment */
.spell-name {
    color: var(--accent-gold);
    text-shadow:
        var(--spell-glow-medium) var(--accent-gold),
        0 0 25px rgba(212, 175, 55, 0.3);
    font-weight: 600;
    font-size: 1.15em;
    background: linear-gradient(45deg, transparent 30%, rgba(212, 175, 55, 0.1) 50%, transparent 70%);
    padding: 2px 4px;
    border-radius: 3px;
}

/* Hover effects for interactive spells */
.spell-word:hover,
.spell-name:hover {
    transform: scale(1.05);
    filter: brightness(1.2);
}

.spell-word.power-1:hover {
    text-shadow: var(--spell-glow-medium) var(--spell-power-1);
}

.spell-word.power-2:hover {
    text-shadow: var(--spell-glow-strong) var(--spell-power-2);
}

.spell-word.power-3:hover {
    text-shadow: var(--spell-glow-intense) var(--spell-power-3);
}

.spell-word.power-4:hover {
    text-shadow:
        var(--spell-glow-intense) var(--spell-power-4),
        0 0 30px rgba(248, 113, 113, 0.4);
}

/* Sparkle animation for spell casting */
@keyframes sparkle {
    0%, 100% { opacity: 0.3; transform: scale(0.8) rotate(0deg); }
    25% { opacity: 0.8; transform: scale(1.1) rotate(90deg); }
    50% { opacity: 1; transform: scale(1.2) rotate(180deg); }
    75% { opacity: 0.8; transform: scale(1.1) rotate(270deg); }
}

.spell-casting {
    animation: sparkle 1.2s ease-in-out infinite;
    position: relative;
}

.spell-casting::before {
    content: "✦";
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 0.7em;
    color: var(--accent-gold);
    animation: sparkle 0.8s ease-in-out infinite reverse;
}

.spell-casting::after {
    content: "✧";
    position: absolute;
    bottom: -8px;
    left: -8px;
    font-size: 0.6em;
    color: var(--spell-power-2);
    animation: sparkle 1s ease-in-out infinite;
}

/* Spell choice buttons get enhanced styling */
.choice-button .spell-word,
.choice-button .spell-name {
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Spell ledger/interface styling */
.spell-ledger .spell-word,
.spell-interface .spell-word {
    margin: 2px 4px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    border: 1px solid currentColor;
    cursor: pointer;
}

/* Spell understanding indicators */
.spell-word.understood {
    border-style: solid;
    background: rgba(255, 255, 255, 0.08);
}

.spell-word.unknown {
    border-style: dashed;
    opacity: 0.7;
    font-style: italic;
}

/* Spell combination/mastery indicators */
.spell-combination {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.2), rgba(0, 0, 0, 0.3));
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--accent-purple);
    margin: 4px 2px;
}

.spell-combination .spell-connector {
    color: var(--accent-purple);
    font-size: 0.8em;
    margin: 0 2px;
}

/* Pulsing effect for spell experimentation */
@keyframes spell-pulse {
    0%, 100% {
        box-shadow: 0 0 5px currentColor;
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 20px currentColor, 0 0 30px rgba(255, 255, 255, 0.1);
        transform: scale(1.02);
    }
}

.spell-experimenting {
    animation: spell-pulse 2s ease-in-out infinite;
}

/* Moonlight enhancement effect */
.moonlight-active .spell-word,
.moonlight-active .spell-name {
    filter: brightness(1.3) saturate(1.2);
}

.moonlight-active .spell-word::before {
    content: "☽";
    position: absolute;
    top: -6px;
    left: -12px;
    font-size: 0.8em;
    color: #e2e8f0;
    opacity: 0.6;
}

/* Accessibility: Reduce effects for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .spell-word,
    .spell-name,
    .spell-casting {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }

    .spell-word:hover,
    .spell-name:hover {
        transform: none !important;
    }
}

/* ========================================
   HELP SYSTEM - Minimal Contextual Tooltips
   ======================================== */

.help-tooltip {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border: 2px solid var(--accent-blue);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    max-width: 300px;
    z-index: 1001;
    animation: helpFadeIn 0.3s ease;
}

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

.help-content {
    padding: 15px;
}

.help-content p {
    color: var(--text-primary);
    margin: 0 0 15px 0;
    line-height: 1.5;
    font-size: 0.9em;
}

.help-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.help-dismiss,
.help-disable {
    background: linear-gradient(135deg, var(--accent-blue), var(--bg-tertiary));
    color: var(--text-primary);
    border: 1px solid var(--accent-blue);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    font-family: inherit;
    transition: all 0.2s ease;
}

.help-dismiss:hover {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-blue));
    border-color: var(--accent-gold);
}

.help-disable {
    background: linear-gradient(135deg, var(--text-muted), var(--bg-tertiary));
    border-color: var(--text-muted);
    font-size: 0.75em;
}

.help-disable:hover {
    background: linear-gradient(135deg, var(--accent-red), var(--text-muted));
    border-color: var(--accent-red);
}

/* Help toggle button in sidebar */
.help-toggle {
    background: linear-gradient(135deg, var(--accent-green), var(--bg-tertiary)) !important;
    border-color: var(--accent-green) !important;
    font-size: 0.85em !important;
}

.help-toggle:hover {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-green)) !important;
}

.help-toggle.disabled {
    background: linear-gradient(135deg, var(--text-muted), var(--bg-tertiary)) !important;
    border-color: var(--text-muted) !important;
    opacity: 0.7;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .choice-button:hover {
        transform: none;
    }

    #game-sidebar button:hover {
        transform: none;
    }

    .help-tooltip {
        animation: none;
    }
}

/* ========================================
   BACKGROUND SELECTOR - Character Creation
   ======================================== */

.background-selector {
    max-width: 900px;
    margin: 0 auto;
}

.background-selector h2 {
    color: var(--accent-gold);
    text-align: center;
    font-size: 1.5em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.background-selector h3 {
    color: var(--accent-purple);
    font-size: 1.5em;
    margin: 20px 0 10px 0;
    text-align: center;
}

.background-instructions {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 15px;
}

/* Name input section */
.name-input-section {
    margin: 15px 0 25px 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.name-input-section label {
    color: var(--text-secondary);
    font-size: 1.1em;
    font-weight: bold;
}

#player-name-input {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--accent-purple);
    padding: 12px 20px;
    font-size: 1.1em;
    border-radius: var(--border-radius);
    min-width: 300px;
    text-align: center;
    font-family: inherit;
    transition: all 0.3s ease;
}

#player-name-input:focus {
    outline: none;
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

#player-name-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

/* Background list view (two-column grid) */
.background-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 15px;
    margin-bottom: 20px;
}

.background-list-item {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border: 2px solid var(--accent-purple);
    border-radius: var(--border-radius);
    padding: 8px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: inherit;
    font-size: 1.1em;
    width: 100%;
    text-align: left;
}

.background-list-item:hover {
    border-color: var(--accent-gold);
    background: linear-gradient(135deg, var(--accent-purple), var(--bg-tertiary));
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.background-list-item:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.background-title {
    color: var(--accent-gold);
    font-weight: bold;
}

.background-arrow {
    color: var(--accent-purple);
    font-size: 1.3em;
    transition: transform 0.3s ease;
}

.background-list-item:hover .background-arrow {
    color: var(--accent-gold);
    transform: translateX(5px);
}

/* Background detail view */
.background-detail-view {
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

.background-description-full {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 18px;
    padding: 9px;
    background: rgba(138, 43, 226, 0.1);
    border-left: 3px solid var(--accent-purple);
    border-radius: 4px;
}

.background-selector h3 {
    color: var(--accent-purple);
    font-size: 1.3em;
    margin: 15px 0 9px 0;
}

.background-narrative-effects {
    margin-bottom: 15px;
}

.narrative-effect-item {
    color: var(--text-primary);
    font-size: 1em;
    line-height: 1.6;
    margin: 5px 0;
    padding-left: 10px;
}

/* Mechanical effects sections */
.mechanical-effects-section {
    margin-bottom: 12px;
    background: var(--bg-tertiary);
    padding: 9px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(138, 43, 226, 0.3);
}

.mechanical-effects-section h4 {
    color: var(--accent-gold);
    font-size: 1em;
    margin-bottom: 7px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
}

.mechanic-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.mechanic-item {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--accent-purple);
    font-size: 0.9em;
    font-weight: bold;
}

.spell-word-item {
    color: var(--accent-gold);
    border: none;
    font-family: 'Cinzel', 'Georgia', serif;
}

/* Detail view action buttons */
.background-detail-actions {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 15px;
    order: -1; /* Move to top */
}

.detail-action-btn {
    flex: 1;
    padding: 15px 25px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.back-btn {
    background: linear-gradient(135deg, var(--accent-blue), var(--bg-tertiary));
    color: var(--text-primary);
    border: 2px solid var(--accent-blue);
}

.back-btn:hover {
    background: linear-gradient(135deg, var(--text-secondary), var(--accent-blue));
    border-color: var(--text-secondary);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.confirm-btn {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-purple));
    color: var(--bg-primary);
}

.confirm-btn:hover {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold));
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    filter: brightness(1.1);
}

.detail-action-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Responsive adjustments for tablet/medium screens */
@media (max-width: 1200px) {
    :root {
        --header-height: 160px; /* Taller to accommodate stat bars wrapping */
    }

    #game-stats {
        gap: 10px;
    }

    .stat-bar-wrapper {
        min-width: 100px;
    }
}

/* Responsive adjustments for mobile devices */
@media (max-width: 800px) {
    /* Header adjustments */
    :root {
        --header-height: 165px; /* Taller to accommodate stat bars */
        --padding: 12px; /* Reduced padding */
    }

    #game-header {
        padding: 12px 10px;
    }

    #game-header h1 {
        font-size: 1.6em;
        margin-bottom: 0.4em;
    }

    #game-stats {
        gap: 8px 10px; /* Reduced gap (vertical horizontal) */
        justify-content: space-around;
    }

    .stat-group {
        gap: 5px;
        font-size: 0.82em; /* Smaller font */
        white-space: nowrap; /* Prevent breaking within stat groups */
        flex-shrink: 0; /* Prevent shrinking */
    }

    .stat-label {
        font-size: 0.95em;
    }

    #day-value, #date-value, #moon-value,
    #gold-value, #sanity-value, #knowledge-value, #power-value {
        min-width: 25px; /* Slightly smaller min-width */
        font-size: 0.95em;
    }

    /* Game container adjustments for mobile */
    #game-container {
        grid-template-areas:
            "header"
            "main"
            "sidebar";
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) 1fr auto;
    }

    /* Sidebar becomes bottom bar on mobile */
    #game-sidebar {
        border-left: none;
        border-top: 2px solid var(--accent-purple);
        max-height: 40vh;
    }

    /* Background selector adjustments */
    #player-name-input {
        min-width: 100%;
    }

    .background-selector h2 {
        font-size: 1.6em;
    }

    /* Two columns on mobile to save vertical space */
    .background-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px 10px;
    }

    .background-detail-actions {
        flex-direction: column;
    }

    .detail-action-btn {
        width: 100%;
    }
}

/* ========================================
   TAROT CARD DISPLAY
   ======================================== */

/* Tarot result container - uses flexbox for side-by-side layout */
.tarot-result-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin: 15px 0;
}

/* Tarot card image styling */
.tarot-card-image {
    flex-shrink: 0;
    width: 150px;
    border: 3px solid;
    border-image: linear-gradient(135deg, var(--accent-purple), var(--accent-gold)) 1;
    border-radius: var(--border-radius);
    box-shadow:
        0 6px 12px rgba(138, 43, 226, 0.4),
        0 0 20px rgba(212, 175, 55, 0.2);
    background: rgba(0, 0, 0, 0.3);
    padding: 3px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: tarotCardReveal 0.6s ease-out;
}

.tarot-card-image:hover {
    transform: translateY(-3px);
    box-shadow:
        0 8px 16px rgba(138, 43, 226, 0.5),
        0 0 30px rgba(212, 175, 55, 0.3);
}

.tarot-card-image img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: calc(var(--border-radius) - 2px);
}

/* Tarot result text content */
.tarot-result-text {
    flex: 1;
    line-height: 1.7;
}

.tarot-result-text p {
    margin: 0.8em 0;
}

.tarot-result-text p:first-child {
    margin-top: 0;
}

/* Card reveal animation */
@keyframes tarotCardReveal {
    0% {
        opacity: 0;
        transform: scale(0.8) rotateY(-90deg);
    }
    60% {
        transform: scale(1.05) rotateY(5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotateY(0deg);
    }
}

/* Mobile responsive: stack card above text */
@media (max-width: 800px) {
    .tarot-result-container {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .tarot-card-image {
        width: 130px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .tarot-card-image {
        animation: none;
        transition: none;
    }

    .tarot-card-image:hover {
        transform: none;
    }
}

/* Changelog Link */
#changelog-link-wrapper {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 999;
}

#changelog-link {
    display: inline-block;
    padding: 6px 12px;
    background: rgba(45, 45, 45, 0.9);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.85em;
    border: 1px solid rgba(138, 43, 226, 0.3);
    transition: all 0.3s ease;
}

#changelog-link:hover {
    color: var(--accent-gold);
    border-color: var(--accent-gold);
    background: rgba(58, 58, 58, 0.95);
}

/* Changelog Modal */
.changelog-modal-content {
    max-width: 800px;
}

.changelog-text {
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 20px;
    border-radius: var(--border-radius);
    border: 1px solid var(--accent-purple);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 0.9em;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 60vh;
    overflow-y: auto;
}
