/* Graphic Novel / Comic Book Style */
/* Optimized for performance and accessibility */
/* 
 * CSS DESIGN SYSTEM v2.1.2
 * ========================
 * 
 * This stylesheet uses CSS custom properties (variables) for consistency.
 * All values follow standardized scales for spacing, typography, colors, etc.
 * 
 * 📖 FULL DOCUMENTATION: docs/CSS_DESIGN_SYSTEM.md
 * 
 * Quick Reference:
 * - Spacing: var(--space-xs) through var(--space-2xl) [4px to 24px, 4px grid]
 * - Typography: var(--font-xs) through var(--font-3xl) [0.75em to 2.5em]
 * - Colors: var(--color-*) and var(--gradient-*)
 * - Borders: var(--border-thin|base|thick) [2px, 3px, 5px]
 * - Radius: var(--radius-sm|md|lg|xl|full) [8px to 50%]
 * - Transitions: var(--transition-fast|base|slow) [0.2s to 0.5s]
 * 
 * ⚠️ IMPORTANT: Always use variables for consistency!
 * ✅ DO: padding: var(--space-md);
 * ❌ DON'T: padding: 10px;
 * 
 * When in doubt, check docs/CSS_DESIGN_SYSTEM.md for examples and guidelines.
 */

/* Design System - CSS Variables for Consistency */
:root {
    /* Spacing Scale (based on 4px grid) */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;
    
    /* Typography Scale */
    --font-xs: 0.75em;   /* 12px */
    --font-sm: 0.85em;   /* 13.6px */
    --font-base: 1em;    /* 16px */
    --font-md: 1.1em;    /* 17.6px */
    --font-lg: 1.3em;    /* 20.8px */
    --font-xl: 1.5em;    /* 24px */
    --font-2xl: 2em;     /* 32px */
    --font-3xl: 2.5em;   /* 40px */
    
    /* Animation Variables */
    --anim-duration-fast: 0.2s;
    --anim-duration-base: 0.3s;
    --anim-duration-slow: 0.5s;
    --anim-easing: cubic-bezier(0.4, 0, 0.2, 1);
    --anim-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* Line Heights */
    --leading-tight: 1.2;
    --leading-snug: 1.3;
    --leading-normal: 1.5;
    --leading-relaxed: 1.6;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 15px;
    --radius-xl: 20px;
    --radius-full: 50%;
    
    /* Border Width */
    --border-thin: 2px;
    --border-base: 3px;
    --border-thick: 5px;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Colors - Primary Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-accent: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    
    /* Colors - Solid */
    --color-dark: #333;
    --color-light: #fff;
    --color-gray-light: #f0f0f0;
    --color-gray-mid: #ddd;
    --color-gray-dark: #666;
    --color-info: #fff9c4;
    --color-purple: #764ba2;
    --color-pink: #f5576c;
    
    /* Rarity Colors */
    --color-rarity-common: #b0bec5;
    --color-rarity-uncommon: #66bb6a;
    --color-rarity-rare: #42a5f5;
    --color-rarity-epic: #ab47bc;
    --color-rarity-legendary: #ffa726;
    
    /* Special Colors */
    --color-gold: #FFD700;
    --color-gold-glow: rgba(255, 215, 0, 0.5);
    --color-gold-glow-strong: rgba(255, 215, 0, 0.8);
    --color-success: #4CAF50;
    --color-success-light: #8BC34A;
    --color-canvas-sky: #87ceeb;
    --color-canvas-water: #98d8c8;
    --color-gray-medium: #999;
    
    /* Additional Gradients */
    --gradient-success: linear-gradient(90deg, #4CAF50 0%, #8BC34A 100%);
    --gradient-canvas-default: linear-gradient(to bottom, #87ceeb 0%, #98d8c8 100%);
    --gradient-locked: linear-gradient(135deg, #999 0%, #666 100%);
    --gradient-button-action: linear-gradient(135deg, #fff9c4 0%, #ffe0b2 100%);
    --gradient-button-gold: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
    --gradient-button-gold-hover: linear-gradient(135deg, #ffe44d 0%, #ffb732 100%);
    --gradient-button-purple: linear-gradient(135deg, #9c27b0 0%, #673ab7 100%);
    --gradient-button-purple-hover: linear-gradient(135deg, #ab47bc 0%, #7e57c2 100%);
    --gradient-button-danger: linear-gradient(135deg, #f44336 0%, #e53935 100%);
    --gradient-button-danger-hover: linear-gradient(135deg, #e53935 0%, #d32f2f 100%);
    
    /* Shadows */
    --shadow-sm: 2px 2px 0 rgba(0,0,0,0.3);
    --shadow-md: 0 10px 30px rgba(0,0,0,0.3);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.3);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.5);
}

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

body {
    font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive, sans-serif;
    background: var(--gradient-primary);
    background-attachment: fixed;
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    color: var(--color-dark);
    line-height: var(--leading-normal);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-container {
    width: 95vw;
    height: 95vh;
    max-width: 1400px;
    max-height: 900px;
    background: var(--color-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: var(--border-thick) solid var(--color-dark);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

header {
    background: var(--gradient-secondary);
    padding: var(--space-lg) var(--space-xl);
    text-align: center;
    border-bottom: var(--border-thick) solid var(--color-dark);
    position: relative;
    flex-shrink: 0;
}

header::after {
    content: "";
    position: absolute;
    bottom: -5px;
    left: 0;
    right: 0;
    height: 5px;
    background: repeating-linear-gradient(
        90deg,
        var(--color-dark) 0px,
        var(--color-dark) 10px,
        transparent 10px,
        transparent 20px
    );
}

h1 {
    font-size: 2.2em;
    color: white;
    text-shadow: 4px 4px 0px var(--color-dark);
    letter-spacing: 2px;
    margin: 0;
}

.tagline {
    color: white;
    font-size: 1em;
    text-shadow: 2px 2px 0px var(--color-dark);
    margin: 5px 0 0 0;
}

#main-game {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-lg);
    gap: var(--space-md);
}

#game-screen {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: var(--space-lg);
    flex-shrink: 0;
    height: 35%;
    min-height: 250px;
    position: relative;
    z-index: 1;
    margin-bottom: var(--space-md);
}

#game-canvas {
    border: 4px solid var(--color-dark);
    border-radius: var(--radius-md);
    background: var(--gradient-canvas-default);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.1);
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#game-info {
    background: var(--color-info);
    border: 4px solid var(--color-dark);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: 5px 5px 0 rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#game-info h3 {
    color: var(--color-pink);
    margin: 0 0 var(--space-md) 0;
    font-size: var(--font-lg);
    text-align: center;
}

#game-info p {
    font-size: var(--font-md);
    margin: var(--space-md) 0;
    color: var(--color-dark);
    font-weight: bold;
}

#collection-panel {
    margin: 20px 0;
    background: var(--color-gray-light);
    border: 4px solid var(--color-dark);
    border-radius: 10px;
    padding: 20px;
    max-height: 80vh; /* Use viewport height to show more cats */
    overflow-y: auto;
    display: none; /* Hidden by default */
    min-height: 200px; /* Ensure minimum height */
}

#collection-panel.visible {
    display: block !important; /* Show when toggled - force with !important */
    position: fixed; /* Fixed positioning to overlay on screen */
    top: 50%; /* Center vertically */
    left: 50%; /* Center horizontally */
    transform: translate(-50%, -50%); /* Center using transform */
    z-index: 1000; /* Very high z-index to appear above everything */
    box-shadow: 0 8px 32px rgba(0,0,0,0.3); /* Add shadow to make it stand out */
    background: var(--color-gray-light);
    width: 90%; /* Use most of screen width */
    max-width: 1400px; /* But not too wide */
}

/* Backdrop for collection panel */
#collection-panel.visible::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

#collection-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

#collection-panel h2 {
    color: var(--color-purple);
    margin: 0;
    font-size: 2em;
}

#cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    width: 100%; /* Ensure grid takes full width */
    min-height: 200px; /* Ensure grid has minimum height */
}

/* Custom scrollbar for cat grid */
#cat-grid::-webkit-scrollbar {
    width: 10px;
}

#cat-grid::-webkit-scrollbar-track {
    background: var(--color-gray-light);
    border-radius: 5px;
    border: 2px solid var(--color-dark);
}

#cat-grid::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: 5px;
    border: 2px solid var(--color-dark);
}

#cat-grid::-webkit-scrollbar-thumb:hover {
    background: var(--gradient-secondary);
}

/* ============================================================================
   ENVIRONMENT SELECTOR
   ============================================================================ */

#environment-selector {
    margin: var(--space-lg) 0;
    padding: var(--space-lg);
    background: var(--color-white);
    border: var(--border-thick) solid var(--color-dark);
    border-radius: var(--border-radius);
    position: relative;
    z-index: 2;
    clear: both;
}

#environment-selector h3 {
    color: var(--color-purple-dark);
    margin-bottom: var(--space-md);
    font-size: 1.5em;
    text-align: center;
}

