﻿/* Bubble Bounce Blitz - Style Sheet */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    margin: 0;
    padding: 0;
    color: white;
    overflow: hidden;
    /* Prevent mobile scrolling and zooming */
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    background: linear-gradient(180deg, #0f0f23 0%, #1a1a3e 100%);
    border-radius: 0;
    box-shadow: 0 0 50px rgba(100, 149, 237, 0.3), inset 0 0 100px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* UI Overlay */
#ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
    font-size: 14px;
    font-weight: bold;
    z-index: 10;
    pointer-events: none;
}

#ui > div {
    padding: 5px 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

#score { 
    color: #ffd700; 
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.3s ease;
}

#score.rain-active {
    animation: rainbowPulse 0.5s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

@keyframes rainbowPulse {
    0%, 100% { 
        color: #ffd700; 
        transform: scale(1);
    }
    50% { 
        color: #ff6b6b; 
        transform: scale(1.1);
    }
}

#highScore { color: #c0c0c0; }
#level { color: #4ecdc4; }
#lives { color: #ff6b6b; }

/* Power-up Display */
#powerup-display {
    position: absolute;
    bottom: 80px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 10;
    pointer-events: none;
}

.powerup-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: rgba(0,0,0,0.7);
    border-radius: 15px;
    font-size: 12px;
    animation: powerupPulse 1s ease-in-out infinite;
}

.powerup-indicator .timer {
    width: 30px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    overflow: hidden;
}

.powerup-indicator .timer-bar {
    height: 100%;
    background: #4ecdc4;
    transition: width 0.1s linear;
}

@keyframes powerupPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Screen Overlays */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 100;
    transition: opacity 0.3s ease, transform 0.3s ease;
    padding-top: 80px; /* Space for menu bricks at top */
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
}

#menu {
    padding-top: 85px; /* Extra space for the 3 rows of bricks */
}

.screen h1 {
    font-size: clamp(1.5em, 6vw, 2.5em);
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    animation: titleGlow 2s ease-in-out infinite;
    white-space: nowrap;
    padding: 0 10px;
}

.screen h2 {
    font-size: 2em;
    margin-bottom: 20px;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

.screen h3 {
    font-size: 1.3em;
    margin: 15px 0;
    color: #ffd700;
}

.subtitle {
    font-size: 1.2em;
    color: #ffd700;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    animation: subtitlePulse 3s ease-in-out infinite;
}

@keyframes subtitlePulse {
    0%, 100% { color: #ffd700; text-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
    50% { color: #fff; text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 100, 100, 0.4); }
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 100, 100, 0.5); }
    50% { text-shadow: 0 0 40px rgba(255, 215, 0, 1), 0 0 60px rgba(255, 100, 100, 0.8), 0 0 80px rgba(100, 200, 255, 0.4); }
}

/* Casino Menu Bricks */
.menu-bricks {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    max-width: 95%;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    row-gap: 6px;
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.menu-brick {
    width: calc((100% - 32px) / 9);
    max-width: 38px;
    min-width: 28px;
    height: 18px;
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: filter 0.1s, box-shadow 0.1s, opacity 0.3s, transform 0.3s;
}

.menu-brick.destroyed {
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
}

.menu-brick.rainbow {
    background: linear-gradient(90deg, #ff0000, #ff7700, #ffff00, #00ff00, #0077ff, #8b00ff);
    animation: rainbowShift 1s linear infinite;
}

.menu-brick.gold {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4a 30%, #ffd700 50%, #b8860b 100%);
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.6);
    animation: goldShimmer 2s ease-in-out infinite;
}

.menu-brick.explosive {
    background: linear-gradient(135deg, #ff4500 0%, #ff6b35 50%, #ff4500 100%);
    animation: explosivePulse 0.5s ease-in-out infinite;
}

.menu-brick.super {
    background: linear-gradient(135deg, #ff00ff 0%, #00ffff 50%, #ffff00 100%);
    box-shadow: 0 4px 25px rgba(255, 0, 255, 0.7);
    animation: superGlow 0.8s ease-in-out infinite;
}

.menu-brick.power {
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.5);
    animation: powerPulse 1.5s ease-in-out infinite;
}

@keyframes brickFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-8px) rotate(-2deg); }
    50% { transform: translateY(-4px) rotate(0deg); }
    75% { transform: translateY(-10px) rotate(2deg); }
}

