/* Import Google Font - Outfit */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&display=swap');

/* CSS Variables for Premium Mobile Theme */
:root {
    /* Primary Palette - Royal Midnight & Gold */
    --primary: #FFD700;      /* Pure Gold */
    --primary-light: #FDE68A;
    --primary-dark: #B45309;
    
    --secondary: #6366F1;    /* Indigo */
    --secondary-light: #818CF8;
    --secondary-dark: #4338CA;

    --accent: #F472B6;       /* Rose */
    --accent-glow: rgba(255, 215, 0, 0.4);

    /* Backgrounds */
    --bg-gradient: radial-gradient(circle at top center, #1e1b4b 0%, #020617 100%); /* Deep Navy to Absolute Dark */
    --card-bg: rgba(30, 41, 59, 0.6); /* Semi-transparent dark slate */
    --glass-shiny: rgba(255, 255, 255, 0.08);
    
    /* Text */
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    
    /* Borders & Shadows */
    --border-light: rgba(255, 215, 0, 0.15); /* Subtle gold border */
    --border-shine: rgba(255, 215, 0, 0.3);
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px rgba(255, 215, 0, 0.2);

    /* UI Dimensions */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    
    /* Animation */
    --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reduced Motion Preference & Settings Override */
body.no-animations *,
body.no-animations *::before,
body.no-animations *::after {
    animation-duration: 0.01s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01s !important;
    scroll-behavior: auto !important;
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Remove mobile tap highlight */
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    overflow: hidden; /* Prevent scrolling on main container */
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background Texture/Shine */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(79, 70, 229, 0.15) 0%, transparent 60%);
    z-index: -1;
    pointer-events: none;
    animation: pulseBg 10s ease-in-out infinite alternate;
}

@keyframes pulseBg {
    from { transform: scale(1); opacity: 0.8; }
    to { transform: scale(1.1); opacity: 1; }
}

/* Common UI Elements */
button {
    font-family: inherit;
    border: none;
    outline: none;
    cursor: pointer;
    user-select: none;
}

/* Screen Management */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s var(--smooth);
    pointer-events: none;
    z-index: 10;
    backdrop-filter: blur(0px); /* Performance optimization, blur only when active if needed */
}

.screen.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    backdrop-filter: blur(10px);
}

/* Container Glass Effect */
.glass-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-top-color: var(--border-shine);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    transform: translateY(20px);
    transition: transform 0.5s var(--bounce);
}

.screen.active .glass-panel {
    transform: translateY(0);
}

/* Typography */
h1 {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.1;
    text-align: center;
    background: linear-gradient(to right, #fff, #a5b4fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 10px rgba(79, 70, 229, 0.3));
    margin-bottom: 8px;
}

h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    text-align: center;
    margin-bottom: 16px;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

p {
    color: var(--text-muted);
    line-height: 1.6;
    text-align: center;
    font-size: 1rem;
}

/* Buttons */
.menu-btn {
    width: 100%;
    padding: 20px 24px; /* Increased vertical padding */
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    font-size: 1.25rem; /* Larger font */
    font-weight: 700; /* Bolder text */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px; /* Wider gap between icon and text */
    transition: all 0.2s var(--smooth);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.5px;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-md);
}

.menu-btn:active {
    transform: translateY(0);
}

.menu-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    box-shadow: var(--shadow-glow);
    color: #1e1b4b; /* Dark text for contrast on gold */
}

.menu-btn.primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 0 30px rgba(79, 70, 229, 0.6);
}

/* Turn Menu Button into 3-Dot (Kebab) Menu */
.hamburger-btn {
    flex-direction: column;
    gap: 4px;
    padding: 0;
    width: 44px;
    height: 44px;
    align-items: center; /* Center dots horizontally */
    justify-content: center;
    /* Transparent, no border look */
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important; /* Subtle hover only */
    border-radius: 50%;
}

.hamburger-btn span {
    width: 5px;
    height: 5px;
    background-color: #fff;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.hamburger-btn:hover span:nth-child(1) { transform: translateY(-2px); }
.hamburger-btn:hover span:nth-child(3) { transform: translateY(2px); }

/* Remove old btn-icon styles for hamburger */
.btn-icon {
    font-size: 1.6rem;
}

/* Back Button */
.back-btn {
    margin-top: 16px;
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.back-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* --- Loading Screen --- */
#loadingScreen {
    z-index: 100;
    background: var(--bg-gradient); /* Opaque background for loading */
}

.logo-icon {
    font-size: 5rem;
    margin-bottom: 24px;
    filter: drop-shadow(0 0 30px rgba(79, 70, 229, 0.6));
    animation: floatIcon 3s ease-in-out infinite;
}

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

.loading-bar {
    width: 240px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin: 32px 0 12px;
    position: relative;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    width: 0%;
    border-radius: 10px;
    transition: width 0.3s ease-out;
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.5);
    position: relative;
    overflow: hidden;
}