.environment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.environment-card {
    background: var(--gradient-primary);
    border: var(--border-thick) solid var(--color-dark);
    border-radius: var(--border-radius);
    padding: var(--space-md);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.environment-card:hover:not(.locked) {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.environment-card:active:not(.locked) {
    transform: translateY(-2px);
}

.environment-card.active {
    background: var(--gradient-secondary);
    box-shadow: 0 0 0 4px var(--color-gold);
    animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% {
        box-shadow: 0 0 0 4px var(--color-gold), 0 0 20px var(--color-gold-glow);
    }
    50% {
        box-shadow: 0 0 0 4px var(--color-gold), 0 0 30px var(--color-gold-glow-strong);
    }
}

.environment-card.locked {
    background: var(--gradient-locked);
    cursor: not-allowed;
    opacity: 0.6;
}

.environment-icon {
    font-size: 3em;
    margin-bottom: var(--space-sm);
}

.environment-name {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--color-white);
    margin-bottom: var(--space-sm);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.environment-progress {
    width: 100%;
    margin-top: var(--space-sm);
}

.progress-text {
    font-size: 0.9em;
    color: var(--color-white);
    margin-bottom: var(--space-xs);
    font-weight: bold;
}

.environment-progress .progress-bar {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--color-dark);
    border-radius: 6px;
    overflow: hidden;
}

.environment-progress .progress-fill {
    height: 100%;
    background: var(--gradient-success);
    transition: width 0.3s ease;
}

.environment-locked-text {
    font-size: 0.85em;
    color: var(--color-white);
    font-style: italic;
    margin-top: var(--space-xs);
}

.cat-card {
    background: white;
    border: 3px solid var(--color-dark);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 3px 3px 0px rgba(0,0,0,0.2);
    position: relative; /* For environment badge positioning (v2.5.0) */
}

.cat-card:hover {
    transform: translateY(-5px) rotate(1deg);
    box-shadow: 5px 8px 0px rgba(0,0,0,0.3);
}

.cat-card.locked {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--color-gray-mid);
}

.cat-card.locked:hover {
    transform: none;
    box-shadow: 3px 3px 0px rgba(0,0,0,0.2);
}

.cat-icon {
    font-size: 2.5em;
    margin: 5px 0;
}

.cat-card h3 {
    font-size: 1.1em;
    color: var(--color-dark);
    margin: 10px 0 5px 0;
}

.cat-card .rarity {
    font-size: 0.9em;
    padding: 3px 8px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 5px;
}

/* Environment badge on cat cards (v2.5.0) */
.environment-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 1.2em;
    background: rgba(255, 255, 255, 0.9);
    padding: 4px 8px;
    border-radius: 50%;
    border: 2px solid var(--color-dark);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.rarity-common { background: var(--color-rarity-common); color: white; }
.rarity-uncommon { background: var(--color-rarity-uncommon); color: white; }
.rarity-rare { background: var(--color-rarity-rare); color: white; }
.rarity-epic { background: var(--color-rarity-epic); color: white; }
.rarity-legendary { background: var(--color-rarity-legendary); color: white; }

/* Dialog Elements - Modern Semantic HTML5 */
dialog {
    border: none;
    padding: 0;
    margin: 0;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    animation: fadeInBackdrop var(--anim-duration-base) var(--anim-easing);
}

/* Cat Details Dialog */
dialog#cat-details {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--color-light);
    border: var(--border-thick) solid var(--color-dark);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    flex-direction: column;
}

dialog#cat-details[open] {
    display: flex;
}

/* Encounter Panel Dialog */
dialog#encounter-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--color-light);
    border: var(--border-thick) solid var(--color-dark);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    max-width: 600px;
    width: 90%;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    text-align: center;
    will-change: transform, opacity;
}

dialog#encounter-panel[open] {
    display: block;
}

/* Help Modal Dialog */
dialog#help-modal {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow-y: auto;
}

dialog#help-modal[open] {
    display: flex;
}

/* Ensure content fits without scroll on most screens */
#cat-details > * {
    flex-shrink: 0;
}

#cat-details #detail-description {
    flex-shrink: 1;
    overflow-y: auto;
}

#cat-details::before {
    content: "";
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: var(--gradient-secondary);
    border-radius: 15px;
    z-index: -1;
}

#cat-portrait {
    font-size: var(--font-3xl);
    text-align: center;
    margin: var(--space-xs) 0;
    max-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cat-portrait canvas {
    max-width: 90px !important;
    max-height: 90px !important;
    width: auto !important;
    height: auto !important;
}

#cat-details h2 {
    color: var(--color-purple);
    font-size: var(--font-lg);
    text-align: center;
    margin-bottom: var(--space-sm);
    margin-top: 0;
}

#detail-description {
    text-align: center;
    margin: var(--space-sm) 0;
    font-size: var(--font-sm);
    line-height: var(--leading-snug);
}

#detail-stats {
    background: var(--color-gray-light);
    border: var(--border-base) solid var(--color-dark);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    margin: var(--space-sm) 0;
}

.stat-bar {
    transition: width 1s cubic-bezier(0.4, 0.0, 0.2, 1);
    margin: var(--space-xs) 0;
}

.stat-bar label {
    display: block;
    font-weight: bold;
    margin-bottom: 1px;
    color: var(--color-dark);
    font-size: var(--font-sm);
}

.stat-bar-bg {
    background: var(--color-gray-mid);
    height: 14px;
    border-radius: var(--radius-md);
    border: var(--border-thin) solid var(--color-dark);
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width var(--transition-slow);
    background: var(--gradient-accent);
}

#detail-origin {
    text-align: center;
    font-style: italic;
    margin-top: var(--space-sm);
    padding: var(--space-xs);
    background: var(--color-info);
    border-radius: var(--radius-sm);
    border: var(--border-thin) solid var(--color-dark);
    font-size: var(--font-sm);
    line-height: var(--leading-snug);
}

#detail-stats h3 {
    margin: 0 0 var(--space-sm) 0;
    font-size: var(--font-base);
    color: var(--color-purple);
}

/* Fieldset styling for encounter actions */
#encounter-actions {
    border: none;
    padding: 0;
    margin: var(--space-xl) 0 0 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

#encounter-actions legend {
    padding: 0;
}

#encounter-panel h2 {
    color: var(--color-pink);
    font-size: var(--font-3xl);
    margin-bottom: var(--space-xl);
    animation: bounce 1s ease-in-out infinite;
}

/* Use GPU-accelerated animations */
@keyframes bounce {
    0%, 100% { 
        transform: translateY(0);
    }
    50% { 
        transform: translateY(-10px);
    }
}

#encounter-cat {
    font-size: 6em;
    margin: 20px 0;
    animation: catAppear var(--anim-duration-slow) var(--anim-bounce);
}

/* Use GPU-accelerated properties for smooth animations */
@keyframes slideIn {
    from {
        transform: translate3d(-100%, 0, 0);
        opacity: 0;
    }
    to {
        transform: translate3d(0, 0, 0);
        opacity: 1;
    }
}

#encounter-text {
    font-size: 1.2em;
    margin: 20px 0;
    line-height: 1.6;
}

/* Action Buttons */
.action-btn {
    background: var(--gradient-primary);
    color: var(--color-light);
    border: var(--border-base) solid var(--color-dark);
    padding: var(--space-lg) var(--space-2xl);
    font-size: var(--font-lg);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.action-btn:hover,
.action-btn:focus {
    transform: translateY(-3px);
    box-shadow: 5px 5px 0 rgba(0,0,0,0.3);
    outline: var(--border-thin) solid var(--color-light);
    outline-offset: var(--border-thin);
}

.action-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.action-btn:focus-visible {
    outline: var(--border-base) solid var(--color-light);
    outline-offset: var(--border-base);
}

#controls {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
    flex-shrink: 0;
    padding: 20px 0;
    margin: 20px 0;
    background: var(--gradient-button-action);
    border-radius: 15px;
    border: 3px solid var(--color-dark);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    position: relative;
    z-index: 3;
    clear: both;
}

.main-btn {
    background: var(--gradient-secondary);
    color: white;
    border: 3px solid var(--color-dark);
    padding: 10px 25px;
    font-size: 1.1em;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.main-btn:hover,
.main-btn:focus {
    transform: translateY(-3px) rotate(-2deg);
    box-shadow: 6px 6px 0 rgba(0,0,0,0.3);
    outline: 2px solid var(--color-dark);
    outline-offset: 2px;
}

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

.main-btn:focus-visible {
    outline: 3px solid var(--color-purple);
    outline-offset: 3px;
}

/* Special styling for explore button to draw attention */
#explore-btn {
    background: var(--gradient-button-gold);
    font-size: 1.3em;
    padding: 15px 35px;
    animation: pulse 2s ease-in-out infinite;
}

#explore-btn:hover,
#explore-btn:focus {
    background: var(--gradient-button-gold-hover);
    transform: translateY(-5px) rotate(-2deg) scale(1.05);
}

