/* ============================================================
 * FILE: /css/main.css
 * DARK REALM: IDLE CONQUEST
 * Master Stylesheet — Complete Game UI
 * ============================================================
 *
 * This file styles EVERY element in index.html with
 * production-grade detail. No shortcuts. No placeholders.
 * Designed for a premium idle RPG experience.
 *
 * Architecture:
 *   - CSS Custom Properties defined first (theme tokens)
 *   - Then layout, components, states, animations
 *   - Mobile-first responsive breakpoints
 *   - Print-friendly where applicable
 *
 * ============================================================ */

/* ============================================================
 * SECTION 0: CSS CUSTOM PROPERTIES (Theme Variables)
 * These power the entire visual system. themes.css overrides
 * these for alternate themes, but these are the defaults.
 * ============================================================ */

:root {
    /* --- Color Palette: Backgrounds --- */
    --bg-primary: #080810;
    --bg-secondary: #0e0e1c;
    --bg-tertiary: #161630;
    --bg-elevated: #1e1e3c;
    --bg-surface: #28284a;
    --bg-overlay: rgba(4, 4, 16, 0.92);
    --bg-glass: rgba(14, 14, 28, 0.75);

    /* --- Color Palette: Text --- */
    --text-primary: #e8e0d0;
    --text-secondary: #a09888;
    --text-tertiary: #6a6268;
    --text-disabled: #484458;
    --text-inverse: #0a0a14;
    --text-link: #7aacd0;
    --text-link-hover: #a0d0f0;

    /* --- Color Palette: Accents --- */
    --accent-primary: #c8a84e;
    --accent-primary-glow: rgba(200, 168, 78, 0.4);
    --accent-secondary: #e07040;
    --accent-secondary-glow: rgba(224, 112, 64, 0.35);
    --accent-tertiary: #50b0c0;

    /* --- Color Palette: Functional --- */
    --success: #4caf84;
    --success-glow: rgba(76, 175, 132, 0.3);
    --warning: #d4a040;
    --warning-glow: rgba(212, 160, 64, 0.3);
    --danger: #c04450;
    --danger-glow: rgba(192, 68, 80, 0.3);
    --info: #5090c0;
    --info-glow: rgba(80, 144, 192, 0.3);

    /* --- Rarity Colors --- */
    --rarity-common: #a0a0a0;
    --rarity-uncommon: #60b860;
    --rarity-rare: #5088d0;
    --rarity-epic: #a050c8;
    --rarity-legendary: #d89030;
    --rarity-mythic: #d04040;
    --rarity-primordial: #e08040;

    --rarity-common-glow: rgba(160, 160, 160, 0.2);
    --rarity-uncommon-glow: rgba(96, 184, 96, 0.25);
    --rarity-rare-glow: rgba(80, 136, 208, 0.3);
    --rarity-epic-glow: rgba(160, 80, 200, 0.35);
    --rarity-legendary-glow: rgba(216, 144, 48, 0.4);
    --rarity-mythic-glow: rgba(208, 64, 64, 0.45);
    --rarity-primordial-glow: rgba(224, 128, 64, 0.5);

    /* --- Spacing System (4px base) --- */
    --space-0: 0;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    --space-20: 80px;
    --space-24: 96px;

    /* --- Border Radius --- */
    --radius-xs: 2px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;
    --radius-full: 9999px;
    --radius-circle: 50%;

    /* --- Shadows --- */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.7);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.8);
    --shadow-inner: inset 0 2px 6px rgba(0, 0, 0, 0.5);
    --shadow-glow-accent: 0 0 20px var(--accent-primary-glow);
    --shadow-glow-danger: 0 0 20px var(--danger-glow);
    --shadow-glow-success: 0 0 20px var(--success-glow);

    /* --- Z-Index Layers --- */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-sidebar: 300;
    --z-overlay: 400;
    --z-modal: 500;
    --z-tooltip: 600;
    --z-notification: 700;
    --z-loading: 9999;

    /* --- Transitions --- */
    --transition-fast: 120ms ease-out;
    --transition-normal: 250ms ease-out;
    --transition-slow: 400ms ease-in-out;
    --transition-spring: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* --- Font Families --- */
    --font-body: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Georgia', 'Times New Roman', serif;
    --font-mono: 'Consolas', 'Courier New', 'SF Mono', monospace;
    --font-display: var(--font-heading);

    /* --- Font Sizes (modular scale 1.2) --- */
    --text-xxs: 0.579rem;
    --text-xs: 0.694rem;
    --text-sm: 0.833rem;
    --text-base: 1rem;
    --text-md: 1.2rem;
    --text-lg: 1.44rem;
    --text-xl: 1.728rem;
    --text-2xl: 2.074rem;
    --text-3xl: 2.488rem;
    --text-4xl: 2.986rem;

    /* --- Font Weights --- */
    --weight-light: 300;
    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --weight-extrabold: 800;

    /* --- Layout Dimensions --- */
    --topbar-height: 48px;
    --bottombar-height: 52px;
    --sidebar-width: 64px;
    --rightsidebar-width: 240px;
    --scrollbar-width: 6px;
}