.loading-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    transform: translateX(-100%);
    animation: shimmer 1.5s infinite;
}

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

/* --- Home Screen --- */
.menu-container {
    width: 100%;
    max-width: 380px; /* Constrain width for optimal button size */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-title {
    margin-bottom: 48px; /* More space below title */
    text-align: center;
}

.home-logo {
    font-size: 6rem;
    line-height: 1;
    margin-bottom: 16px;
    display: inline-block;
    filter: drop-shadow(0 0 40px rgba(99, 102, 241, 0.6)); /* Indigo glow */
    animation: floatIcon 4s ease-in-out infinite;
}

.game-title .subtitle {
    font-size: 1.1rem;
    letter-spacing: 3px; /* Premium spacing */
    text-transform: uppercase;
    font-weight: 600;
    color: var(--accent);
    text-shadow: 0 0 10px rgba(244, 114, 182, 0.4);
    margin-top: 8px;
    display: block;
}

.menu-buttons {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px; /* Increased gap */
}

/* --- Level Screen --- */
/* --- Level Screen --- */
.level-container {
    width: 100%;
    max-width: 420px;
}

.screen-header {
    text-align: center;
    margin-bottom: 24px;
}

.screen-header h2 {
    font-size: 2rem;
    margin-bottom: 8px;
    background: linear-gradient(to right, #fff, var(--primary-light));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.screen-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

.level-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.level-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s var(--smooth);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.level-item:hover {
    transform: translateX(5px);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-shine);
}

.level-item:active {
    transform: scale(0.98);
}

.level-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-right: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.level-details {
    flex: 1;
}

.level-details h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
    color: var(--text-main);
    font-weight: 700;
}

.level-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.play-indicator {
    opacity: 0.5;
    color: var(--text-muted);
    font-size: 1rem;
    transition: all 0.3s var(--bounce);
}

.level-item:hover .play-indicator {
    opacity: 1;
    color: var(--primary);
    transform: translateX(3px);
}

/* Specific Level Styling */
.level-item.easy .level-icon-wrapper {
    background: rgba(16, 185, 129, 0.2);
    color: #34D399; /* Emerald */
    border-color: rgba(16, 185, 129, 0.3);
}

.level-item.medium .level-icon-wrapper {
    background: rgba(245, 158, 11, 0.2);
    color: #FBBF24; /* Amber */
    border-color: rgba(245, 158, 11, 0.3);
}

.level-item.hard .level-icon-wrapper {
    background: rgba(239, 68, 68, 0.2);
    color: #F87171; /* Red */
    border-color: rgba(239, 68, 68, 0.3);
}

.level-item.easy:hover { border-color: #34D399; box-shadow: 0 0 15px rgba(52, 211, 153, 0.15); }
.level-item.medium:hover { border-color: #FBBF24; box-shadow: 0 0 15px rgba(251, 191, 36, 0.15); }
.level-item.hard:hover { border-color: #F87171; box-shadow: 0 0 15px rgba(248, 113, 113, 0.15); }

/* --- Game Screen --- */
#gameScreen {
    padding: 16px; 
    justify-content: flex-start; /* Start from top to ensure fit */
    padding-top: max(20px, env(safe-area-inset-top)); /* Safe area for mobiles */
}

/* Game Screen Layout */
.game-top-bar {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0; /* Removed horizontal padding to push to edges */
    margin-bottom: 20px;
    /* Removed pill styling for cleaner look */
    background: transparent;
    border: none;
    box-shadow: none;
}

.game-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 10px rgba(0,0,0,0.3));
}

.brand-text {
    font-size: 1.8rem; /* Larger text */
    font-weight: 800;
    /* Premium Gold Gradient */
    background: linear-gradient(135deg, #FFD700 20%, #FDB931 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 20px rgba(253, 185, 49, 0.2);
    letter-spacing: 0.5px;
}

.stats-bar {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03); /* Lighter, more subtle */
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    padding: 16px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    min-width: 60px;
}

.info-item .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.info-item span:last-child {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.info-item.badge span:last-child {
    font-size: 0.9rem;
    background: rgba(16, 185, 129, 0.2); /* Low opacity var(--primary) */
    color: var(--primary-light);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.game-controls {
    display: flex;
    gap: 12px;
}

.control-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%; /* Perfect circle */
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Game Grid Container */
.game-wrapper {
    width: 100%;
    max-width: 600px;
    perspective: 1000px;
    flex: 1; /* Allow it to take available space */
    display: flex;
    align-items: center; /* Center vertically */
    justify-content: center;
}

.cards {
    display: grid;
    gap: 12px;
    width: 100%;
    max-width: 450px; /* Cap width for larger screens */
    margin: 0 auto;
    padding: 0;
    list-style: none;
    /* Aspect ratio will be handled by grid setup */
}

.card {
    position: relative;
    cursor: pointer;
    perspective: 1000px;
    transform-style: preserve-3d;
    aspect-ratio: 1; /* Ensure square cards */
}

/* Card Visuals */
.view {
    width: 100%;
    height: 100%;
    position: absolute;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    transition: transform 0.35s var(--bounce);
    box-shadow: var(--shadow-sm);
    user-select: none;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.front-view {
    background: linear-gradient(135deg, rgba(30, 27, 75, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
    border: 1px solid var(--border-light);
}

.front-view img {
    width: 40%;
    opacity: 1;
    transition: transform 0.3s var(--bounce);
}

.card:hover .front-view img {
    transform: scale(1.1);
}

.back-view {
    transform: rotateY(-180deg);
    background: rgba(255, 255, 255, 0.95); /* Light background for images to pop */
}

.back-view img {
    max-width: 70%;
    max-height: 70%;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.card.flip .back-view {
    transform: rotateY(0);
}

.card.flip .front-view {
    transform: rotateY(180deg);
}

.card.matched .view {
    border-color: var(--secondary);
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.4);
}

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

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

/* Grid Layouts - Using flexible sizing */
.cards.grid-4x4 {
    grid-template-columns: repeat(4, 1fr);
}

.cards.grid-4x6 {
    grid-template-columns: repeat(4, 1fr);
}

.cards.grid-6x6 {
    grid-template-columns: repeat(6, 1fr);
    gap: 8px; /* Tighter gap for denser grid */
}

/* Mobile Responsiveness for Grid */
@media screen and (max-height: 700px) and (orientation: portrait) {
    .game-header {
        margin-bottom: 10px;
        padding: 8px 16px;
    }
    
    .cards {
        max-width: 90vw; /* Use almost full width */
        gap: 8px;
    }
    
    .view {
        border-radius: 8px;
    }
}

/* Adjustments for Landscape Mode on Mobile and Small Desktops (800x450, 800x600) */
@media screen and (max-height: 640px) and (orientation: landscape) {
    #gameScreen {
        flex-direction: row;
        align-items: center;
        gap: 24px;
    }
    
    .game-top-bar {
        padding: 0 10px;
    }

    .brand-text {
        font-size: 1.2rem;
    }

    .stats-bar {
        padding: 10px;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
        flex-direction: column;
        max-width: 240px; /* Constrain width to behave like sidebar if redundant with responsive.css */
    }
    
    .game-wrapper {
        height: 100%;
        width: auto;
    }
    
    .cards {
        height: 90vh;
        width: 90vh; /* Make it square based on height */
        max-width: none;
    }

    .card {
        width: 72px;
        height: 72px;
    }
}

/* --- Settings & About Items --- */

#settingsScreen {
    padding: 0;
}

/* --- Settings Screen Layout --- */
.settings-container {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-top-color: var(--border-shine);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    transform: translateY(20px);
    transition: transform 0.5s var(--bounce);
}

.screen.active .settings-container {
    transform: translateY(0);
}

.settings-options {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px; /* Increased gap for better spacing */
}

/* Base Styles for Settings Items */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: var(--radius-sm);
    width: 100%;
}

.toggle-switch {
    width: 50px;
    height: 28px;
    position: relative;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 34px;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* --- Info Container (Shared by How To Play & About) --- */
.info-container {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-top-color: var(--border-shine);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 480px; /* Slightly wider for text content */
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    max-height: 85vh; /* Prevent overflow on small screens */
    overflow-y: auto; /* Allow scrolling if content is long */
}

/* Custom Scrollbar for Info Container */
.info-container::-webkit-scrollbar {
    width: 6px;
}

.info-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.info-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* --- How to Play Styles --- */
.instructions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.instruction-step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s ease;
}

.instruction-step:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(5px);
    border-color: rgba(255, 255, 255, 0.1);
}

.step-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #1e1b4b; /* Dark text for contrast against gold */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(255, 215, 0, 0.3);
}

.step-content {
    flex: 1;
    text-align: left;
}

.step-content h3 {
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 4px;
    text-align: left; /* Override default centered h3 */
}

.step-content p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.4;
    text-align: left; /* Override default centered p */
    margin: 0;
}

