/* ===== MAGIC BASER - 16-BIT RETRO STYLE ===== */

/* Press Start 2P - классический пиксельный шрифт */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    /* 16-bit Dark Theme */
    --bg-dark: #0c0c14;
    --bg-darker: #080810;
    --bg-card: #181828;
    --bg-card-hover: #202038;
    
    /* Blood Red Accent (SNES-style) */
    --primary: #e02040;
    --primary-dark: #a01830;
    --primary-glow: rgba(224, 32, 64, 0.4);
    
    /* Gold Accent */
    --gold: #f8d830;
    --gold-dark: #c0a020;
    --gold-glow: rgba(248, 216, 48, 0.3);
    
    /* Text */
    --text: #f0f0f0;
    --text-dim: #909090;
    --text-dark: #606060;
    
    /* Health & XP */
    --health: #e84040;
    --health-dark: #b02020;
    --xp: #40a8f0;
    --xp-dark: #2070b0;
    
    /* UI */
    --border: #404858;
    --border-light: #606878;
    --shadow: rgba(0, 0, 0, 0.9);
    
    /* Pixel Fonts */
    --font-pixel: 'Press Start 2P', monospace;
    --font-title: 'Press Start 2P', monospace;
    --font-body: 'Press Start 2P', monospace;
    
    /* Pixel borders */
    --pixel-border: 4px solid var(--border);
    --pixel-border-inset: inset 4px 4px 0 rgba(255,255,255,0.1), inset -4px -4px 0 rgba(0,0,0,0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    background: var(--bg-darker);
    color: var(--text);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== SCREENS ===== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none !important;
    flex-direction: column;
    background: var(--bg-dark);
    z-index: 1;
}

.screen.active {
    display: flex !important;
    z-index: 10;
}

/* ===== CONNECT SCREEN ===== */
#connect-screen {
    background: #0c0c14;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.connect-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    text-align: center;
    padding: 40px;
}

.connect-title {
    margin-bottom: 10px;
}

.connect-subtitle {
    font-family: var(--font-pixel);
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 40px;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.8);
}

/* Connect button - same style as menu buttons */
.connect-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 40px;
    min-width: 280px;
    font-family: var(--font-pixel);
    font-size: 14px;
    letter-spacing: 2px;
    color: var(--gold) !important;
    background: var(--bg-card) !important;
    border: 4px solid var(--gold) !important;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.1s ease;
    box-shadow:
        inset 4px 4px 0 rgba(255, 255, 255, 0.08),
        inset -4px -4px 0 rgba(0, 0, 0, 0.2),
        0 4px 0 var(--gold-dark),
        0 6px 12px rgba(0, 0, 0, 0.4);
    text-transform: uppercase;
}

.connect-btn:hover {
    transform: translateY(-2px);
    background: var(--bg-card-hover) !important;
    box-shadow:
        inset 4px 4px 0 rgba(255, 255, 255, 0.12),
        inset -4px -4px 0 rgba(0, 0, 0, 0.2),
        0 6px 0 var(--gold-dark),
        0 10px 20px rgba(248, 216, 48, 0.2);
    color: #ffffff !important;
}

.connect-btn:active {
    transform: translateY(2px);
    box-shadow:
        inset 4px 4px 0 rgba(0, 0, 0, 0.1),
        inset -4px -4px 0 rgba(255, 255, 255, 0.05),
        0 2px 0 var(--gold-dark);
}

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

.connect-text {
    font-weight: normal;
}

.connect-hint {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--text-dark);
    margin-top: 20px;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.8);
}

/* Loading state */
.connect-btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

.connect-btn.loading .connect-text {
    animation: pulse 1s infinite;
}

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

/* Connected state */
.connect-btn.connected {
    color: #50ff50 !important;
    border-color: #50ff50 !important;
    box-shadow:
        inset 4px 4px 0 rgba(255, 255, 255, 0.08),
        inset -4px -4px 0 rgba(0, 0, 0, 0.2),
        0 4px 0 #30a030,
        0 6px 12px rgba(80, 255, 80, 0.2);
}

/* ===== USER PROFILE (Top Right) ===== */
.user-profile {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(24, 24, 40, 0.9);
    border: 3px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    z-index: 150;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--gold);
    object-fit: cover;
    image-rendering: pixelated;
    background: var(--bg-darker);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--text);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .user-profile {
        top: 10px;
        right: 10px;
        padding: 6px 10px;
    }
    
    .user-avatar {
        width: 32px;
        height: 32px;
    }
    
    .user-name {
        font-size: 8px;
        max-width: 80px;
    }
    
    .user-level {
        font-size: 6px;
    }
}