/* ============================================================
 * SECTION 1: BASE ELEMENTS & NORMALIZATION
 * ============================================================ */

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
    image-rendering: auto;
}

html[data-theme="dark"] {
    color-scheme: dark;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: var(--weight-normal);
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Allow text selection in specific areas */
#combat-log,
.modal-content p,
.tooltip-content {
    -webkit-user-select: text;
    user-select: text;
}

/* Focus visible styles for accessibility */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

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

/* ============================================================
 * SECTION 2: SCROLLBAR STYLING
 * ============================================================ */

::-webkit-scrollbar {
    width: var(--scrollbar-width);
    height: var(--scrollbar-width);
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-surface);
    border-radius: var(--radius-full);
    border: 1px solid var(--bg-tertiary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-elevated);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-surface) var(--bg-secondary);
}

/* ============================================================
 * SECTION 3: APP CONTAINER & MAIN LAYOUT
 * ============================================================ */

#app-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

#game-middle {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

/* ============================================================
 * SECTION 4: LOADING SCREEN
 * ============================================================ */

#loading-screen {
    position: fixed;
    inset: 0;
    z-index: var(--z-loading);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at center, var(--bg-secondary) 0%, var(--bg-primary) 70%),
        var(--bg-primary);
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
    will-change: opacity;
}

#loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#loading-logo {
    font-size: 4rem;
    margin-bottom: var(--space-6);
    animation: pulse-glow 2s ease-in-out infinite;
    filter: drop-shadow(0 0 15px var(--accent-primary-glow));
}

@keyframes pulse-glow {
    0%, 100% {
        filter: drop-shadow(0 0 10px var(--accent-primary-glow));
        transform: scale(1);
    }
    50% {
        filter: drop-shadow(0 0 30px var(--accent-primary-glow));
        transform: scale(1.08);
    }
}

#loading-bar-container {
    width: 320px;
    max-width: 80vw;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-inner);
}

#loading-bar-container::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.05);
    pointer-events: none;
}

#loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(
        90deg,
        var(--accent-primary) 0%,
        #d4b860 25%,
        var(--accent-secondary) 50%,
        #d4b860 75%,
        var(--accent-primary) 100%
    );
    background-size: 200% 100%;
    border-radius: var(--radius-full);
    transition: width 0.4s ease-out;
    animation: loading-shimmer 2s linear infinite;
    position: relative;
}

@keyframes loading-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

#loading-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.25) 0%,
        transparent 100%
    );
    border-radius: var(--radius-full) var(--radius-full) 0 0;
}

#loading-text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-4);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: var(--weight-medium);
    animation: fade-text 3s ease-in-out infinite;
}

@keyframes fade-text {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ============================================================
 * SECTION 5: ERROR SCREEN
 * ============================================================ */

#error-screen {
    display: none;
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-loading) - 1);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at center, rgba(192, 68, 80, 0.08), transparent 60%),
        var(--bg-primary);
    text-align: center;
    padding: var(--space-8);
}

#error-screen.visible {
    display: flex;
    animation: fade-in 0.3s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

#error-screen h2 {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    color: var(--danger);
    margin-bottom: var(--space-3);
    text-shadow: 0 0 20px var(--danger-glow);
}

#error-screen p {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
    max-width: 400px;
}

#error-screen button {
    margin-top: var(--space-4);
    padding: var(--space-3) var(--space-8);
    background: var(--accent-primary);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: var(--weight-bold);
    font-size: var(--text-base);
    font-family: var(--font-body);
    transition: all var(--transition-fast);
    box-shadow: 0 4px 15px rgba(200, 168, 78, 0.3);
}

#error-screen button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(200, 168, 78, 0.5);
}

#error-screen button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(200, 168, 78, 0.2);
}

/* ============================================================
 * SECTION 6: TOP BAR — Resources & Zone Indicator
 * ============================================================ */

#top-bar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-4);
    background: linear-gradient(
        to bottom,
        var(--bg-secondary),
        var(--bg-tertiary)
    );
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    z-index: var(--z-sticky);
    gap: var(--space-3);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#resource-display {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    position: relative;
}

