/* ============================================================================
   STACK BALL CLONE - STYLES
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

:root {
    --bg-dark: #1a1a2e;
    --bg-gradient-top: #667eea;
    --bg-gradient-bottom: #764ba2;
    --text-white: #ffffff;
    --text-shadow: rgba(0, 0, 0, 0.5);
    --accent-yellow: #ffd93d;
    --accent-orange: #ff6b35;
    --accent-red: #ff3366;
    --accent-green: #6bcb77;
    --panel-bg: rgba(0, 0, 0, 0.8);
    --panel-border: rgba(255, 255, 255, 0.2);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', 'Arial Black', sans-serif;
    background: linear-gradient(180deg, #3d3d3d 0%, #1a1a1a 100%);
    touch-action: none;
}

.hidden {
    display: none !important;
}

/* ============================================================================
   GAME CONTAINER & CANVAS
   ============================================================================ */

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* ============================================================================
   MAIN MENU
   ============================================================================ */

#main-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #4a4a4a 0%, #2d2d2d 50%, #1a1a1a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.menu-content {
    text-align: center;
    color: var(--text-white);
}

.game-title {
    margin-bottom: 40px;
}

.ball-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #ff6b35 0%, #ff3366 100%);
    border-radius: 50%;
    box-shadow:
        0 10px 30px rgba(255, 107, 53, 0.5),
        inset 0 -10px 20px rgba(0, 0, 0, 0.3),
        inset 0 10px 20px rgba(255, 255, 255, 0.3);
    animation: bounce-preview 1s ease-in-out infinite;
}

@keyframes bounce-preview {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.game-title h1 {
    font-size: 72px;
    font-weight: 900;
    letter-spacing: 8px;
    text-shadow:
        4px 4px 0 var(--accent-orange),
        8px 8px 0 rgba(0, 0, 0, 0.3);
    margin-bottom: -10px;
}

.game-title h2 {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 12px;
    color: var(--accent-yellow);
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
}

.high-score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 40px;
    font-size: 18px;
    opacity: 0.9;
}

.high-score-display span:last-child {
    font-size: 36px;
    font-weight: 800;
    color: var(--accent-yellow);
}

.menu-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 220px;
    height: 70px;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 3px;
    color: white;
    background: linear-gradient(135deg, var(--accent-green) 0%, #4CAF50 100%);
    border: none;
    border-radius: 35px;
    cursor: pointer;
    box-shadow:
        0 8px 0 #2E7D32,
        0 15px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.1s ease;
}

.play-btn:active {
    transform: translateY(4px);
    box-shadow:
        0 4px 0 #2E7D32,
        0 8px 15px rgba(0, 0, 0, 0.3);
}

.play-icon {
    font-size: 24px;
}

.reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    font-size: 32px;
    color: white;
    background: linear-gradient(135deg, var(--accent-orange) 0%, var(--accent-red) 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow:
        0 8px 0 #b33000,
        0 15px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.1s ease;
}

.reset-btn:active {
    transform: translateY(4px);
    box-shadow:
        0 4px 0 #b33000,
        0 8px 15px rgba(0, 0, 0, 0.3);
}

.reset-icon {
    font-size: 32px;
}

.menu-options {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.option-btn {
    width: 60px;
    height: 60px;
    font-size: 28px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.3);
}

.option-btn.muted {
    opacity: 0.5;
}

.other-games-btn {
    position: absolute;
    bottom: 30px;
    right: 30px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.2s ease;
}

.other-games-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.other-games-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

/* ============================================================================
   GAME HUD
   ============================================================================ */

#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    pointer-events: none;
    z-index: 50;
}

.level-display {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--panel-bg);
    padding: 10px 20px;
    border-radius: 15px;
    border: 2px solid var(--panel-border);
}

.level-display span:first-child {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 2px;
}

.level-display span:last-child {
    font-size: 32px;
    font-weight: 800;
    color: var(--accent-yellow);
}

.score-display {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--panel-bg);
    padding: 10px 25px;
    border-radius: 15px;
    border: 2px solid var(--panel-border);
}

.score-display span {
    font-size: 28px;
    font-weight: 800;
    color: white;
}

.progress-container {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.progress-bar {
    width: 150px;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-green) 0%, var(--accent-yellow) 100%);
    border-radius: 4px;
    transition: width 0.2s ease;
}

.progress-text {
    font-size: 14px;
    font-weight: 700;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* ============================================================================
   FIREBALL INDICATOR
   ============================================================================ */

#fireball-indicator {
    position: absolute;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 60;
    animation: fireball-pulse 0.5s ease-in-out infinite;
}

@keyframes fireball-pulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.1); }
}

.fireball-meter {
    width: 120px;
    height: 16px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--accent-orange);
}

.fireball-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-orange) 0%, var(--accent-red) 100%);
    border-radius: 6px;
    transition: width 0.15s ease;
}

#fireball-indicator span {
    font-size: 20px;
    font-weight: 800;
    color: var(--accent-orange);
    text-shadow: 0 0 20px var(--accent-orange);
    letter-spacing: 3px;
}

#fireball-indicator.active {
    animation: fireball-active 0.2s ease-in-out infinite;
}

#fireball-indicator.active span {
    color: var(--accent-red);
    text-shadow: 0 0 30px var(--accent-red);
}

@keyframes fireball-active {
    0%, 100% { transform: translateX(-50%) scale(1.1); }
    50% { transform: translateX(-50%) scale(1.2); }
}

/* ============================================================================
   COMBO DISPLAY
   ============================================================================ */

#combo-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 55;
    pointer-events: none;
}

