/* ============================================
   DUNGEON HUNTER — Core Design System
   Light Cream Default + Dark Mode Toggle
   ============================================ */

/* ---- LIGHT THEME (default) ---- */
:root {
    --ui-bg: #fdfbf7;
    --ui-bg-deep: #f4f0e6;
    --ui-bg-card: rgba(255, 255, 255, 0.95);
    --ui-bg-glass: rgba(255, 252, 255, 0.85);
    --ui-bg-glass-strong: rgba(255, 255, 255, 0.95);

    --ui-gold: #ffaa00;
    --ui-gold-bright: #ffcc00;
    --ui-gold-glow: rgba(255, 170, 0, 0.4);
    --ui-gold-dim: #c88000;

    --ui-red: #ff4a4a;
    --ui-red-glow: rgba(255, 74, 74, 0.4);
    --ui-green: #3ad261;
    --ui-green-glow: rgba(58, 210, 97, 0.3);
    --ui-blue: #4aa0ff;
    --ui-blue-glow: rgba(74, 160, 255, 0.3);
    --ui-purple: #9050d0;

    --ui-text: #201530;
    --ui-text-secondary: #5a4b70;
    --ui-text-dim: #8b7d9e;
    --ui-text-bright: #000000;

    --ui-border: rgba(255, 170, 0, 0.3);
    --ui-border-active: rgba(255, 170, 0, 0.6);

    --ui-shadow-sm: 0 4px 12px rgba(40,20,60,0.1);
    --ui-shadow-md: 0 8px 24px rgba(40,20,60,0.15);
    --ui-shadow-lg: 0 16px 48px rgba(40,20,60,0.25);
    --ui-shadow-glow-gold: 0 0 24px var(--ui-gold-glow), 0 0 60px rgba(255,170,0,0.15);
    --ui-shadow-glow-red: 0 0 24px var(--ui-red-glow);

    --ui-overlay: rgba(253, 251, 247, 0.85);
    --ui-overlay-strong: rgba(253, 251, 247, 0.95);
    --ui-menu-bg: #fdfbf7;
    --ui-shop-overlay: radial-gradient(circle at 50% 50%, transparent 0%, transparent 50%, rgba(253,251,247,0.5) 100%);
    --ui-model-glow: rgba(255, 200, 0, 0.3);

    /* Fonts */
    --font-heading: 'Cinzel', 'Georgia', serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --font-fantasy: 'MedievalSharp', cursive;

    /* Spacing */
    --gap-xs: 4px;
    --gap-sm: 8px;
    --gap-md: 16px;
    --gap-lg: 24px;
    --gap-xl: 40px;
    --gap-2xl: 64px;

    /* Radius */
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 32px;
    --radius-round: 50%;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-fast: 0.15s var(--ease-out);
    --transition-normal: 0.3s var(--ease-out);
    --transition-slow: 0.6s var(--ease-out);
}

/* ---- DARK THEME (toggle) ---- */
[data-theme="dark"] {
    --ui-bg: #291b40;
    --ui-bg-deep: #1d1230;
    --ui-bg-card: rgba(45, 30, 70, 0.92);
    --ui-bg-glass: rgba(45, 30, 70, 0.75);
    --ui-bg-glass-strong: rgba(45, 30, 70, 0.90);

    --ui-gold: #ffcc00;
    --ui-gold-bright: #ffe680;
    --ui-gold-glow: rgba(255, 204, 0, 0.5);
    --ui-gold-dim: #c69400;

    --ui-red: #ff5555;
    --ui-red-glow: rgba(255, 85, 85, 0.4);
    --ui-green: #4ded73;
    --ui-green-glow: rgba(77, 237, 115, 0.3);
    --ui-blue: #5cb0ff;
    --ui-blue-glow: rgba(92, 176, 255, 0.3);
    --ui-purple: #c07bff;

    --ui-text: #ffffff;
    --ui-text-secondary: #dcd0ef;
    --ui-text-dim: #9b8ba9;
    --ui-text-bright: #ffffff;

    --ui-border: rgba(255, 204, 0, 0.35);
    --ui-border-active: rgba(255, 204, 0, 0.65);

    --ui-shadow-sm: 0 4px 12px rgba(15,8,30,0.5);
    --ui-shadow-md: 0 8px 24px rgba(15,8,30,0.7);
    --ui-shadow-lg: 0 16px 48px rgba(15,8,30,0.9);
    --ui-shadow-glow-gold: 0 0 24px var(--ui-gold-glow), 0 0 70px rgba(255,204,0,0.2);
    --ui-shadow-glow-red: 0 0 24px var(--ui-red-glow);

    --ui-overlay: rgba(30, 20, 45, 0.88);
    --ui-overlay-strong: rgba(30, 20, 45, 0.97);
    --ui-menu-bg: radial-gradient(circle at 50% 30%, rgba(80, 40, 140, 0.5) 0%, rgba(41, 27, 64, 0.9) 70%);
    --ui-shop-overlay: radial-gradient(circle at 50% 50%, transparent 0%, transparent 50%, rgba(41,27,64,0.7) 100%);
    --ui-model-glow: rgba(255, 255, 255, 0.15);
}

