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

body {
    background: #0f0f1a;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Silkscreen', cursive;
    overflow: hidden;
    background-image: 
        radial-gradient(ellipse at top, #1e1b4b 0%, transparent 50%),
        radial-gradient(ellipse at bottom, #0f172a 0%, transparent 50%);
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: calc(100vh - 50px);
    display: flex;
    align-items: center;
    justify-content: center;
}

#canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border: 4px solid #f97316;
    border-radius: 8px;
    box-shadow: 
        0 0 40px rgba(249, 115, 22, 0.3),
        0 0 80px rgba(249, 115, 22, 0.1),
        inset 0 0 60px rgba(0, 0, 0, 0.5);
}

#canvas.shake {
    animation: shake 0.2s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px) rotate(-1deg); }
    40% { transform: translateX(8px) rotate(1deg); }
    60% { transform: translateX(-6px) rotate(-0.5deg); }
    80% { transform: translateX(6px) rotate(0.5deg); }
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen {
    pointer-events: all;
    background: rgba(15, 15, 26, 0.97);
    padding: 28px;
    border: 3px solid #f97316;
    border-radius: 12px;
    text-align: center;
    color: #fff;
    max-width: 340px;
    box-shadow: 
        0 0 50px rgba(249, 115, 22, 0.4),
        inset 0 0 30px rgba(249, 115, 22, 0.05);
    animation: screenFadeIn 0.3s ease-out;
}

@keyframes screenFadeIn {
    from { 
        opacity: 0; 
        transform: scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}

.hidden {
    display: none !important;
}

.title-container {
    margin-bottom: 16px;
}

.game-title {
    font-size: 22px;
    font-weight: 700;
    color: #f97316;
    text-shadow: 
        3px 3px 0 #7c3aed,
        -1px -1px 0 #fff,
        0 0 20px rgba(249, 115, 22, 0.5);
    letter-spacing: 3px;
    line-height: 1.3;
}

.title-sorter {
    color: #7c3aed;
    text-shadow: 
        3px 3px 0 #f97316,
        -1px -1px 0 #fff,
        0 0 20px rgba(124, 58, 237, 0.5);
}

.snoo-container {
    margin: 16px 0;
    display: flex;
    justify-content: center;
}

#snoo-canvas {
    width: 64px;
    height: 64px;
    image-rendering: pixelated;
    animation: snooFloat 2s ease-in-out infinite;
}

@keyframes snooFloat {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-8px) rotate(2deg); }
}

