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

body {
    overflow: hidden;
    background: #0a0a1a;
    font-family: 'Outfit', sans-serif;
    color: #fff;
    user-select: none;
}

#scene-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#scene-container canvas {
    display: block;
}

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

.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: rgba(5, 5, 20, 0.85);
    backdrop-filter: blur(10px);
}

.hidden { display: none !important; }

/* Start Screen */
.start-content, .win-content, .lb-content {
    text-align: center;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
}

.game-title {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(2.5rem, 8vw, 5rem);
    background: linear-gradient(135deg, #ff3366, #ff6633, #ffcc00, #33ff66, #3366ff, #cc33ff);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: rainbowShift 3s ease infinite, titleBounce 2s ease-in-out infinite;
    text-shadow: none;
    filter: drop-shadow(0 4px 20px rgba(255, 51, 102, 0.4));
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.berry-icon {
    -webkit-text-fill-color: initial;
    font-size: 0.8em;
}

@keyframes rainbowShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes titleBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.subtitle {
    font-size: 1rem;
    color: #aab;
    margin-bottom: 2rem;
    font-style: italic;
}

.color-picker-section {
    margin-bottom: 1.5rem;
}

.picker-label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 700;
    color: #dde;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.color-swatch {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.selected {
    border-color: #fff;
    transform: scale(1.2);
    box-shadow: 0 0 16px rgba(255,255,255,0.5);
}

.play-btn {
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    padding: 14px 48px;
    background: linear-gradient(180deg, #00e86d, #00b853);
    color: #fff;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    display: block;
    margin: 0.75rem auto;
    box-shadow: 0 6px 0 #008f3d, 0 8px 20px rgba(0, 232, 109, 0.3);
    transition: all 0.15s;
    animation: btnPulse 2s ease-in-out infinite;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.play-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 0 #008f3d, 0 12px 30px rgba(0, 232, 109, 0.4);
}

.play-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #008f3d;
}

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

.lb-btn {
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
    padding: 10px 30px;
    background: linear-gradient(180deg, #ffc833, #e6a800);
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: block;
    margin: 0.5rem auto;
    box-shadow: 0 4px 0 #b38600, 0 6px 15px rgba(255, 200, 51, 0.3);
    transition: all 0.15s;
    text-shadow: 0 2px 3px rgba(0,0,0,0.2);
}

.lb-btn:hover { transform: translateY(-2px); }
.lb-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b38600; }

/* HUD */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 16px;
    z-index: 50;
    pointer-events: none;
}

.hud-left, .hud-center, .hud-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.hud-panel {
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    background: rgba(10, 10, 30, 0.75);
    padding: 6px 16px;
    border-radius: 10px;
    border: 2px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(6px);
    white-space: nowrap;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* Death Flash */
.death-flash {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(255, 30, 60, 0.6);
    z-index: 80;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
}

.death-flash.active {
    opacity: 1;
}

/* Win Screen */
.win-title {
    font-family: 'Fredoka One', cursive;
    font-size: clamp(2rem, 6vw, 3.5rem);
    color: #ffcc00;
    margin-bottom: 1.5rem;
    text-shadow: 0 0 20px rgba(255, 204, 0, 0.5);
    animation: titleBounce 1.5s ease-in-out infinite;
}

.win-stats {
    background: rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-family: 'Fredoka One', cursive;
    font-size: 1.3rem;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.stat-row:last-child { border-bottom: none; }

.username-input {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 12px 20px;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-align: center;
    width: 80%;
    margin-bottom: 0.5rem;
    outline: none;
    transition: border-color 0.2s;
}

.username-input:focus {
    border-color: #00e86d;
}

/* Leaderboard */
.lb-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2.5rem;
    color: #ffc833;
    margin-bottom: 1.5rem;
    text-shadow: 0 0 15px rgba(255, 200, 51, 0.4);
}

.lb-list {
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.lb-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
    margin-bottom: 6px;
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
}

.lb-rank {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.lb-rank.gold { background: linear-gradient(135deg, #ffd700, #ffaa00); color: #333; }
.lb-rank.silver { background: linear-gradient(135deg, #c0c0c0, #a0a0a0); color: #333; }
.lb-rank.bronze { background: linear-gradient(135deg, #cd7f32, #a0622e); color: #fff; }
.lb-rank.default { background: rgba(255,255,255,0.1); }

.lb-name { flex: 1; text-align: left; }
.lb-time { color: #00e86d; }

/* Mobile Controls */
#mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    pointer-events: none;
}

#joystick-zone {
    position: fixed;
    bottom: 30px;
    left: 30px;
    pointer-events: auto;
}

#joystick-base {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 3px solid rgba(255,255,255,0.2);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#joystick-thumb {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255,255,255,0.35);
    position: absolute;
    transition: none;
}

.jump-button {
    position: fixed;
    bottom: 40px;
    right: 30px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(180deg, #00e86d, #00b853);
    border: none;
    color: #fff;
    font-family: 'Fredoka One', cursive;
    font-size: 0.85rem;
    box-shadow: 0 4px 0 #008f3d;
    pointer-events: auto;
    cursor: pointer;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.jump-button:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #008f3d;
}

/* Footer */
.footer {
    position: fixed;
    bottom: 4px;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 200;
    pointer-events: auto;
}

.footer a {
    color: rgba(255,255,255,0.25);
    font-size: 0.7rem;
    text-decoration: none;
    font-family: 'Outfit', sans-serif;
}

.footer a:hover { color: rgba(255,255,255,0.5); }

@media (min-width: 769px) {
    #mobile-controls { display: none !important; }
}