/* ==========================================
   WHACK-A-BUG - Styles
   ========================================== */

/* Variables */
:root {
    --primary: #00d9ff;
    --secondary: #a855f7;
    --accent: #f472b6;
    --bg-dark: #0a0a0f;
    --bg-card: rgba(255, 255, 255, 0.05);
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    
    /* Bug colors */
    --bug-green: #22c55e;
    --bug-red: #ef4444;
    --bug-gold: #eab308;
    --hole-color: #1a1a2e;
    --hole-shadow: #0d0d15;
    
    --success: #22c55e;
    --error: #ef4444;
}

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

/* Body */
body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32"><text y="24" font-size="24">🔨</text></svg>') 8 8, auto;
}

/* Custom cursor for game area */
.game-area {
    cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><text y="32" font-size="32">🔨</text></svg>') 16 16, pointer;
}

/* Background Grid */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image: 
        linear-gradient(rgba(0, 217, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 217, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}

/* Floating Orbs */
.floating-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: var(--primary);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 250px;
    height: 250px;
    background: var(--secondary);
    bottom: 20%;
    left: -80px;
    animation-delay: -7s;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: var(--accent);
    bottom: -50px;
    right: 20%;
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

/* Game Wrapper */
.game-wrapper {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    padding-bottom: env(safe-area-inset-bottom, 1rem);
}

/* Header */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.back-link:hover {
    color: var(--primary);
}

.game-logo {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--bug-green), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sound-btn {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.5rem;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
}

.sound-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sound-btn.muted {
    opacity: 0.5;
}

/* Game Container */
.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

/* Screens */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.screen.hidden {
    display: none;
}

/* ==========================================
   MENU SCREEN
   ========================================== */

.menu-screen {
    justify-content: center;
    padding: 1rem 0;
}

.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.title-glow {
    font-size: 2.5rem;
    font-weight: 800;
    text-align: center;
    background: linear-gradient(135deg, var(--bug-green), var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 40px rgba(34, 197, 94, 0.3);
    animation: titlePulse 2s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    text-align: center;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--bug-green), var(--primary));
    border: none;
    color: white;
    padding: 1rem 2.5rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(34, 197, 94, 0.4);
}

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

.btn-glow {
    animation: btnGlow 2s ease-in-out infinite;
}

@keyframes btnGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(34, 197, 94, 0.3); }
    50% { box-shadow: 0 0 40px rgba(34, 197, 94, 0.5); }
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

/* Instructions */
.instructions {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
}

.instructions h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--primary);
}

.instruction-grid {
    display: grid;
    gap: 0.8rem;
}

.instruction {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.instruction .icon {
    font-size: 1.5rem;
    width: 40px;
    text-align: center;
}

.keyboard-hint {
    text-align: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Leaderboard Preview */
.leaderboard-preview {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
}

.leaderboard-preview h3,
.leaderboard-full h3 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--bug-gold);
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    font-size: 0.9rem;
}

.leaderboard-item.top-3 {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.1), rgba(168, 85, 247, 0.1));
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.lb-rank {
    font-weight: 700;
    width: 24px;
    text-align: center;
}