/* ===== MAIN MENU - 16-BIT STYLE ===== */
#main-menu {
    background: #0c0c14;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Animated Background Canvas - реальная игра на фоне */
.menu-bg-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    filter: blur(1.5px) brightness(0.75);  /* Меньше блюр, больше яркость */
    image-rendering: pixelated;
    pointer-events: none;
}

/* Ensure menu content is above background */
#main-menu .menu-container {
    z-index: 100 !important;
    position: relative !important;
}

#main-menu .menu-buttons {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
}

#main-menu .menu-btn {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}
    image-rendering: pixelated;
}

.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 30px 40px;
    position: relative;
    z-index: 10;
    background: rgba(12, 12, 20, 0.85);
    border-radius: 16px;
    border: 2px solid rgba(64, 72, 88, 0.5);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    margin-top: -120px; /* Поднимаем меню выше */
}

.game-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: titleBlink 2s steps(2) infinite;
}

.title-icon {
    font-size: 64px;
    image-rendering: pixelated;
    filter: drop-shadow(4px 4px 0 var(--primary-dark));
    animation: iconBounce 1s steps(4) infinite;
}

.title-text {
    font-family: var(--font-pixel);
    font-size: clamp(16px, 5vw, 28px);
    letter-spacing: 2px;
    color: var(--primary);
    text-shadow: 
        4px 4px 0 var(--primary-dark),
        -2px -2px 0 #ff6080;
    line-height: 1.4;
    margin-top: 10px;
}

@keyframes titleBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.9; }
}

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

/* ===== BUTTONS - 16-BIT PIXEL STYLE ===== */
.menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    min-width: 240px;
    font-family: var(--font-pixel);
    font-size: 11px;
    letter-spacing: 1px;
    color: #f0f0f0 !important;
    background: #181828 !important;
    border: 4px solid #404858 !important;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.1s ease;
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.15),
        inset -2px -2px 0 rgba(0,0,0,0.4),
        4px 4px 0 rgba(0,0,0,0.6);
    text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    image-rendering: pixelated;
    opacity: 1 !important;
}

.menu-btn:hover, .menu-btn:active {
    transform: translate(2px, 2px);
    border-color: var(--primary);
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.15),
        inset -2px -2px 0 rgba(0,0,0,0.4),
        2px 2px 0 rgba(0,0,0,0.6);
    background: var(--bg-card-hover);
}

.menu-btn.primary {
    background: var(--primary);
    border-color: #404858;
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.2),
        inset -2px -2px 0 rgba(0,0,0,0.3),
        4px 4px 0 rgba(0,0,0,0.6);
}

.menu-btn.primary:hover {
    background: #f03050;
    transform: translate(2px, 2px);
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.2),
        inset -2px -2px 0 rgba(0,0,0,0.3),
        2px 2px 0 var(--primary-dark);
}

.menu-btn.danger {
    background: #404050;
    border-color: #505060;
}

/* Revive Button - Blockchain Style */
.menu-btn.revive-btn {
    background: linear-gradient(135deg, #1a5f2a 0%, #0d3518 100%);
    border: 2px solid #2a8f4a;
    color: #7fff7f !important;
    animation: revive-pulse 2s ease-in-out infinite;
}

.menu-btn.revive-btn:hover {
    background: linear-gradient(135deg, #2a8f4a 0%, #1a5f2a 100%);
    border-color: #4fbf6f;
    box-shadow: 0 0 20px rgba(79, 191, 111, 0.4);
}

.menu-btn.revive-btn .revive-icon {
    font-size: 18px;
}

.menu-btn.revive-btn .revive-price {
    font-size: 9px;
    opacity: 0.8;
    margin-left: 8px;
    padding: 2px 6px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
}

@keyframes revive-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(79, 191, 111, 0.3); }
    50% { box-shadow: 0 0 20px rgba(79, 191, 111, 0.6); }
}

.revives-info {
    margin-top: 12px;
    font-size: 12px;
    color: #7fff7f;
    text-align: center;
}

.revives-info .revive-count {
    font-weight: bold;
    font-size: 16px;
}