/* Mute button styling */
#mute-btn {
    background: var(--gradient-button-purple);
}

#mute-btn:hover,
#mute-btn:focus {
    background: var(--gradient-button-purple-hover);
}

/* Volume slider styling */
#volume-slider {
    width: 100%;
    margin: var(--space-sm) 0;
    cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--color-purple);
    cursor: pointer;
    border-radius: 50%;
    border: var(--border-thin) solid var(--color-dark);
}

#volume-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--color-purple);
    cursor: pointer;
    border-radius: 50%;
    border: var(--border-thin) solid var(--color-dark);
}

#volume-slider::-webkit-slider-track {
    height: 8px;
    background: var(--color-gray-light);
    border-radius: var(--radius-sm);
    border: var(--border-thin) solid var(--color-dark);
}

#volume-slider::-moz-range-track {
    height: 8px;
    background: var(--color-gray-light);
    border-radius: var(--radius-sm);
    border: var(--border-thin) solid var(--color-dark);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 3px 3px 0 rgba(0,0,0,0.3);
    }
    50% {
        box-shadow: 3px 3px 0 rgba(0,0,0,0.3), 0 0 20px rgba(255, 215, 0, 0.6);
    }
}

.close-btn {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: var(--color-pink);
    color: var(--color-light);
    border: var(--border-base) solid var(--color-dark);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    font-size: var(--font-xl);
    cursor: pointer;
    font-weight: bold;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-base), background-color var(--transition-fast);
}

.close-btn:hover,
.close-btn:focus {
    background: var(--color-pink);
    filter: brightness(0.9);
    transform: rotate(90deg);
    outline: var(--border-thin) solid var(--color-light);
    outline-offset: var(--border-thin);
}

.close-btn:focus-visible {
    outline: var(--border-base) solid var(--color-purple);
    outline-offset: var(--border-base);
}

.hidden {
    display: none !important;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--color-light);
    border: var(--border-thick) solid var(--color-dark);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.help-section {
    margin: var(--space-xl) 0;
    padding: var(--space-lg);
    background: var(--color-gray-light);
    border-radius: var(--radius-md);
    border: var(--border-thin) solid var(--color-dark);
}

/* Help list styling */
.help-list {
    margin: var(--space-sm) 0;
    padding-left: var(--space-xl);
    list-style-type: disc;
}

.help-list li {
    margin: var(--space-xs) 0;
}

/* Reset button styling */
.reset-btn {
    background: var(--gradient-button-danger) !important;
    margin-top: var(--space-md) !important;
}

.reset-btn:hover {
    background: var(--gradient-button-danger-hover) !important;
    transform: translateY(-2px) scale(1.05);
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.help-section h3 {
    color: var(--color-purple);
    margin-bottom: var(--space-md);
    font-size: var(--font-lg);
}

.help-section p {
    line-height: var(--leading-relaxed);
    font-size: var(--font-base);
}

/* Responsive Design */
@media (max-width: 1024px) {
    #game-screen {
        grid-template-columns: 1fr 180px;
        height: 30%;
        min-height: 200px;
    }
    
    #cat-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    #game-container {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
    
    header {
        padding: 10px;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    .tagline {
        font-size: 0.9em;
    }
    
    #main-game {
        padding: 10px;
        gap: 8px;
    }
    
    #game-screen {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
    }
    
    #game-canvas {
        height: 200px;
    }
    
    #game-info {
        padding: 8px;
    }
    
    #cat-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 8px;
    }
    
    .cat-card {
        padding: 8px;
        min-height: 80px;
    }
    
    .cat-icon {
        font-size: 2em;
    }
    
    .main-btn {
        padding: 8px 15px;
        font-size: 0.95em;
    }
    
    #encounter-panel,
    .modal-content {
        padding: 20px;
        width: 95%;
    }
    
    #encounter-cat {
        font-size: 4em;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5em;
    }
    
    #cat-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 6px;
    }
    
    .cat-card {
        padding: 6px;
        min-height: 70px;
    }
    
    .cat-icon {
        font-size: 1.8em;
    }
    
    .cat-card h3 {
        font-size: 0.85em;
    }
}

/* ============================================
   ACHIEVEMENTS SYSTEM STYLES
   ============================================ */

.achievement-notification {
    position: fixed;
    bottom: 20px;
    right: -400px;
    width: 350px;
    background: var(--gradient-primary);
    color: white;
    padding: 15px;
    border-radius: 15px;
    border: 4px solid var(--color-dark);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: right 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 9999;
    animation: slideInRight var(--anim-duration-base) var(--anim-easing),
               pulse 2s ease-in-out 3 var(--anim-duration-base);
}

.achievement-notification.show {
    right: 20px;
}

.achievement-notification.legendary {
    background: var(--gradient-button-gold);
    animation: legendary-glow 2s infinite;
}

