:root {
    --primary-red: #A6312A; /* Primary Red */
    --primary-red-dark: #7D251F; /* Deep Ember */
    --accent-gold: #C29233; /* Gold Accent */
    --accent-gold-light: #D4A84B;
    --parchment-light: #E9D9B6; /* Parchment Light */
    --parchment-dark: #CBB68A; /* Parchment Dark */
    --parchment-medium: #f5deb3;
    --parchment-dark-border: #704a2c;
    --lightning-yellow: #FFDE64;
    --ink-black: #1B1B1B;
    --iron-grey: #4A4A4A;
    --arcane-blue: #5890C3;
    --arcane-blue-dark: #2D4F75;
    --arcane-purple: #5B3A70;
    --arcane-purple-light: #8B5FA0;
    --forest-green: #4A6B42;
    --blood-orange: #B0451B;
    --mystic-teal: #2A6B6B;
}

html, body {
    font-family: 'Crimson Text', Georgia, serif;
    background-color: var(--parchment-light);
    min-height: 100vh;
}

/* Parchment texture background for main content */
body {
    background:
        /* Subtle noise texture */
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E"),
        linear-gradient(180deg, var(--parchment-light) 0%, var(--parchment-dark) 100%);
    background-blend-mode: soft-light, normal;
}

/* Vignette overlay for atmosphere */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(59, 43, 30, 0.4) 100%);
    z-index: 0;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

    .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
        box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
    }

.content {
    padding-top: 1.1rem;
}

.content-text {
    font-family: 'MedievalSharp', cursive; /* Use for body text if it remains readable */
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

.btn-base {
    padding: 10px 20px;
    border: 1px solid #ccc;
    color: white;
    cursor: pointer;
    text-align: center;
    min-width: 300px;
    max-width: 300px;
    word-wrap: break-word;
    white-space: normal;
    border-radius: 999px; /* Makes the left and right ends perfectly rounded */
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
    text-transform: uppercase !important; /* Force uppercase */
}

/* Inherits all base styles, adds Arcane Blue background */
.btn-primary {
    background-color: var(--arcane-blue);
}

/* Inherits all base styles, adds Primary Red background */
.spell-button {
    background-color: var(--primary-red-dark);
    /* Add a smooth transition for the color change */
    transition: background-color 0.2s, transform 0.1s;
    /* Optional: Change the cursor to indicate it can be grabbed/dragged */
    cursor: grab;
}

/* Scroll Button Styles */
.invisible-button {
    /* Removes all browser default styling */
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    outline: none;
}

/* For accessibility, you can add a visible effect when the button is focused via keyboard navigation */
.invisible-button:focus {
    outline: 2px solid var(--arcane-blue); /* Add a custom focus indicator */
}

.scroll-button-container {
    position: relative; /* Makes this the positioning context for absolute children */
    display: inline-block; /* Helps wrap the button tightly around the image size */
    width: 200px; /* Must match the width of your SVG/Image */
    height: 100px; /* Must match the height of your SVG/Image */
}


/* The new subtle shadow class */
.subtle-shadow {
    /* Horizontal offset | Vertical offset | Blur radius | Color (semi-transparent black) */
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.4));
    /* You may need a small margin to ensure the shadow doesn't get clipped by nearby elements */
    margin: 5px;
}

.scroll-text {
    position: absolute; /* Positions the text relative to the button container */
    top: 55%; /* Starts text positioning halfway down from the top */
    left: 55%; /* Starts text positioning halfway across from the left */
    transform: translate(-50%, -50%); /* Centers the text perfectly within that midpoint */
    /* Text styling */
    color: var(--ink-black); /* Dark gray text color */
    
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    text-align: center;
    pointer-events: none; /* Allows clicks to pass through the text to the button below it */
    width: 100%; /* Ensures text doesn't overflow container */
}

.tome-header-small {
    color: var(--ink-black);
    font-family: 'Cinzel', serif;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    pointer-events: none;
    width: 100%;
}

