@import url('https://fonts.googleapis.com/css2?family=Burbank+Big+Condensed&family=Luckiest+Guy&family=Russo+One&display=swap');

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

body {
    font-family: 'Russo One', 'Arial Black', sans-serif;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

/* Animated background storm effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(138, 43, 226, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 191, 255, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(255, 215, 0, 0.05) 0%, transparent 70%);
    pointer-events: none;
    animation: stormPulse 8s ease-in-out infinite;
}

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

.game-container {
    background: linear-gradient(145deg, #1e1e3f 0%, #2d2d5a 100%);
    border-radius: 20px;
    padding: 30px;
    box-shadow:
        0 0 40px rgba(138, 43, 226, 0.4),
        0 0 80px rgba(0, 191, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    text-align: center;
    max-width: 600px;
    border: 3px solid;
    border-image: linear-gradient(145deg, #00d4ff, #8a2be2, #ffd700) 1;
    position: relative;
    z-index: 1;
}

h1 {
    font-family: 'Luckiest Guy', 'Arial Black', cursive;
    color: #fff;
    font-size: 2.8rem;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow:
        0 0 10px #00d4ff,
        0 0 20px #00d4ff,
        0 0 40px #8a2be2,
        3px 3px 0 #1a1a2e;
    background: linear-gradient(180deg, #ffffff 0%, #00d4ff 50%, #8a2be2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.instructions {
    color: #a0a0c0;
    font-size: 1rem;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.key {
    background: linear-gradient(145deg, #ffd700, #ff8c00);
    padding: 5px 15px;
    border-radius: 8px;
    font-weight: bold;
    color: #1a1a2e;
    box-shadow:
        0 4px 0 #b8860b,
        0 0 15px rgba(255, 215, 0, 0.5);
    display: inline-block;
    text-transform: uppercase;
    font-size: 0.9rem;
}

/* Game Stats (Level & Timer) - Fortnite HUD style */
.game-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 15px;
}

.stat {
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.6), rgba(30, 30, 60, 0.8));
    padding: 12px 30px;
    border-radius: 10px;
    border: 2px solid #00d4ff;
    box-shadow:
        0 0 15px rgba(0, 212, 255, 0.3),
        inset 0 0 20px rgba(0, 212, 255, 0.1);
    position: relative;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

.stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00d4ff, transparent);
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: #00d4ff;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 2px;
}

.stat-value {
    display: block;
    font-size: 2.2rem;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.timer-stat .stat-value {
    color: #00ff88;
    text-shadow: 0 0 15px rgba(0, 255, 136, 0.7);
}

.timer-stat.warning .stat-value {
    color: #ffaa00;
    text-shadow: 0 0 15px rgba(255, 170, 0, 0.7);
    animation: warningPulse 0.5s ease infinite;
}

.timer-stat.danger .stat-value {
    color: #ff4444;
    text-shadow: 0 0 20px rgba(255, 68, 68, 0.9);
    animation: dangerPulse 0.25s ease infinite;
}

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

@keyframes dangerPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.game-wrapper {
    position: relative;
    display: inline-block;
    border-radius: 15px;
    overflow: hidden;
    box-shadow:
        0 0 30px rgba(138, 43, 226, 0.5),
        0 0 60px rgba(0, 212, 255, 0.3),
        inset 0 0 50px rgba(0, 0, 0, 0.5);
    border: 3px solid #8a2be2;
}

#gameCanvas {
    display: block;
    background: #0a0a1a;
}

