/* Google Fonts - Cinzel and Lora */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Lora:ital,wght@0,400;0,700;1,400&family=Georgia&display=swap');

/* Reset & Base - Soft Anime/Watercolor Theme */
/* Inspired by Frieren & Studio Ghibli */

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

/* Premium Cosmetics */
.premium-name-gold {
    color: #d4af37 !important;
    text-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.premium-name-gold::before {
    content: '🪽';
    display: inline-block;
    transform: scaleX(-1);
    /* Mirror the left wing */
    font-size: 0.9em;
}

.premium-name-gold::after {
    content: '🪽';
    display: inline-block;
    font-size: 0.9em;
}

/* Global Close Button (Windows Style) */
.close-grimoire {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-weight: bold;
    font-family: 'Segoe UI', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 100;
    text-decoration: none;
}

.close-grimoire:hover {
    background: #c0392b;
    transform: scale(1.1);
}

/* Base Body Gradient */
:root {
    /* Base Theme Variables (Updated by Chronology) */
    --realm-bg: #fdfbf7;
    --realm-body-bg: #e8f4f8;
    --realm-header: #e8e0d5;
    --realm-border: #d4c5b0;
    --realm-panel: rgba(139, 125, 107, 0.05);
    --realm-overlay: rgba(255, 255, 255, 0);

    --primary-color: #5a4a3a;
    --secondary-color: #8b7d6b;
    --gold-accent: #d4af37;
}


body {
    background-color: var(--realm-body-bg) !important;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 2s ease;
}

/* Unified Atmosphere Layer - MOVED TO atmosphere.css */
/* GLOBAL PARTICLE EFFECTS - MOVED TO atmosphere.css */
/* ANIMATIONS - MOVED TO atmosphere.css */


.auth-page {
    background:
        /* Layer 1: White Dithered Pixels */
        radial-gradient(circle, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
        /* Layer 2: Deep Dark Gradient Overlay (0.75 opacity) */
        linear-gradient(135deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.7) 100%),
        /* Layer 3: Main World Image */
        url('../images/backgrounds/BG.jpg') no-repeat center center fixed !important;
    background-size: 3px 3px, cover, cover !important;
    background-attachment: fixed !important;
}


.container {
    max-width: 1800px;
    /* Increased from 1600px to give cards more width */
    margin: 0 auto;
    padding: 10px 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    position: relative;
    z-index: 10;
}

/* Page Specific Container Sizes */
.stats-page .container,
.equipment-page .container,
.inventory-page .container {
    max-width: 1400px;
    /* Standard fit */
}

/* Top Navigation Bar - Soft Pastel Style */
.top-bar {
    background: linear-gradient(180deg,
            rgba(245, 241, 232, 0.95) 0%,
            rgba(232, 220, 200, 0.92) 100%);
    color: #4a5a4a;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 16px rgba(106, 90, 74, 0.15);
    border-bottom: 3px solid rgba(184, 212, 168, 0.4);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 2000;
    /* Higher than grimoire and other elements */
}

.game-title {
    font-size: 26px;
    font-weight: bold;
    color: #6a7a5a;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.8);
    font-family: 'Georgia', serif;
    letter-spacing: 1px;
}

/* Currency Display */
.currency-display {
    display: flex;
    gap: 30px;
}

.currency-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-family: 'Segoe UI', sans-serif;
}

.currency-icon {
    font-size: 20px;
}

.currency-label {
    color: #7a8a7a;
}

.currency-value {
    font-weight: bold;
    color: #6a7a5a;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.6);
}

/* Menu Dropdown */
.menu-dropdown {
    position: relative;
}

.menu-button {
    background: rgba(200, 184, 168, 0.3);
    border: 2px solid rgba(168, 152, 136, 0.5);
    color: #6a7a5a;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: 'Georgia', serif;
}

.menu-button:hover {
    background: rgba(200, 184, 168, 0.5);
    border-color: rgba(138, 157, 119, 0.7);
}

.menu-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    padding-top: 5px;
    z-index: 1000;
    background: linear-gradient(135deg,
            rgba(245, 241, 232, 0.98),
            rgba(232, 220, 200, 0.96));
    min-width: 180px;
    width: max-content;
    box-shadow: 0 8px 24px rgba(106, 90, 74, 0.2);
    border-radius: 12px;
    border: 3px solid rgba(184, 212, 168, 0.3);
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.menu-dropdown:hover .menu-content {
    display: block;
}