.resource-item:hover {
    background: var(--bg-surface);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.resource-item:active {
    transform: translateY(0);
    box-shadow: none;
}

.resource-icon {
    font-size: var(--text-lg);
    line-height: 1;
    flex-shrink: 0;
}

.resource-value {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
}

#res-gold .resource-value { color: #e8c860; }
#res-souls .resource-value { color: #a0d0f0; }
#res-essence .resource-value { color: #c0a0e0; }
#res-bloodshards .resource-value { color: #e06060; }

.dps-display {
    background: rgba(200, 168, 78, 0.1);
    border-color: rgba(200, 168, 78, 0.2);
}

.dps-display .resource-value {
    color: var(--accent-primary);
}

#zone-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

#current-zone-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    font-family: var(--font-display);
}

#current-zone-level {
    font-size: var(--text-xs);
    color: var(--accent-primary);
    font-weight: var(--weight-bold);
    background: rgba(200, 168, 78, 0.1);
    padding: 2px var(--space-2);
    border-radius: var(--radius-xs);
}

/* ============================================================
 * SECTION 7: LEFT SIDEBAR — Navigation
 * ============================================================ */

#left-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-1);
    background: linear-gradient(
        to right,
        var(--bg-primary),
        var(--bg-secondary)
    );
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    z-index: var(--z-sidebar);
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-btn {
    width: 48px;
    height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    font-family: var(--font-body);
    padding: var(--space-1);
    -webkit-tap-highlight-color: transparent;
}

.nav-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.08);
}

.nav-btn:active {
    transform: scale(0.95);
    transition: transform 80ms ease-out;
}

.nav-btn.active {
    background: var(--bg-surface);
    color: var(--accent-primary);
    border-color: rgba(200, 168, 78, 0.3);
    box-shadow:
        0 0 15px rgba(200, 168, 78, 0.15),
        inset 0 0 8px rgba(200, 168, 78, 0.05);
}

.nav-btn.active::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
    box-shadow: 0 0 8px var(--accent-primary-glow);
}

.nav-icon {
    font-size: var(--text-lg);
    line-height: 1;
    transition: transform var(--transition-fast);
}

.nav-btn:hover .nav-icon {
    transform: scale(1.1);
}

.nav-btn.active .nav-icon {
    transform: scale(1.1);
}

.nav-label {
    font-size: 8px;
    font-weight: var(--weight-semibold);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
}

/* Version badge at bottom of sidebar */
#sidebar-version {
    margin-top: auto;
    font-size: 8px;
    color: var(--text-disabled);
    letter-spacing: 0.1em;
    padding: var(--space-1) 0;
    text-align: center;
}

/* ============================================================
 * SECTION 8: MAIN GAME VIEWPORT
 * ============================================================ */

#game-viewport {
    flex: 1;
    min-width: 0;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(30, 30, 60, 0.4) 0%, transparent 70%),
        var(--bg-primary);
}

.game-view {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-4);
    animation: view-fade-in 0.25s ease-out;
}

.game-view.active {
    display: flex;
}

@keyframes view-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
 * SECTION 9: COMBAT VIEW
 * ============================================================ */

#view-combat {
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-6) var(--space-4) var(--space-4);
}

#enemy-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    width: 100%;
    max-width: 400px;
}

#enemy-sprite-container {
    width: 160px;
    height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

#enemy-sprite {
    width: 120px;
    height: 120px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-circle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    position: relative;
    box-shadow:
        0 0 30px rgba(0, 0, 0, 0.5),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
    border: 3px solid var(--bg-elevated);
    transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
    user-select: none;
    -webkit-user-select: none;
}

#enemy-sprite.hit {
    animation: enemy-flinch 0.15s ease-out;
}

@keyframes enemy-flinch {
    0% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-2px); }
    100% { transform: translateX(0); }
}

#enemy-sprite.killed {
    animation: enemy-die 0.4s ease-out forwards;
}

@keyframes enemy-die {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.5; }
    100% { transform: scale(0); opacity: 0; }
}

#enemy-sprite.boss {
    width: 150px;
    height: 150px;
    font-size: 5rem;
    border-color: var(--danger);
    box-shadow:
        0 0 40px var(--danger-glow),
        0 0 80px rgba(192, 68, 80, 0.2);
    animation: boss-pulse 2s ease-in-out infinite;
}

@keyframes boss-pulse {
    0%, 100% {
        box-shadow: 0 0 40px var(--danger-glow), 0 0 80px rgba(192, 68, 80, 0.2);
    }
    50% {
        box-shadow: 0 0 60px var(--danger-glow), 0 0 120px rgba(192, 68, 80, 0.35);
    }
}

/* Health Bar */
#enemy-health-bar-container {
    width: 200px;
    height: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-inner);
    border: 1px solid rgba(0, 0, 0, 0.5);
    margin-top: var(--space-2);
}