/* ---- RESET ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    color: var(--ui-text);
    background: var(--ui-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
    transition: background 0.4s ease, color 0.4s ease;
}

/* Canvas */
#game-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* Screen layers */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-slow);
    pointer-events: none;
}

.screen.active {
    display: flex;
    opacity: 1;
    pointer-events: all;
}

.screen-overlay, .menu-overlay, .pause-overlay, .gameover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ui-overlay-strong);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: -1;
}

/* ---- BUTTONS ---- */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--gap-sm);
    padding: 18px 40px;
    border: 3px solid var(--ui-border);
    border-radius: var(--radius-lg);
    background: var(--ui-bg-card); /* Less glassy, more solid */
    color: var(--ui-text);
    font-family: var(--font-heading);
    font-size: 18px; /* Bigger */
    font-weight: 900;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.4); /* Better readability */
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    min-width: 240px;
    box-shadow: var(--ui-shadow-sm);
}

.btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -100%;
    width: 200%;
    height: 200%;
    background: linear-gradient(135deg, rgba(255,255,255,0.0) 40%, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0.0) 60%);
    transition: left 0.4s ease;
    transform: rotate(20deg);
}

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

.btn:hover {
    border-color: var(--ui-gold);
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--ui-shadow-glow-gold);
}

.btn:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: inset 0 4px 8px rgba(0,0,0,0.3);
}

.btn-primary {
    background: linear-gradient(180deg, var(--ui-gold-bright), var(--ui-gold));
    border: 3px solid #ffeeaa;
    color: #442200;
    text-shadow: 0 2px 2px rgba(255,255,255,0.4);
    box-shadow: 0 6px 0 var(--ui-gold-dim), 0 10px 20px rgba(0,0,0,0.4);
}

.btn-primary:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 var(--ui-gold-dim), inset 0 3px 6px rgba(0,0,0,0.3);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #ffff55, var(--ui-gold-bright));
    color: #221100;
}

.btn-glow {
    animation: btn-pulse 2.5s ease-in-out infinite;
}

@keyframes btn-pulse {
    0%, 100% { box-shadow: 0 0 12px var(--ui-gold-glow); }
    50% { box-shadow: 0 0 25px var(--ui-gold-glow), 0 0 50px rgba(184,134,11,0.06); }
}

.btn-danger {
    border-color: var(--ui-red);
    color: var(--ui-red);
}

.btn-danger:hover {
    border-color: var(--ui-red);
    box-shadow: var(--ui-shadow-glow-red);
}

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

.btn-back {
    background: none;
    border: none;
    color: var(--ui-text-secondary);
    font-family: var(--font-body);
    font-size: 15px;
    cursor: pointer;
    padding: 8px 16px;
    transition: color var(--transition-fast);
    border-radius: var(--radius-sm);
}

.btn-back:hover {
    color: var(--ui-gold);
    background: var(--ui-bg-glass);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); border-radius: 3px; }
::-webkit-scrollbar-thumb { background: var(--ui-gold-dim); border-radius: 3px; }

[data-theme="dark"] ::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); }

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

/* ---- DAMAGE NUMBERS ---- */
.damage-numbers {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 50;
    pointer-events: none;
}

.damage-number {
    position: absolute;
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 24px;
    color: var(--ui-red);
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    animation: damage-float 1s ease-out forwards;
    pointer-events: none;
}

.damage-number.heal {
    color: var(--ui-green);
}

@keyframes damage-float {
    0% { opacity: 1; transform: translateY(0) scale(1.2); }
    100% { opacity: 0; transform: translateY(-60px) scale(0.8); }
}

/* Responsive */
@media (max-width: 768px) {
    .btn {
        min-width: 180px;
        padding: 12px 24px;
        font-size: 13px;
    }
}