.menu-content a {
    display: block;
    padding: 12px 20px;
    color: #6a7a5a;
    text-decoration: none;
    font-family: 'Georgia', serif;
    transition: background 0.2s;
    white-space: nowrap;
}

.menu-content a:hover {
    background: rgba(184, 212, 168, 0.3);
    color: #4a5a4a;
}

/* Eye-catching Back Link Animation */
.nav-back-link {
    display: inline-block;
    color: #8b7d6b;
    text-decoration: none;
    font-size: 0.9rem;
    font-style: italic;
    transition: all 0.3s ease;
    animation: nav-look-at-me 3s ease-in-out infinite;
    padding: 5px 10px;
    border-radius: 15px;
}

.nav-back-link:hover {
    color: #5a4a3a;
    background: rgba(255, 255, 255, 0.5);
    animation-play-state: paused;
}

@keyframes nav-look-at-me {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    20% {
        transform: translateX(-5px);
    }

    15% {
        transform: translateX(-2px);
    }

    30% {
        transform: translateX(0);
    }
}

.char-return-wrapper {
    margin-top: auto;
    width: 100%;
    text-align: center;
    padding-bottom: 5px;
    /* Alignment adjustment */
}

/* Auth Box (Login/Register) - Soft Watercolor */
.auth-box {
    background: linear-gradient(135deg,
            rgba(245, 241, 232, 0.95) 0%,
            rgba(232, 220, 200, 0.92) 100%);
    max-width: 450px;
    margin: 100px auto;
    padding: 40px;
    border-radius: 20px;
    box-shadow:
        0 12px 48px rgba(106, 90, 74, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border: 3px solid rgba(212, 197, 176, 0.3);
}

.auth-box h1 {
    text-align: center;
    margin-bottom: 10px;
    color: #4a5a4a;
    font-family: 'Georgia', serif;
    font-size: 28px;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.8);
}

.auth-box>p {
    text-align: center;
    color: #6a7a6a;
    margin-bottom: 30px;
    font-family: 'Georgia', serif;
    font-style: italic;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #5a6a5a;
    font-family: 'Georgia', serif;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 3px solid rgba(184, 212, 168, 0.4);
    border-radius: 10px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.8);
    color: #4a4a4a;
    font-family: 'Segoe UI', sans-serif;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: rgba(138, 157, 119, 0.7);
    box-shadow: 0 0 12px rgba(184, 212, 168, 0.4);
    background: rgba(255, 255, 255, 0.95);
}

/* Buttons - Soft Pastel Style */
.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Georgia', serif;
    text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.5);
    box-shadow: 0 6px 16px rgba(106, 90, 74, 0.2);
    position: relative;
}

.btn-primary {
    background: linear-gradient(135deg, #c8b8a8 0%, #b8a898 100%);
    color: #fefefe;
    border: 3px solid rgba(168, 152, 136, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #b8a898 0%, #a89888 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(106, 90, 74, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(106, 90, 74, 0.2);
}

.btn-secondary {
    background: linear-gradient(135deg, #e8e4dc 0%, #dcd8d0 100%);
    color: #6a5a4a;
    border: 3px solid rgba(168, 152, 136, 0.3);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #dcd8d0 0%, #cec8c0 100%);
    transform: translateY(-3px);
}

/* Error Messages - Soft Pink */
.error {
    background: linear-gradient(135deg,
            rgba(245, 213, 213, 0.9),
            rgba(235, 203, 203, 0.85));
    color: #8a5a5a;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid rgba(198, 106, 106, 0.6);
    font-family: 'Georgia', serif;
    box-shadow: 0 2px 8px rgba(139, 58, 58, 0.15);
}

.success {
    background: linear-gradient(135deg,
            rgba(212, 237, 218, 0.9),
            rgba(195, 230, 203, 0.85));
    color: #155724;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid #28a745;
    font-family: 'Georgia', serif;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.15);
}

/* Auth Links */
.auth-link {
    text-align: center;
    margin-top: 20px;
    color: #7a8a7a;
    font-family: 'Georgia', serif;
}

.auth-link a {
    color: #8a9a7a;
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover {
    text-decoration: underline;
    color: #6a7a5a;
}

/* Dashboard - Soft Watercolor Card */
.dashboard {
    background: linear-gradient(135deg,
            rgba(245, 241, 232, 0.95) 0%,
            rgba(232, 220, 200, 0.92) 100%);
    padding: 40px;
    border-radius: 20px;
    margin-top: 30px;
    box-shadow:
        0 12px 48px rgba(106, 90, 74, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border: 3px solid rgba(212, 197, 176, 0.3);
}

.dashboard h1 {
    color: #4a5a4a;
    margin-bottom: 30px;
    font-family: 'Georgia', serif;
    font-size: 32px;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.8);
}

/* Player Stats */
.player-stats h2 {
    margin-bottom: 20px;
    color: #4a5a4a;
    font-family: 'Georgia', serif;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.6);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-item {
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.6) 0%,
            rgba(245, 241, 232, 0.7) 100%);
    padding: 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 3px solid rgba(184, 212, 168, 0.3);
    box-shadow: 0 4px 12px rgba(106, 90, 74, 0.1);
}

.stat-label {
    color: #7a8a7a;
    font-weight: 600;
    font-family: 'Georgia', serif;
}

.stat-value {
    color: #6a7a5a;
    font-size: 24px;
    font-weight: bold;
    font-family: 'Georgia', serif;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.6);
}