.tome-header {
    color: var(--arcane-blue-dark);
    font-family: 'Cinzel', serif;
    font-size: 28px;
    font-weight: 600;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 2px;
    pointer-events: none;
    width: 100%;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.tome-header-big {
    color: var(--parchment-medium);
    font-family: 'Cinzel', serif;
    font-size: 28px;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 3px;
    pointer-events: none;
    width: 100%;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.btn-active-clicked {
    background-color: var(--arcane-purple) !important; /* Arcane Purple background */
    border-color: var(--accent-gold) !important;
}

/* The state while actively being dragged */
.btn-dragging-state {
    background-color: var(--iron-grey) !important; /* Arcane Purple background */
    border-color: var(--accent-gold) !important;
    cursor: grabbing !important;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.4);
    transform: scale(1.05); /* Optional visual flair */
}

.button-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center; /* Horizontally centers the *buttons* within this container */
    width: 100%; /* Make the container span full width to give align-items space to work */
}

/* Container for the sliding content (Manages layout space) */
.collapsible-details {
    /* Takes up zero vertical space when closed */
    max-height: 0;
    overflow: hidden;
    /* The transition property for smooth opening/closing */
    transition: max-height 0.4s ease-in-out, padding 0.4s ease-in-out;
    padding: 0 10px;
}

/* Class applied when the details are selected/visible */
.collapsible-details.is-open {
    max-height: 500px; /* Must be large enough for all content */
    padding-top: 10px;
    padding-bottom: 10px;
}

/* Style the details content itself (Keep your border styles) */
.spell-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--parchment-dark-border); /* Use the dark color for the border */
    padding: 15px;
    border-radius: 4px;
    color: var(--ink-black);
    background: var(--parchment-medium);
}

.spell-button:hover {
    background-color: var(--primary-red);
}

/* Nav Bar */
.top-row {
    background-color: var(--primary-red-dark) !important;
    border-bottom: 3px solid var(--accent-gold);
}

    .top-row a, .top-row button {
        color: var(--parchment-light);
    }
/* Main Side Menu Container */
.nav-scrollable {
    background-color: var(--parchment-dark);
}
/* Nav Links */
.nav-link {
    color: var(--primary-red-dark) !important;
    font-weight: bold;
}
/* Active Nav Page */
.nav-item .nav-link.active {
    background-color: var(--primary-red);
    color: var(--parchment-light);
    border-radius: 4px;
}
/* On Hover */
.nav-link:hover {
    background-color: var(--parchment-light) !important;
}