/* --- About Screen Styles --- */
.about-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    text-align: left;
}

.about-section h3 {
    font-size: 1.2rem;
    color: var(--primary);
    margin-bottom: 12px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
}

.about-section ul {
    list-style: none;
    padding: 0;
    display: grid;
    gap: 8px;
}

.about-section ul li {
    padding-left: 20px;
    position: relative;
    color: var(--text-gray);
    font-size: 0.95rem;
}

.about-section ul li::before {
    content: '•';
    color: var(--primary);
    position: absolute;
    left: 0;
    font-weight: bold;
}

.about-section p {
    text-align: left;
    margin-bottom: 4px;
}

/* Remove padding for full-screen centered layouts */
#howToPlayScreen, #aboutScreen {
    padding: 0;
}



/* --- Game Over Screen --- */

/* Celebration Wrapper with Confetti Animation */
.celebration-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.victory-icon {
    font-size: 5rem;
    animation: celebrationBounce 1.2s ease-in-out infinite;
    filter: drop-shadow(0 4px 20px rgba(255, 215, 0, 0.4));
    z-index: 2;
}

@keyframes celebrationBounce {
    0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
    25% { transform: translateY(-15px) rotate(-5deg) scale(1.05); }
    50% { transform: translateY(0) rotate(0deg) scale(1); }
    75% { transform: translateY(-10px) rotate(5deg) scale(1.05); }
}