/* MINT/BUY Button on Character Cards */
.char-action-btn {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 12px;
    font-size: 10px;
    font-family: var(--font-pixel);
    border: 2px solid;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.char-action-btn.mint-btn {
    background: linear-gradient(135deg, #4a90d9 0%, #2a5080 100%);
    border-color: #6ab0ff;
    color: #fff;
}

.char-action-btn.mint-btn:hover {
    background: linear-gradient(135deg, #6ab0ff 0%, #4a90d9 100%);
    box-shadow: 0 0 10px rgba(106, 176, 255, 0.5);
}

.char-action-btn.buy-btn {
    background: linear-gradient(135deg, #d9a04a 0%, #806020 100%);
    border-color: #ffc04a;
    color: #fff;
}

.char-action-btn.buy-btn:hover {
    background: linear-gradient(135deg, #ffc04a 0%, #d9a04a 100%);
    box-shadow: 0 0 10px rgba(255, 192, 74, 0.5);
}

.char-action-btn .eth-price {
    font-size: 8px;
    opacity: 0.9;
}

.menu-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    filter: grayscale(0.5);
}

.btn-icon {
    font-size: 16px;
    image-rendering: pixelated;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== GOLD DISPLAY - 16-BIT ===== */
.gold-display {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    margin-top: 20px;
    background: #282820;
    border: 4px solid var(--gold-dark);
    border-radius: 0;
    font-family: var(--font-pixel);
    font-size: 12px;
    color: var(--gold);
    text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.1),
        inset -2px -2px 0 rgba(0,0,0,0.3);
}

.gold-display.small {
    padding: 4px 10px;
    font-size: 10px;
}

.gold-icon {
    font-size: 18px;
    image-rendering: pixelated;
}


/* ===== SCREEN HEADER - 16-BIT ===== */
.screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-darker);
    border-bottom: 4px solid var(--border);
    box-shadow: inset 0 -2px 0 rgba(255,255,255,0.05);
}

.screen-header h2 {
    font-family: var(--font-pixel);
    font-size: 12px;
    color: var(--primary);
    text-shadow: 2px 2px 0 var(--primary-dark);
}

.back-btn {
    padding: 6px 12px;
    background: var(--bg-card);
    border: 3px solid var(--border);
    border-radius: 0;
    color: var(--text);
    font-family: var(--font-pixel);
    font-size: 9px;
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.1),
        2px 2px 0 rgba(0,0,0,0.5);
}

.back-btn:hover {
    border-color: var(--primary);
    transform: translate(1px, 1px);
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.1),
        1px 1px 0 rgba(0,0,0,0.5);
}

/* ===== CHARACTER SELECT - 16-BIT ===== */
.characters-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
    background: var(--bg-dark);
}

.character-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    background: var(--bg-card);
    border: 4px solid var(--border);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.08),
        inset -2px -2px 0 rgba(0,0,0,0.3),
        3px 3px 0 rgba(0,0,0,0.5);
}

.character-card:hover {
    border-color: var(--primary);
    transform: translate(1px, 1px);
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.08),
        inset -2px -2px 0 rgba(0,0,0,0.3),
        1px 1px 0 rgba(0,0,0,0.5);
}

.character-card.selected {
    border-color: var(--gold);
    background: #282820;
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,0,0.1),
        inset -2px -2px 0 rgba(0,0,0,0.3),
        0 0 0 2px var(--gold);
}

.character-card.locked {
    opacity: 0.4;
    filter: grayscale(1);
}

.character-card .char-icon {
    font-size: 36px;
    margin-bottom: 6px;
    image-rendering: pixelated;
}

.character-card .char-name {
    font-family: var(--font-pixel);
    font-size: 8px;
    text-align: center;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
}

.character-card .char-cost {
    font-family: var(--font-pixel);
    font-size: 7px;
    color: var(--gold);
    margin-top: 4px;
}

.character-info {
    padding: 16px;
    background: var(--bg-darker);
    border-top: 4px solid var(--border);
    text-align: center;
}

.character-info h3 {
    font-family: var(--font-pixel);
    font-size: 12px;
    color: var(--gold);
    margin-bottom: 8px;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}

.character-info p {
    font-family: var(--font-pixel);
    font-size: 8px;
    color: var(--text-dim);
    margin: 4px 0;
    line-height: 1.6;
}

/* ===== POWERUPS GRID ===== */
.powerups-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 20px;
    overflow-y: auto;
}

.powerup-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.powerup-card:hover {
    border-color: var(--primary);
}