.achievement-notification.epic {
    background: linear-gradient(135deg, var(--color-rarity-epic) 0%, #8e24aa 100%);
}

.achievement-notification.rare {
    background: linear-gradient(135deg, var(--color-rarity-rare) 0%, #1976d2 100%);
}

@keyframes legendary-glow {
    0%, 100% { box-shadow: 0 10px 30px rgba(255, 215, 0, 0.5); }
    50% { box-shadow: 0 10px 50px rgba(255, 215, 0, 0.8); }
}

.achievement-icon {
    font-size: 48px;
    flex-shrink: 0;
}

.achievement-text {
    flex: 1;
}

.achievement-title {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.achievement-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 3px;
}

.achievement-desc {
    font-size: 13px;
    opacity: 0.9;
}

.side-panel {
    position: fixed;
    right: -450px;
    top: 50%;
    transform: translateY(-50%);
    width: 400px;
    max-height: 85vh;
    background: white;
    border: 5px solid var(--color-dark);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    transition: right 0.4s ease;
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.side-panel:not(.hidden) {
    right: 20px;
    animation: slideInRight var(--anim-duration-base) var(--anim-easing);
}

.panel-header {
    background: var(--gradient-secondary);
    padding: 15px;
    border-bottom: 4px solid var(--color-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.panel-header h3 {
    margin: 0;
    font-size: 24px;
    color: white;
}

.close-panel-btn {
    background: rgba(255,255,255,0.3);
    border: 3px solid white;
    color: white;
    font-size: 28px;
    font-weight: bold;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close-panel-btn:hover,
.close-panel-btn:focus {
    background: rgba(255,255,255,0.6);
    transform: rotate(90deg) scale(1.1);
    outline: 2px solid white;
}

.achievements-header {
    padding: 20px;
    text-align: center;
    background: #f5f5f5;
    border-bottom: 3px solid var(--color-dark);
}

.achievement-progress {
    font-size: 18px;
    font-weight: bold;
    color: #667eea;
    margin-top: 5px;
}

.achievements-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    overflow-y: auto;
    max-height: 600px;
}

.achievement-card {
    background: white;
    border: 3px solid var(--color-dark);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: help;
}

.achievement-card:not(.locked):hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.achievement-card.locked {
    opacity: 0.4;
    filter: grayscale(100%);
}

/* Cat Care Activities */
#care-panel {
.achievement-card.common { border-color: #b0bec5; }
.achievement-card.uncommon { border-color: #66bb6a; }
.achievement-card.rare { border-color: #42a5f5; }
.achievement-card.epic { border-color: #ab47bc; }
.achievement-card.legendary { 
    border-color: #ffa726;
    animation: legendary-pulse 2s infinite;
}

@keyframes legendary-pulse {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 167, 38, 0.5); }
    50% { box-shadow: 0 0 20px rgba(255, 167, 38, 0.8); }
}

.achievement-card-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.achievement-card-name {
    font-size: 12px;
    font-weight: bold;
    color: #333;
}

/* ============================================
   ANALYTICS DASHBOARD STYLES
   ============================================ */

.analytics-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    overflow-y: auto;
    max-height: calc(85vh - 100px);
}

.stat-card {
    background: white;
    border: 4px solid var(--color-dark);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.stat-card.primary { border-color: #667eea; }
.stat-card.secondary { border-color: #f5576c; }
.stat-card.success { border-color: #66bb6a; }
.stat-card.info { border-color: #42a5f5; }

.stat-icon {
    font-size: 48px;
    flex-shrink: 0;
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
    margin-bottom: 5px;
}

.stat-number {
    font-size: 32px;
    font-weight: bold;
    color: #333;
    line-height: 1;
    margin-bottom: 5px;
}

.stat-subtext {
    font-size: 12px;
    color: #888;
}

.stat-progress {
    margin-top: 8px;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    transition: width 1s ease;
}

.analytics-section {
    background: #f9f9f9;
    border: 3px solid var(--color-dark);
    border-radius: 12px;
    padding: 20px;
}

.analytics-section.full-width {
    grid-column: 1 / -1;
}

.analytics-section h4 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: #333;
}

.action-stats {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.action-stat {
    background: white;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.action-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.action-icon {
    font-size: 24px;
}

.action-name {
    font-weight: bold;
    font-size: 16px;
}

.action-bar-container {
    background: #e0e0e0;
    height: 30px;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 5px;
}

.action-bar {
    height: 100%;
    background: linear-gradient(90deg, #66bb6a 0%, #43a047 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 1s ease;
    min-width: 50px;
}

.action-rate {
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.action-details {
    font-size: 12px;
    color: #666;
    text-align: center;
}

.rarity-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rarity-bar {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.rarity-label {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: bold;
}

.rarity-bar-container {
    background: #e0e0e0;
    height: 25px;
    border-radius: 12px;
    overflow: hidden;
}

.rarity-bar-fill {
    height: 100%;
    transition: width 1s ease;
    border-radius: 12px;
}

.origin-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.origin-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 10px;
    align-items: center;
}

.origin-name {
    font-weight: bold;
    font-size: 14px;
}

.origin-bar-container {
    background: #e0e0e0;
    height: 25px;
    border-radius: 12px;
    overflow: hidden;
}

.origin-bar {
    height: 100%;
    background: linear-gradient(90deg, #42a5f5 0%, #1976d2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 1s ease;
    border-radius: 12px;
    min-width: 40px;
}

.origin-count {
    color: white;
    font-weight: bold;
    font-size: 13px;
}

.bests-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.best-stat {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    text-align: center;
}

.best-label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.best-value {
    display: block;
    font-size: 20px;
    font-weight: bold;
    color: #667eea;
}

/* ============================================
   ENHANCED VISUAL EFFECTS
   ============================================ */

.floating-text {
    position: fixed;
    font-size: 24px;
    font-weight: bold;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transform: translateY(0);
    transition: all 2s ease-out;
}

.floating-text.animate {
    opacity: 1;
    transform: translateY(-100px);
}

.energy-pulse {
    animation: energy-pulse 0.6s ease;
}

@keyframes energy-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); color: #ffd700; }
}

.legendary-pulse {
    animation: legendary-portrait-pulse 2s infinite;
}

@keyframes legendary-portrait-pulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.05); filter: brightness(1.2); }
}

/* Canvas particle effects are rendered directly */

/* ============================================
   RESPONSIVE ADJUSTMENTS FOR NEW FEATURES
   ============================================ */

@media (max-width: 1200px) {
    .side-panel {
        width: 350px;
    }
    
    .analytics-grid {
        grid-template-columns: 1fr;
    }
    
    .bests-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .side-panel {
        width: 90vw;
        right: -95vw;
    }
    
    .side-panel:not(.hidden) {
        right: 5vw;
    }
    
    .achievement-notification {
        width: 90vw;
        right: -95vw;
    }
    
    .achievement-notification.show {
        right: 5vw;
    }
}
/* ============================================================================
   PHASE 4.1: SMOOTH TRANSITIONS & ANIMATIONS
   ============================================================================ */

/* Animation Variables - Already defined in root variables above */

/* ============================================================================
   1. FADE ANIMATIONS FOR MODALS/DIALOGS
   ============================================================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -48%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

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

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -48%);
    }
}

/* Apply fade animation to all dialogs */
dialog[open] {
    animation: fadeIn var(--anim-duration-base) var(--anim-easing);
}
/* Animation already added to the dialog::backdrop rule above */

/* Closing animation (requires JS support) */
dialog.closing {
    animation: fadeOut var(--anim-duration-base) var(--anim-easing);
}

/* ============================================================================
   2. SLIDE ANIMATIONS FOR SIDE PANELS
   ============================================================================ */

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}
/* Animation applied in the original rule */

.side-panel.closing {
    animation: slideOutRight var(--anim-duration-base) var(--anim-easing);
}

/* ============================================================================
   3. HOVER EFFECTS WITH SMOOTH TRANSITIONS
   ============================================================================ */

/* Enhanced button hover effects */
.main-btn,
.action-btn,
.cat-card,
.achievement-card,
.minigame-card,
.environment-card {
    transition: 
        transform var(--anim-duration-fast) var(--anim-easing),
        box-shadow var(--anim-duration-fast) var(--anim-easing),
        filter var(--anim-duration-fast) var(--anim-easing);
}

.main-btn:hover:not(:disabled),
.action-btn:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.main-btn:active:not(:disabled),
.action-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.cat-card:hover,
.achievement-card:hover,
.minigame-card:hover,
.environment-card:hover:not(.locked) {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* Smooth icon transitions */
.cat-card .cat-icon,
.achievement-card .achievement-icon {
    transition: transform var(--anim-duration-fast) var(--anim-bounce);
}

.cat-card:hover .cat-icon,
.achievement-card:hover .achievement-icon {
    transform: scale(1.15) rotate(5deg);
}

/* ============================================================================
   4. CARD FLIP ANIMATIONS FOR COLLECTION
   ============================================================================ */

@keyframes cardFlip {
    0% {
        transform: perspective(600px) rotateY(0deg);
    }
    50% {
        transform: perspective(600px) rotateY(90deg);
    }
    100% {
        transform: perspective(600px) rotateY(0deg);
    }
}

.cat-card.newly-collected {
    animation: cardFlip 0.6s var(--anim-easing);
}

/* Card reveal animation for newly discovered cats */
@keyframes cardReveal {
    0% {
        opacity: 0;
        transform: scale(0.8) rotateY(-180deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotateY(0deg);
    }
}

.cat-card.revealing {
    animation: cardReveal var(--anim-duration-slow) var(--anim-bounce);
}

/* ============================================================================
   5. ENERGY REGENERATION VISUAL
   ============================================================================ */

@keyframes energyPulse {
    0%, 100% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.05);
        filter: brightness(1.2);
    }
}

#player-energy.regenerating {
    animation: energyPulse 2s ease-in-out infinite;
    color: var(--color-success);
    font-weight: bold;
}

/* Energy bar fill animation */
@keyframes energyFill {
    from {
        width: 0%;
    }
    to {
        width: var(--energy-percent);
    }
}

.energy-bar-fill {
    animation: energyFill var(--anim-duration-slow) var(--anim-easing);
}

/* ============================================================================
   6. CAT APPEARANCE ANIMATIONS
   ============================================================================ */

@keyframes catAppear {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(20px);
    }
    60% {
        opacity: 1;
        transform: scale(1.1) translateY(-5px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Animation already applied to #encounter-cat above */

/* Cat icon bounce on hover in encounter */
#encounter-cat:hover {
    animation: catBounce 0.5s ease-in-out;
}

@keyframes catBounce {
    0%, 100% {
        transform: translateY(0);
    }
    25% {
        transform: translateY(-10px);
    }
    50% {
        transform: translateY(0);
    }
    75% {
        transform: translateY(-5px);
    }
}

/* ============================================================================
   7. PARTICLE EFFECTS FOR SUCCESS
   ============================================================================ */

@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(0.5);
    }
}

.particle {
    position: absolute;
    pointer-events: none;
    font-size: 2em;
    animation: particleFloat 1s ease-out forwards;
    z-index: 9999;
}

/* Confetti animation for milestones */
@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(-100px) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg);
    }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    pointer-events: none;
    animation: confettiFall 3s ease-out forwards;
    z-index: 9999;
}

/* Sparkle effect for legendary cats */
@keyframes sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

.legendary-sparkle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, var(--color-gold) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    animation: sparkle 2s ease-in-out infinite;
}

.cat-card[data-rarity="legendary"] {
    position: relative;
    overflow: visible;
}

.cat-card[data-rarity="legendary"]::before,
.cat-card[data-rarity="legendary"]::after {
    content: '✨';
    position: absolute;
    font-size: 1.2em;
    animation: sparkle 2s ease-in-out infinite;
    pointer-events: none;
}

.cat-card[data-rarity="legendary"]::before {
    top: -10px;
    left: -10px;
    animation-delay: 0s;
}

.cat-card[data-rarity="legendary"]::after {
    bottom: -10px;
    right: -10px;
    animation-delay: 1s;
}

/* ============================================================================
   8. SHAKE ANIMATIONS FOR FAILURE
   ============================================================================ */

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

.shake-animation {
    animation: shake 0.5s ease-in-out;
}

/* Error shake for buttons */
@keyframes errorShake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

.error-shake {
    animation: errorShake 0.4s ease-in-out;
}

/* ============================================================================
   9. GLOW EFFECTS FOR SPECIAL ITEMS
   ============================================================================ */

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px var(--color-gold-glow),
                    0 0 10px var(--color-gold-glow);
    }
    50% {
        box-shadow: 0 0 20px var(--color-gold-glow-strong),
                    0 0 30px var(--color-gold-glow-strong);
    }
}

.glow-effect {
    animation: glow 2s ease-in-out infinite;
}

/* Achievement glow when unlocked */
.achievement-card.just-unlocked {
    animation: glow 1s ease-in-out 3;
    border-color: var(--color-gold);
}

/* ============================================================================
   10. PROGRESS BAR ANIMATIONS
   ============================================================================ */

@keyframes progressFill {
    from {
        transform: scaleX(0);
        transform-origin: left;
    }
    to {
        transform: scaleX(1);
        transform-origin: left;
    }
}

.progress-bar-fill {
    animation: progressFill var(--anim-duration-slow) var(--anim-easing);
}

/* ============================================================================
   11. PULSE ANIMATIONS FOR NOTIFICATIONS
   ============================================================================ */

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}
/* Animation used in .achievement-notification declaration */