/* Experience Bar - Soft Green */
.experience-bar {
    margin-top: 30px;
}

.exp-label {
    margin-bottom: 10px;
    color: #5a6a5a;
    font-weight: 600;
    font-family: 'Georgia', serif;
}

.exp-bar-container {
    background: rgba(232, 220, 200, 0.6);
    height: 30px;
    border-radius: 15px;
    overflow: hidden;
    border: 3px solid rgba(184, 212, 168, 0.4);
    box-shadow: inset 0 2px 8px rgba(106, 90, 74, 0.1);
}

.exp-bar-fill {
    background: linear-gradient(90deg, #b8d4a8 0%, #a8c7a8 100%);
    height: 100%;
    transition: width 0.5s ease;
    box-shadow:
        inset 0 2px 4px rgba(255, 255, 255, 0.5),
        0 0 12px rgba(184, 212, 168, 0.4);
}

/* Stat Allocation Orb - Floating UI */
.stat-orb-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    animation: orb-float 3s ease-in-out infinite;
}

.stat-orb-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700 0%, #ffec8b 100%);
    border: 3px solid rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    box-shadow:
        0 0 15px rgba(255, 215, 0, 0.6),
        inset 0 0 10px rgba(255, 255, 255, 0.5);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    color: #8b7d6b;
}

.stat-orb-container:hover .stat-orb-circle {
    transform: scale(1.1) rotate(5deg);
    box-shadow:
        0 0 25px rgba(255, 215, 0, 0.8),
        inset 0 0 15px rgba(255, 255, 255, 0.8);
}

.stat-orb-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff6b6b;
    color: white;
    font-size: 12px;
    font-weight: bold;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.stat-orb-label {
    background: rgba(255, 255, 255, 0.9);
    padding: 5px 12px;
    border-radius: 15px;
    color: #8b7d6b;
    font-weight: bold;
    font-size: 14px;
    margin-top: 10px;
    box-shadow: 0 4px 10px rgba(106, 90, 74, 0.15);
    border: 1px solid rgba(184, 212, 168, 0.4);
    opacity: 0.9;
    transition: opacity 0.3s;
    white-space: nowrap;
}

.stat-orb-container:hover .stat-orb-label {
    opacity: 1;
    background: #fff;
}

@keyframes orb-float {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0);
    }
}

/* ==========================================================================
   GLOBAL ATMOSPHERE & PARTICLES
   ========================================================================== */

.atmosphere-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: linear-gradient(135deg, #8bc34a 0%, #4caf50 100%);
    opacity: 0.2;
    /* Slightly softer for global */
    overflow: hidden;
    pointer-events: none;
}

/* Default green theme */
.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.05) 20%, rgba(0, 0, 0, 0.15) 50%, rgba(0, 0, 0, 0.3) 80%, rgba(0, 0, 0, 0.4) 100%);
    z-index: -1;
    pointer-events: none;
}

.atmosphere-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0) 70%);
    z-index: -1;
    pointer-events: none;
    animation: atmosphere-pulse 20s ease-in-out infinite alternate;
}

@keyframes atmosphere-pulse {
    0% {
        opacity: 0.02;
    }

    100% {
        opacity: 0.06;
    }
}

.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    pointer-events: none;
    animation: float-particle 15s linear infinite;
}