#combo-display span {
    font-size: 72px;
    font-weight: 900;
    color: var(--accent-yellow);
    text-shadow:
        4px 4px 0 var(--accent-orange),
        0 0 40px rgba(255, 217, 61, 0.8);
    animation: combo-pop 0.3s ease-out;
}

@keyframes combo-pop {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); opacity: 1; }
}

/* ============================================================================
   LEVEL COMPLETE
   ============================================================================ */

#level-complete {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.complete-panel {
    background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
    border: 3px solid var(--accent-green);
    border-radius: 25px;
    padding: 30px 40px;
    text-align: center;
    color: white;
    min-width: 300px;
    animation: panel-slide 0.4s ease-out;
}

@keyframes panel-slide {
    0% { transform: translateY(-50px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.complete-panel h2 {
    font-size: 32px;
    color: var(--accent-green);
    margin-bottom: 15px;
    text-shadow: 0 0 20px rgba(107, 203, 119, 0.5);
}

.complete-icon {
    font-size: 60px;
    margin-bottom: 20px;
}

.level-score, .bonus-score, .total-score {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 18px;
}

.level-score span:last-child,
.bonus-score span:last-child {
    color: var(--accent-yellow);
    font-weight: 700;
}

.total-score {
    border-bottom: none;
    font-size: 24px;
    font-weight: 800;
    margin-top: 10px;
}

.total-score span:last-child {
    color: var(--accent-green);
}

.next-btn {
    margin-top: 20px;
    width: 100%;
    padding: 18px;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 2px;
    color: white;
    background: linear-gradient(135deg, var(--accent-green) 0%, #4CAF50 100%);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 6px 0 #2E7D32;
    transition: all 0.1s ease;
}

.next-btn:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #2E7D32;
}

.next-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================================
   GAME OVER
   ============================================================================ */

#game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.gameover-panel {
    background: linear-gradient(180deg, #4a1a1a 0%, #1a0a0a 100%);
    border: 3px solid var(--accent-red);
    border-radius: 25px;
    padding: 30px 40px;
    text-align: center;
    color: white;
    min-width: 300px;
    animation: shake-panel 0.5s ease-out;
}

@keyframes shake-panel {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

.gameover-panel h2 {
    font-size: 36px;
    color: var(--accent-red);
    margin-bottom: 15px;
    text-shadow: 0 0 20px rgba(255, 51, 102, 0.5);
}

.shatter-icon {
    font-size: 70px;
    margin-bottom: 20px;
}

.final-score, .best-score {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    font-size: 20px;
}

.final-score span:last-child {
    color: var(--accent-yellow);
    font-weight: 700;
}

.best-score span:last-child {
    color: var(--accent-green);
    font-weight: 700;
}

.retry-btn {
    width: 100%;
    padding: 18px;
    margin-top: 20px;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 2px;
    color: white;
    background: linear-gradient(135deg, var(--accent-orange) 0%, var(--accent-red) 100%);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 6px 0 #b33000;
    transition: all 0.1s ease;
}

.retry-btn:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #b33000;
}

.gameover-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.gameover-buttons-row {
    display: flex;
    gap: 10px;
}

.gameover-buttons .retry-btn {
    flex: 1;
    margin-top: 0;
}

.menu-btn {
    flex: 1;
    padding: 18px;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 2px;
    color: white;
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 6px 0 #1a202c;
    transition: all 0.1s ease;
}

.menu-btn:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #1a202c;
}

.share-btn-small {
    width: 100%;
    padding: 14px;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 2px;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 6px 0 #4a3a7a;
    transition: all 0.1s ease;
}

.share-btn-small:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #4a3a7a;
}

/* ============================================================================
   TOUCH INSTRUCTION
   ============================================================================ */

#touch-instruction {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
}

#touch-instruction span {
    font-size: 36px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8);
    letter-spacing: 8px;
}

#touch-instruction.hidden {
    display: none;
}

/* ============================================================================
   PAUSE BUTTON
   ============================================================================ */

#pause-btn {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 50px;
    font-size: 24px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    z-index: 70;
    pointer-events: auto;
}

/* ============================================================================
   SCREEN EFFECTS
   ============================================================================ */

.screen-shake {
    animation: screen-shake 0.3s ease-out;
}

@keyframes screen-shake {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-5px, 5px); }
    50% { transform: translate(5px, -5px); }
    75% { transform: translate(-5px, -5px); }
}

.screen-flash {
    animation: screen-flash 0.2s ease-out;
}

@keyframes screen-flash {
    0% { filter: brightness(2); }
    100% { filter: brightness(1); }
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 500px) {
    .game-title h1 {
        font-size: 52px;
    }

    .game-title h2 {
        font-size: 36px;
    }

    .ball-icon {
        width: 60px;
        height: 60px;
    }

    .play-btn {
        width: 180px;
        height: 60px;
        font-size: 22px;
    }

    .reset-btn {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }

    .reset-icon {
        font-size: 28px;
    }

    .level-display, .score-display {
        padding: 8px 15px;
    }

    .level-display span:last-child {
        font-size: 26px;
    }

    .score-display span {
        font-size: 22px;
    }

    #combo-display span {
        font-size: 56px;
    }

    .complete-panel, .gameover-panel {
        padding: 25px 30px;
        min-width: 280px;
    }
}

@media (max-height: 600px) {
    .game-title {
        margin-bottom: 20px;
    }

    .game-title h1 {
        font-size: 48px;
    }

    .ball-icon {
        width: 50px;
        height: 50px;
        margin-bottom: 10px;
    }

    .high-score-display {
        margin-bottom: 20px;
    }

    .play-btn {
        margin-bottom: 15px;
    }
}