/* Notification badge pulse */
@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

.notification-badge {
    animation: badgePulse 1s ease-in-out infinite;
}

/* ============================================================================
   12. LOADING ANIMATIONS
   ============================================================================ */

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

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-gray-mid);
    border-top-color: var(--color-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Skeleton loading animation */
@keyframes skeleton {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.skeleton {
    background: linear-gradient(90deg, 
        var(--color-gray-light) 25%, 
        var(--color-gray-mid) 50%, 
        var(--color-gray-light) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s ease-in-out infinite;
}

/* ============================================================================
   13. SMOOTH OPACITY TRANSITIONS
   ============================================================================ */

.fade-in {
    animation: fadeInSimple var(--anim-duration-base) var(--anim-easing);
}

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

.fade-out {
    animation: fadeOut var(--anim-duration-base) var(--anim-easing);
}

/* ============================================================================
   14. BOUNCE ANIMATIONS
   ============================================================================ */

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.bounce-in {
    animation: bounceIn var(--anim-duration-slow) var(--anim-bounce);
}

/* ============================================================================
   15. COLLECTION MILESTONE ANIMATIONS
   ============================================================================ */

@keyframes celebrationScale {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.1);
    }
    50% {
        transform: scale(0.95);
    }
    75% {
        transform: scale(1.05);
    }
}

.celebration-animation {
    animation: celebrationScale 0.6s ease-in-out;
}

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

/* Success Animation */
@keyframes success {
    0% { 
        transform: scale(1);
    }
    50% { 
        transform: scale(1.2);
    }
    100% { 
        transform: scale(1);
    }
}

.success-animation {
    animation: success 0.5s ease-in-out;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .cat-card,
    .main-btn,
    .action-btn {
        border-width: 5px;
    }
}

/* Keyboard navigation styles */
kbd {
    background-color: var(--color-gray-light);
    border: 2px solid var(--color-dark);
    border-radius: 5px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 0.9em;
}

/* Skip to content link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #f5576c;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* ============================================================================
   Daily Challenges Styles (Phase 5.1)
   ============================================================================ */

/* Challenges Panel Content */
#challenges-content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(85vh - 100px);
}

.challenges-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border: 3px solid var(--color-dark);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    color: white;
}

.streak-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.streak-icon {
    font-size: 40px;
    animation: flicker 2s infinite;
}

@keyframes flicker {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

.streak-number {
    font-size: 32px;
    font-weight: bold;
    line-height: 1;
}

.streak-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
}

.total-challenges {
    font-size: 14px;
}

.total-challenges strong {
    font-size: 24px;
    display: block;
}

.challenges-subtitle {
    margin-bottom: 20px;
}

.challenges-subtitle h4 {
    font-size: 20px;
    margin: 0 0 5px 0;
    color: var(--color-dark);
}

.challenges-subtitle p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* Challenge List */
.challenges-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Challenge Card */
.challenge-card {
    background: white;
    border: 4px solid var(--color-dark);
    border-radius: 15px;
    padding: 15px;
    display: flex;
    gap: 15px;
    align-items: flex-start;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.challenge-card:hover {
    transform: translateX(5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.challenge-card.completed {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-color: var(--rarity-uncommon);
}

.challenge-card.completed::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 60px 60px 0;
    border-color: transparent var(--rarity-uncommon) transparent transparent;
}

/* Difficulty Colors */
.challenge-card.difficulty-easy {
    border-left-width: 8px;
    border-left-color: var(--rarity-uncommon);
}

.challenge-card.difficulty-medium {
    border-left-width: 8px;
    border-left-color: var(--rarity-rare);
}

.challenge-card.difficulty-hard {
    border-left-width: 8px;
    border-left-color: var(--rarity-epic);
}

.challenge-icon {
    font-size: 48px;
    flex-shrink: 0;
}

.challenge-info {
    flex: 1;
    min-width: 0;
}

.challenge-name {
    font-size: 18px;
    font-weight: bold;
    margin: 0 0 5px 0;
    color: var(--color-dark);
}

.challenge-description {
    font-size: 14px;
    margin: 0 0 10px 0;
    color: #666;
}

/* Challenge Progress Bar */
.challenge-progress-bar {
    background: #e0e0e0;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
    border: 2px solid var(--color-dark);
}

.challenge-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.6s ease;
    border-radius: 4px;
}

.challenge-card.completed .challenge-progress-fill {
    background: linear-gradient(90deg, #66bb6a 0%, #43a047 100%);
}

/* Challenge Stats */
.challenge-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.challenge-progress-text {
    font-weight: bold;
    color: var(--color-dark);
}

.reward-text {
    color: #f5576c;
    font-weight: bold;
}

/* Completed Badge */
.completed-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--rarity-uncommon);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Challenges Info */
.challenges-info {
    margin-top: 20px;
    padding: 15px;
    background: #fff9c4;
    border: 3px solid #fbc02d;
    border-radius: 12px;
}

.challenges-info p {
    margin: 0;
    font-size: 14px;
    color: #333;
}

/* Challenge Notification */
.challenge-notification {
    position: fixed;
    top: 20px;
    right: -400px;
    background: white;
    border: 4px solid var(--rarity-uncommon);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 10000;
    transition: right 0.4s ease;
    max-width: 350px;
}

.challenge-notification.show {
    right: 20px;
    animation: bounceIn 0.6s ease;
}

@keyframes bounceIn {
    0% { transform: translateX(100%) scale(0.8); }
    50% { transform: translateX(-10px) scale(1.05); }
    100% { transform: translateX(0) scale(1); }
}

.notification-content {
    display: flex;
    gap: 15px;
    align-items: center;
}

.notification-icon {
    font-size: 48px;
    flex-shrink: 0;
}

.notification-text {
    flex: 1;
}

.notification-text strong {
    display: block;
    font-size: 18px;
    color: var(--color-dark);
    margin-bottom: 5px;
}

.notification-text p {
    margin: 0 0 5px 0;
    font-size: 14px;
    color: #666;
}

.notification-reward {
    color: #f5576c;
    font-weight: bold;
    font-size: 16px;
}

/* ============================================================================
   Encyclopedia Styles (Phase 6.5)
   ============================================================================ */

/* Encyclopedia Panel Content */
#encyclopedia-content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(85vh - 100px);
}

/* Encyclopedia Home */
.encyclopedia-home {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.encyclopedia-welcome {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    color: white;
}

.encyclopedia-welcome h3 {
    margin: 0 0 10px 0;
    font-size: 24px;
}

.encyclopedia-welcome p {
    margin: 0;
    font-size: 14px;
    opacity: 0.95;
}

/* Encyclopedia Progress */
.encyclopedia-progress {
    background: white;
    border: 3px solid var(--color-dark);
    border-radius: 15px;
    padding: 20px;
}

.encyclopedia-progress h4 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: var(--color-dark);
}

.progress-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: bold;
}

.encyclopedia-stat-icon {
    font-size: 24px;
}

.encyclopedia-progress-bar-container {
    background: #e0e0e0;
    height: 20px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--color-dark);
}

.encyclopedia-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 1s ease;
}

.stat-percentage {
    text-align: center;
    font-weight: bold;
    color: #667eea;
}

/* Encyclopedia Menu */
.encyclopedia-menu {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.encyclopedia-menu-btn {
    background: white;
    border: 4px solid var(--color-dark);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.encyclopedia-menu-btn:hover,
.encyclopedia-menu-btn:focus {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    outline: 2px solid #667eea;
}

.encyclopedia-menu-btn.quiz-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border-color: #f5576c;
    position: relative;
}

.menu-icon {
    font-size: 48px;
}

.encyclopedia-menu-btn h4 {
    margin: 0;
    font-size: 18px;
    color: var(--color-dark);
}

.encyclopedia-menu-btn.quiz-btn h4 {
    color: white;
}

.encyclopedia-menu-btn p {
    margin: 0;
    font-size: 13px;
    color: #666;
}

.encyclopedia-menu-btn.quiz-btn p {
    color: rgba(255,255,255,0.9);
}

.best-score {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.3);
    color: white;
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.encyclopedia-tip {
    background: #fff9c4;
    border: 3px solid #fbc02d;
    border-radius: 12px;
    padding: 15px;
}

.encyclopedia-tip p {
    margin: 0;
    font-size: 14px;
    color: #333;
}

/* Encyclopedia Header */
.encyclopedia-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--color-dark);
}

.encyclopedia-header h3 {
    margin: 0;
    font-size: 22px;
    flex: 1;
}