@keyframes rainbowShift {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

@keyframes goldShimmer {
    0%, 100% { box-shadow: 0 4px 20px rgba(255, 215, 0, 0.6); }
    50% { box-shadow: 0 4px 30px rgba(255, 215, 0, 1), 0 0 15px rgba(255, 255, 255, 0.5); }
}

@keyframes explosivePulse {
    0%, 100% { transform: scale(1); box-shadow: 0 4px 15px rgba(255, 69, 0, 0.5); }
    50% { transform: scale(1.08); box-shadow: 0 6px 25px rgba(255, 69, 0, 0.9); }
}

@keyframes superGlow {
    0%, 100% { box-shadow: 0 4px 25px rgba(255, 0, 255, 0.7); }
    50% { box-shadow: 0 4px 35px rgba(0, 255, 255, 1), 0 0 50px rgba(255, 255, 0, 0.5); }
}

@keyframes powerPulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(78, 205, 196, 0.5); }
    50% { box-shadow: 0 4px 25px rgba(78, 205, 196, 0.9), 0 0 20px rgba(78, 205, 196, 0.4); }
}

/* Brick hit effect when demo ball collides */
.menu-brick.brick-hit {
    animation: brickHitFlash 0.2s ease-out !important;
    filter: brightness(1.5) !important;
}

@keyframes brickHitFlash {
    0% { transform: scale(1.2); filter: brightness(2); }
    100% { transform: scale(1); filter: brightness(1); }
}

/* Demo ball styling handled by JS, but add trail effect */
.demo-ball::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: inherit;
    border-radius: 50%;
    opacity: 0.3;
    transform: scale(0.8);
    filter: blur(2px);
}

/* Sparkle Effects */
.sparkle-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
}

.sparkle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: radial-gradient(circle, #fff 0%, rgba(255, 215, 0, 0.8) 40%, transparent 70%);
    border-radius: 50%;
    animation: sparkleFloat 3s ease-in-out infinite;
}

.sparkle:nth-child(1) { left: 8%; top: 15%; animation-delay: 0s; width: 8px; height: 8px; }
.sparkle:nth-child(2) { left: 92%; top: 25%; animation-delay: 0.5s; }
.sparkle:nth-child(3) { left: 15%; top: 55%; animation-delay: 1s; width: 10px; height: 10px; }
.sparkle:nth-child(4) { left: 85%; top: 65%; animation-delay: 1.5s; }
.sparkle:nth-child(5) { left: 50%; top: 8%; animation-delay: 2s; width: 7px; height: 7px; }
.sparkle:nth-child(6) { left: 25%; top: 35%; animation-delay: 0.3s; }
.sparkle:nth-child(7) { left: 75%; top: 45%; animation-delay: 0.8s; width: 9px; height: 9px; }
.sparkle:nth-child(8) { left: 40%; top: 75%; animation-delay: 1.3s; }

@keyframes sparkleFloat {
    0%, 100% { 
        opacity: 0;
        transform: scale(0) translateY(0) rotate(0deg);
    }
    10% {
        opacity: 1;
        transform: scale(1.2) translateY(-5px) rotate(45deg);
    }
    30% {
        opacity: 1;
        transform: scale(1) translateY(-15px) rotate(90deg);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.3) translateY(-25px) rotate(180deg);
    }
    70% {
        opacity: 0.6;
        transform: scale(0.9) translateY(-35px) rotate(270deg);
    }
    90% {
        opacity: 0.2;
        transform: scale(0.5) translateY(-45px) rotate(360deg);
    }
}

/* Button Glow Effect */
.btn-glow {
    animation: buttonGlow 2s ease-in-out infinite;
}