/* Page Banner - Ornate spell book header */
.page-banner {
    font-family: 'Cinzel', 'MedievalSharp', serif;
    background: linear-gradient(180deg, var(--primary-red-dark) 0%, #4a1510 100%);
    color: white;
    padding: 25px 20px;
    text-align: center;
    border: 3px solid var(--accent-gold);
    border-left-width: 6px;
    border-right-width: 6px;
    margin: 0 0 30px 0;
    border-radius: 4px;
    position: relative;
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

/* Decorative corner flourishes */
.page-banner::before,
.page-banner::after {
    content: '✦';
    position: absolute;
    font-size: 1.2rem;
    color: var(--accent-gold);
    top: 50%;
    transform: translateY(-50%);
    text-shadow: 0 0 10px var(--accent-gold);
    animation: sparkle 2s ease-in-out infinite;
}

.page-banner::before {
    left: 15px;
}

.page-banner::after {
    right: 15px;
}

@keyframes sparkle {
    0%, 100% { opacity: 0.6; transform: translateY(-50%) scale(1); }
    50% { opacity: 1; transform: translateY(-50%) scale(1.2); }
}

    .page-banner h1,
    .page-banner h2 {
        color: inherit;
        margin: 0 0 10px 0;
    }

    .page-banner h2 {
        margin-bottom: 0;
        font-size: 1.2rem;
    }

/* Expandable Scroll Button Styles */
.expandable-scroll-button-text {
    position: absolute; /* Positions the text relative to the button container */
    top: 55%; /* Starts text positioning halfway down from the top */
    left: 55%; /* Starts text positioning halfway across from the left */
    transform: translate(-50%, -50%); /* Centers the text perfectly within that midpoint */
    /* Text styling */
    color: var(--ink-black);

    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    text-align: center;
    pointer-events: none; /* Allows clicks to pass through the text to the button below it */
    width: 100%; /* Ensures text doesn't overflow container */
}

.expandable-scroll-button {
    position: relative; /* Makes this the positioning context for absolute children */
    display: inline-block; /* Helps wrap the button tightly around the image size */
    width: 200px; /* Must match the width of your SVG/Image */
    height: 100px; /* Must match the height of your SVG/Image */
}

.glowing-text {
    color: var(--lightning-yellow);/* The color inside the letters */
    text-align: center;
    animation: glow 3s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        text-shadow:
        /* 1. Static Black Outline (No blur) */
        1px 1px 0 var(--ink-black), -1px 1px 0 var(--ink-black), 1px -1px 0 var(--ink-black), -1px -1px 0 var(--ink-black),
        /* 2. The Subtle Blue Glow (Animates from subtle to intense) */
        0 0 15px var(--arcane-blue);
    }

    to {
        text-shadow:
        /* 1. Static Black Outline (Must be repeated here) */
        1px 3px 0 var(--ink-black), -1px 1px 0 var(--ink-black), 1px -1px 0 var(--ink-black), -1px -1px 0 var(--ink-black),
        /* 2. The Intense Blue Glow */
        0 0 45px var(--arcane-blue-dark), 0 0 60px var(--arcane-purple); /* Added extra intensity for the peak animation */
    }
}

.pill-cap {
    height: 52px; /* Matches the standard MudExpansionPanel header height */
    background-color: var(--accent-gold); /* Your primary color */
    flex-shrink: 0;
}

.left-semi {
    width: 26px; /* Half of height for a perfect semi-circle */
    border-radius: 26px 0 0 26px;
}

.right-semi {
    width: 26px;
    border-radius: 0 26px 26px 0;
}

/* ================================================
   MAGICAL FLOATING PARTICLES
   ================================================ */
.magical-particles {
    display: none; /* Disabled for performance */
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, var(--accent-gold) 0%, transparent 70%);
    border-radius: 50%;
    animation: float-up 15s infinite linear;
    opacity: 0;
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; animation-duration: 12s; }
.particle:nth-child(2) { left: 20%; animation-delay: 2s; animation-duration: 14s; }
.particle:nth-child(3) { left: 30%; animation-delay: 4s; animation-duration: 11s; }
.particle:nth-child(4) { left: 40%; animation-delay: 1s; animation-duration: 16s; }
.particle:nth-child(5) { left: 50%; animation-delay: 3s; animation-duration: 13s; }
.particle:nth-child(6) { left: 60%; animation-delay: 5s; animation-duration: 15s; }
.particle:nth-child(7) { left: 70%; animation-delay: 2.5s; animation-duration: 12s; }
.particle:nth-child(8) { left: 80%; animation-delay: 4.5s; animation-duration: 14s; }
.particle:nth-child(9) { left: 90%; animation-delay: 1.5s; animation-duration: 11s; }
.particle:nth-child(10) { left: 15%; animation-delay: 3.5s; animation-duration: 13s; }
.particle:nth-child(11) { left: 25%; animation-delay: 0.5s; animation-duration: 15s; }
.particle:nth-child(12) { left: 75%; animation-delay: 2.2s; animation-duration: 12s; }

@keyframes float-up {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-100px) scale(1);
        opacity: 0;
    }
}

/* ================================================
   ENHANCED SPELL DETAILS - Old Book Style
   ================================================ */
.spell-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 2px solid var(--parchment-dark-border);
    padding: 20px;
    border-radius: 4px;
    color: var(--ink-black);
    background:
        linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%),
        var(--parchment-medium);
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.2);
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 1.05rem;
    line-height: 1.6;
    position: relative;
}

/* Aged corner effect */
.spell-details::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--parchment-dark) 50%, transparent 50%);
    opacity: 0.5;
}

/* ================================================
   ENHANCED MUD EXPANSION PANELS - Scroll Style
   ================================================ */