.back-btn {
    background: #e0e0e0;
    border: 3px solid var(--color-dark);
    border-radius: 10px;
    padding: 8px 15px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-btn:hover,
.back-btn:focus {
    background: #d0d0d0;
    transform: translateX(-3px);
}

/* Breed Guide */
.breed-guide {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.breed-section h4 {
    margin: 0 0 15px 0;
    font-size: 20px;
    color: var(--color-dark);
}

.environment-header {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 10px 15px;
    border-radius: 10px;
    border: 3px solid var(--color-dark);
}

.breed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
}

.breed-card {
    background: white;
    border: 3px solid var(--color-dark);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.breed-card:not(.locked):hover,
.breed-card:not(.locked):focus {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    outline: 2px solid #667eea;
}

.breed-card.locked {
    opacity: 0.5;
    filter: grayscale(100%);
}

.breed-icon {
    font-size: 48px;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 50%;
}

.breed-icon.common { background: rgba(176, 190, 197, 0.2); }
.breed-icon.uncommon { background: rgba(102, 187, 106, 0.2); }
.breed-icon.rare { background: rgba(66, 165, 245, 0.2); }
.breed-icon.epic { background: rgba(171, 71, 188, 0.2); }
.breed-icon.legendary { background: rgba(255, 167, 38, 0.2); }

.breed-name {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 5px;
    color: var(--color-dark);
}

.breed-origin {
    font-size: 12px;
    color: #666;
}

.locked-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
}

/* Breed Details */
.breed-details {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.breed-main-info {
    background: white;
    border: 4px solid var(--color-dark);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.breed-portrait {
    font-size: 80px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 50%;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.breed-basic-info {
    flex: 1;
}

.breed-basic-info h4 {
    margin: 0 0 10px 0;
    font-size: 24px;
    color: var(--color-dark);
}

.breed-description {
    margin: 0 0 15px 0;
    font-size: 14px;
    line-height: 1.6;
    color: #666;
}

.breed-meta {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.meta-item {
    font-size: 13px;
    color: #555;
}

.meta-item.rarity-common { color: var(--rarity-common); }
.meta-item.rarity-uncommon { color: var(--rarity-uncommon); }
.meta-item.rarity-rare { color: var(--rarity-rare); }
.meta-item.rarity-epic { color: var(--rarity-epic); }
.meta-item.rarity-legendary { color: var(--rarity-legendary); }

.breed-stats-section,
.breed-behavior-section,
.breed-facts-section {
    background: white;
    border: 3px solid var(--color-dark);
    border-radius: 15px;
    padding: 20px;
}

.breed-stats-section h4,
.breed-behavior-section h4,
.breed-facts-section h4 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: var(--color-dark);
}

.stat-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.breed-stat-bar-item {
    display: grid;
    grid-template-columns: 140px 1fr 50px;
    gap: 10px;
    align-items: center;
}

.breed-stat-label {
    font-size: 14px;
    font-weight: bold;
    color: var(--color-dark);
}

.breed-stat-bar {
    background: #e0e0e0;
    height: 24px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--color-dark);
}

.stat-fill {
    height: 100%;
    transition: width 0.8s ease;
    border-radius: 10px;
}

.stat-value {
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    color: var(--color-dark);
}

.breed-behavior-section p {
    margin: 0 0 10px 0;
    font-size: 14px;
    line-height: 1.6;
    color: #555;
}

.breed-behavior-section p:last-child {
    margin-bottom: 0;
}

.fact-box {
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
}

.fact-box p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #555;
}

/* Geography Map */
.geography-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.geography-intro {
    background: #fff9c4;
    border: 3px solid #fbc02d;
    border-radius: 12px;
    padding: 15px;
    margin: 0;
    font-size: 14px;
    color: #333;
}

.regions-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.region-card {
    background: white;
    border: 3px solid var(--color-dark);
    border-radius: 15px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.region-card:hover,
.region-card:focus {
    transform: translateX(5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    outline: 2px solid #667eea;
}

.region-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.region-header h4 {
    margin: 0;
    font-size: 18px;
    color: var(--color-dark);
}

.region-count {
    font-size: 12px;
    font-weight: bold;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 5px 10px;
    border-radius: 10px;
}

.region-fact {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

.region-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.region-cat-icon {
    font-size: 28px;
    opacity: 1;
    transition: transform 0.2s ease;
}

.region-cat-icon.locked {
    opacity: 0.3;
    filter: grayscale(100%);
}

.region-cat-icon:hover {
    transform: scale(1.2);
}

/* Fun Facts */
.fun-facts-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.facts-intro {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 12px;
    margin: 0;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
}

.facts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.fact-card {
    background: white;
    border: 3px solid var(--color-dark);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    gap: 15px;
    align-items: flex-start;
    transition: all 0.3s ease;
}

.fact-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.fact-number {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
}

.fact-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #555;
    flex: 1;
}

.facts-footer {
    text-align: center;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 12px;
    border: 3px solid var(--color-dark);
}

.facts-footer p {
    margin: 0;
    font-size: 14px;
}

.inline-link-btn {
    background: none;
    border: none;
    color: #667eea;
    font-weight: bold;
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    padding: 0;
}

.inline-link-btn:hover {
    color: #764ba2;
}

/* Quiz Styles */
.quiz-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.quiz-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border: 3px solid var(--color-dark);
    border-radius: 12px;
    padding: 15px;
    font-weight: bold;
}

.quiz-difficulty {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.quiz-question-card {
    background: white;
    border: 4px solid var(--color-dark);
    border-radius: 15px;
    padding: 30px;
}

.quiz-question {
    margin: 0 0 25px 0;
    font-size: 20px;
    color: var(--color-dark);
    line-height: 1.5;
}

.quiz-answers {
    display: grid;
    gap: 15px;
}

.quiz-answer-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 3px solid var(--color-dark);
    border-radius: 12px;
    padding: 18px;
    font-size: 16px;
    font-weight: bold;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quiz-answer-btn:hover,
.quiz-answer-btn:focus {
    transform: translateX(5px) scale(1.02);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    outline: 2px solid white;
}

.quiz-score-display {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    color: #667eea;
    padding: 15px;
    background: white;
    border: 3px solid var(--color-dark);
    border-radius: 12px;
}

/* Quiz Results */
.quiz-results {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.results-header {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    text-align: center;
    padding: 30px;
    border-radius: 15px;
    border: 4px solid var(--color-dark);
}

.results-grade {
    font-size: 80px;
    margin-bottom: 15px;
}

.results-header h4 {
    margin: 0 0 20px 0;
    font-size: 24px;
}

.results-score {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
}

.score-number {
    font-size: 64px;
    font-weight: bold;
    line-height: 1;
}

.score-divider {
    font-size: 32px;
}

.score-total {
    font-size: 32px;
}

.results-percentage {
    font-size: 28px;
    font-weight: bold;
}

.new-record {
    margin-top: 15px;
    background: rgba(255,255,255,0.3);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 18px;
    font-weight: bold;
}

.best-score-display {
    margin-top: 10px;
    font-size: 14px;
    opacity: 0.9;
}

.results-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.results-details {
    background: white;
    border: 3px solid var(--color-dark);
    border-radius: 15px;
    padding: 20px;
}

.results-details h4 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: var(--color-dark);
}

.answers-review {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-review-item {
    background: #f5f5f5;
    border: 3px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.answer-review-item.correct {
    border-color: var(--rarity-uncommon);
    background: rgba(102, 187, 106, 0.1);
}

.answer-review-item.incorrect {
    border-color: #f5576c;
    background: rgba(245, 87, 108, 0.1);
}

.review-number {
    background: var(--color-dark);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.review-content {
    flex: 1;
}

.review-question {
    margin: 0 0 8px 0;
    font-weight: bold;
    font-size: 14px;
    color: var(--color-dark);
}

.review-answer,
.review-correct {
    margin: 0 0 5px 0;
    font-size: 13px;
    color: #555;
}

.review-answer:last-child,
.review-correct:last-child {
    margin-bottom: 0;
}

.review-icon {
    font-size: 32px;
    flex-shrink: 0;
}

/* ============================================================================
   Mini-Games Styles
   ============================================================================ */

/* Mini-game Modal */
dialog#minigame-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 5px solid #333;
    border-radius: 15px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    z-index: 1000;
}

#care-panel h2 {
    color: #f5576c;
    font-size: 2em;
    text-align: center;
    margin-bottom: 20px;
}

#care-cat-info {
    text-align: center;
    margin-bottom: 25px;
    padding: 15px;
    background: #f0f0f0;
    border-radius: 10px;
    border: 3px solid #333;
}

#care-cat-icon {
    font-size: 4em;
    margin: 10px 0;
}

#care-cat-name {
    color: #764ba2;
    font-size: 1.5em;
    margin: 10px 0;
}

#care-happiness-bar {
    margin: 15px auto;
    max-width: 300px;
}

#care-happiness-bar label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
}

.happiness-bar-bg {
    background: #ddd;
    height: 25px;
    border-radius: 12px;
    border: 3px solid #333;
    overflow: hidden;
}

.happiness-bar-fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s;
    background: linear-gradient(90deg, #f093fb 0%, #f5576c 100%);
}