/* Overlay Screens - Victory Royale style */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 30, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.overlay-screen.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    animation: victorySlam 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes victorySlam {
    0% { transform: scale(3) rotate(-10deg); opacity: 0; }
    50% { transform: scale(0.9) rotate(2deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.win-content h2,
.gameover-content h2,
.victory-content h2 {
    font-family: 'Luckiest Guy', 'Arial Black', cursive;
    font-size: 2.8rem;
    text-transform: uppercase;
    letter-spacing: 4px;
    margin-bottom: 15px;
}

.win-content h2 {
    color: #ffd700;
    text-shadow:
        0 0 20px #ffd700,
        0 0 40px #ff8c00,
        0 0 60px #ffd700,
        4px 4px 0 #8a2be2;
    animation: goldGlow 1.5s ease-in-out infinite;
}

@keyframes goldGlow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

.gameover-content h2 {
    color: #ff4444;
    text-shadow:
        0 0 20px #ff4444,
        0 0 40px #ff0000,
        4px 4px 0 #1a1a2e;
}

.victory-content h2 {
    background: linear-gradient(180deg, #ffd700 0%, #ff8c00 50%, #ffd700 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 20px #ffd700) drop-shadow(4px 4px 0 #8a2be2);
    font-size: 3rem;
    animation: victoryShine 2s ease-in-out infinite;
}

@keyframes victoryShine {
    0%, 100% { filter: drop-shadow(0 0 20px #ffd700) drop-shadow(4px 4px 0 #8a2be2) brightness(1); }
    50% { filter: drop-shadow(0 0 40px #ffd700) drop-shadow(4px 4px 0 #8a2be2) brightness(1.2); }
}

.overlay-content p {
    color: #a0a0c0;
    font-size: 1.2rem;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.time-bonus {
    color: #00ff88 !important;
    font-size: 1.5rem !important;
    font-weight: bold;
    text-shadow: 0 0 15px rgba(0, 255, 136, 0.7);
}

.total-time {
    color: #00d4ff !important;
    font-size: 1.4rem !important;
    text-shadow: 0 0 15px rgba(0, 212, 255, 0.7);
}

.play-again-btn {
    background: linear-gradient(145deg, #ffd700, #ff8c00);
    color: #1a1a2e;
    border: none;
    padding: 18px 50px;
    font-size: 1.4rem;
    font-family: 'Russo One', 'Arial Black', sans-serif;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow:
        0 6px 0 #b8860b,
        0 0 30px rgba(255, 215, 0, 0.5);
    clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
}

.play-again-btn:hover {
    transform: translateY(-3px);
    box-shadow:
        0 9px 0 #b8860b,
        0 0 50px rgba(255, 215, 0, 0.8);
    filter: brightness(1.1);
}

.play-again-btn:active {
    transform: translateY(3px);
    box-shadow:
        0 3px 0 #b8860b,
        0 0 20px rgba(255, 215, 0, 0.4);
}

.mobile-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    gap: 8px;
}

.horizontal-controls {
    display: flex;
    gap: 8px;
}

.control-btn {
    width: 65px;
    height: 65px;
    font-size: 2rem;
    background: linear-gradient(145deg, #2d2d5a, #1e1e3f);
    color: #00d4ff;
    border: 2px solid #00d4ff;
    border-radius: 12px;
    cursor: pointer;
    box-shadow:
        0 5px 0 #0a0a1a,
        0 0 15px rgba(0, 212, 255, 0.3);
    transition: all 0.1s;
    user-select: none;
    -webkit-user-select: none;
}

.control-btn:active {
    transform: translateY(5px);
    box-shadow:
        0 0 0 #0a0a1a,
        0 0 25px rgba(0, 212, 255, 0.6);
    background: linear-gradient(145deg, #3d3d7a, #2e2e5f);
}

.level-info {
    margin-top: 15px;
}

.hint {
    color: #8a8aaa;
    font-size: 0.95rem;
    font-style: normal;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

/* Skin Selector */
.skin-selector {
    margin-top: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 1px solid rgba(0, 212, 255, 0.3);
}

.skin-label {
    color: #00d4ff;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.skin-options {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.skin-option {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.skin-option:hover:not(.locked) {
    transform: scale(1.1);
}

.skin-option.selected {
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.skin-option.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.skin-option.locked::after {
    content: '🔒';
    position: absolute;
    font-size: 1.2rem;
}

.skin-option .skin-preview {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.skin-option[data-skin="default"] .skin-preview {
    background: linear-gradient(145deg, #00e5ff, #0097a7);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.skin-option[data-skin="gold"] .skin-preview {
    background: linear-gradient(145deg, #ffd700, #ff8c00);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.skin-option[data-skin="purple"] .skin-preview {
    background: linear-gradient(145deg, #9932cc, #4b0082);
    box-shadow: 0 0 10px rgba(153, 50, 204, 0.5);
}

.skin-name {
    position: absolute;
    bottom: -20px;
    font-size: 0.6rem;
    color: #a0a0c0;
    white-space: nowrap;
}

/* Unlock Message */
.unlock-message {
    margin: 15px 0;
    padding: 15px;
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.2), rgba(255, 140, 0, 0.2));
    border: 2px solid #ffd700;
    border-radius: 10px;
    animation: unlockPulse 1s ease-in-out infinite;
}

.unlock-message.hidden {
    display: none;
}

@keyframes unlockPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.5); }
    50% { box-shadow: 0 0 40px rgba(255, 215, 0, 0.8); }
}

.unlock-title {
    color: #ffd700 !important;
    font-size: 1.3rem !important;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
    margin-bottom: 5px !important;
}

.unlocked-skin-name {
    color: #ffffff !important;
    font-size: 1.5rem !important;
    font-weight: bold;
    text-transform: uppercase;
}

/* Mobile responsiveness */
@media (max-width: 600px) {
    .game-container {
        padding: 15px;
    }

    h1 {
        font-size: 2rem;
    }

    .instructions {
        font-size: 0.85rem;
    }

    .game-stats {
        gap: 15px;
    }

    .stat {
        padding: 10px 20px;
    }

    .stat-value {
        font-size: 1.7rem;
    }

    #gameCanvas {
        width: 320px;
        height: 320px;
    }

    .mobile-controls {
        display: flex;
    }

    .overlay-content h2 {
        font-size: 2rem;
    }

    .play-again-btn {
        padding: 15px 35px;
        font-size: 1.1rem;
    }
}

/* Touch device detection */
@media (hover: none) and (pointer: coarse) {
    .mobile-controls {
        display: flex;
    }
}