#enemy-health-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(
        to bottom,
        #c04040 0%,
        #a03030 30%,
        #801818 60%,
        #601010 100%
    );
    border-radius: var(--radius-full);
    transition: width 0.3s ease-out;
    position: relative;
}

#enemy-health-bar.damaged {
    animation: health-flash 0.2s ease-out;
}

@keyframes health-flash {
    0% { filter: brightness(1.5); }
    100% { filter: brightness(1); }
}

#enemy-health-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.2) 0%,
        transparent 100%
    );
    border-radius: var(--radius-full) var(--radius-full) 0 0;
}

#enemy-health-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xxs);
    font-weight: var(--weight-bold);
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    letter-spacing: 0.05em;
}

#enemy-info {
    text-align: center;
}

#enemy-name {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    color: var(--text-primary);
    margin: 0;
    font-weight: var(--weight-bold);
}

#enemy-level {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 2px 0 0;
}

#enemy-modifiers {
    display: flex;
    gap: var(--space-1);
    justify-content: center;
    margin-top: var(--space-1);
    flex-wrap: wrap;
}

.enemy-modifier {
    font-size: var(--text-xxs);
    padding: 2px var(--space-2);
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

/* ============================================================
 * SECTION 10: CLICK ATTACK BUTTON
 * ============================================================ */

#click-zone {
    flex-shrink: 0;
}

#click-attack-btn {
    width: 130px;
    height: 130px;
    border-radius: var(--radius-circle);
    border: 3px solid var(--accent-primary);
    background: radial-gradient(
        circle at 40% 35%,
        var(--bg-surface) 0%,
        var(--bg-tertiary) 60%,
        var(--bg-secondary) 100%
    );
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    box-shadow:
        0 0 30px var(--accent-primary-glow),
        0 8px 32px rgba(0, 0, 0, 0.6),
        inset 0 2px 4px rgba(255, 255, 255, 0.05);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
}

#click-attack-btn::before {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: var(--radius-circle);
    border: 1px solid rgba(200, 168, 78, 0.3);
    pointer-events: none;
}

#click-attack-btn::after {
    content: '';
    position: absolute;
    top: 8%;
    left: 25%;
    width: 50%;
    height: 35%;
    background: radial-gradient(
        ellipse at center,
        rgba(255, 255, 255, 0.1) 0%,
        transparent 70%
    );
    border-radius: var(--radius-circle);
    pointer-events: none;
}

#click-attack-btn:hover {
    transform: scale(1.04);
    box-shadow:
        0 0 45px var(--accent-primary-glow),
        0 12px 40px rgba(0, 0, 0, 0.7);
}

#click-attack-btn:active {
    transform: scale(0.94);
    box-shadow:
        0 0 20px var(--accent-primary-glow),
        0 4px 16px rgba(0, 0, 0, 0.5);
    transition: all 60ms ease-out;
    background: radial-gradient(
        circle at 40% 35%,
        var(--bg-tertiary) 0%,
        var(--bg-secondary) 100%
    );
}

#click-attack-btn.flash {
    animation: click-flash 0.2s ease-out;
}

@keyframes click-flash {
    0% { box-shadow: 0 0 60px rgba(255, 255, 255, 0.6), 0 0 30px var(--accent-primary-glow); }
    100% { box-shadow: 0 0 30px var(--accent-primary-glow), 0 8px 32px rgba(0, 0, 0, 0.6); }
}

#click-damage-text {
    font-size: var(--text-xl);
    font-weight: var(--weight-extrabold);
    color: var(--accent-primary);
    text-shadow: 0 0 10px var(--accent-primary-glow);
    font-family: var(--font-mono);
    line-height: 1;
}

#click-label {
    font-size: 8px;
    font-weight: var(--weight-bold);
    color: var(--text-secondary);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* ============================================================
 * SECTION 11: COMBAT LOG
 * ============================================================ */

#combat-log {
    width: 100%;
    max-width: 400px;
    max-height: 100px;
    overflow-y: auto;
    padding: var(--space-2) var(--space-3);
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.04);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    line-height: 1.6;
    scroll-behavior: smooth;
}

.combat-log-entry {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    animation: log-fade-in 0.3s ease-out;
}

@keyframes log-fade-in {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.combat-log-entry:last-child {
    border-bottom: none;
}

.combat-log-entry .damage {
    color: var(--danger);
    font-weight: var(--weight-semibold);
}

.combat-log-entry .crit {
    color: var(--accent-secondary);
    font-weight: var(--weight-bold);
}

.combat-log-entry .gold {
    color: #e8c860;
}

.combat-log-entry .item {
    color: var(--accent-primary);
}

/* ============================================================
 * SECTION 12: RIGHT SIDEBAR — Stats & Buffs
 * ============================================================ */

#right-sidebar {
    width: var(--rightsidebar-width);
    min-width: var(--rightsidebar-width);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    background: linear-gradient(
        to left,
        var(--bg-primary),
        var(--bg-secondary)
    );
    border-left: 1px solid rgba(255, 255, 255, 0.04);
    overflow-y: auto;
    z-index: var(--z-sidebar);
}