#care-activities {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.care-activity-btn {
    background: white;
    border: 4px solid #333;
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.care-activity-btn:hover {
    transform: translateY(-5px);
    box-shadow: 6px 8px 0px rgba(0,0,0,0.3);
    background: #fff9c4;
}

.care-activity-btn:active {
    transform: translateY(0);
    box-shadow: 2px 2px 0px rgba(0,0,0,0.2);
}

.care-activity-btn .activity-icon {
    font-size: 3em;
}

.care-activity-btn .activity-name {
    font-size: 1.3em;
    font-weight: bold;
    color: #764ba2;
}

.care-activity-btn .activity-desc {
    font-size: 0.9em;
    color: #666;
    text-align: center;
}

#cat-happiness {
    margin: 15px 0;
    padding: 12px;
    background: #fff9c4;
    border-radius: 10px;
    border: 3px solid #333;
    text-align: center;
    font-weight: bold;
}

/* Training Minigame */
#training-game {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 5px solid #333;
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    z-index: 1001;
    text-align: center;
}

#training-game h2 {
    color: #f5576c;
    font-size: 2em;
    margin-bottom: 15px;
}

#training-instructions {
    font-size: 1.1em;
    margin-bottom: 20px;
    color: #333;
}

#training-arena {
    position: relative;
    background: linear-gradient(to bottom, #87ceeb 0%, #98d8c8 100%);
    border: 4px solid #333;
    border-radius: 15px;
    height: 300px;
    margin: 20px 0;
    overflow: hidden;
}

#training-cat {
    position: absolute;
    font-size: 4em;
    transition: all 0.3s;
    cursor: default;
}

#training-treat {
    position: absolute;
    font-size: 3em;
    cursor: pointer;
    transition: all 0.2s;
    animation: treatBounce 0.5s infinite;
}

#training-treat:hover {
    transform: scale(1.2);
}

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

#training-score {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
}

#training-score p {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #care-activities {
        grid-template-columns: 1fr;
    }
}
    background: var(--color-light);
    border: var(--border-thick) solid var(--color-dark);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
}

dialog#minigame-modal[open] {
    display: block;
}

#minigame-modal .modal-content {
    width: 100%;
}

#minigame-modal h2 {
    color: var(--color-purple);
    text-align: center;
    margin-bottom: var(--space-md);
    font-size: var(--font-xl);
}

/* Game selection and game screen visibility */
#minigame-modal #game-selection {
    display: block;
}

#minigame-modal #minigame-screen {
    display: none;
    min-height: 400px;
}

/* Game Selection Grid */
.game-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.game-select-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: var(--border-thick) solid var(--color-dark);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    color: white;
    text-align: center;
    font-family: var(--font-main);
}

.game-select-btn:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.game-select-btn:active {
    transform: translateY(-2px);
}

.game-select-btn .game-icon {
    font-size: var(--font-3xl);
    display: block;
    margin-bottom: var(--space-xs);
}

.game-select-btn h3 {
    font-size: var(--font-md);
    margin: var(--space-xs) 0;
    color: white;
}

.game-select-btn p {
    font-size: var(--font-sm);
    margin: var(--space-xs) 0;
    opacity: 0.9;
}

.game-select-btn .high-score {
    margin-top: var(--space-sm);
    font-weight: bold;
    font-size: var(--font-md);
    opacity: 1;
}

.minigame-header {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.minigame-header h3 {
    font-size: var(--font-xl);
    color: var(--color-purple);
    margin-bottom: var(--space-xs);
}

.minigame-header p {
    font-size: var(--font-md);
    color: var(--color-dark);
    margin: var(--space-xs) 0;
}

.minigame-score {
    font-size: var(--font-lg);
    font-weight: bold;
    color: var(--color-purple);
}

.minigame-status {
    text-align: center;
    margin: var(--space-lg) 0;
    font-size: var(--font-lg);
    font-weight: bold;
    color: var(--color-purple);
}

.minigame-result {
    font-size: var(--font-xl);
    font-weight: bold;
    color: var(--color-purple);
    padding: var(--space-md);
    background: var(--color-yellow);
    border-radius: var(--radius-md);
    margin: var(--space-lg) 0;
}

/* Game 1: Follow the Treat */
.treat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    margin: var(--space-lg) 0;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.treat-button {
    aspect-ratio: 1;
    font-size: var(--font-3xl);
    background: linear-gradient(135deg, #f5af19 0%, #f12711 100%);
    border: var(--border-thick) solid var(--color-dark);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.treat-button:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.treat-button.treat-active {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(245, 175, 25, 0.8);
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
}

/* Game 2: Cat Toy Chase */
.chase-area {
    position: relative;
    background: linear-gradient(to bottom, #87ceeb 0%, #98d8c8 50%, #90ee90 100%);
    border: var(--border-thick) solid var(--color-dark);
    border-radius: var(--radius-lg);
    height: 400px;
    margin: var(--space-lg) 0;
    overflow: hidden;
}

.toy-target {
    position: absolute;
    width: 50px;
    height: 50px;
    font-size: var(--font-2xl);
    background: white;
    border: 3px solid var(--color-dark);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-md);
}

.toy-target:hover {
    transform: scale(1.2);
}

.toy-target:active {
    transform: scale(0.9);
}

/* Game 3: Hide and Seek */
.seek-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: var(--space-sm);
    margin: var(--space-lg) 0;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.seek-box {
    aspect-ratio: 1;
    font-size: var(--font-2xl);
    background: linear-gradient(135deg, #8e9eab 0%, #eef2f3 100%);
    border: var(--border-thick) solid var(--color-dark);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.seek-box:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, #a8b8c8 0%, #f0f4f7 100%);
}

.seek-box.seek-found {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    animation: foundPulse 0.5s ease;
}

.seek-box.seek-wrong {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    animation: wrongShake 0.5s ease;
}

@keyframes foundPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Responsive Mini-games */
@media (max-width: 768px) {
    .game-selection-grid {
        grid-template-columns: 1fr;
    }
    
    .treat-grid {
        gap: var(--space-sm);
    }
    
    .chase-area {
        height: 300px;
    }
    
    .seek-grid {
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    }
}

/* ============================================================================
   PHASE 4.2: LOADING STATES
   ============================================================================ */

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity var(--anim-duration-slow) ease-out;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: var(--color-light);
    animation: fadeInSimple 0.5s ease-out;
}

.loading-cat {
    font-size: 4em;
    margin-bottom: var(--space-lg);
    animation: catBounce 1s ease-in-out infinite;
}

.loading-overlay-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--color-light);
    border-radius: 50%;
    margin: 0 auto var(--space-lg);
    animation: spin 1s linear infinite;
}

.loading-text {
    font-size: var(--font-xl);
    font-weight: bold;
    margin-bottom: var(--space-sm);
}

.loading-subtext {
    font-size: var(--font-md);
    opacity: 0.9;
}

/* Skeleton Loading for Collection Grid */
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-md);
    padding: var(--space-lg);
}

.skeleton-card {
    background: var(--color-gray-light);
    border: var(--border-base) solid var(--color-gray-mid);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    height: 180px;
    position: relative;
    overflow: hidden;
}

.skeleton-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.5),
        transparent
    );
    animation: skeletonShimmer 1.5s infinite;
}

@keyframes skeletonShimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.skeleton-icon {
    width: 80px;
    height: 80px;
    background: var(--color-gray-mid);
    border-radius: 50%;
    margin: 0 auto var(--space-sm);
}

.skeleton-title {
    width: 80%;
    height: 16px;
    background: var(--color-gray-mid);
    border-radius: 4px;
    margin: 0 auto var(--space-sm);
}

.skeleton-text {
    width: 60%;
    height: 12px;
    background: var(--color-gray-mid);
    border-radius: 4px;
    margin: 0 auto;
}

/* Loading State for Buttons */
.main-btn.loading,
.action-btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
    cursor: not-allowed;
}