.powerup-card.maxed {
    border-color: var(--gold);
    background: linear-gradient(180deg, #2a2a15 0%, var(--bg-card) 100%);
}

.powerup-card .pu-icon {
    font-size: 30px;
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 32px;
}

.powerup-card .pu-icon canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.powerup-card .pu-name {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 5px;
}

.powerup-card .pu-level {
    font-size: 11px;
    color: var(--xp);
}

.powerup-card .pu-cost {
    font-size: 11px;
    color: var(--gold);
    margin-top: 5px;
}

/* ===== GAME SCREEN ===== */
#game-screen {
    background: #0d0d12;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ===== GAME HUD - 16-BIT RETRO ===== */
#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 10;
    image-rendering: pixelated;
}

.hud-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 8px 12px;
    gap: 8px;
}

.hud-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    max-width: 180px;
}

.health-bar, .exp-bar {
    position: relative;
    height: 18px;
    background: #101018;
    border: 3px solid var(--border);
    border-radius: 0;
    overflow: hidden;
    box-shadow: 
        inset 2px 2px 0 rgba(0,0,0,0.5),
        inset -1px -1px 0 rgba(255,255,255,0.05);
}

.health-fill {
    height: 100%;
    width: 100%;
    background: var(--health);
    box-shadow: inset 0 -4px 0 var(--health-dark), inset 0 2px 0 rgba(255,255,255,0.2);
    transition: width 0.15s steps(10);
}

.exp-fill {
    height: 100%;
    width: 0%;
    background: var(--xp);
    box-shadow: inset 0 -4px 0 var(--xp-dark), inset 0 2px 0 rgba(255,255,255,0.2);
    transition: width 0.15s steps(10);
}

.health-bar span, .exp-bar span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-pixel);
    font-size: 8px;
    text-shadow: 1px 1px 0 black, -1px -1px 0 black;
}

.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.combo-display {
    font-family: var(--font-pixel);
    font-size: 10px;
    color: #ff6644;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.8);
    margin-top: 4px;
}

.timer {
    padding: 6px 16px;
    background: #181820;
    border: 3px solid var(--border);
    border-radius: 0;
    font-family: var(--font-pixel);
    font-size: 14px;
    color: var(--gold);
    text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.05),
        inset -2px -2px 0 rgba(0,0,0,0.3),
        3px 3px 0 rgba(0,0,0,0.5);
}

.kills {
    font-family: var(--font-pixel);
    font-size: 9px;
    color: var(--text-dim);
    text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
}

.hud-right {
    pointer-events: auto;
}

.pause-btn {
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 3px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.1),
        inset -2px -2px 0 rgba(0,0,0,0.3),
        3px 3px 0 rgba(0,0,0,0.5);
}

.pause-btn::before,
.pause-btn::after {
    content: '';
    width: 6px;
    height: 18px;
    background: var(--text);
    border-radius: 2px;
}

.pause-btn:hover {
    border-color: var(--primary);
    transform: translate(1px, 1px);
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.1),
        inset -2px -2px 0 rgba(0,0,0,0.3),
        1px 1px 0 rgba(0,0,0,0.5);
}

/* ===== WEAPONS DISPLAY ===== */
.weapons-display {
    position: absolute;
    top: 85px;
    left: 10px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    max-width: 200px;
}

.weapon-slot {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 20px;
}

.weapon-slot.evolved {
    border-color: var(--gold);
    box-shadow: 0 0 10px var(--gold-glow);
}

/* ===== JOYSTICK ===== */
.joystick-zone {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 120px;
    height: 120px;
    pointer-events: auto;
    display: none;
}

.joystick-base {
    position: relative;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
}

.joystick-stick {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin-top: -25px;
    margin-left: -25px;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transition: transform 0.1s;
}

/* ===== MODALS - 16-BIT RETRO ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 16px;
    image-rendering: pixelated;
}

.modal.active {
    display: flex;
    animation: modalOpen 0.2s steps(4);
}

@keyframes modalOpen {
    0% { opacity: 0; transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

.modal-content {
    background: var(--bg-card);
    border: 6px solid var(--primary);
    border-radius: 0;
    padding: 20px;
    max-width: 380px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,255,0.08),
        inset -4px -4px 0 rgba(0,0,0,0.4),
        8px 8px 0 rgba(0,0,0,0.7);
}

.modal-content h2 {
    font-family: var(--font-pixel);
    font-size: 14px;
    color: var(--gold);
    margin-bottom: 12px;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.5);
    letter-spacing: 1px;
}

/* ===== LEVEL UP MODAL - 16-BIT ===== */
.levelup-content {
    border-color: var(--gold);
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,0,0.1),
        inset -4px -4px 0 rgba(0,0,0,0.4),
        8px 8px 0 var(--gold-dark);
}