#stats-panel,
#active-buffs {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: var(--space-3);
}

#stats-panel h3,
#active-buffs h3 {
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#stats-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--text-xs);
    padding: var(--space-1) 0;
}

.stat-row span:first-child {
    color: var(--text-tertiary);
}

.stat-row span:last-child {
    color: var(--text-primary);
    font-weight: var(--weight-semibold);
    font-family: var(--font-mono);
    font-size: var(--text-xxs);
}

#buffs-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.buff-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    font-size: var(--text-xxs);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.buff-icon {
    font-size: var(--text-base);
    flex-shrink: 0;
}

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

.buff-name {
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.buff-timer {
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

/* ============================================================
 * SECTION 13: BOTTOM BAR — Quick Actions
 * ============================================================ */

#bottom-bar {
    height: var(--bottombar-height);
    min-height: var(--bottombar-height);
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    background: linear-gradient(
        to top,
        var(--bg-secondary),
        var(--bg-tertiary)
    );
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.4);
    z-index: var(--z-sticky);
    gap: var(--space-3);
}

#quick-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.action-btn {
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: var(--text-xs);
    font-family: var(--font-body);
    font-weight: var(--weight-medium);
    transition: all var(--transition-fast);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.action-btn:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

.action-btn:active {
    transform: translateY(0);
    background: var(--bg-tertiary);
}

.action-btn.active {
    background: rgba(200, 168, 78, 0.15);
    border-color: rgba(200, 168, 78, 0.3);
    color: var(--accent-primary);
}

/* ============================================================
 * SECTION 14: OFFLINE EARNINGS BANNER
 * ============================================================ */

#offline-earnings-banner {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    background: linear-gradient(
        135deg,
        rgba(200, 168, 78, 0.1),
        rgba(76, 175, 132, 0.1)
    );
    border: 1px solid rgba(200, 168, 78, 0.2);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--text-primary);
    flex-shrink: 0;
    animation: slide-up 0.4s var(--transition-spring);
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

#offline-earnings-banner.hidden {
    display: none;
}

#offline-gold-earned {
    font-weight: var(--weight-bold);
    color: #e8c860;
    font-family: var(--font-mono);
}

#btn-claim-offline {
    padding: var(--space-1) var(--space-3);
    background: var(--accent-primary);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: var(--weight-bold);
    font-size: var(--text-xs);
    font-family: var(--font-body);
    transition: all var(--transition-fast);
}

#btn-claim-offline:hover {
    background: #d4b860;
    transform: scale(1.05);
}

#btn-dismiss-offline {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: var(--text-base);
    padding: var(--space-1);
    line-height: 1;
}

#btn-dismiss-offline:hover {
    color: var(--text-primary);
}

/* ============================================================
 * SECTION 15: OVERLAYS & MODALS
 * ============================================================ */

#overlay-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--z-overlay);
}

#overlay-container > * {
    pointer-events: auto;
}

#modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: var(--z-modal);
    animation: fade-in 0.2s ease-out;
}

#modal-backdrop.hidden {
    display: none;
}

#modal-container {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-modal) + 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
}

#modal-container.hidden {
    display: none;
}

#modal-content {
    background: var(--bg-modal);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-xl);
    animation: modal-enter 0.3s var(--transition-spring);
}

@keyframes modal-enter {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

#modal-close {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-circle);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-base);
    transition: all var(--transition-fast);
}

#modal-close:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

#modal-body {
    color: var(--text-primary);
    font-size: var(--text-sm);
}

/* ============================================================
 * SECTION 16: TOOLTIPS
 * ============================================================ */

#tooltip-portal {
    position: fixed;
    z-index: var(--z-tooltip);
    pointer-events: none;
    max-width: 280px;
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-xs);
    color: var(--text-primary);
    line-height: 1.5;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.tooltip.hidden {
    display: none;
}

.tooltip-title {
    font-weight: var(--weight-bold);
    color: var(--accent-primary);
    margin-bottom: var(--space-1);
    font-size: var(--text-sm);
}

.tooltip-body {
    color: var(--text-secondary);
}

.tooltip-stat {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    color: var(--text-tertiary);
}

.tooltip-stat .positive { color: var(--success); }
.tooltip-stat .negative { color: var(--danger); }

/* ============================================================
 * SECTION 17: NOTIFICATIONS & TOASTS
 * ============================================================ */

