:root {
    --primary: #0ea5e9;
    --primary-glow: rgba(14, 165, 233, 0.5);
    --secondary: #6366f1;
    --gold: #fbbf24;
    --gold-glow: rgba(251, 191, 36, 0.5);
    --red: #ef4444;
    --bg-dark: rgba(15, 23, 42, 0.8);
    --bg-panel: rgba(30, 41, 59, 0.85);
    
    --font-heading: 'Fredoka One', cursive;
    --font-ui: 'Nunito', sans-serif;
}

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

body {
    overflow: hidden;
    background-color: #000;
    font-family: var(--font-ui);
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s ease;
    pointer-events: auto;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

#screen-main, #screen-characters, #screen-missions, #screen-gameover {
    background: radial-gradient(circle at center, transparent 0%, var(--bg-dark) 100%);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* Typography */
.logo-container { text-align: center; margin-bottom: 3rem; }
.logo { font-family: var(--font-heading); font-size: 5rem; line-height: 1; text-shadow: 0 10px 20px rgba(0,0,0,0.5); }
.highlight { color: var(--primary); text-shadow: 0 0 15px var(--primary-glow); }
.text-gold { color: var(--gold) !important; text-shadow: 0 0 10px var(--gold-glow); }
.text-blue { color: var(--primary) !important; text-shadow: 0 0 10px var(--primary-glow); }
.text-red { color: var(--red) !important; text-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
h2 { font-family: var(--font-heading); font-size: 2.5rem; margin-bottom: 2rem; letter-spacing: 2px; }

/* Stats Bar */
.stats-bar {
    display: flex; gap: 1.5rem; background: var(--bg-panel); padding: 0.5rem 1.5rem;
    border-radius: 30px; border: 1px solid rgba(255,255,255,0.1); margin-bottom: 2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.stats-bar.top-bar { position: absolute; top: 2rem; margin-bottom: 0; }
.stat { display: flex; align-items: center; gap: 0.5rem; font-size: 1.2rem; font-weight: 800; }

/* Buttons */
.btn {
    background: var(--bg-panel); border: 2px solid rgba(255,255,255,0.1);
    color: #fff; padding: 1rem 2.5rem; font-size: 1.2rem; font-weight: 800;
    border-radius: 12px; cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; align-items: center; justify-content: center; gap: 0.8rem;
    min-width: 280px; font-family: var(--font-ui); box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.btn:hover { background: rgba(255,255,255,0.1); transform: translateY(-3px) scale(1.02); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn.primary { background: var(--primary); border: none; box-shadow: 0 8px 25px var(--primary-glow); }
.btn.primary:hover { filter: brightness(1.1); }
.menu-buttons { display: flex; flex-direction: column; gap: 1rem; }
.menu-buttons.horizontal { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.mt-2 { margin-top: 2rem; }

/* Animations */
@keyframes pulse { 0% { transform: scale(1); box-shadow: 0 0 0 0 var(--primary-glow); } 70% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(14, 165, 233, 0); } 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(14, 165, 233, 0); } }
.pulse { animation: pulse 2s infinite; }

/* Gameplay HUD */
#screen-game { pointer-events: none; }
.hud-top {
    position: absolute; top: 2rem; left: 0; width: 100%; display: flex; justify-content: center; align-items: center; padding: 0 2rem;
}
.score-display {
    font-family: var(--font-heading); font-size: 5rem; text-shadow: 0 5px 15px rgba(0,0,0,0.5);
    -webkit-text-stroke: 2px rgba(255,255,255,0.2);
}
.hud-stats { position: absolute; right: 2rem; top: 2rem; display: flex; flex-direction: column; gap: 0.5rem; }
.hud-coin { display: flex; align-items: center; gap: 0.5rem; font-size: 1.5rem; font-weight: 800; background: rgba(0,0,0,0.4); padding: 0.5rem 1rem; border-radius: 20px; }
.touch-hint { position: absolute; bottom: 20%; font-family: var(--font-heading); font-size: 1.5rem; opacity: 0.5; animation: blink 1.5s infinite; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }
@keyframes blink { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.8; } }

/* Powerup Bar */
.powerup-display { position: absolute; bottom: 3rem; display: flex; align-items: center; gap: 1rem; background: rgba(0,0,0,0.5); padding: 0.5rem 1rem; border-radius: 20px; }
.powerup-bar { width: 150px; height: 10px; background: rgba(255,255,255,0.2); border-radius: 5px; overflow: hidden; }
.powerup-fill { height: 100%; background: var(--primary); width: 100%; }

/* Cards & Layouts */
.result-card, .rank-card { background: var(--bg-panel); border: 1px solid rgba(255,255,255,0.1); border-radius: 20px; padding: 2rem; width: 90%; max-width: 400px; box-shadow: 0 20px 40px rgba(0,0,0,0.5); margin-bottom: 2rem; }
.result-row { display: flex; justify-content: space-between; align-items: center; font-size: 1.5rem; font-weight: 800; margin: 0.8rem 0; }
.result-row .highlight { font-family: var(--font-heading); font-size: 2.5rem; }
.divider { height: 1px; background: rgba(255,255,255,0.1); margin: 1.5rem 0; }

.rank-card { display: flex; align-items: center; gap: 1.5rem; }
.rank-icon { font-size: 4rem; color: var(--primary); text-shadow: 0 0 15px var(--primary-glow); }
.rank-info { flex: 1; }
.xp-bar { width: 100%; height: 10px; background: rgba(255,255,255,0.1); border-radius: 5px; margin: 0.5rem 0; overflow: hidden; }
.xp-fill { height: 100%; background: var(--gold); width: 0%; transition: width 0.3s; }

/* Grids */
.character-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 2rem; width: 90%; max-width: 600px; max-height: 50vh; overflow-y: auto; padding-right: 10px; }
.char-card { background: rgba(255,255,255,0.05); border: 2px solid rgba(255,255,255,0.1); border-radius: 12px; padding: 1rem; text-align: center; cursor: pointer; transition: 0.2s; position: relative; }
.char-card:hover { transform: scale(1.05); background: rgba(255,255,255,0.1); }
.char-card.active { border-color: var(--primary); box-shadow: 0 0 15px var(--primary-glow); background: rgba(14, 165, 233, 0.2); }
.char-card.locked { opacity: 0.6; filter: grayscale(100%); }
.char-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.char-price { display: flex; justify-content: center; align-items: center; gap: 0.2rem; font-weight: 800; color: var(--gold); }
.char-name { font-weight: 800; font-size: 0.9rem; }

.mission-list { display: flex; flex-direction: column; gap: 1rem; width: 90%; max-width: 500px; max-height: 40vh; overflow-y: auto; margin-bottom: 2rem; }
.mission-card { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.mission-desc { font-weight: 600; font-size: 1.1rem; }
.mission-reward { display: flex; align-items: center; gap: 0.3rem; color: var(--gold); font-weight: 800; }
.mission-card.completed { border-color: var(--gold); background: rgba(251, 191, 36, 0.1); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius: 3px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

@media (max-width: 600px) {
    .logo { font-size: 3.5rem; }
    .character-grid { grid-template-columns: repeat(2, 1fr); }
    .menu-buttons.horizontal { flex-direction: column; }
    .btn { min-width: 250px; }
    .hud-stats { right: 1rem; top: 1rem; }
}