@keyframes buttonGlow {
    0%, 100% { 
        box-shadow: 0 5px 20px rgba(78, 205, 196, 0.4);
    }
    50% { 
        box-shadow: 0 5px 30px rgba(78, 205, 196, 0.8), 0 0 40px rgba(78, 205, 196, 0.4);
    }
}

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

@keyframes buttonGlowSecondary {
    0%, 100% { 
        box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
    }
    50% { 
        box-shadow: 0 5px 30px rgba(102, 126, 234, 0.8), 0 0 40px rgba(255, 215, 0, 0.3);
    }
}

/* Buttons */
button {
    font-family: inherit;
    font-size: 1.1em;
    font-weight: bold;
    padding: 15px 40px;
    margin: 10px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    color: white;
    box-shadow: 0 5px 20px rgba(78, 205, 196, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(78, 205, 196, 0.6);
}

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

.btn-primary:disabled {
    background: linear-gradient(135deg, #666 0%, #444 100%);
    color: #999;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-primary:disabled:hover {
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.6);
}

/* Controls Info */
.controls-info {
    margin-top: 30px;
    padding: 20px;
    background: rgba(255,255,255,0.05);
    border-radius: 15px;
    text-align: center;
}

.controls-info h3 {
    color: #4ecdc4;
    margin-bottom: 10px;
}

.controls-info p {
    color: #aaa;
    margin: 5px 0;
    font-size: 0.9em;
}

/* High Score Input */
#nameInput {
    font-family: inherit;
    font-size: 1em;
    padding: 10px 15px;
    margin: 0;
    border: 2px solid #4ecdc4;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    color: white;
    text-align: center;
    text-transform: uppercase;
    width: 140px;
    flex-shrink: 0;
}

#submitScore {
    margin: 0;
    padding: 10px 20px;
    font-size: 0.9em;
    flex-shrink: 0;
}

#nameInput::placeholder {
    color: rgba(255,255,255,0.5);
    text-transform: none;
}

#nameInput:focus {
    outline: none;
    border-color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

/* High Scores List */
#highScores {
    text-align: center;
}

#highScores h2 {
    font-size: clamp(1.3em, 5vw, 2em);
    margin-bottom: 15px;
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#scoresList {
    width: 90%;
    max-width: 400px;
    max-height: 50vh;
    overflow-y: auto;
    margin: 15px auto;
    padding: 15px;
    background: linear-gradient(180deg, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.2) 100%);
    border-radius: 20px;
    border: 1px solid rgba(78, 205, 196, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3), inset 0 0 30px rgba(78, 205, 196, 0.05);
}

.scores-table {
    width: 100%;
    border-collapse: collapse;
}

.scores-table th,
.scores-table td {
    padding: 12px 8px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.scores-table th {
    color: #4ecdc4;
    font-weight: bold;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid rgba(78, 205, 196, 0.3);
}

.scores-table tbody tr {
    transition: background 0.2s ease;
}

.scores-table tbody tr:hover {
    background: rgba(78, 205, 196, 0.1);
}

.scores-table tr.rank-1 td { 
    color: #ffd700; 
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}
.scores-table tr.rank-2 td { 
    color: #e0e0e0; 
    font-weight: bold;
}
.scores-table tr.rank-3 td { 
    color: #cd7f32; 
    font-weight: bold;
}

.no-scores {
    text-align: center;
    color: #888;
    padding: 40px;
    font-style: italic;
}

/* Score Displays */
#finalScore, #levelScore {
    font-size: 1.5em;
    color: #ffd700;
    margin: 10px 0;
}

#finalLevel, #levelBonus {
    font-size: 1.1em;
    color: #4ecdc4;
}

/* New High Score Section */
#newHighScore {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px 0;
}

#newHighScore h3 {
    animation: highScoreCelebrate 0.5s ease infinite;
    margin-bottom: 5px;
}

.rank-text {
    font-size: 1.1em;
    color: #4ecdc4;
    margin: 0 0 10px 0;
    font-weight: bold;
}

.high-score-input-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: nowrap;
}

@keyframes highScoreCelebrate {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.05) rotate(-2deg); }
    75% { transform: scale(1.05) rotate(2deg); }
}

