/* Premium Dark/Neon Aesthetic for Bubble Shooter */
:root {
    --bg-main: #0b061d;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary-neon: #a855f7; /* Purple */
    --primary-glow: rgba(168, 85, 247, 0.4);
    --accent-neon: #3b82f6; /* Blue */
    --accent-glow: rgba(59, 130, 246, 0.4);
    
    --color-pink: #ec4899;
    --color-blue: #3b82f6;
    --color-green: #22c55e;
    --color-yellow: #eab308;
    --color-purple: #a855f7;
    --color-orange: #f97316;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Noto Sans TC', sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Background Glowing Orbs */
body::before, body::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.25;
    animation: orb-float 20s infinite alternate;
}

body::before {
    background-color: var(--primary-neon);
    top: 10%;
    left: 10%;
}

body::after {
    background-color: var(--accent-neon);
    bottom: 10%;
    right: 10%;
    animation-delay: -5s;
}

@keyframes orb-float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(80px, 50px) scale(1.2); }
}

/* Game Outer Wrapper */
.game-container {
    background: rgba(15, 10, 36, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid var(--bg-card-border);
    border-radius: 24px;
    padding: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 480px;
    height: 98vh;
    max-height: 720px;
    justify-content: space-between;
}

/* Header UI Elements */
.game-header {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto 1.2fr auto;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: 16px;
    padding: 8px 12px;
}

.score-container {
    display: flex;
    flex-direction: column;
}

.score-container .label {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.score-container .value {
    font-size: 1.3rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.streak-badge {
    background: linear-gradient(135deg, var(--color-pink), var(--primary-neon));
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
    box-shadow: 0 0 10px rgba(236, 72, 153, 0.5);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.streak-badge.pop {
    transform: scale(1.3);
}

.progress-bar-container {
    position: relative;
    background: rgba(0, 0, 0, 0.4);
    height: 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-neon), var(--primary-neon));
    transition: width 0.3s ease;
    box-shadow: 0 0 8px var(--primary-glow);
}

.progress-label {
    position: relative;
    font-size: 0.65rem;
    font-weight: 800;
    color: #fff;
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

/* Canvas Wrapper with responsive locking */
.canvas-wrapper {
    position: relative;
    flex: 1;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
    background: #06030f;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
    aspect-ratio: 480 / 720;
    cursor: crosshair;
}

/* Bottom Controls UI */
.controls-overlay {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: 16px;
    padding: 10px 16px;
}

.bubble-previews {
    display: flex;
    align-items: center;
    gap: 15px;
}

.preview-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 6px 12px;
    transition: transform 0.2s, border-color 0.2s;
}

.preview-slot:hover {
    transform: scale(1.05);
    border-color: var(--primary-neon);
}

.preview-slot .slot-label {
    font-size: 0.55rem;
    font-weight: 800;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.bubble-circle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.4), 0 0 8px rgba(255,255,255,0.2);
    transition: background 0.3s;
}

.swap-instruction {
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.swap-instruction i {
    animation: spin 6s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* Buttons and Controls styling */
.icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--primary-neon);
    border-color: var(--primary-neon);
    color: #fff;
    box-shadow: 0 0 10px var(--primary-glow);
    transform: translateY(-2px);
}

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

/* Modal Overlays (Glassmorphic) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 2, 15, 0.7);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: rgba(15, 10, 36, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 30px rgba(168, 85, 247, 0.2);
    border-radius: 28px;
    padding: 35px 30px;
    width: 440px;
    max-width: 90vw;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-icon {
    font-size: 3.5rem;
    color: var(--primary-neon);
    text-shadow: 0 0 20px var(--primary-glow);
    margin-bottom: 5px;
}

.animated-icon {
    animation: icon-float 3s ease-in-out infinite alternate;
}

@keyframes icon-float {
    0% { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(-10px) rotate(15deg); }
}

.modal-title {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.modal-desc .highlight {
    color: #fff;
    font-weight: 700;
    margin-bottom: 12px;
    font-size: 1.05rem;
}

.modal-desc .rules {
    text-align: left;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px;
    font-size: 0.85rem;
}

.modal-btn {
    background: linear-gradient(135deg, var(--accent-neon), var(--primary-neon));
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
    transition: all 0.2s;
    width: 100%;
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6), 0 0 10px rgba(59, 130, 246, 0.4);
}

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

.modal-btn.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--bg-card-border);
    box-shadow: none;
    margin-top: 10px;
}

.modal-btn.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.modal-actions {
    width: 100%;
}

/* Stat Grid for Game Over screen */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    margin: 10px 0;
}

.stat-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-item .stat-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.stat-item .stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
}

/* Responsive adjustments for smaller height viewports (such as in iframe) */
.modal-desc {
    max-height: 40vh;
    overflow-y: auto;
}

@media (max-height: 600px) {
    .modal-content {
        padding: 16px 20px;
        gap: 10px;
    }
    .modal-title {
        font-size: 1.4rem;
    }
    .modal-icon {
        font-size: 2.2rem;
        margin-bottom: 0px;
    }
    .modal-desc {
        font-size: 0.85rem;
    }
    .modal-desc .highlight {
        font-size: 0.9rem;
        margin-bottom: 4px;
    }
    .modal-desc .rules {
        font-size: 0.75rem;
        padding: 6px 10px;
    }
    .modal-btn {
        padding: 8px 20px;
        font-size: 0.9rem;
    }
}
