* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg-dark: #1a1a2e;
    --bg-mid: #16213e;
    --bg-light: #0f3460;
    --accent: #e94560;
    --text: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.6);
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 500px;
    margin: 0 auto;
    overflow: hidden;
    background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-mid) 100%);
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

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

/* Start Screen */
#start-screen {
    gap: 25px;
    background: radial-gradient(ellipse at center, var(--bg-mid) 0%, var(--bg-dark) 70%);
}

.logo-container {
    text-align: center;
}

.blob-preview {
    position: relative;
    height: 80px;
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.preview-shape {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    animation: float-blob 3s ease-in-out infinite;
    box-shadow: 0 0 20px currentColor;
}

.preview-shape.color-red {
    background: radial-gradient(circle at 30% 30%, #ff6b6b, #c0392b);
    color: #e74c3c;
    animation-delay: 0s;
}

.preview-shape.color-yellow {
    background: radial-gradient(circle at 30% 30%, #f9e076, #d4ac0d);
    color: #f1c40f;
    animation-delay: 0.3s;
}

.preview-shape.color-blue {
    background: radial-gradient(circle at 30% 30%, #5dade2, #2471a3);
    color: #3498db;
    animation-delay: 0.6s;
}

.color-guide {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px 25px;
    border-radius: 15px;
    margin-bottom: 10px;
    text-align: center;
}

.mix-row {
    font-size: 0.95rem;
    padding: 5px 0;
    color: rgba(255, 255, 255, 0.85);
}

.mix-row b {
    color: #fff;
}

.sparkle-hint {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.2);
    color: #ffeaa7;
    animation: sparkle-text 1.5s ease-in-out infinite;
}

@keyframes sparkle-text {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; text-shadow: 0 0 10px #ffeaa7; }
}

#next-blob-preview.sparkle-preview {
    animation: sparkle-preview 0.5s ease-in-out infinite;
}

@keyframes sparkle-preview {
    0%, 100% { filter: brightness(1) drop-shadow(0 0 5px #fff); }
    50% { filter: brightness(1.3) drop-shadow(0 0 10px #fff); }
}

@keyframes float-blob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.game-title {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, #e74c3c 0%, #f1c40f 50%, #3498db 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 60px rgba(241, 196, 15, 0.5);
}

.tagline {
    font-size: 1.1rem;
    color: var(--text-dim);
    margin-top: 10px;
}

.stats-row {
    display: flex;
    gap: 20px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px 25px;
    border-radius: 15px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 5px;
}

.how-to-play {
    font-size: 0.9rem;
    color: var(--text-dim);
    max-width: 280px;
    text-align: center;
    line-height: 1.5;
}

/* Buttons */
.btn {
    padding: 18px 50px;
    font-size: 1.2rem;
    font-weight: 700;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

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

.btn-primary:active {
    transform: scale(0.95);
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
}

.btn-share {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-share:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.25);
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

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

/* Game Screen */
#game-screen {
    padding: 0;
    justify-content: flex-start;
}

#game-header {
    width: 100%;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.header-left {
    display: flex;
    flex-direction: column;
}

.score-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    letter-spacing: 1px;
}

.score-value {
    font-size: 2rem;
    font-weight: 800;
}

#next-blob-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 25px;
}

.next-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    letter-spacing: 1px;
}

#next-blob-preview {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#next-blob-preview canvas {
    border-radius: 4px;
}

#game-canvas {
    flex: 1;
    width: 100%;
    touch-action: none;
}

#danger-line {
    position: absolute;
    top: 150px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.5;
    pointer-events: none;
}

#game-over-warning {
    position: absolute;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    animation: warning-pulse 0.5s ease-in-out infinite;
    z-index: 20;
}

#game-over-warning.hidden {
    display: none;
}

@keyframes warning-pulse {
    0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
    50% { opacity: 0.7; transform: translateX(-50%) scale(1.05); }
}

/* Result Screen */
#result-screen {
    background: radial-gradient(ellipse at center, var(--bg-mid) 0%, var(--bg-dark) 70%);
}

#result-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

#result-emoji {
    font-size: 4rem;
    animation: pop 0.5s ease-out;
}

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

#result-title {
    font-size: 2rem;
    font-weight: 800;
}

.result-stats {
    display: flex;
    gap: 30px;
}

.result-stat {
    text-align: center;
}

.result-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.result-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    margin-top: 5px;
}

#new-record {
    background: linear-gradient(135deg, #ffe66d 0%, #f0b429 100%);
    color: #1a1a2e;
    padding: 10px 25px;
    border-radius: 25px;
    font-weight: 700;
    animation: record-bounce 0.5s ease-in-out infinite alternate;
}

#new-record.hidden {
    display: none;
}

@keyframes record-bounce {
    from { transform: scale(1) rotate(-2deg); }
    to { transform: scale(1.05) rotate(2deg); }
}

#biggest-blob-display {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-dim);
}

#biggest-blob-icon {
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffeaa7;
    font-weight: 700;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

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

@keyframes score-float {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-60px) scale(1.5); opacity: 0; }
}

/* Merge effect */
.merge-effect {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: merge-ring 0.5s ease-out forwards;
}

@keyframes merge-ring {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

/* Drop indicator */
#drop-indicator {
    position: absolute;
    width: 2px;
    background: linear-gradient(180deg, rgba(255,255,255,0.5), transparent);
    pointer-events: none;
    z-index: 5;
}

/* Dynamite */
#dynamite-container {
    font-size: 1.4rem;
    letter-spacing: 3px;
    cursor: grab;
    padding: 5px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    transition: transform 0.1s, background 0.1s;
}

#dynamite-container:hover {
    background: rgba(255, 255, 255, 0.2);
}

#dynamite-container:active {
    cursor: grabbing;
    transform: scale(1.1);
}

/* Explosion effects */
.explosion-particle {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    pointer-events: none;
    animation: explode-particle 0.5s ease-out forwards;
    z-index: 100;
}

@keyframes explode-particle {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0);
        opacity: 0;
    }
}

.explosion-flash {
    position: absolute;
    width: 100px;
    height: 100px;
    margin-left: -50px;
    margin-top: -50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,217,61,0.8) 0%, rgba(255,107,107,0.4) 50%, transparent 70%);
    pointer-events: none;
    animation: flash-expand 0.3s ease-out forwards;
    z-index: 99;
}

@keyframes flash-expand {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Mobile */
@media (max-height: 600px) {
    .game-title { font-size: 2.5rem; }
    .btn { padding: 14px 40px; font-size: 1rem; }
    #result-emoji { font-size: 3rem; }
    .result-value { font-size: 2rem; }
    .blob-preview { height: 70px; }
    .preview-blob.b1 { width: 40px; height: 40px; }
    .preview-blob.b2 { width: 55px; height: 55px; }
    .preview-blob.b3 { width: 35px; height: 35px; }
}

@media (min-width: 500px) {
    #game-container {
        border-left: 3px solid rgba(255,255,255,0.1);
        border-right: 3px solid rgba(255,255,255,0.1);
    }
}