.main-btn.loading::after,
.action-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--color-light);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Loading Pulse for Content */
.loading-pulse {
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Progress Bar Container */
.progress-bar-container {
    width: 100%;
    margin: var(--space-sm) 0;
}

.progress-bar-container .progress-bar {
    width: 100%;
    height: 8px;
    background: var(--color-gray-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-container .progress-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transition: width var(--anim-duration-base) ease-out;
    animation: progressShine 1.5s ease-in-out infinite;
}

@keyframes progressShine {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* Loading Dots Animation */
.loading-dots {
    display: inline-block;
}

.loading-dots::after {
    content: '.';
    animation: loadingDots 1.5s steps(4, end) infinite;
}

@keyframes loadingDots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60% {
        content: '...';
    }
    80%, 100% {
        content: '';
    }
}

/* Spinner in Modal/Dialog */
.modal-loading,
.dialog-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.modal-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-gray-mid);
    border-top-color: var(--color-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Inline Loading Indicator */
.inline-loading {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}

.inline-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-gray-mid);
    border-top-color: var(--color-purple);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Reduced Motion for Loading States */
@media (prefers-reduced-motion: reduce) {
    .loading-cat {
        animation: none;
    }
    
    .skeleton-card::before {
        animation: none;
    }
    
    .progress-bar-fill {
        animation: none;
    }
    
    .loading-dots::after {
        animation: none;
        content: '...';
    }
}

/* Print styles */
@media print {
    #controls,
    .close-btn,
    #encounter-panel,
    .modal {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    #game-container {
        box-shadow: none;
        border: none;
    }
}

/* ============================================================================
   TUTORIAL & ONBOARDING SYSTEM (v2.9.0)
   ============================================================================ */

.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.tutorial-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.tutorial-box {
    position: relative;
    background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
    border: 5px solid #333;
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 10001;
}

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.tutorial-header h3 {
    margin: 0;
    font-size: var(--font-xl);
    color: #333;
}

.tutorial-skip-btn {
    background: #e0e0e0;
    border: 2px solid #999;
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-md);
    font-size: var(--font-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.tutorial-skip-btn:hover {
    background: #d0d0d0;
    transform: scale(1.05);
}

.tutorial-body {
    margin-bottom: var(--space-xl);
}

.tutorial-body p {
    font-size: var(--font-base);
    line-height: 1.6;
    color: #333;
    margin: 0;
}

.tutorial-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tutorial-progress {
    font-size: var(--font-sm);
    color: #666;
    font-weight: bold;
}

.tutorial-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 3px solid #333;
    border-radius: var(--radius-sm);
    padding: var(--space-md) var(--space-xl);
    font-size: var(--font-md);
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition-fast);
}

.tutorial-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.tutorial-highlight {
    position: relative;
    box-shadow: 0 0 0 4px #ffd54f, 0 0 20px rgba(255, 213, 79, 0.6) !important;
    animation: tutorialPulse 2s ease-in-out infinite;
}

@keyframes tutorialBounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes tutorialPulse {
    0%, 100% {
        box-shadow: 0 0 0 4px #ffd54f, 0 0 20px rgba(255, 213, 79, 0.6);
    }
    50% {
        box-shadow: 0 0 0 8px #ffd54f, 0 0 30px rgba(255, 213, 79, 0.8);
    }
}

/* Tooltips */
.tooltip {
    position: fixed;
    background: #333;
    color: white;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    font-size: var(--font-sm);
    max-width: 250px;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tooltip::before {
    content: '';
    position: absolute;
    border: 6px solid transparent;
}

.tooltip-top::before {
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: #333;
}

.tooltip-bottom::before {
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-color: #333;
}

.tooltip-left::before {
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    border-left-color: #333;
}

.tooltip-right::before {
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    border-right-color: #333;
}

.tooltip-icon {
    display: inline-block;
    margin-left: 5px;
    opacity: 0.6;
    font-size: 0.8em;
    cursor: help;
    transition: opacity 0.2s;
}

button:hover .tooltip-icon,
.stat-item:hover .tooltip-icon {
    opacity: 1;
}

/* ============================================================================
   MILESTONE REWARDS SYSTEM (v2.9.0)
   ============================================================================ */

.milestones-panel {
    padding: var(--space-xl);
}

.milestones-panel h3 {
    font-size: var(--font-2xl);
    margin-bottom: var(--space-md);
    text-align: center;
    color: #333;
}

.milestones-description {
    text-align: center;
    color: #666;
    margin-bottom: var(--space-xl);
    font-size: var(--font-md);
}

.milestones-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-xl);
}

.milestone-card {
    background: white;
    border: 4px solid #333;
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    transition: var(--transition-base);
    position: relative;
    overflow: hidden;
}

.milestone-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #b0bec5, #90a4ae);
}

.milestone-card.rarity-common::before {
    background: linear-gradient(90deg, var(--color-rarity-common), #90a4ae);
}

.milestone-card.rarity-uncommon::before {
    background: linear-gradient(90deg, var(--color-rarity-uncommon), #4caf50);
}

.milestone-card.rarity-rare::before {
    background: linear-gradient(90deg, var(--color-rarity-rare), #1e88e5);
}

.milestone-card.rarity-epic::before {
    background: linear-gradient(90deg, var(--color-rarity-epic), #8e24aa);
}

.milestone-card.rarity-legendary::before {
    background: linear-gradient(90deg, var(--color-rarity-legendary), #ff8f00);
}

.milestone-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.milestone-card.milestone-completed {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-color: #4caf50;
}

.milestone-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.milestone-icon-large {
    font-size: 3em;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.milestone-header h4 {
    margin: 0;
    font-size: var(--font-lg);
    color: #333;
}

.milestone-desc {
    color: #666;
    margin-bottom: var(--space-lg);
    font-size: var(--font-sm);
}

.milestone-progress {
    margin-bottom: var(--space-md);
}

.milestone-progress .progress-bar-container {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border: 2px solid #333;
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

.milestone-progress .progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #66bb6a);
    transition: width 0.5s ease-out;
    position: relative;
}

.milestone-progress .progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.milestone-progress .progress-text {
    text-align: center;
    margin-top: var(--space-xs);
    font-size: var(--font-sm);
    font-weight: bold;
    color: #333;
}

.milestone-reward-display {
    text-align: center;
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 2px solid #e0e0e0;
}

.milestone-claimed {
    color: #4caf50;
    font-weight: bold;
    font-size: var(--font-md);
}

.milestone-pending {
    color: #ff9800;
    font-weight: bold;
    font-size: var(--font-sm);
}

.milestone-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: linear-gradient(135deg, #fff9c4 0%, #fff59d 100%);
    border: 5px solid #333;
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    max-width: 400px;
    z-index: 9999;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: all 0.5s ease-out;
    cursor: pointer;
}

.milestone-content {
    display: flex;
    gap: var(--space-lg);
    align-items: center;
}

.milestone-notification .milestone-icon {
    font-size: 4em;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.milestone-text h3 {
    margin: 0 0 var(--space-xs) 0;
    font-size: var(--font-xl);
    color: #333;
}

.milestone-text h4 {
    margin: 0 0 var(--space-sm) 0;
    font-size: var(--font-lg);
    color: #555;
}

.milestone-text p {
    margin: var(--space-xs) 0;
    font-size: var(--font-sm);
    color: #666;
}

.milestone-reward {
    font-weight: bold;
    color: #ff6f00;
    font-size: var(--font-md) !important;
}

/* ============================================================================
   PERSONALITY TRAITS SYSTEM (v2.9.0)
   ============================================================================ */

.personality-trait {
    background: white;
    border: 3px solid #9575cd;
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin: var(--space-md) 0;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.personality-icon {
    font-size: 2.5em;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.personality-info strong {
    display: block;
    font-size: var(--font-lg);
    color: #333;
    margin-bottom: var(--space-xs);
}

.personality-info p {
    margin: 0;
    color: #666;
    font-size: var(--font-sm);
}

.personality-filter {
    margin: var(--space-xl) 0;
    padding: var(--space-lg);
    background: #f5f5f5;
    border: 3px solid #333;
    border-radius: var(--radius-md);
}

.personality-filter h4 {
    margin: 0 0 var(--space-md) 0;
    font-size: var(--font-lg);
    color: #333;
    text-align: center;
}

.personality-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
}

.filter-btn {
    background: white;
    border: 3px solid #333;
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-sm);
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition-fast);
}

.filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.filter-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-2px) scale(1.05);
}

.personality-stats-panel {
    padding: var(--space-xl);
}

.personality-stats-panel h3 {
    font-size: var(--font-2xl);
    margin-bottom: var(--space-md);
    text-align: center;
    color: #333;
}

.panel-description {
    text-align: center;
    color: #666;
    margin-bottom: var(--space-xl);
    font-size: var(--font-md);
}

.personality-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--space-lg);
}

.personality-stat-card {
    background: white;
    border: 3px solid #333;
    border-left-width: 4px;
    border-radius: var(--radius-md);
    padding: var(--space-md);
    transition: var(--transition-base);
}

.personality-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.personality-stat-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.personality-icon-large {
    font-size: 2em;
}

.personality-stat-header h4 {
    margin: 0;
    font-size: var(--font-md);
    color: #333;
}

.personality-stat-progress {
    margin-top: var(--space-md);
}

.personality-hint {
    margin-top: var(--space-sm);
    font-size: var(--font-xs);
    color: #888;
    font-style: italic;
}

/* Responsive adjustments for new features */
@media (max-width: 768px) {
    .tutorial-box {
        padding: var(--space-lg);
        max-width: 95%;
    }
    
    .milestones-grid,
    .personality-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .milestone-notification {
        max-width: 90%;
        padding: var(--space-md);
    }
    
    .milestone-content {
        flex-direction: column;
        text-align: center;
    }
}

/* Accessibility for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .tutorial-box,
    .tutorial-highlight {
        animation: none !important;
    }
    
    .tutorial-btn:hover,
    .milestone-card:hover {
        transform: none;
    }
    
    .progress-bar-fill::after {
        animation: none;
    }
}