@keyframes float-particle {
    0% {
        transform: translateY(110vh) translateX(0);
        opacity: 0;
    }

    10% {
        opacity: 0.5;
    }

    90% {
        opacity: 0.5;
    }

    100% {
        transform: translateY(-10vh) translateX(50px);
        opacity: 0;
    }
}

/* ==========================================================================
   Character Grimoire/Sheet Styles - "Frieren" MMO Theme
   ========================================================================== */


/* Main Grimoire Container */
.grimoire-container {
    display: grid;
    grid-template-columns: 1fr 2fr;
    /* Left: Portrait, Right: Stats - Wider ratio for stats */
    gap: 40px;
    /* Reduced gap */
    background:
        linear-gradient(135deg, var(--realm-bg) 0%, #f4eadd 100%);
    border-radius: 8px;
    padding: 40px;
    /* Reduced padding from 60px */
    box-shadow:
        0 0 0 5px #e3d5c0,
        0 0 0 10px var(--realm-border),
        0 30px 60px rgba(0, 0, 0, 0.4);
    max-width: 1400px;
    /* BIGGER for Desktop */
    margin: 20px auto;
    /* Reduced margin */
    position: relative;
    border: 1px solid var(--realm-border);
    min-height: 550px;
    /* Reduced min-height from 700px */
    width: 100%;
    transition: all 2s ease;
}

/* Decorative Corner Accents (Pseudo-elements) */
.grimoire-container::before,
.grimoire-container::after {
    content: "❖";
    position: absolute;
    font-size: 24px;
    /* More compact and elegant */
    color: #8b7d6b;
    opacity: 0.3;
    /* Subtle */
}

.grimoire-container::before {
    top: 5px;
    left: 5px;
}

.grimoire-container::after {
    bottom: 5px;
    right: 5px;
}

/* Special simplified grimoire for Auth pages */
.auth-grimoire {
    display: flex !important;
    flex-direction: column;
    max-width: 500px !important;
    min-height: auto !important;
    margin: 60px auto !important;
    padding: 50px 40px !important;
    align-items: stretch !important;
}

.auth-grimoire .section-header {
    justify-content: center;
    margin-bottom: 25px;
}

.auth-grimoire .section-header::after {
    display: none;
    /* Centered title doesn't need the line */
}

/* Left Column: Portrait & Identity */
.grimoire-portrait-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 2px solid rgba(139, 125, 107, 0.2);
    padding-right: 40px;
    justify-content: flex-start;
    padding-top: 20px;
}

.character-portrait {
    width: 260px;
    /* Larger Portrait */
    height: 260px;
    background: #dcd0c0;
    border-radius: 50%;
    border: 5px solid #fff;
    box-shadow:
        0 0 0 6px #c8b8a8,
        0 15px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 100px;
    color: #fff;
    overflow: hidden;
    position: relative;
    transition: transform 0.3s ease;
}

.character-portrait:hover {
    transform: scale(1.02);
}

/* Placeholder for class icon */
.character-portrait::after {
    content: "🧙‍♂️";
}

.character-name-title {
    text-align: center;
    margin-bottom: 10px;
}

.character-name-title h1 {
    font-family: 'Cinzel', 'Georgia', serif;
    font-size: 36px;
    /* Larger Name */
    color: #5a4a3a;
    margin-bottom: 5px;
    border-bottom: 2px solid #8b7d6b;
    display: inline-block;
    padding-bottom: 8px;
}

.character-level {
    font-size: 20px;
    color: #8b7d6b;
    font-style: italic;
    margin-bottom: 30px;
}