.mud-expand-panel {
    background-color: var(--parchment-medium) !important;
    border: 1px solid var(--parchment-dark-border) !important;
    margin-bottom: 4px;
    transition: all 0.3s ease;
}

.mud-expand-panel:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.mud-expand-panel-header {
    font-family: 'Cinzel', serif !important;
    font-weight: 600 !important;
    letter-spacing: 0.5px;
}

/* ================================================
   MAGICAL HOVER EFFECTS
   ================================================ */
.mud-icon-button:hover {
    animation: magic-pulse 0.5s ease-in-out;
}

@keyframes magic-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); filter: drop-shadow(0 0 8px var(--arcane-blue)); }
    100% { transform: scale(1); }
}

/* ================================================
   LOADING SCREEN - Mystical Theme
   ================================================ */
.loading-progress circle {
    stroke: var(--parchment-dark);
}

.loading-progress circle:last-child {
    stroke: var(--arcane-purple);
}

.loading-progress-text:after {
    font-family: 'Cinzel', serif;
    color: var(--primary-red-dark);
}

/* ================================================
   AUTOCOMPLETE SEARCH - Enchanted Look
   ================================================ */
.mud-input-outlined .mud-input-outlined-border {
    border-color: var(--parchment-dark-border) !important;
}

.mud-input-outlined:hover .mud-input-outlined-border {
    border-color: var(--accent-gold) !important;
}

.mud-input-outlined.mud-input-focused .mud-input-outlined-border {
    border-color: var(--arcane-purple) !important;
    box-shadow: 0 0 8px rgba(91, 58, 112, 0.3);
}

/* ================================================
   CONTENT AREA STYLING
   ================================================ */
.content {
    padding-top: 1.1rem;
    position: relative;
}

article.content {
    background:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E"),
        transparent;
}

/* ================================================
   EMPTY SPELLBOOK STATE
   ================================================ */
.empty-spellbook {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 30px;
    margin: 40px auto;
    max-width: 500px;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%),
        var(--parchment-medium);
    border: 2px solid var(--parchment-dark-border);
    border-radius: 8px;
    box-shadow:
        inset 0 0 40px rgba(0, 0, 0, 0.1),
        0 4px 20px rgba(0, 0, 0, 0.2);
    position: relative;
}

/* Decorative corners */
.empty-spellbook::before,
.empty-spellbook::after {
    content: '⚜';
    position: absolute;
    font-size: 1.5rem;
    color: var(--accent-gold);
    opacity: 0.6;
}

.empty-spellbook::before {
    top: 15px;
    left: 15px;
}

.empty-spellbook::after {
    bottom: 15px;
    right: 15px;
}

.empty-spellbook-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.empty-spellbook-title {
    font-family: 'Cinzel', serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-red-dark);
    margin: 0 0 20px 0;
    letter-spacing: 2px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.empty-spellbook-text {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 1.15rem;
    color: var(--ink-black);
    margin: 0 0 12px 0;
    line-height: 1.6;
    font-style: italic;
}

.empty-spellbook-runes {
    margin-top: 25px;
    font-size: 1.2rem;
    color: var(--accent-gold);
    letter-spacing: 8px;
    animation: sparkle 2s ease-in-out infinite;
}

.mystical-link {
    color: var(--arcane-purple);
    text-decoration: none;
    font-weight: 600;
    font-style: normal;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
}

.mystical-link:hover {
    color: var(--arcane-blue);
    border-bottom-color: var(--arcane-blue);
    text-shadow: 0 0 8px rgba(88, 144, 195, 0.5);
}

/* ================================================
   SCRYING ORB LOADING SCREEN
   ================================================ */
.scrying-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 30px;
    margin: 40px auto;
    max-width: 400px;
}

.crystal-orb {
    position: relative;
    width: 150px;
    height: 150px;
    margin-bottom: 30px;
}

.orb-glow {
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(88, 144, 195, 0.4) 0%, transparent 70%);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.15); opacity: 1; }
}