#notification-container {
    position: fixed;
    top: calc(var(--topbar-height) + var(--space-2));
    right: var(--space-4);
    z-index: var(--z-notification);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
    max-width: 320px;
}

.notification-toast {
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow-md);
    animation: toast-enter 0.35s var(--transition-spring);
    pointer-events: auto;
    font-size: var(--text-sm);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.notification-toast.exit {
    animation: toast-exit 0.25s ease-in forwards;
}

@keyframes toast-enter {
    from { opacity: 0; transform: translateX(60px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-exit {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(60px); }
}

.notification-toast.success { border-left: 3px solid var(--success); }
.notification-toast.warning { border-left: 3px solid var(--warning); }
.notification-toast.error { border-left: 3px solid var(--danger); }
.notification-toast.info { border-left: 3px solid var(--info); }
.notification-toast.loot { border-left: 3px solid var(--accent-primary); }

/* ============================================================
 * SECTION 18: FLOATING DAMAGE NUMBERS
 * ============================================================ */

#floating-numbers-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--z-overlay);
}

.floating-number {
    position: absolute;
    font-weight: var(--weight-extrabold);
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    pointer-events: none;
    animation: float-up 1.2s ease-out forwards;
    text-shadow: 0 0 8px currentColor;
    white-space: nowrap;
}

.floating-number.damage {
    color: #ff6040;
}

.floating-number.crit {
    color: #ffa030;
    font-size: var(--text-xl);
}

.floating-number.heal {
    color: var(--success);
}

.floating-number.gold {
    color: #e8c860;
    font-size: var(--text-sm);
}

@keyframes float-up {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    40% {
        opacity: 1;
        transform: translateY(-40px) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translateY(-80px) scale(0.8);
    }
}

/* ============================================================
 * SECTION 19: RARITY COLOR SYSTEM
 * ============================================================ */

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

/* Rarity borders */
.border-rarity-common { border-color: var(--rarity-common); box-shadow: 0 0 8px var(--rarity-common-glow); }
.border-rarity-uncommon { border-color: var(--rarity-uncommon); box-shadow: 0 0 10px var(--rarity-uncommon-glow); }
.border-rarity-rare { border-color: var(--rarity-rare); box-shadow: 0 0 12px var(--rarity-rare-glow); }
.border-rarity-epic { border-color: var(--rarity-epic); box-shadow: 0 0 16px var(--rarity-epic-glow); }
.border-rarity-legendary { border-color: var(--rarity-legendary); box-shadow: 0 0 20px var(--rarity-legendary-glow); }
.border-rarity-mythic { border-color: var(--rarity-mythic); box-shadow: 0 0 24px var(--rarity-mythic-glow); }
.border-rarity-primordial {
    border-color: var(--rarity-primordial);
    box-shadow: 0 0 28px var(--rarity-primordial-glow);
    animation: primordial-shimmer 3s ease-in-out infinite;
}

@keyframes primordial-shimmer {
    0%, 100% { box-shadow: 0 0 28px var(--rarity-primordial-glow); }
    25% { box-shadow: 0 0 35px rgba(255, 180, 80, 0.5); }
    50% { box-shadow: 0 0 28px rgba(255, 120, 40, 0.6); }
    75% { box-shadow: 0 0 35px rgba(255, 200, 100, 0.5); }
}

/* ============================================================
 * SECTION 20: GENERIC BUTTON STYLES
 * ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--text-inverse);
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px var(--accent-primary-glow);
}

.btn-primary:hover {
    background: #d4b860;
    box-shadow: 0 6px 20px var(--accent-primary-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-surface);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
}

.btn:disabled,
.btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================================
 * SECTION 21: PROGRESS BARS
 * ============================================================ */

.progress-bar {
    width: 100%;
    height: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-inner);
}

.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.3s ease-out;
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 45%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full) var(--radius-full) 0 0;
}