/* Points Available Display - Floating Magic text */
.points-available-display {
    background: rgba(255, 255, 255, 0.7);
    border: 2px solid #c8b8a8;
    padding: 20px 40px;
    border-radius: 40px;
    margin-top: 10px;
    text-align: center;
    animation: glow-pulse 3s infinite alternate;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.points-count {
    font-size: 48px;
    /* Huge Number */
    font-weight: bold;
    color: #d4af37;
    text-shadow: 2px 2px 0 #fff, 0 0 15px rgba(212, 175, 55, 0.5);
    line-height: 1;
    margin-bottom: 5px;
}

.points-label {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #8b7d6b;
    font-weight: 600;
}

/* Right Column: Attributes */
.grimoire-stats-section {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.section-header {
    font-family: 'Georgia', serif;
    font-size: 28px;
    /* Larger Header */
    color: #6a5a4a;
    margin-bottom: 35px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.section-header::after {
    content: "";
    flex-grow: 1;
    height: 2px;
    background: linear-gradient(90deg, #c8b8a8, transparent);
}

/* Stat Row */
.stat-row {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
    /* More spacing */
    padding: 20px;
    /* Larger touch area */
    border-radius: 12px;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid transparent;
}

.stat-row:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(200, 184, 168, 0.5);
    transform: translateX(5px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.stat-icon {
    font-size: 32px;
    /* Bigger Icons */
    width: 60px;
    text-align: center;
    margin-right: 20px;
}

.stat-details {
    flex-grow: 1;
}

.stat-name-val {
    display: flex;
    justify-content: space-between;
    font-size: 20px;
    /* Larger Text */
    font-weight: bold;
    color: #5a4a3a;
    margin-bottom: 8px;
}

.stat-desc {
    font-size: 14px;
    color: #9a8a7a;
    margin-top: 4px;
}

/* Stat Bar Visual */
.stat-bar-bg {
    height: 10px;
    /* Thicker Bar */
    background: #e0d5c8;
    border-radius: 5px;
    width: 100%;
    margin-top: 8px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-bar-fill {
    height: 100%;
    border-radius: 5px;
    width: 0%;
    transition: width 1s ease-out;
}

/* Control Buttons (Runes) */
.stat-controls-group {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: 30px;
    min-width: 160px;
    justify-content: flex-end;
}

.rune-btn {
    width: 40px;
    /* Bigger Buttons */
    height: 40px;
    border-radius: 50%;
    border: 2px solid #c8b8a8;
    background: #fdfbf7;
    color: #8b7d6b;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.rune-btn:hover:not(:disabled) {
    border-color: #8b7d6b;
    color: #5a4a3a;
    transform: scale(1.1);
    background: #fff;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
}

.stat-added-value {
    font-weight: bold;
    color: #28a745;
    width: 40px;
    text-align: center;
    font-family: monospace;
    font-size: 20px;
}

/* Action Footer */
.grimoire-footer {
    grid-column: 1 / -1;
    margin-top: 40px;
    border-top: 2px solid rgba(139, 125, 107, 0.2);
    padding-top: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.btn-magic-primary {
    padding: 16px 40px;
    /* Bigger Button */
    font-size: 18px;
    background: linear-gradient(135deg, #7a9b5a 0%, #5a7a3a 100%);
    color: white;
    border: none;
    border-radius: 4px;
    /* More "parchment" like corner */
    font-family: 'Georgia', serif;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(90, 122, 58, 0.3);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-magic-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(90, 122, 58, 0.4);
}

.btn-magic-primary:disabled {
    background: #c8b8a8;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-magic-secondary {
    padding: 16px 30px;
    background: rgba(255, 255, 255, 0.4);
    border: 2px solid #c8b8a8;
    color: #8b7d6b;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Georgia', serif;
    font-size: 16px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.8);
}

.btn-magic-secondary:hover {
    border-color: #8b7d6b;
    color: #5a4a3a;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Inventory Grid Scrolling & Filters */
.inventory-grid-container {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
    padding: 30px;
    background: rgba(139, 125, 107, 0.1);
    border-radius: 12px;
    border: 2px solid rgba(139, 125, 107, 0.2);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
    /* SCROLLING LOGIC */
    max-height: 600px;
    overflow-y: auto;
    align-content: start;

    /* STABILITY FIXES */
    width: 100%;
    /* Force full width of parent */
    min-height: 500px;
    /* Force consistent height even if empty */

    /* Custom Scrollbar for Grimoire */
    scrollbar-width: thin;
    scrollbar-color: #c8b8a8 #f4eadd;
}

.inventory-grid-container::-webkit-scrollbar {
    width: 8px;
}

.inventory-grid-container::-webkit-scrollbar-track {
    background: #f4eadd;
    border-radius: 4px;
}

.inventory-grid-container::-webkit-scrollbar-thumb {
    background-color: #c8b8a8;
    border-radius: 4px;
    border: 1px solid #f4eadd;
}

/* Filter Tabs */
.inventory-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px dashed rgba(139, 125, 107, 0.3);
    overflow-x: auto;
    /* Allow horizontal scroll on mobile */
}

.filter-tab {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid #c8b8a8;
    border-radius: 20px;
    color: #8b7d6b;
    font-family: 'Georgia', serif;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-tab:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #5a4a3a;
    border-color: #8b7d6b;
}

.filter-tab.active {
    background: #8b7d6b;
    color: #fff;
    border-color: #5a4a3a;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Individual Slot */
.inventory-slot {
    width: 100%;
    aspect-ratio: 1;
    /* Perfect square */
    min-width: 100px;
    /* MASSIVE slots */
    background: rgba(255, 255, 255, 0.4);
    border: 3px solid #c8b8a8;
    /* Thicker border */
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.inventory-slot:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: #8b7d6b;
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.inventory-slot.selected {
    border-color: #d4af37;
    /* Gold highlight */
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.3);
    background: #fff;
}

.inventory-slot.empty {
    opacity: 0.5;
    cursor: default;
}

.inventory-slot.empty:hover {
    transform: none;
    border-color: #c8b8a8;
    background: rgba(255, 255, 255, 0.4);
    box-shadow: none;
}

/* Item Icons & Rarity */
.inventory-item-icon {
    font-size: 54px;
    /* MASSIVE icons */
}

.inventory-slot.common {
    border-color: #a8a8a8;
}

.inventory-slot.rare {
    border-color: #4a90e2;
    box-shadow: inset 0 0 10px rgba(74, 144, 226, 0.2);
}

.inventory-slot.epic {
    border-color: #9013fe;
    box-shadow: inset 0 0 10px rgba(144, 19, 254, 0.2);
}

.inventory-slot.legendary {
    border-color: #f5a623;
    box-shadow: inset 0 0 15px rgba(245, 166, 35, 0.3);
}

/* Stack Badge */
.item-stack-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 10px;
    /* Reduced from 11px */
    padding: 1px 4px;
    border-radius: 4px;
    font-family: sans-serif;
    pointer-events: none;
}

/* Equipped Badge - Green E */
.equipped-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #28a745;
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    z-index: 5;
    pointer-events: none;
}

/* Ensure headers are consistent to keep boxes aligned at the top */
.inventory-grimoire .section-header {
    margin-bottom: 10px !important;
    /* Reduced from 25px/35px to tighten the gap */
}

/* Details Panel (Right Side) */
.item-details-panel {
    background: rgba(255, 255, 255, 0.5);
    border: 2px solid rgba(139, 125, 107, 0.3);
    border-radius: 8px;
    padding: 15px;
    /* Reduced from 20px */
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.detail-icon {
    font-size: 40px;
    /* Reduced from 48px */
    margin-bottom: 12px;
    /* Reduced from 15px */
    background: #fff;
    width: 70px;
    /* Reduced from 80px */
    height: 70px;
    /* Reduced from 80px */
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    border: 3px solid #c8b8a8;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.detail-name {
    font-family: 'Cinzel', serif;
    font-size: 20px;
    /* Reduced from 24px */
    color: #5a4a3a;
    margin-bottom: 8px;
    /* Reduced from 10px */
    border-bottom: 2px solid #c8b8a8;
    padding-bottom: 4px;
    /* Reduced from 5px */
    width: 100%;
}

.detail-type {
    font-size: 13px;
    /* Reduced from 14px */
    color: #8b7d6b;
    font-style: italic;
    margin-bottom: 15px;
    /* Reduced from 20px */
}

.detail-desc {
    color: #6a5a4a;
    line-height: 1.5;
    /* Reduced from 1.6 */
    margin-bottom: auto;
    /* Pushes buttons to bottom */
    font-size: 14px;
    /* Reduced from default */
}

.detail-actions {
    width: 100%;
    margin-top: 15px;
    /* Reduced from 20px */
    display: flex;
    gap: 10px;
}

/* Inventory Specific Desktop Scaling (-5%) */
@media (min-width: 901px) {
    .inventory-grimoire {
        max-width: 1300px;
        /* Reduced from 1400px (~7% reduction) */
        padding: 50px 40px 40px 40px;
        /* Increased TOP padding to clear sigils */
        gap: 30px;
        /* Reduced from 40px */
        width: 100%;
    }

    .inventory-grimoire .grimoire-portrait-section {
        padding-top: 0 !important;
        /* Remove extra top padding */
    }

    .inventory-grimoire .inventory-grid-container {
        gap: 15px;
        /* Reduced from 20px */
        padding: 20px;
        /* Reduced from 30px */
        min-height: 580px;
        /* Balanced height for 5 rows */
        min-width: 600px;
        /* Prevent shrinking when content is small */
    }

    .inventory-grimoire .inventory-slot {
        min-width: 90px;
        /* Reduced from 100px (~10% reduction) */
    }

    .inventory-grimoire .inventory-item-icon {
        font-size: 48px;
        /* Reduced from 54px */
    }

    /* Fixed Height for Inspection Panel to align with Bag */
    .inventory-grimoire .item-details-panel {
        height: 580px;
        /* Matches the grid container height */
        min-height: 580px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        /* Prevents stretching */
        justify-content: flex-start;
        /* Items start from top */
        padding-top: 30px;
    }
}

/* Responsive - Mobile Optimization for Header & Container (OVERRIDE) */
@media (max-width: 900px) {
    .grimoire-container {
        grid-template-columns: 1fr;
        /* Stack vertically */
        padding: 30px 20px;
        /* Reduce side padding for mobile */
        gap: 30px;
    }

    .grimoire-portrait-section {
        border-right: none;
        border-bottom: 2px solid rgba(139, 125, 107, 0.2);
        padding-right: 0;
        padding-bottom: 30px;
        margin-bottom: 10px;
        width: 100%;
    }

    .char-return-wrapper {
        margin-top: 20px !important;
        margin-bottom: 20px;
    }

    .grimoire-stats-section {
        padding-left: 0;
    }

    .stat-row {
        flex-direction: column;
        /* Stack row contents vertically on small screens */
        align-items: stretch;
        text-align: center;
        padding: 15px;
        background: rgba(255, 255, 255, 0.7) !important;
        /* Increased opacity for better legibility and to hide background bleed */
    }

    .stat-icon {
        margin: 0 auto 10px auto;
        /* Center icon */
    }

    .stat-controls-group {
        margin-left: 0;
        margin-top: 15px;
        justify-content: center;
        /* Center buttons */
        width: 100%;
    }

    .stat-bar-bg {
        margin-bottom: 10px;
    }

    .grimoire-footer {
        flex-direction: column;
        /* Change from column-reverse to column */
        gap: 15px;
        margin-top: 30px;
        position: relative;
        /* Ensure it's in normal flow */
        background: rgba(255, 255, 255, 0.3);
        padding: 20px;
        border-radius: 8px;
    }

    .btn-magic-primary,
    .btn-magic-secondary {
        width: 100%;
        justify-content: center;
    }
}

/* Responsive - Mobile Optimization for Header & Container (OVERRIDE) */
@media (max-width: 768px) {

    /* Standardized Mobile Spacing from Top Bar (Production-Grade) */
    .container {
        padding: 5px 15px !important;
        margin-top: 20px !important;
        /* Fixed 20px gap from sticky top-bar */
        width: 100% !important;
        max-width: none !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        min-height: calc(100vh - 80px);
        /* Fill most of screen, but keep gap */
    }

    .grimoire-container {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        zoom: 1 !important;
        /* Ensure no residual zoom */
        border-radius: 8px !important;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    /* Stack Header Elements */
    .top-bar {
        flex-wrap: wrap;
        padding: 10px 15px;
        gap: 10px;
    }

    .top-bar-left {
        order: 1;
    }

    .top-bar-right {
        order: 2;
    }

    .top-bar-center {
        order: 3;
        width: 100%;
        border-top: 1px solid rgba(139, 125, 107, 0.2);
        padding-top: 10px;
        margin-top: 5px;
        overflow-x: auto;
        /* Allow scrolling if currencies overflow */
    }

    .currency-display {
        justify-content: space-around;
        /* Distribute evenly */
        gap: 15px;
        font-size: 14px;
    }

    .currency-icon {
        font-size: 18px;
    }

    /* Mobile Inventory Grid Override - MUST BE LAST */
    .inventory-grimoire {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Auth Page Mobile Adjustments */
    .auth-grimoire {
        margin: 20px auto !important;
        padding: 30px 20px !important;
        width: 95% !important;
    }

    .auth-grimoire .form-row {
        grid-template-columns: 1fr !important;
        /* Stack confirmation fields */
        gap: 0 !important;
    }

    .inventory-grimoire .grimoire-stats-section {
        order: -1;
        /* Move Inspection to TOP */
        padding-left: 0 !important;
        padding-top: 20px !important;
        /* Drop down to clear sigil */
        margin-bottom: 5px !important;
        /* Reduce gap between box and Bag title */
        border-left: none !important;
    }

    .inventory-grimoire .item-details-panel {
        flex-direction: row !important;
        /* Horizontal layout */
        text-align: left !important;
        align-items: center !important;
        padding: 10px 15px !important;
        min-height: 80px !important;
        height: auto !important;
        gap: 15px;
        justify-content: flex-start;
        margin-bottom: 10px;
        /* Tighten bottom margin */
    }

    .inventory-grimoire .detail-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 24px !important;
        margin-bottom: 0 !important;
        flex-shrink: 0;
    }

    /* Column for text info */
    .inventory-grimoire .mobile-detail-text {
        display: flex;
        flex-direction: column;
        text-align: left;
        gap: 2px;
        flex-grow: 1;
    }

    .inventory-grimoire .detail-name {
        font-size: 15px !important;
        margin-bottom: 0 !important;
        border-bottom: none !important;
        padding-bottom: 0 !important;
        width: auto !important;
        text-align: left !important;
    }

    .inventory-grimoire .detail-type {
        display: block !important;
        font-size: 11px !important;
        margin-bottom: 0 !important;
        opacity: 0.8;
    }

    .inventory-grimoire .detail-desc {
        display: block !important;
        font-size: 12px !important;
        margin-bottom: 0 !important;
        line-height: 1.2 !important;
        max-width: 180px;
        /* Prevent it from pushing the button off screen */
    }

    .inventory-grimoire .detail-actions {
        margin-top: 0 !important;
        margin-left: auto !important;
        width: auto !important;
    }

    .inventory-grimoire .detail-actions button {
        padding: 8px 15px !important;
        font-size: 13px !important;
    }

    .inventory-grimoire {
        height: 85vh !important;
        max-height: 85vh !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    .inventory-slot {
        min-width: auto !important;
        border-width: 2px;
        border-radius: 6px;
    }

    .inventory-item-icon {
        font-size: 22px !important;
    }

    .item-stack-badge {
        font-size: 9px;
        padding: 1px 3px;
        bottom: 1px;
        right: 1px;
    }

    .inventory-page {
        background: linear-gradient(135deg,
                rgba(232, 220, 200, 0.9) 0%,
                rgba(245, 241, 232, 0.9) 30%,
                rgba(232, 244, 248, 0.9) 60%,
                rgba(212, 229, 240, 0.9) 100%),
            url('../images/backgrounds/inventory_bg_mobile.jpg') no-repeat center center fixed;
        background-size: cover;
    }
}

/* Ensure PayPal buttons are clickable above background layers */
.paypal-button-container {
    position: relative;
    z-index: 100 !important;
}

/* DASHBOARD MOBILE RESPONSIVE */
@media (max-width: 768px) {

    /* Dashboard specific */
    .dashboard-page .container {
        padding: 10px;
    }

    .dashboard-page .grimoire-container {
        grid-template-columns: 1fr !important;
        gap: 20px;
        padding: 15px;
    }

    /* Identity section */
    .identity-top {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }

    .character-portrait {
        width: 100px !important;
        height: 100px !important;
    }

    #player-display-name {
        font-size: 20px !important;
    }

    .character-level {
        font-size: 14px !important;
    }

    /* Chat wrapper */
    .mmo-chat-wrapper {
        height: 300px !important;
        margin-top: 15px;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .stat-item {
        padding: 10px !important;
    }

    .stat-label,
    .stat-value {
        font-size: 14px !important;
    }

    /* Quick access buttons */
    .section-header {
        font-size: 16px;
        margin-bottom: 15px;
    }

    .btn-magic-secondary,
    .btn-magic-primary {
        padding: 10px !important;
        font-size: 13px !important;
    }

    /* Modals */
    .modal-content {
        width: 90% !important;
        padding: 20px !important;
    }

    .modal-content h2 {
        font-size: 20px !important;
    }

    /* Stat orb floating notification */
    .stat-orb-container {
        bottom: 80px !important;
        right: 15px !important;
    }

    .stat-orb-circle {
        width: 50px !important;
        height: 50px !important;
    }

    .stat-orb-label {
        font-size: 11px !important;
    }
}

@media (max-width: 480px) {
    .dashboard-page .grimoire-container {
        padding: 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .identity-top>div {
        width: 100% !important;
    }

    .mmo-chat-wrapper {
        height: 250px !important;
    }

    .chat-msg {
        font-size: 12px !important;
    }
}

/* Broken Image Shield */
img[src=''],
img:not([src]) {
    opacity: 0 !important;
}

img:after {
    content: '??';
    /* Fallback emoji */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: #fdfbf7;
    border: 1px dashed #d4c5b0;
    border-radius: 4px;
}