.orb-inner {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%,
        rgba(200, 220, 255, 0.9) 0%,
        rgba(88, 144, 195, 0.8) 30%,
        rgba(45, 79, 117, 0.9) 60%,
        rgba(91, 58, 112, 0.95) 100%);
    box-shadow:
        inset 0 0 30px rgba(255, 255, 255, 0.3),
        inset 0 0 60px rgba(88, 144, 195, 0.5),
        0 0 20px rgba(88, 144, 195, 0.5);
    overflow: hidden;
}

.magic-swirl {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        conic-gradient(from 0deg, transparent, rgba(255, 222, 100, 0.3), transparent, rgba(139, 95, 160, 0.3), transparent);
    animation: swirl 4s linear infinite;
    border-radius: 50%;
}

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

.orb-reflection {
    position: absolute;
    top: 15px;
    left: 25px;
    width: 40px;
    height: 25px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, transparent 60%);
    border-radius: 50%;
    transform: rotate(-40deg);
}

.scrying-title {
    font-family: 'Cinzel', serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--arcane-blue-dark);
    margin: 0 0 15px 0;
    letter-spacing: 2px;
    text-align: center;
    animation: text-shimmer 3s ease-in-out infinite;
}

@keyframes text-shimmer {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; text-shadow: 0 0 20px rgba(88, 144, 195, 0.5); }
}

.scrying-text {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 1.1rem;
    color: var(--iron-grey);
    margin: 0 0 25px 0;
    font-style: italic;
    text-align: center;
}