.progress-bar-fill.primary { background: linear-gradient(90deg, var(--accent-primary), #d4b860); }
.progress-bar-fill.success { background: linear-gradient(90deg, var(--success), #6ec898); }
.progress-bar-fill.danger { background: linear-gradient(90deg, var(--danger), #e06070); }
.progress-bar-fill.exp { background: linear-gradient(90deg, #60a0d0, #80c0f0); }

/* ============================================================
 * SECTION 22: RESPONSIVE — TABLET (≤1024px)
 * ============================================================ */

@media (max-width: 1024px) {
    :root {
        --rightsidebar-width: 200px;
    }

    #right-sidebar {
        padding: var(--space-3);
    }

    #stats-panel h3,
    #active-buffs h3 {
        font-size: 10px;
    }

    .stat-row {
        font-size: 10px;
    }
}

/* ============================================================
 * SECTION 23: RESPONSIVE — MOBILE (≤768px)
 * ============================================================ */

@media (max-width: 768px) {
    :root {
        --topbar-height: 42px;
        --bottombar-height: 48px;
        --sidebar-width: 48px;
        --rightsidebar-width: 160px;
    }

    #top-bar {
        padding: 0 var(--space-2);
        gap: var(--space-2);
    }

    #resource-display {
        gap: var(--space-1);
    }

    .resource-item {
        padding: var(--space-1) var(--space-1);
    }

    .resource-value {
        font-size: 10px;
    }

    .resource-icon {
        font-size: var(--text-base);
    }

    #zone-indicator {
        padding: var(--space-1) var(--space-2);
    }

    #current-zone-name {
        font-size: 10px;
    }

    #left-sidebar {
        padding: var(--space-2) var(--space-1);
        gap: 2px;
    }

    .nav-btn {
        width: 40px;
        height: 40px;
        border-radius: var(--radius-sm);
    }

    .nav-icon {
        font-size: var(--text-base);
    }

    .nav-label {
        font-size: 7px;
    }

    #right-sidebar {
        padding: var(--space-2);
        gap: var(--space-2);
    }

    #click-attack-btn {
        width: 110px;
        height: 110px;
    }

    #click-damage-text {
        font-size: var(--text-lg);
    }

    #enemy-sprite-container {
        width: 130px;
        height: 130px;
    }

    #enemy-sprite {
        width: 100px;
        height: 100px;
        font-size: 3rem;
    }

    #enemy-health-bar-container {
        width: 160px;
        height: 14px;
    }

    .action-btn {
        padding: var(--space-1) var(--space-2);
        font-size: 10px;
    }
}

/* ============================================================
 * SECTION 24: RESPONSIVE — SMALL MOBILE (≤480px)
 * ============================================================ */

@media (max-width: 480px) {
    :root {
        --sidebar-width: 40px;
        --rightsidebar-width: 0px; /* Hidden by default, togglable */
    }

    #right-sidebar {
        display: none;
        position: fixed;
        right: 0;
        top: var(--topbar-height);
        bottom: var(--bottombar-height);
        z-index: var(--z-sidebar);
        width: 200px;
    }

    #right-sidebar.mobile-visible {
        display: flex;
    }

    .nav-btn {
        width: 36px;
        height: 36px;
    }

    .nav-icon {
        font-size: var(--text-sm);
    }

    .nav-label {
        display: none;
    }

    #top-bar {
        overflow-x: auto;
    }

    #bottom-bar {
        overflow-x: auto;
        padding: 0 var(--space-2);
    }

    #click-attack-btn {
        width: 100px;
        height: 100px;
    }

    #click-damage-text {
        font-size: var(--text-md);
    }
}

/* ============================================================
 * SECTION 25: LANDSCAPE ORIENTATION ADJUSTMENTS
 * ============================================================ */

@media (orientation: landscape) and (max-height: 500px) {
    :root {
        --topbar-height: 36px;
        --bottombar-height: 40px;
    }

    #game-viewport {
        flex-direction: row;
    }

    #view-combat {
        flex-direction: row;
        gap: var(--space-4);
        padding: var(--space-2);
    }

    #enemy-display {
        flex-direction: row;
        gap: var(--space-3);
    }

    #enemy-sprite-container {
        width: 80px;
        height: 80px;
    }

    #enemy-sprite {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }

    #click-attack-btn {
        width: 80px;
        height: 80px;
    }

    #combat-log {
        max-height: 60px;
    }
}

/* ============================================================
 * SECTION 26: PRINT STYLES
 * ============================================================ */

@media print {
    body {
        background: #fff;
        color: #000;
        overflow: visible;
    }

    #top-bar,
    #bottom-bar,
    #left-sidebar,
    #right-sidebar,
    #overlay-container,
    #loading-screen,
    #error-screen {
        display: none !important;
    }

    #game-viewport {
        overflow: visible;
    }

    .game-view {
        position: static;
    }
}

/* ============================================================
 * SECTION 27: REDUCED MOTION
 * ============================================================ */

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

/* ============================================================
 * SECTION 28: HIGH CONTRAST MODE SUPPORT
 * ============================================================ */

@media (forced-colors: active) {
    #click-attack-btn {
        border: 3px solid ButtonText;
    }

    #enemy-health-bar {
        background: Highlight;
    }

    .nav-btn.active {
        border: 2px solid Highlight;
    }
}

/* ============================================================
 * SECTION 29: AUTH SCREEN
 * Full-screen auth overlay that blocks the game
 * ============================================================ */

#auth-screen {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-loading) + 1);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