.lb-rank.gold { color: #ffd700; }
.lb-rank.silver { color: #c0c0c0; }
.lb-rank.bronze { color: #cd7f32; }

.lb-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-score {
    font-weight: 600;
    color: var(--bug-green);
}

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 1rem;
}

/* ==========================================
   GAME SCREEN
   ========================================== */

.game-screen {
    justify-content: flex-start;
    gap: 1rem;
}

/* HUD */
.game-hud {
    display: flex;
    justify-content: space-around;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.8rem;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.hud-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hud-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.hud-score .hud-value {
    color: var(--bug-green);
}

#combo {
    color: var(--bug-gold);
}

/* Game Area */
.game-area {
    flex: 1;
    position: relative;
    background: linear-gradient(180deg, #1a1a2e 0%, #0d0d15 100%);
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    min-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-area-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s;
}

.game-area-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.countdown {
    font-size: 6rem;
    font-weight: 800;
    color: var(--primary);
    text-shadow: 0 0 50px var(--primary);
    animation: countdownPop 1s ease-out infinite;
}

@keyframes countdownPop {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Holes Grid */
.holes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 20px;
    width: 100%;
    max-width: 360px;
}

.hole {
    position: relative;
    aspect-ratio: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.hole-bg {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 40%;
    background: radial-gradient(ellipse at center, var(--hole-shadow) 0%, var(--hole-color) 50%, transparent 70%);
    border-radius: 50%;
    z-index: 2;
}

/* Bug Container */
.bug-container {
    position: absolute;
    bottom: 10%;
    width: 70%;
    height: 80%;
    overflow: hidden;
    z-index: 1;
}

.bug {
    position: absolute;
    bottom: -100%;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 60px;
    font-size: 50px;
    line-height: 60px;
    text-align: center;
    cursor: pointer;
    transition: bottom 0.15s ease-out;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.bug.active {
    bottom: 20%;
    animation: bugWiggle 0.3s ease-in-out infinite;
}

.bug.hit {
    animation: bugHit 0.2s ease-out forwards;
}

@keyframes bugWiggle {
    0%, 100% { transform: translateX(-50%) rotate(-5deg); }
    50% { transform: translateX(-50%) rotate(5deg); }
}

@keyframes bugHit {
    0% { transform: translateX(-50%) scale(1); opacity: 1; }
    50% { transform: translateX(-50%) scale(1.3); }
    100% { transform: translateX(-50%) scale(0); opacity: 0; }
}

/* Splat Effect */
#splatContainer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 50;
}

.splat {
    position: absolute;
    font-size: 3rem;
    animation: splatAnim 0.5s ease-out forwards;
    pointer-events: none;
}

@keyframes splatAnim {
    0% { transform: scale(0) rotate(0deg); opacity: 1; }
    50% { transform: scale(1.5) rotate(180deg); opacity: 1; }
    100% { transform: scale(2) rotate(360deg); opacity: 0; }
}

/* Score Popup */
.score-popup {
    position: absolute;
    font-size: 1.5rem;
    font-weight: 800;
    animation: scorePopup 0.8s ease-out forwards;
    pointer-events: none;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 60;
}

.score-popup.positive {
    color: var(--bug-green);
}

.score-popup.negative {
    color: var(--error);
}

.score-popup.bonus {
    color: var(--bug-gold);
}

@keyframes scorePopup {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    20% { transform: translateY(-10px) scale(1.2); opacity: 1; }
    100% { transform: translateY(-60px) scale(1); opacity: 0; }
}

/* ==========================================
   GAME OVER SCREEN
   ========================================== */

.gameover-screen {
    justify-content: flex-start;
    padding: 1rem 0;
    overflow-y: auto;
}

.gameover-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
}

.gameover-title {
    font-size: 1.8rem;
    color: var(--bug-green);
    text-align: center;
}

.score-final {
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(168, 85, 247, 0.1));
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 16px;
}

.score-big {
    font-size: 4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--bug-green), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.score-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.rating {
    font-size: 1.3rem;
    font-weight: 600;
    padding: 0.5rem 1.5rem;
    border-radius: 30px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    width: 100%;
    max-width: 400px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 12px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Save Score Form */
.save-score-form {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 350px;
}

.pseudo-input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.3s;
}

.pseudo-input:focus {
    border-color: var(--primary);
}

.pseudo-input::placeholder {
    color: var(--text-muted);
}

.save-status {
    min-height: 1.5rem;
    font-size: 0.9rem;
    text-align: center;
}

.save-status.success {
    color: var(--success);
}

.save-status.error {
    color: var(--error);
}

.gameover-actions {
    display: flex;
    gap: 1rem;
}

/* Leaderboard Full */
.leaderboard-full {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 480px) {
    .title-glow {
        font-size: 2rem;
    }
    
    .game-wrapper {
        padding: 0.5rem;
    }
    
    .holes-grid {
        gap: 10px;
        padding: 15px;
    }
    
    .bug {
        width: 50px;
        height: 50px;
        font-size: 40px;
        line-height: 50px;
    }
    
    .hud-value {
        font-size: 1.2rem;
    }
    
    .score-big {
        font-size: 3rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .stat-item {
        padding: 0.8rem 0.5rem;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .countdown {
        font-size: 4rem;
    }
}

/* ==========================================
   ANIMATIONS
   ========================================== */

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

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

/* Timer warning */
#timer.warning {
    color: var(--error);
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}