#new-level-text {
    font-family: var(--font-pixel);
    font-size: 11px;
    color: var(--xp);
    margin-bottom: 16px;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}

.upgrade-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.upgrade-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-dark);
    border: 4px solid var(--border);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.1s;
    text-align: left;
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.05),
        inset -2px -2px 0 rgba(0,0,0,0.3),
        3px 3px 0 rgba(0,0,0,0.5);
}

.upgrade-option:hover {
    border-color: var(--primary);
    transform: translate(2px, 2px);
    box-shadow: 
        inset 2px 2px 0 rgba(255,255,255,0.05),
        inset -2px -2px 0 rgba(0,0,0,0.3),
        1px 1px 0 rgba(0,0,0,0.5);
}

.upgrade-option.new-weapon {
    border-color: var(--gold);
    background: #202018;
}

.upgrade-option.evolution {
    border-color: #e040e0;
    background: #201828;
    box-shadow: 
        inset 2px 2px 0 rgba(255,0,255,0.1),
        inset -2px -2px 0 rgba(0,0,0,0.3),
        3px 3px 0 #801080;
}

.upgrade-icon {
    font-size: 28px;
    flex-shrink: 0;
    image-rendering: pixelated;
}

.upgrade-info {
    flex: 1;
}

.upgrade-info h4 {
    font-family: var(--font-pixel);
    font-size: 9px;
    margin-bottom: 4px;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
}

.upgrade-info p {
    font-family: var(--font-pixel);
    font-size: 7px;
    color: var(--text-dim);
    line-height: 1.5;
}

.upgrade-level {
    font-family: var(--font-pixel);
    font-size: 7px;
    color: var(--xp);
    margin-top: 4px;
}

/* ===== PAUSE MODAL - 16-BIT ===== */
.pause-stats p, .gameover-stats p {
    font-family: var(--font-pixel);
    font-size: 9px;
    margin: 6px 0;
    line-height: 1.6;
}

.pause-stats span, .gameover-stats span {
    color: var(--gold);
}

.pause-weapons {
    margin: 16px 0;
}

.pause-weapons h3 {
    font-family: var(--font-pixel);
    font-size: 9px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

#pause-weapons-list {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pause-buttons, .gameover-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

/* ===== CHEST MODAL - 16-BIT ===== */
.chest-content {
    border-color: var(--gold);
    box-shadow: 
        inset 4px 4px 0 rgba(255,255,0,0.1),
        inset -4px -4px 0 rgba(0,0,0,0.4),
        8px 8px 0 var(--gold-dark);
}

.chest-rewards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.chest-reward {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-dark);
    border: 3px solid var(--border);
    border-radius: 0;
    box-shadow: inset 2px 2px 0 rgba(255,255,255,0.05);
}

.chest-reward .reward-icon {
    font-size: 24px;
    image-rendering: pixelated;
}

.chest-reward .reward-name {
    font-family: var(--font-pixel);
    font-size: 9px;
}

/* ===== DAMAGE NUMBERS - 16-BIT ===== */
.damage-number {
    position: absolute;
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--gold);
    text-shadow: 2px 2px 0 black, -1px -1px 0 black;
    pointer-events: none;
    animation: damageFloat 0.8s ease-out forwards;
    z-index: 50;
}

.damage-number.crit {
    font-size: 24px;
    color: #ff4444;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .title-icon {
        font-size: 60px;
    }
    
    .menu-btn {
        min-width: 220px;
        padding: 14px 30px;
        font-size: 16px;
    }
    
    .characters-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 10px;
        padding: 15px;
    }
    
    .character-card {
        padding: 10px 5px;
    }
    
    .character-card .char-icon {
        font-size: 32px;
    }
    
    .character-card .char-name {
        font-size: 10px;
    }
    
    .joystick-zone {
        display: block;
    }
    
    .timer {
        font-size: 16px;
        padding: 6px 15px;
    }
    
    .hud-left {
        max-width: 150px;
    }
    
    .health-bar, .exp-bar {
        height: 16px;
    }
    
    .weapons-display {
        max-width: 40%;
    }
    
    .weapon-slot {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}

@media (hover: none) {
    .joystick-zone {
        display: block;
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dark);
}