.blink-text {
    font-size: 11px;
    color: #fbbf24;
    animation: blink 1s step-end infinite;
    margin: 16px 0;
    cursor: pointer;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.high-score-display {
    font-size: 9px;
    color: #fbbf24;
    margin: 12px 0;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

.instructions {
    font-size: 7px;
    color: #94a3b8;
    line-height: 2.2;
    margin: 14px 0;
}

.pixel-btn {
    font-family: 'Silkscreen', cursive;
    font-size: 11px;
    padding: 14px 28px;
    background: linear-gradient(180deg, #f97316 0%, #c2410c 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin: 8px 4px;
    box-shadow: 
        0 4px 0 #7c2d12,
        0 6px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.1s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pixel-btn:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 6px 0 #7c2d12,
        0 8px 16px rgba(0, 0, 0, 0.4);
    background: linear-gradient(180deg, #fb923c 0%, #ea580c 100%);
}

.pixel-btn:active {
    transform: translateY(2px);
    box-shadow: 
        0 2px 0 #7c2d12,
        0 3px 6px rgba(0, 0, 0, 0.4);
}

.pixel-btn.secondary {
    background: linear-gradient(180deg, #6366f1 0%, #4338ca 100%);
    box-shadow: 
        0 4px 0 #3730a3,
        0 6px 12px rgba(0, 0, 0, 0.4);
}

.pixel-btn.secondary:hover {
    box-shadow: 
        0 6px 0 #3730a3,
        0 8px 16px rgba(0, 0, 0, 0.4);
}

.pixel-btn.secondary:active {
    box-shadow: 
        0 2px 0 #3730a3,
        0 3px 6px rgba(0, 0, 0, 0.4);
}

#game-hud {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    padding: 0 4px;
}

.hud-left, .hud-center, .hud-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.hud-label {
    font-size: 6px;
    color: #94a3b8;
    margin-bottom: 2px;
    letter-spacing: 1px;
}

#score-display, #combo-display, #timer-display {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
}

#timer-display.timer-warning {
    color: #ef4444;
    animation: timerPulse 0.5s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% { transform: scale(1); text-shadow: 2px 2px 0 #000; }
    50% { transform: scale(1.15); text-shadow: 0 0 10px #ef4444, 2px 2px 0 #000; }
}

.combo-container {
    display: flex;
    align-items: center;
    gap: 4px;
}

#combo-multiplier {
    font-size: 11px;
    color: #fbbf24;
    opacity: 0;
    transition: opacity 0.2s;
}

#combo-multiplier.active {
    opacity: 1;
    animation: comboFire 0.3s ease-in-out infinite alternate;
}

@keyframes comboFire {
    0% { color: #fbbf24; text-shadow: 0 0 8px #f97316; }
    100% { color: #f97316; text-shadow: 0 0 12px #fbbf24; }
}

.lives-container {
    margin-top: 4px;
    display: flex;
    gap: 2px;
}

.heart {
    font-size: 14px;
    transition: transform 0.2s;
}

.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Pause Screen */
.pause-title {
    font-size: 28px;
    color: #f97316;
    margin-bottom: 24px;
    text-shadow: 3px 3px 0 #000;
}

/* Game Over Screen */
.game-over-title {
    font-size: 26px;
    color: #ef4444;
    text-shadow: 3px 3px 0 #000, 0 0 20px rgba(239, 68, 68, 0.5);
    margin-bottom: 16px;
    animation: glitchText 3s ease-in-out infinite;
}

@keyframes glitchText {
    0%, 100% { text-shadow: 3px 3px 0 #000, 0 0 20px rgba(239, 68, 68, 0.5); }
    10% { text-shadow: -3px 3px 0 #ec4899, 3px -3px 0 #3b82f6; }
    20% { text-shadow: 3px 3px 0 #000, 0 0 20px rgba(239, 68, 68, 0.5); }
}

.rank-display {
    margin: 16px 0;
}

.rank-label {
    font-size: 8px;
    color: #94a3b8;
    display: block;
    margin-bottom: 8px;
}

.rank-grade {
    font-size: 52px;
    font-weight: bold;
    display: inline-block;
    animation: rankPop 0.5s ease-out;
}

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

.rank-s { color: #ffd700; text-shadow: 0 0 30px #ffd700, 0 0 60px #ffd700; }
.rank-a { color: #22c55e; text-shadow: 0 0 20px #22c55e; }
.rank-b { color: #3b82f6; text-shadow: 0 0 20px #3b82f6; }
.rank-c { color: #f97316; text-shadow: 0 0 20px #f97316; }
.rank-d { color: #9ca3af; }
.rank-f { color: #ef4444; text-shadow: 0 0 10px #ef4444; }

.final-stats {
    font-size: 8px;
    color: #d1d5db;
    line-height: 2.4;
    margin: 16px 0;
}

.final-stats span {
    color: #fbbf24;
    font-weight: 700;
}

.game-over-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

#floating-texts {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 100;
}

.floating-text {
    position: absolute;
    font-family: 'Silkscreen', cursive;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 2px 2px 0 #000, -1px -1px 0 #000;
    animation: floatUp 1s ease-out forwards;
    pointer-events: none;
    transform: translate(-50%, -50%);
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.8);
    }
    20% {
        transform: translate(-50%, -60%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(1);
    }
}

.game-footer {
    font-size: 9px;
    color: #64748b;
    padding: 12px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.game-footer a {
    color: #f97316;
    text-decoration: none;
    transition: color 0.2s;
}

.game-footer a:hover {
    color: #fb923c;
    text-decoration: underline;
}

.mute-btn {
    background: rgba(249, 115, 22, 0.2);
    border: 1px solid #f97316;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.mute-btn:hover {
    background: rgba(249, 115, 22, 0.4);
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .game-title {
        font-size: 18px;
    }
    
    .screen {
        padding: 20px;
        margin: 8px;
        max-width: 300px;
    }
    
    .instructions {
        font-size: 6px;
    }
    
    .pixel-btn {
        font-size: 9px;
        padding: 12px 20px;
    }
    
    #game-hud {
        top: 4px;
    }
    
    .hud-left, .hud-center, .hud-right {
        padding: 4px 6px;
    }
    
    #score-display, #combo-display, #timer-display {
        font-size: 12px;
    }
    
    .hud-label {
        font-size: 5px;
    }
    
    .rank-grade {
        font-size: 40px;
    }
    
    .final-stats {
        font-size: 7px;
    }
}

/* Tall screens */
@media (min-height: 800px) {
    #game-container {
        max-height: 750px;
    }
}