/* Animated Confetti Particles */
.confetti-particle {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    opacity: 0;
    animation: confettiFall 2.5s ease-out infinite;
    box-shadow: 0 0 8px currentColor;
}

.confetti-particle:nth-child(2) {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.confetti-particle:nth-child(3) {
    background: linear-gradient(135deg, #6366F1, #818CF8);
    top: 30%;
    right: 15%;
    animation-delay: 0.3s;
}

.confetti-particle:nth-child(4) {
    background: linear-gradient(135deg, #F472B6, #EC4899);
    bottom: 25%;
    left: 20%;
    animation-delay: 0.6s;
}

.confetti-particle:nth-child(5) {
    background: linear-gradient(135deg, #34D399, #10B981);
    bottom: 30%;
    right: 10%;
    animation-delay: 0.9s;
}

.confetti-particle:nth-child(6) {
    background: linear-gradient(135deg, #FBBF24, #F59E0B);
    top: 50%;
    left: 50%;
    animation-delay: 1.2s;
}

@keyframes confettiFall {
    0% {
        opacity: 0;
        transform: translateY(0) rotate(0deg) scale(0);
    }
    15% {
        opacity: 1;
        transform: translateY(-25px) rotate(45deg) scale(1.2);
    }
    85% {
        opacity: 0.8;
    }
    100% {
        opacity: 0;
        transform: translateY(120px) rotate(360deg) scale(0.3);
    }
}

/* Game Over Content Container */
.game-over-content {
    background: linear-gradient(145deg, rgba(30, 27, 75, 0.95), rgba(15, 23, 42, 0.98));
    border: 2px solid transparent;
    background-clip: padding-box;
    position: relative;
    padding: 56px 40px 48px;
    border-radius: var(--radius-lg);
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(255, 215, 0, 0.1),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    animation: slideUpFade 0.6s var(--bounce);
    max-width: 480px;
    width: 100%;
}

.game-over-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: var(--radius-lg);
    padding: 2px;
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.3), rgba(99, 102, 241, 0.3), rgba(244, 114, 182, 0.3));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
}

@keyframes slideUpFade {
    0% { 
        transform: translateY(30px) scale(0.95); 
        opacity: 0; 
    }
    100% { 
        transform: translateY(0) scale(1); 
        opacity: 1; 
    }
}

/* Title Styling */
#gameOverTitle {
    font-size: 2.8rem;
    font-weight: 900;
    background: linear-gradient(135deg, #A78BFA 0%, #FDE68A 50%, #F472B6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    margin-top: 8px;
    text-align: center;
    line-height: 1.2;
    filter: drop-shadow(0 2px 10px rgba(167, 139, 250, 0.3));
    animation: titleShine 3s ease-in-out infinite;
}

@keyframes titleShine {
    0%, 100% { filter: drop-shadow(0 2px 10px rgba(167, 139, 250, 0.3)); }
    50% { filter: drop-shadow(0 4px 20px rgba(253, 230, 138, 0.5)); }
}

#gameOverMessage {
    font-size: 1.15rem;
    color: var(--text-main);
    font-weight: 500;
}

/* Premium Stats Grid */
.final-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px; /* Very tight gap */
    width: 100%;
    margin: 8px 0 16px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px; /* Slightly squarer for slickness */
    padding: 10px 12px; /* Small padding */
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s var(--smooth);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(5px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.05), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 215, 0, 0.3);
    background: rgba(255, 255, 255, 0.08);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-icon {
    font-size: 1.4rem; /* Smaller icon */
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(99, 102, 241, 0.1));
    border-radius: 8px;
    border: 1px solid rgba(255, 215, 0, 0.15);
    flex-shrink: 0;
}