.scrying-runes {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.scrying-runes .rune {
    font-size: 1.5rem;
    color: var(--accent-gold);
    animation: rune-glow 1.5s ease-in-out infinite;
    text-shadow: 0 0 10px var(--accent-gold);
}

.scrying-runes .rune:nth-child(1) { animation-delay: 0s; }
.scrying-runes .rune:nth-child(2) { animation-delay: 0.3s; }
.scrying-runes .rune:nth-child(3) { animation-delay: 0.6s; }
.scrying-runes .rune:nth-child(4) { animation-delay: 0.9s; }
.scrying-runes .rune:nth-child(5) { animation-delay: 1.2s; }

@keyframes rune-glow {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* ================================================
   SPELL LIST - Sectioned by Level
   ================================================ */
.spell-level-section {
    margin-bottom: 2rem;
}

.spell-level-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(180deg, var(--primary-red-dark) 0%, #4a1510 100%);
    border: 2px solid var(--accent-gold);
    border-bottom: none;
    position: relative;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease;
}

.spell-level-header:hover {
    background: linear-gradient(180deg, #8d2e27 0%, #5a1813 100%);
}

.spell-level-header:active {
    background: linear-gradient(180deg, #6d1e19 0%, #3a0f0d 100%);
}

.spell-level-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.expand-icon {
    font-size: 1rem;
    color: var(--accent-gold);
    transition: transform 0.2s ease;
    width: 20px;
    text-align: center;
}

.spell-level-header h3 {
    margin: 0;
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--parchment-light);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.spell-count {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    color: var(--accent-gold-light);
    font-weight: 600;
}

.spell-list {
    border: 2px solid var(--parchment-dark-border);
    background-color: var(--parchment-medium);
}

.spell-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--parchment-dark-border);
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--parchment-medium);
    -webkit-tap-highlight-color: transparent;
}

.spell-list-item:last-child {
    border-bottom: none;
}

.spell-list-item:hover {
    background-color: var(--parchment-light);
    padding-left: 25px;
    box-shadow: inset 3px 0 0 var(--primary-red-dark);
}

.spell-list-item:active {
    background-color: var(--parchment-dark);
}

.spell-list-main {
    flex: 1;
    min-width: 0;
}

.spell-list-name {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink-black);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spell-list-school {
    font-size: 0.85rem;
    color: var(--primary-red-dark);
    font-weight: 500;
}

.spell-list-actions {
    margin-left: 12px;
    flex-shrink: 0;
}

/* Mobile adjustments for spell list */
@media (max-width: 480px) {
    .spell-level-header {
        padding: 10px 15px;
    }

    .spell-level-header h3 {
        font-size: 1.1rem;
    }

    .spell-count {
        font-size: 0.75rem;
    }

    .spell-list-item {
        padding: 10px 15px;
    }

    .spell-list-name {
        font-size: 0.95rem;
    }

    .spell-list-school {
        font-size: 0.8rem;
    }
}

/* ================================================
   SPELL CARD GRID - Enhanced Card Design (Legacy - keeping for reference)
   ================================================ */
.spell-card {
    transition: all 0.3s ease;
    border: 2px solid var(--parchment-dark-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    position: relative;
    margin-bottom: 12px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Torn parchment effect at bottom - inside card */
.spell-card .mud-card-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: linear-gradient(to bottom, transparent, rgba(203, 182, 138, 0.3));
    clip-path: polygon(
        0% 30%, 3% 70%, 6% 40%, 9% 80%, 12% 50%, 15% 65%,
        18% 45%, 21% 75%, 24% 55%, 27% 70%, 30% 50%, 33% 80%,
        36% 60%, 39% 75%, 42% 50%, 45% 85%, 48% 55%, 51% 70%,
        54% 45%, 57% 80%, 60% 60%, 63% 70%, 66% 50%, 69% 75%,
        72% 55%, 75% 80%, 78% 60%, 81% 70%, 84% 50%, 87% 75%,
        90% 60%, 93% 70%, 96% 55%, 100% 40%
    );
    pointer-events: none;
}

.spell-card:hover {
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.2),
        0 0 10px rgba(125, 37, 31, 0.3);
    border-color: var(--primary-red-dark);
}

.spell-card .mud-card-header {
    background: linear-gradient(180deg, var(--primary-red-dark) 0%, #4a1510 100%) !important;
    border-bottom: 2px solid var(--accent-gold) !important;
}

.spell-card .mud-card-content {
    background-color: var(--parchment-medium);
}

/* ================================================
   SPELL MODAL OVERLAY
   ================================================ */
.spell-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
    backdrop-filter: blur(3px);
}

.spell-modal-content {
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    animation: modal-slide-in 0.3s ease-out;
}

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

.spell-stats strong {
    color: var(--primary-red-dark);
    font-weight: 600;
}

.spell-description {
    line-height: 1.8;
}

/* ================================================
   MOBILE OPTIMIZATIONS
   ================================================ */

/* Small mobile devices (phones in portrait) */
@media (max-width: 480px) {
    /* Reduce header size on very small screens */
    .tome-header-big {
        font-size: 20px;
        letter-spacing: 2px;
    }

    .page-banner {
        padding: 15px 10px;
    }

    .page-banner::before,
    .page-banner::after {
        font-size: 0.9rem;
        left: 8px;
    }

    .page-banner::after {
        right: 8px;
    }

    /* Make spell cards slightly smaller on very small screens */
    .spell-card {
        margin-bottom: 8px;
    }

    /* Reduce modal padding on small screens */
    .spell-modal-content {
        padding: 10px;
    }

    .spell-modal-overlay {
        padding: 10px;
    }

    /* Make search box more compact */
    .mud-autocomplete {
        font-size: 0.9rem;
    }
}

/* Tablets and larger phones */
@media (max-width: 768px) {
    /* Ensure proper touch targets (at least 44x44px) */
    .mud-icon-button {
        min-width: 44px;
        min-height: 44px;
    }

    /* Make modal full height on tablets */
    .spell-modal-content {
        max-height: 95vh;
    }

    /* Adjust particle count for performance */
    .particle:nth-child(n+7) {
        display: none;
    }
}

/* Disable hover effects on touch devices */
@media (hover: none) {
    .spell-card:hover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        border-color: var(--parchment-dark-border);
    }

    .nav-item ::deep a:hover {
        animation: none;
    }
}

/* Improve scrolling performance on mobile */
@media (max-width: 768px) {
    .spell-card {
        transform: translateZ(0);
        will-change: auto;
    }

    /* Disable backdrop blur on mobile for performance */
    .spell-modal-overlay {
        backdrop-filter: none;
    }
}