/* Scrollbar Styling */
#scoresList::-webkit-scrollbar {
    width: 8px;
}

#scoresList::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

#scoresList::-webkit-scrollbar-thumb {
    background: #4ecdc4;
    border-radius: 4px;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    #game-container {
        max-width: 100%;
        height: 100vh;
        border-radius: 0;
    }
    
    #ui {
        font-size: 12px;
        padding: 8px 10px;
    }
    
    .screen h1 {
        font-size: clamp(1.2em, 5.5vw, 1.8em);
    }
    
    .screen h2 {
        font-size: 1.5em;
    }
    
    button {
        font-size: 1em;
        padding: 12px 30px;
    }
    
    .controls-info {
        padding: 15px;
        margin: 20px 15px;
    }
    
    /* High score input row stays inline on mobile */
    #nameInput {
        width: 120px;
        font-size: 0.9em;
        padding: 8px 10px;
    }
    
    #submitScore {
        padding: 8px 15px;
        font-size: 0.85em;
    }
    
    .high-score-input-row {
        gap: 6px;
    }
}

/* Touch feedback */
@media (hover: none) {
    button:active {
        transform: scale(0.95);
    }
}

/* Firebase Leaderboard Styles */
.leaderboard-header {
    text-align: center;
    margin-bottom: 15px;
}

.sync-status {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: bold;
    margin-bottom: 10px;
}

.sync-status.online {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    box-shadow: 0 2px 10px rgba(76, 175, 80, 0.3);
}

.sync-status.offline {
    background: linear-gradient(45deg, #FF9800, #f57c00);
    color: white;
    box-shadow: 0 2px 10px rgba(255, 152, 0, 0.3);
}

.loading-scores {
    text-align: center;
    padding: 40px 20px;
    font-size: 1.1em;
    color: #4ecdc4;
    animation: pulse 2s ease-in-out infinite;
}

.error-scores {
    text-align: center;
    padding: 40px 20px;
    font-size: 1.1em;
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(255, 107, 107, 0.3);
}

.sync-info {
    text-align: center;
    margin-top: 15px;
    font-size: 0.8em;
    color: #bbb;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

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

/* Mobile Optimizations */
@media screen and (max-width: 768px) {
    body {
        padding: 0;
        margin: 0;
    }
    
    #game-container {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-width: none;
        border-radius: 0;
    }
    
    /* Make UI text slightly smaller on mobile */
    #ui {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    /* Adjust menu for mobile */
    .screen {
        padding: 20px 15px;
    }
    
    .screen h1 {
        font-size: clamp(1.2em, 5.5vw, 2.2em);
        margin-bottom: 15px;
    }
    
    .screen h2 {
        font-size: clamp(1.2em, 4.5vw, 1.8em);
    }
    
    button {
        font-size: 1.1em;
        padding: 15px 35px;
        margin: 8px;
        min-height: 50px; /* Better touch targets */
    }
    
    .controls-info {
        padding: 15px;
        margin: 15px 10px;
        font-size: 0.9em;
    }
    
    /* High score input for mobile */
    #nameInput {
        font-size: 1.1em;
        padding: 12px;
        width: 200px;
    }
    
    /* Leaderboard mobile */
    #scoresList {
        max-height: 45vh;
        padding: 10px;
    }
    
    .scores-table th,
    .scores-table td {
        padding: 10px 5px;
        font-size: 0.9em;
    }
}

/* Landscape mobile optimization */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .screen h1 {
        font-size: 1.8em;
        margin-bottom: 10px;
    }
    
    .screen h2 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }
    
    button {
        padding: 10px 25px;
        margin: 5px;
        font-size: 0.95em;
        min-height: 40px;
    }
    
    .controls-info {
        padding: 10px;
        margin: 10px 5px;
        font-size: 0.8em;
    }
}

/* Desktop - restore border radius */
@media screen and (min-width: 769px) {
    #game-container {
        border-radius: 15px;
        height: 800px;
        max-height: 800px;
    }
}