.stat-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    flex: 1;
}

.stat-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.2rem; /* Compact value */
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.stat-value.rating-stars {
    font-size: 1.3rem;
    letter-spacing: 2px;
}

/* Action Buttons */
.game-over-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    margin-top: 8px;
}

/* Premium Button Styles */
.glow-btn {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border: none;
    color: #1e1b4b;
    font-weight: 700;
    box-shadow: 
        0 4px 15px rgba(255, 215, 0, 0.4),
        0 0 30px rgba(255, 215, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.glow-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.glow-btn:hover::before {
    left: 100%;
}

.glow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 20px rgba(255, 215, 0, 0.5),
        0 0 40px rgba(255, 215, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.secondary-btn {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(79, 70, 229, 0.3));
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: var(--text-main);
}

.secondary-btn:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(79, 70, 229, 0.4));
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.tertiary-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-muted);
}

.tertiary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--text-main);
}

/* Pause Screen */
.pause-container {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    backdrop-filter: blur(20px);
    padding: 20px;
    border-radius: var(--radius-lg);
    text-align: center;
    width: 100%;
    max-width: 320px;
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 24px;
}

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

/* Safe Area & Mobile Optimization */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #gameScreen {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* Additional Responsive Tweaks */
@media screen and (max-width: 380px) {

    
    h1 { font-size: 2.2rem; }
    h2 { font-size: 1.6rem; }
    
    .loading-bar { width: 180px; }
    
    .cards { gap: 8px; }

    
    .control-btn {
        width: 36px;
        height: 36px;
    }
    
    /* Game Over Screen Mobile Adjustments */
    .game-over-content {
        padding: 55px 24px 32px !important;
        /* Center content properly in a compact card */
        display: flex; /* Keep flex for column */
        flex-direction: column;
        justify-content: flex-start;
        min-height: auto; 
        gap: 16px; 
        width: 100%;
        max-width: 360px; /* Constrain width */
        margin: auto; /* Center in screen */
        border-radius: 24px;
        position: relative; /* Back to relative */
        top: auto; bottom: auto;
        overflow: visible !important;
    }
    
    #gameScreen .screen {
        align-items: center; /* Back to center */
    }
    
    #gameOverTitle {
        font-size: 2.2rem;
        margin-top: 10px;
        flex-shrink: 0;
    }
    
    #gameOverMessage {
        margin-bottom: 12px;
        flex-shrink: 0;
    }

    .final-stats {
        margin: 8px 0 20px;
        flex-grow: 0;
        align-content: stretch;
        gap: 12px;
    }
    
    .celebration-wrapper {
        position: absolute !important;
        top: -50px; /* Pop out by half */
        left: 0;
        right: 0;
        margin: 0 auto !important;
        width: 100px;
        height: 100px;
        z-index: 10;
    }
    
    .victory-icon {
        font-size: 4rem;
    }
    
    .stat-card {
        padding: 10px 12px; /* Even tighter for small screens */
        gap: 10px;
    }
    
    .stat-icon {
        font-size: 1.5rem;
        width: 36px;
        height: 36px;
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
}

/* --- Mobile Optimizations for Settings --- */
@media screen and (max-width: 480px) {
    .settings-container {
        padding: 24px;
        width: 90%;
        max-width: 90%;
        gap: 20px;
    }

    .settings-options {
        gap: 16px;
    }

    .setting-item {
        padding: 14px;
    }

    /* Ensure back button doesn't have too much space on mobile */
    .settings-container .back-btn {
        margin-top: 8px;
    }
    
    /* Info Container Mobile */
    .info-container {
        padding: 10px;
        width: 90%;
        max-height: 80vh;
        gap: 20px;
    }
    
    .instruction-step {
        padding: 10px;
        gap: 12px;
    }
    
    .step-number {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    /* Compact Menu Buttons for Mobile */
    .menu-container {
        max-width: 90%; /* Use full available width with margins */
    }

    .menu-btn {
        padding: 16px 20px; /* Reduced padding */
        font-size: 1.1rem; /* Smaller font */
        gap: 12px;
    }
    
    .btn-icon {
        font-size: 1.3rem; /* Smaller icon */
    }
}