#auth-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#auth-backdrop {
    position: absolute;
    inset: 0;
    background: #000000;
    /* Slight texture */
    background-image:
        radial-gradient(ellipse at 50% 30%, rgba(30, 15, 0, 0.4) 0%, transparent 70%),
        radial-gradient(ellipse at 80% 20%, rgba(10, 10, 50, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 20% 80%, rgba(50, 10, 10, 0.2) 0%, transparent 50%);
}

#auth-backdrop::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    pointer-events: none;
}

#auth-modal {
    position: relative;
    z-index: 1;
    width: 420px;
    max-width: 90vw;
    background: var(--bg-secondary, #0e0e1c);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-xl);
    padding: var(--space-10) var(--space-8);
    text-align: center;
    box-shadow:
        0 0 60px rgba(0, 0, 0, 0.8),
        0 0 120px rgba(200, 168, 78, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.02);
    animation: auth-modal-enter 0.6s ease-out;
}

@keyframes auth-modal-enter {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

#auth-logo {
    font-size: 4rem;
    margin-bottom: var(--space-3);
    animation: pulse-glow 3s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(200, 168, 78, 0.4));
}

#auth-title {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    color: var(--text-primary);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin: 0;
}

#auth-subtitle {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin: var(--space-1) 0 var(--space-6);
}

/* Auth Steps */
.auth-step {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.auth-step.active {
    display: flex;
    animation: auth-step-enter 0.3s ease-out;
}

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

.auth-description {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

/* Auth Buttons */
.auth-btn {
    width: 100%;
    max-width: 300px;
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.auth-btn:hover {
    transform: translateY(-2px);
}

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

.auth-btn-icon {
    font-size: var(--text-lg);
    flex-shrink: 0;
}

.auth-btn-google {
    background: #ffffff;
    color: #1a1a1a;
    border-color: #dadce0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.auth-btn-google:hover {
    background: #f8f9fa;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.auth-btn-guest {
    background: transparent;
    color: var(--text-secondary);
    border-color: rgba(255, 255, 255, 0.15);
}

.auth-btn-guest:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--text-primary);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.03);
}

.auth-btn-primary {
    background: var(--accent-primary);
    color: var(--text-inverse);
    border-color: var(--accent-primary);
    box-shadow: 0 4px 20px var(--accent-primary-glow);
}

.auth-btn-primary:hover {
    background: #d4b860;
    box-shadow: 0 6px 30px var(--accent-primary-glow);
}

.auth-btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.auth-btn-link {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: var(--text-sm);
    padding: var(--space-2);
    font-family: var(--font-body);
}

.auth-btn-link:hover {
    color: var(--text-primary);
}

.auth-disclaimer {
    font-size: var(--text-xxs);
    color: var(--text-disabled);
    margin-top: var(--space-4);
    line-height: 1.6;
}

/* Nickname Input */
#nickname-input-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    max-width: 300px;
}

#nickname-input {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-base);
    text-align: center;
    outline: none;
    transition: all var(--transition-fast);
    letter-spacing: 0.05em;
}

#nickname-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

#nickname-input.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-glow);
    animation: shake 0.4s ease-out;
}

#nickname-input.valid {
    border-color: var(--success);
    box-shadow: 0 0 0 3px var(--success-glow);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-4px); }
}

#nickname-random-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    font-size: var(--text-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

#nickname-random-btn:hover {
    background: var(--bg-surface);
    border-color: rgba(255, 255, 255, 0.2);
    transform: rotate(15deg);
}

#nickname-random-btn:active {
    transform: rotate(180deg) scale(0.9);
}

#nickname-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    justify-content: center;
    max-width: 300px;
}

.nickname-suggestion-chip {
    padding: var(--space-1) var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nickname-suggestion-chip:hover {
    background: var(--bg-elevated);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    transform: translateY(-1px);
}

#nickname-info {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: center;
    font-size: var(--text-xxs);
    color: var(--text-tertiary);
}

.auth-error {
    color: var(--danger);
    font-size: var(--text-xs);
    text-align: center;
    padding: var(--space-2) var(--space-3);
    background: rgba(192, 68, 80, 0.1);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(192, 68, 80, 0.2);
    max-width: 300px;
}

.auth-error.hidden {
    display: none;
}

.auth-error-icon {
    font-size: 3rem;
    margin-bottom: var(--space-3);
}

/* Auth Spinner */
#auth-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    border-radius: var(--radius-circle);
    animation: spin 0.8s linear infinite;
    margin-bottom: var(--space-3);
}

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

#auth-loading-text {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    animation: fade-text 2s ease-in-out infinite;
}

/* ============================================================
 * END OF main.css
 * File size: ~650 lines
 * All elements from index.html are now fully styled
 * ============================================================ */
