/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Poppins', sans-serif;
    background: #1a1a2e;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== CANVAS ===== */
#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* ===== OVERLAYS ===== */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

/* ===== LOADING SCREEN ===== */
.loading-overlay {
    background: url(../assets/splash.webp) center center / cover no-repeat;
    z-index: 999;
}

.loading-overlay::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(to top, rgba(8,8,20,0.95) 0%, rgba(8,8,20,0.6) 60%, transparent 100%);
    pointer-events: none;
}

.loading-content {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 8vh 5vw 7vh;
    box-sizing: border-box;
    text-align: center;
}

.loading-logo-img {
    width: clamp(220px, 78vw, 500px);
    height: auto;
    filter: drop-shadow(0 6px 32px rgba(0,0,0,0.85));
    animation: titleDriftFloat 3s ease-in-out infinite;
}

.loading-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
}

.loading-progress-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tap-to-start-btn {
    padding: clamp(10px, 2vh, 14px) clamp(28px, 7vw, 50px);
}

.loading-bar-container {
    width: clamp(200px, 60vw, 400px);
    height: 14px;
    background: linear-gradient(180deg, #1a2535 0%, #101820 100%);
    border: 2px solid #3a5a7a;
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto 1rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}

.loading-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(180deg, #5eddbb 0%, #38b289 100%);
    border-radius: 8px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(78,204,163,0.4);
}

.loading-text {
    color: rgba(255,255,255,0.5);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* ===== LOBBY SCREEN ===== */
#lobbyScreen {
    background: transparent;
    pointer-events: auto;
    z-index: 100;
    overflow: hidden;
}

/* Animated background overlay */
.lobby-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(78, 204, 163, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(255, 190, 11, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(69, 183, 209, 0.04) 0%, transparent 60%);
    animation: lobbyBgShift 8s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

@keyframes lobbyBgShift {
    0% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 0.7; transform: scale(1.02) translateY(-1%); }
}

#lobbyParticles {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* Floating ambient particles — CSS-animated, compositor thread */
@keyframes lobby-float {
    from { transform: translate(0, 0); opacity: 0.15; }
    to   { transform: translate(var(--vx, 0px), var(--vy, -40px)); opacity: 0.5; }
}
.lobby-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
}

.lobby-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.35rem, 1.1vh, 0.75rem);
    width: 90%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* Title */
.game-title {
    line-height: 1;
    position: relative;
}

.lobby-logo-img {
    width: clamp(140px, min(70vw, 28vh), 320px);
    height: auto;
    max-height: 28vh;
    object-fit: contain;
    filter: drop-shadow(0 6px 28px rgba(0,0,0,0.7));
    animation: titleDriftFloat 3s ease-in-out infinite;
}

.title-line {
    font-family: 'Russo One', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.title-drift {
    font-size: clamp(2.5rem, 10vw, 5.5rem);
    color: #fff;
    text-shadow:
        0 4px 0 #2d6a4f,
        0 8px 0 #1b4332,
        0 12px 30px rgba(0,0,0,0.3),
        0 0 60px rgba(78, 204, 163, 0.3);
    animation: titleDriftFloat 3s ease-in-out infinite;
}

@keyframes titleDriftFloat {
    0%, 100% { transform: translateY(0) rotate(-0.5deg); text-shadow: 0 4px 0 #2d6a4f, 0 8px 0 #1b4332, 0 12px 30px rgba(0,0,0,0.3), 0 0 60px rgba(78,204,163,0.3); }
    50% { transform: translateY(-4px) rotate(0.5deg); text-shadow: 0 6px 0 #2d6a4f, 0 10px 0 #1b4332, 0 16px 40px rgba(0,0,0,0.3), 0 0 80px rgba(78,204,163,0.5); }
}

.title-boss {
    font-size: clamp(3rem, 12vw, 6.5rem);
    color: #ffbe0b;
    text-shadow:
        0 4px 0 #e08e00,
        0 8px 0 #b87300,
        0 12px 30px rgba(0,0,0,0.3),
        0 0 60px rgba(255, 190, 11, 0.3);
    margin-top: -0.15em;
    animation: titleBossFloat 3s ease-in-out infinite 0.3s;
}

@keyframes titleBossFloat {
    0%, 100% { transform: translateY(0) rotate(0.5deg) scale(1); text-shadow: 0 4px 0 #e08e00, 0 8px 0 #b87300, 0 12px 30px rgba(0,0,0,0.3), 0 0 60px rgba(255,190,11,0.3); }
    50% { transform: translateY(-3px) rotate(-0.5deg) scale(1.02); text-shadow: 0 6px 0 #e08e00, 0 12px 0 #b87300, 0 16px 40px rgba(0,0,0,0.3), 0 0 90px rgba(255,190,11,0.5); }
}

/* Title glow pulse underline */
/* .game-title::after {
    content: '';
    display: block;
    width: 60%;
    height: 2px;
    margin: 6px auto 0;
    background: linear-gradient(90deg, transparent, rgba(78,204,163,0.5), rgba(255,190,11,0.5), transparent);
    border-radius: 2px;
    animation: titleUnderGlow 2.5s ease-in-out infinite;
} */

@keyframes titleUnderGlow {
    0%, 100% { opacity: 0.3; width: 50%; }
    50% { opacity: 0.8; width: 70%; }
}

/* Car preview area */
.lobby-car-area {
    width: 100%;
    height: clamp(80px, 14vh, 140px);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.lobby-pedestal-glow {
    position: absolute;
    bottom: 0;
    width: 160px;
    height: 30px;
    background: radial-gradient(ellipse, rgba(78, 204, 163, 0.3) 0%, rgba(69,183,209,0.15) 40%, transparent 70%);
    border-radius: 50%;
    filter: blur(8px);
    animation: pedestalGlow 2s ease-in-out infinite alternate;
}

@keyframes pedestalGlow {
    0% { opacity: 0.5; transform: scaleX(0.9); }
    100% { opacity: 1; transform: scaleX(1.1); }
}

/* ===== CAR CAROUSEL ===== */
.lobby-carousel {
    display: flex;
    align-items: center;
    gap: clamp(12px, 3vw, 24px);
    width: 100%;
    justify-content: center;
}

.carousel-arrow {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: linear-gradient(180deg, #5b7db5 0%, #3d5a8a 100%);
    border: 3px solid #7ba0d4;
    border-bottom: 5px solid #2c4570;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, border-bottom-width 0.1s;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    animation: none;
}

.carousel-arrow:active {
    transform: translateY(3px);
    border-bottom-width: 2px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.carousel-info {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.carousel-car-name {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(1.3rem, 5vw, 2rem);
    color: #ffe066;
    letter-spacing: 0.1em;
    text-shadow:
        0 2px 0 rgba(0,0,0,0.8),
        0 0 20px rgba(255, 190, 11, 0.4);
    background: rgba(0, 0, 0, 0.45);
    padding: 4px 16px 6px;
    border-radius: 10px;
    white-space: normal;
    overflow-wrap: break-word;
    display: inline-block;
}

.carousel-car-desc {
    font-size: clamp(0.7rem, 2vw, 0.85rem);
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    margin-top: 2px;
}

/* ===== CAR ACTION (buy/select/selected) ===== */
.lobby-car-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-height: clamp(50px, 9vh, 70px);
}

.car-price-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.95rem, 3vw, 1.15rem);
    color: #ffd54f;
    text-shadow: 0 0 8px rgba(255, 190, 11, 0.3);
}

.car-price-value {
    color: #ffd54f;
}

.action-btn {
    padding: 10px 36px;
    border: 3px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    color: #fff;
    letter-spacing: 0.08em;
    transition: transform 0.1s, border-bottom-width 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.action-btn:active {
    transform: translateY(3px);
    border-bottom-width: 2px;
}

.buy-btn {
    background: linear-gradient(180deg, #ffe060 0%, #ffb300 100%);
    border-color: #ffe888;
    border-bottom: 5px solid #c08000;
    color: #3e2723;
    text-shadow: none;
}

.buy-btn.confirm {
    background: linear-gradient(180deg, #ff8860 0%, #e64a19 100%);
    border-color: #ffaa80;
    border-bottom: 5px solid #a03010;
    color: #fff;
    animation: confirmShake 0.4s ease;
}

.buy-btn.not-enough {
    background: linear-gradient(180deg, #ff6060 0%, #c62828 100%);
    border-color: #ff9090;
    border-bottom: 5px solid #7a0000;
    color: #fff;
}

@keyframes confirmShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.select-btn {
    background: linear-gradient(180deg, #5eddbb 0%, #38b289 100%);
    border-color: #80f0d0;
    border-bottom: 5px solid #2a7a5e;
}

.selected-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    color: #fff;
    letter-spacing: 0.08em;
    padding: 10px 28px;
    background: linear-gradient(180deg, #4ecca3 0%, #38b289 100%);
    border: 3px solid #6ee8c4;
    border-bottom: 5px solid #2a7a5e;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(78,204,163,0.3);
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.lock-icon {
    flex-shrink: 0;
}

/* ===== LOBBY STATS BAR ===== */
.lobby-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(16px, 5vw, 36px);
    width: 100%;
    padding: clamp(8px, 1.8vh, 14px) 24px;
    background: linear-gradient(180deg, #2e4a6e 0%, #1e3450 100%);
    border: 3px solid #4a7aaa;
    border-bottom: 5px solid #152540;
    border-radius: 18px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    animation: none;
}

.lobby-stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lobby-coin-count {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(1rem, 3vw, 1.3rem);
    color: #ffbe0b;
    text-shadow: 0 0 8px rgba(255, 190, 11, 0.3);
}

.lobby-best-label {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.6rem, 1.5vw, 0.7rem);
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.12em;
}

.lobby-best-value {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(1rem, 3vw, 1.3rem);
    color: #ffd54f;
    text-shadow: 0 0 10px rgba(255, 190, 11, 0.4);
}

/* Play button (shared with lobby) */
.play-btn {
    position: relative;
    background: linear-gradient(180deg, #5eddbb 0%, #38b289 100%);
    border: 3px solid #80f0d0;
    border-bottom: 6px solid #2a7a5e;
    border-radius: 16px;
    padding: clamp(11px, 2vh, 16px) clamp(30px, 8vw, 60px);
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.1s, border-bottom-width 0.1s;
    box-shadow: 0 6px 25px rgba(78,204,163,0.4);
    animation: playBtnGlow 2s ease-in-out infinite alternate;
    will-change: transform, box-shadow;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

@keyframes playBtnGlow {
    0% { box-shadow: 0 4px 25px rgba(78,204,163,0.3), 0 0 40px rgba(78,204,163,0.08); }
    100% { box-shadow: 0 4px 35px rgba(78,204,163,0.5), 0 0 80px rgba(78,204,163,0.15); }
}

.play-btn:active {
    transform: translateY(3px);
    border-bottom-width: 2px;
}

.play-btn-text {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.95rem, 3vw, 1.25rem);
    color: #fff;
    letter-spacing: 0.1em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    position: relative;
    z-index: 1;
}

.play-btn-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
    transform: skewX(-20deg);
    animation: btnShine 3s ease-in-out infinite;
}

@keyframes btnShine {
    0%, 70% { left: -100%; }
    85%, 100% { left: 150%; }
}

.start-hint {
    color: rgba(255,255,255,0.55);
    font-size: clamp(0.7rem, 2vw, 0.9rem);
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* ===== HUD ===== */
.hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: clamp(12px, 2vh, 24px) clamp(16px, 3vw, 32px);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    z-index: 50;
    pointer-events: none;
}

.hud > * {
    pointer-events: auto;
}

.hud-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Coin display */
.coin-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(180deg, #2e4a6e 0%, #1e3450 100%);
    border-radius: 50px;
    padding: 8px 18px 8px 10px;
    border: 3px solid #4a7aaa;
    border-bottom: 4px solid #152540;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.coin-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffbe0b 0%, #fb8500 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(255, 190, 11, 0.4);
    flex-shrink: 0;
}

.coin-icon.small {
    width: 22px;
    height: 22px;
}

.coin-inner {
    width: 60%;
    height: 60%;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
}

.coin-count {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ===== POWER-UP HUD INDICATORS ===== */
.powerup-hud {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pu-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(180deg, #2e4a6e 0%, #1e3450 100%);
    border-radius: 20px;
    padding: 6px 14px 6px 8px;
    border: 3px solid #4a7aaa;
    border-bottom: 4px solid #152540;
    box-shadow: 0 3px 10px rgba(0,0,0,0.4);
    min-width: 100px;
}

.pu-icon {
    font-size: 1.1rem;
    line-height: 1;
    flex-shrink: 0;
}

.pu-bar-bg {
    flex: 1;
    height: 8px;
    background: #152030;
    border: 1px solid #0a1018;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
}

.pu-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.15s linear;
}

.pu-indicator.pu-warning {
    animation: puWarningPulse 0.4s ease-in-out infinite alternate;
}

@keyframes puWarningPulse {
    from { opacity: 1; }
    to { opacity: 0.4; }
}

/* ===== COMBO DISPLAY ===== */
.combo-display {
    text-align: center;
    margin-top: 4px;
}

.combo-value {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(1.3rem, 4.5vw, 2rem);
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
    letter-spacing: 0.05em;
    transition: color 0.3s, text-shadow 0.3s;
}

.combo-value.combo-yellow {
    color: #ffd54f;
    text-shadow: 0 0 12px rgba(255, 213, 79, 0.5), 0 2px 8px rgba(0,0,0,0.3);
}

.combo-value.combo-orange {
    color: #ff9800;
    text-shadow: 0 0 16px rgba(255, 152, 0, 0.6), 0 2px 8px rgba(0,0,0,0.3);
}

.combo-value.combo-red {
    color: #ff4444;
    text-shadow: 0 0 20px rgba(255, 68, 68, 0.7), 0 0 40px rgba(255, 68, 68, 0.3), 0 2px 8px rgba(0,0,0,0.3);
}

.combo-value.combo-max {
    animation: comboMaxPulse 0.3s ease-in-out infinite alternate;
}

@keyframes comboMaxPulse {
    from { transform: scale(1); }
    to { transform: scale(1.08); }
}

/* Score display */
.hud-center {
    text-align: center;
}

.score-display {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(2rem, 7vw, 3.5rem);
    color: #fff;
    text-shadow:
        0 2px 0 rgba(0,0,0,0.2),
        0 4px 12px rgba(0,0,0,0.15);
    text-align: center;
    line-height: 1;
    opacity: 0.9;
}

/* HUD right section — buttons in a row */
.hud-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* HUD fullscreen button — same style as pause button */
.hud-fs-btn {
    width: clamp(44px, 6vw, 54px);
    height: clamp(44px, 6vw, 54px);
    border-radius: 16px;
    background: linear-gradient(180deg, #60b5ee 0%, #357abd 100%);
    border: 3px solid #90d0ff;
    border-bottom: 5px solid #2a5080;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(53, 122, 189, 0.4);
    transition: transform 0.1s, border-bottom-width 0.1s;
    pointer-events: auto;
}
.hud-fs-btn:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

/* Pause button */
.pause-btn {
    width: clamp(44px, 6vw, 54px);
    height: clamp(44px, 6vw, 54px);
    border-radius: 16px;
    background: linear-gradient(180deg, #60b5ee 0%, #357abd 100%);
    border: 3px solid #90d0ff;
    border-bottom: 5px solid #2a5080;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(53, 122, 189, 0.4);
    transition: transform 0.1s, border-bottom-width 0.1s;
}

.pause-btn:active {
    transform: translateY(2px);
    border-bottom-width: 1px;
}

.pause-icon {
    display: flex;
    gap: 4px;
}

.pause-icon span {
    display: block;
    width: 4px;
    height: 16px;
    background: #fff;
    border-radius: 2px;
}

/* ===== PAUSE SCREEN ===== */
#pauseScreen {
    background: rgba(10,15,25,0.97);
    flex-direction: column;
    justify-content: center;
    gap: 0;
}

.pause-level-label {
    position: absolute;
    top: clamp(14px, 2.5vh, 22px);
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Exo 2', 'Russo One', sans-serif;
    font-weight: 800;
    font-size: clamp(0.75rem, 2.5vw, 0.95rem);
    color: rgba(255,255,255,0.45);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
}

.pause-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(1rem, 3vh, 1.5rem);
}

.pause-title {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(2.5rem, 10vw, 4.5rem);
    color: #fff;
    text-shadow: 0 4px 20px rgba(0,0,0,0.3);
    letter-spacing: 0.1em;
}

/* Menu buttons (shared) */
.menu-btn {
    position: relative;
    min-width: clamp(180px, 45vw, 260px);
    padding: clamp(12px, 2vh, 18px) clamp(30px, 6vw, 50px);
    border: 3px solid transparent;
    border-radius: 16px;
    cursor: pointer;
    font-family: 'Exo 2', 'Russo One', sans-serif;
    font-weight: 800;
    font-size: clamp(0.95rem, 3vw, 1.2rem);
    color: #fff;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-shadow: 0 2px 3px rgba(0,0,0,0.3);
    transition: transform 0.1s, border-bottom-width 0.1s;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.menu-btn:active {
    transform: translateY(3px);
    border-bottom-width: 1px;
}

/* ===== PAUSE SOUND CONTROLS ===== */
.pause-sound-section {
    width: clamp(240px, 75vw, 320px);
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 12px 16px;
}

.pause-sound-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
}

.pause-sound-label {
    font-family: 'Exo 2', 'Russo One', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.8);
    flex: 1;
    text-align: left;
    letter-spacing: 0.05em;
}

.pause-slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px 4px 28px;
}

.resume-btn {
    background: linear-gradient(180deg, #5eddbb 0%, #38b289 100%);
    border-color: #80f0d0;
    border-bottom: 5px solid #2a7a5e;
}

.restart-btn {
    background: linear-gradient(180deg, #ff7878 0%, #ee5a5a 100%);
    border-color: #ffa0a0;
    border-bottom: 5px solid #a03535;
}

.pause-lobby-btn {
    background: linear-gradient(180deg, #4a5568 0%, #2d3748 100%);
    border-color: #718096;
    border-bottom: 5px solid #1a202c;
}

.go-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
    width: 100%;
}

.go-buttons .menu-btn {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-again-btn {
    background: linear-gradient(180deg, #5eddbb 0%, #38b289 100%);
    border-color: #80f0d0;
    border-bottom: 5px solid #2a7a5e;
}

/* ===== GAME OVER SCREEN ===== */
#gameOverScreen {
    background: rgba(10,10,20,0.9);
}

/* ===== GAME OVER ENTRY ANIMATIONS (compositor thread) ===== */
@keyframes go-title-down  { from { transform: translateY(-80px) scale(2); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes go-title-up    { from { transform: translateY(80px)  scale(2); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes go-card-in     { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes go-btn-in      { from { transform: translateY(40px) scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }

#gameOverScreen.go-play .go-line-game   { animation: go-title-down 0.45s cubic-bezier(0.34,1.56,0.64,1) 0.08s both; }
#gameOverScreen.go-play .go-line-over   { animation: go-title-up   0.45s cubic-bezier(0.34,1.56,0.64,1) 0.2s  both; }
#gameOverScreen.go-play .go-card        { animation: go-card-in    0.4s  ease-out                        0.45s both; }
#gameOverScreen.go-play #goReplayBtn    { animation: go-btn-in     0.35s cubic-bezier(0.34,1.56,0.64,1) 0.75s both; }
#gameOverScreen.go-play #playAgainBtn   { animation: go-btn-in     0.35s cubic-bezier(0.34,1.56,0.64,1) 0.88s both; }

.gameover-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.8rem, 2.5vh, 1.4rem);
    max-width: 380px;
    width: 90%;
    position: relative;
    overflow: visible;
}

.gameover-title {
    line-height: 0.9;
    position: relative;
}

.go-line {
    font-family: 'Russo One', sans-serif;
    letter-spacing: 0.08em;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
}

.go-line-game {
    font-size: clamp(2rem, 9vw, 3rem);
    color: #fff;
    text-shadow:
        0 0 30px rgba(255, 255, 255, 0.3),
        0 4px 0 rgba(200, 200, 200, 0.3),
        0 8px 20px rgba(0, 0, 0, 0.4);
}

.go-line-over {
    font-size: clamp(1.8rem, 12vw, 3.5rem);
    color: #ff4757;
    text-shadow:
        0 0 40px rgba(255, 71, 87, 0.5),
        0 0 80px rgba(255, 71, 87, 0.25),
        0 4px 0 rgba(180, 30, 40, 0.6),
        0 8px 0 rgba(120, 15, 25, 0.3),
        0 12px 30px rgba(0, 0, 0, 0.4);
    margin-top: -0.05em;
}

/* Game Over Card */
.go-card {
    width: 100%;
    background: linear-gradient(180deg, #2e4a6e 0%, #1e3450 100%);
    border: 3px solid #4a7aaa;
    border-bottom: 5px solid #152540;
    border-radius: 22px;
    padding: clamp(18px, 3vh, 30px) clamp(22px, 5vw, 38px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}

.go-score-section {
    margin-bottom: clamp(10px, 2vh, 16px);
}

.go-score-label {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.65rem, 1.8vw, 0.8rem);
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.25em;
    margin-bottom: 4px;
}

.final-score-value {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(3rem, 12vw, 5rem);
    color: #fff;
    line-height: 1;
    text-shadow:
        0 0 30px rgba(255, 255, 255, 0.15),
        0 2px 8px rgba(0, 0, 0, 0.3);
}

.go-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    margin-bottom: clamp(10px, 2vh, 16px);
}

.go-stats-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(20px, 6vw, 40px);
}

.go-stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.go-earned-label {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    color: #4ecca3;
}

.final-coin-count {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(1rem, 3vw, 1.3rem);
    color: #ffbe0b;
    text-shadow: 0 0 8px rgba(255, 190, 11, 0.3), 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* Best score in game over */
.go-best-stat {
    padding-left: clamp(16px, 4vw, 28px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.go-trophy-svg {
    flex-shrink: 0;
    filter: drop-shadow(0 1px 4px rgba(255, 190, 11, 0.5));
}

.go-best-label {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.6rem, 1.5vw, 0.7rem);
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.12em;
}

.go-best-value {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(1rem, 3vw, 1.3rem);
    color: #ffd54f;
    text-shadow: 0 0 10px rgba(255, 190, 11, 0.4), 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* NEW HIGH SCORE badge */
.new-high-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.85rem, 2.8vw, 1.1rem);
    color: #fff;
    background: linear-gradient(180deg, #ff8040 0%, #ee5a24 100%);
    background-size: 100% 100%;
    animation: none;
    padding: 12px 30px;
    border-radius: 16px;
    border: 3px solid #ffb080;
    border-bottom: 5px solid #a03010;
    letter-spacing: 0.12em;
    text-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.new-high-star {
    flex-shrink: 0;
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.6));
}

@keyframes badgeGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ===== DEATH FLASH ===== */
.death-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(255, 60, 60, 0.8) 0%, rgba(180, 20, 20, 0.6) 100%);
    z-index: 90;
    pointer-events: none;
}

/* ===== DEATH PARTICLES ===== */
.death-particle {
    position: absolute;
    top: 50%;
    left: 50%;
    pointer-events: none;
    will-change: transform, opacity;
    z-index: 0;
}

/* ===== CONFETTI ===== */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 500;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    pointer-events: none;
    will-change: transform, opacity;
}

/* ===== FLOATING TEXT ===== */
.floating-text {
    position: fixed;
    top: 45%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Russo One', sans-serif;
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 200;
    pointer-events: none;
    white-space: nowrap;
}

/* ===== RESPONSIVE TWEAKS ===== */

/* Desktop — make lobby-content fill full viewport height.
   .game-title gets flex:1 so logo floats in the top zone,
   keeping .lobby-car-area at ~50% of screen — where Babylon's
   ArcRotateCamera always renders the 3D car. */
@media (min-width: 600px) {
    .lobby-content {
        height: 100%;
        max-width: 460px;
        gap: clamp(0.2rem, 0.8vh, 0.55rem);
        justify-content: flex-end; /* stack from bottom so car-area stays centered */
        padding-bottom: clamp(0.5rem, 1.5vh, 1.2rem);
    }
    .game-title {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 0;
    }
    .lobby-logo-img {
        width: clamp(140px, min(60vw, 34vh), 300px);
        max-height: 34vh;
        object-fit: contain;
    }
    .lobby-car-area {
        height: clamp(80px, 13vh, 130px);
        flex-shrink: 0;
    }
    .play-btn {
        padding: clamp(10px, 1.6vh, 15px) clamp(28px, 7vw, 55px);
    }
    .start-hint {
        font-size: clamp(0.6rem, 1.4vw, 0.8rem);
    }
}

/* Small portrait phones — tighten gaps so all content fits without scroll */
@media (max-height: 720px) and (orientation: portrait) {
    .lobby-content {
        gap: clamp(0.2rem, 0.7vh, 0.45rem);
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
    .lobby-car-area {
        height: clamp(65px, 12vh, 100px);
    }
    .lobby-logo-img {
        max-height: 22vh;
    }
    .lobby-stats {
        padding: 7px 20px;
    }
    .lobby-car-action {
        min-height: 50px;
    }
}

/* Landscape phone — ultra-compact */
@media (max-height: 500px) and (orientation: landscape) {
    .lobby-content {
        gap: 0.3rem;
    }
    .title-drift {
        font-size: 2rem;
    }
    .title-boss {
        font-size: 2.5rem;
    }
    .lobby-car-area {
        height: 60px;
    }
    .play-btn {
        padding: 10px 40px;
    }
    .pause-content, .gameover-content {
        gap: 0.6rem;
    }
    .pu-indicator {
        min-width: 80px;
        padding: 3px 8px 3px 4px;
    }
    .pu-icon {
        font-size: 0.9rem;
    }
}

/* ===== LEVEL SELECT SCREEN ===== */
#levelSelectScreen {
    background: linear-gradient(160deg, #0a0e1a 0%, #111827 100%);
    z-index: 100;
    flex-direction: column;
    align-items: stretch;
}

.ls-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}

.ls-container {
    width: 100%;
    max-width: 520px;
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.ls-header {
    display: flex;
    align-items: center;
    padding: clamp(14px, 2.5vh, 20px) clamp(16px, 4vw, 24px);
    gap: 12px;
    flex-shrink: 0;
}

.ls-back-btn {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(180deg, #5b7db5 0%, #3d5a8a 100%);
    border: 3px solid #7ba0d4;
    border-bottom: 5px solid #2c4570;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, border-bottom-width 0.1s;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.ls-back-btn:active {
    transform: translateY(3px);
    border-bottom-width: 2px;
}

.ls-title {
    flex: 1;
    font-family: 'Russo One', sans-serif;
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    color: #fff;
    letter-spacing: 0.12em;
}

.ls-total-stars {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    color: #fff;
    background: linear-gradient(180deg, #d4a020 0%, #a07818 100%);
    padding: 8px 14px;
    border-radius: 12px;
    border: 2px solid #f0c840;
    border-bottom: 4px solid #705010;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.ls-scroller {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px clamp(12px, 3vw, 20px) clamp(24px, 4vh, 40px);
    -webkit-overflow-scrolling: touch;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    align-content: start;
}

.ls-scroller::-webkit-scrollbar { width: 2px; }
.ls-scroller::-webkit-scrollbar-track { background: transparent; }
.ls-scroller::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }

/* --- Level Button Base --- */
.ls-btn {
    height: 52px;
    border-radius: 12px;
    border: 2px solid #4a7aaa;
    border-bottom: 4px solid #152540;
    background: linear-gradient(180deg, #2e4a6e 0%, #1e3450 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, border-bottom-width 0.1s;
    font-family: inherit;
    color: #fff;
    padding: 0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.ls-btn:not(.locked):active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.ls-btn:not(.locked):hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}

/* --- Number --- */
.ls-num {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(1rem, 3.2vw, 1.3rem);
    line-height: 1;
    color: rgba(255, 255, 255, 0.7);
}

/* ======== LOCKED ======== */
.ls-btn.locked {
    cursor: not-allowed;
    pointer-events: none;
    background: linear-gradient(180deg, #1a2535 0%, #101820 100%);
    border-color: #1e2a3a;
    border-bottom-color: #0a1015;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.ls-btn.locked .ls-num {
    color: rgba(255, 255, 255, 0.12);
    font-size: clamp(0.85rem, 2.5vw, 1rem);
}

.ls-lock {
    color: rgba(255, 255, 255, 0.15);
    margin-left: 2px;
    line-height: 0;
}

.ls-lock svg {
    width: 10px;
    height: 10px;
}

/* ======== DONE (completed, any stars) ======== */
.ls-btn.done {
    background: linear-gradient(180deg, #3a5a7e 0%, #2a4460 100%);
    border-color: #5a8aba;
    border-bottom-color: #1a3050;
}

.ls-btn.done .ls-num {
    color: rgba(255, 255, 255, 0.9);
}

/* ======== CURRENT (next to play) ======== */
.ls-btn.current {
    border-color: #70b0ff;
    border-bottom-color: #2050a0;
    background: linear-gradient(180deg, #4080c8 0%, #305898 100%);
    box-shadow: 0 3px 12px rgba(96, 165, 250, 0.3);
    animation: ls-pulse 2s ease-in-out infinite;
}

@keyframes ls-pulse {
    0%, 100% { box-shadow: 0 3px 12px rgba(96, 165, 250, 0.2); }
    50% { box-shadow: 0 3px 20px rgba(96, 165, 250, 0.5); }
}

.ls-btn.current .ls-num {
    color: #93c5fd;
}

/* ===== LEVEL COMPLETE SCREEN ===== */
#levelCompleteScreen {
    background: rgba(10,20,15,0.9);
    z-index: 100;
}

.lc-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.8rem, 2.5vh, 1.4rem);
    max-width: 380px;
    width: 90%;
}

.lc-title {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(2rem, 8vw, 3.5rem);
    color: #4ecca3;
    text-shadow:
        0 0 30px rgba(78, 204, 163, 0.5),
        0 0 60px rgba(78, 204, 163, 0.25),
        0 4px 0 rgba(45, 138, 110, 0.6),
        0 8px 20px rgba(0, 0, 0, 0.4);
    letter-spacing: 0.05em;
}

.lc-stars {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(8px, 3vw, 16px);
}

.lc-star {
    transition: fill 0.3s;
}

.lc-star.earned path {
    fill: #ffd54f;
}

.lc-all-complete {
    width: 100%;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(255,200,50,0.12) 0%, rgba(255,140,0,0.08) 100%);
    border: 1px solid rgba(255,200,50,0.3);
    border-radius: 10px;
    text-align: center;
    overflow: hidden;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lcAllCompleteText {
    font-family: 'Poppins', sans-serif;
    font-size: clamp(11px, 3vw, 14px);
    font-weight: 600;
    font-style: italic;
    color: #ffd54f;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.lc-info {
    font-family: 'Poppins', sans-serif;
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.05em;
}

.lc-coin-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    color: #ffbe0b;
    text-shadow: 0 0 8px rgba(255, 190, 11, 0.3);
}

.lc-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    align-items: center;
}

.lc-next-btn {
    background: linear-gradient(180deg, #5eddbb 0%, #38b289 100%);
    border-color: #80f0d0;
    border-bottom: 5px solid #2a7a5e;
}

.lc-replay-btn {
    background: linear-gradient(180deg, #60b5ee 0%, #357abd 100%);
    border-color: #90d0ff;
    border-bottom: 5px solid #2a5080;
}

.lc-levels-btn {
    background: linear-gradient(180deg, #ffb040 0%, #f57c00 100%);
    border-color: #ffd080;
    border-bottom: 5px solid #c05500;
}

/* ===== TUTORIAL DIM + INTRO ===== */
.tutorial-dim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    z-index: 99;
    pointer-events: none;
}
.tutorial-intro {
    position: fixed;
    top: 28%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 145;
    pointer-events: none;
    text-align: center;
    padding: 0 28px;
    max-width: 360px;
    width: 92%;
}
.tut-intro-text {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(14px, 4.2vw, 20px);
    color: #fff;
    text-shadow: 0 0 24px rgba(0,0,0,1), 0 2px 10px rgba(0,0,0,1);
    margin: 0;
    line-height: 1.35;
    letter-spacing: 0.03em;
}

/* ===== TUTORIAL HINT HUD ===== */
.tutorial-hint {
    position: fixed;
    bottom: clamp(72px, 16vh, 130px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 150;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}
.tut-icon-wrap {
    position: relative;
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tut-hand-img {
    width: 64px;
    height: 64px;
    position: relative;
    z-index: 1;
    object-fit: contain;
    filter: drop-shadow(0 0 14px rgba(78,204,163,0.95)) drop-shadow(0 2px 6px rgba(0,0,0,0.8));
    animation: tut-tap 1.4s cubic-bezier(0.4,0,0.6,1) infinite;
}
.tut-ripple {
    position: absolute;
    bottom: 2px;
    left: 50%;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(78,204,163,0.55) 0%, transparent 68%);
    transform: translateX(-50%) scale(0.2);
    opacity: 0;
    animation: tut-ripple 1.4s ease-out infinite;
}
.tut-ripple.tr2 { animation-delay: 0.7s; }
@keyframes tut-tap {
    0%, 60%, 100% { transform: translateY(0); }
    28%            { transform: translateY(12px); }
}
@keyframes tut-ripple {
    0%   { transform: translateX(-50%) scale(0.2); opacity: 0.85; }
    100% { transform: translateX(-50%) scale(2.2); opacity: 0; }
}
.tut-text {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(12px, 3.4vw, 15px);
    color: #fff;
    text-align: center;
    margin: 0;
    letter-spacing: 0.03em;
    text-shadow: 0 0 12px rgba(0,0,0,1), 0 2px 8px rgba(0,0,0,0.9), 0 0 4px rgba(0,0,0,1);
    max-width: 280px;
    line-height: 1.35;
}

/* ===== COUNTDOWN OVERLAY ===== */
.countdown-overlay {
    position: fixed;
    inset: 0;
    z-index: 201;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.countdown-num {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(100px, 30vw, 220px);
    line-height: 1;
    color: #fff;
    text-shadow: 0 0 60px rgba(0,0,0,0.9), 0 6px 24px rgba(0,0,0,0.7);
    will-change: transform, opacity;
}

/* ===== LEVEL START BANNER ===== */
.level-start-banner {
    position: fixed;
    top: 50%;
    left: 0;
    width: 100%;
    text-align: center;
    z-index: 200;
    pointer-events: none;
    padding: 6px 20px;
}

.lsb-world {
    display: none;
}

.lsb-level {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(2.2rem, 8vw, 4rem);
    color: #fff;
    text-shadow:
        0 0 40px rgba(255,255,255,0.4),
        0 3px 0 rgba(0,0,0,0.6),
        0 6px 20px rgba(0,0,0,0.8);
    letter-spacing: 0.1em;
}

/* ===== LEVEL PROGRESS BAR ===== */
.level-progress-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: #152030;
    border-bottom: 2px solid #0a1018;
    z-index: 51;
    pointer-events: none;
}

.level-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(180deg, #5eddbb 0%, #38b289 100%);
    border-radius: 0 3px 3px 0;
    transition: width 0.3s ease;
    box-shadow: 0 0 6px rgba(78,204,163,0.5);
}

@media (max-width: 380px) {
    .coin-display {
        padding: 4px 12px 4px 6px;
    }
    .coin-icon {
        width: 22px;
        height: 22px;
    }
    .pu-indicator {
        min-width: 80px;
    }
    .carousel-arrow {
        width: 36px;
        height: 36px;
    }
}

/* ===== TOP-RIGHT BUTTON GROUP (Lobby) ===== */
.lobby-top-btns {
    position: absolute;
    top: clamp(14px, 2.5vh, 20px);
    right: clamp(14px, 3vw, 20px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.lobby-fs-btn {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(180deg, #4a6a9a 0%, #2e4a70 100%);
    border: 3px solid #6a90c4;
    border-bottom: 5px solid #1c3050;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: transform 0.1s, border-bottom-width 0.1s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    padding: 0;
}
.lobby-fs-btn:active {
    transform: translateY(3px);
    border-bottom-width: 2px;
}

/* ===== SETTINGS BUTTON (Lobby) ===== */
.lobby-settings-btn {
    position: relative;
    top: unset;
    right: unset;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(180deg, #5b7db5 0%, #3d5a8a 100%);
    border: 3px solid #7ba0d4;
    border-bottom: 5px solid #2c4570;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    z-index: 10;
    transition: transform 0.1s, border-bottom-width 0.1s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    padding: 0;
}

.lobby-settings-btn:active {
    transform: translateY(3px);
    border-bottom-width: 2px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* ===== SETTINGS SCREEN ===== */
#settingsScreen {
    background: linear-gradient(180deg, #141e30 0%, #0a1018 100%);
    z-index: 150;
    flex-direction: column;
}

.settings-container {
    width: 90%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 2vh, 20px);
    max-height: 90vh;
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-title {
    flex: 1;
    font-family: 'Russo One', sans-serif;
    font-size: clamp(1.3rem, 4vw, 1.8rem);
    color: #fff;
    letter-spacing: 0.12em;
}

.settings-section-label {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.65rem, 1.8vw, 0.8rem);
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.2em;
}

/* ===== SETTINGS TOGGLE SWITCHES ===== */
.settings-toggles {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 14px;
    background: linear-gradient(180deg, #2e4a6e 0%, #1e3450 100%);
    border: 2px solid #4a7aaa;
    border-bottom: 4px solid #152540;
    cursor: pointer;
    transition: transform 0.1s, border-bottom-width 0.1s;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

.settings-toggle-row:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.toggle-icon {
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.toggle-label {
    flex: 1;
    font-family: 'Poppins', sans-serif;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

.toggle-switch {
    width: 50px;
    height: 28px;
    border-radius: 14px;
    background: linear-gradient(180deg, #3a2020 0%, #2a1515 100%);
    border: 2px solid #5a3030;
    position: relative;
    flex-shrink: 0;
    transition: background 0.25s, border-color 0.25s;
}

.toggle-switch .toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 10px;
    background: linear-gradient(180deg, #ff7070 0%, #cc4040 100%);
    border: 2px solid #ff9090;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: left 0.25s, background 0.25s, border-color 0.25s;
}

.settings-toggle-row.active .toggle-switch,
.pause-sound-toggle.active .toggle-switch {
    background: linear-gradient(180deg, #1e5040 0%, #153830 100%);
    border-color: #3a8a6e;
}

.settings-toggle-row.active .toggle-switch .toggle-knob,
.pause-sound-toggle.active .toggle-switch .toggle-knob {
    left: 24px;
    background: linear-gradient(180deg, #5eddbb 0%, #38b289 100%);
    border-color: #80f0d0;
}

.settings-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border-radius: 12px;
    background: linear-gradient(180deg, #253d5c 0%, #1a2e45 100%);
    border: 2px solid #3a6090;
    border-bottom: 3px solid #12202f;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.slider-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

.volume-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #2a4060 0%, #3a5a80 100%);
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(180deg, #5eddbb 0%, #38b289 100%);
    border: 2px solid #80f0d0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(180deg, #5eddbb 0%, #38b289 100%);
    border: 2px solid #80f0d0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    cursor: pointer;
}

.slider-value {
    font-family: 'Poppins', sans-serif;
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    font-weight: 700;
    color: #5eddbb;
    min-width: 36px;
    text-align: right;
}

.settings-lang-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 50vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
}

.settings-lang-list::-webkit-scrollbar { width: 3px; }
.settings-lang-list::-webkit-scrollbar-track { background: transparent; }
.settings-lang-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.settings-lang-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 14px;
    background: linear-gradient(180deg, #2e4a6e 0%, #1e3450 100%);
    border: 2px solid #4a7aaa;
    border-bottom: 4px solid #152540;
    cursor: pointer;
    transition: transform 0.1s, border-bottom-width 0.1s;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

.settings-lang-item:active {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.settings-lang-item:hover {
    background: linear-gradient(180deg, #36567e 0%, #254060 100%);
    border-color: #5a8aba;
}

.settings-lang-item.active {
    background: linear-gradient(180deg, #3a8a6e 0%, #2a6a52 100%);
    border-color: #5cc8a0;
    border-bottom-color: #1e5040;
    box-shadow: 0 3px 12px rgba(78, 204, 163, 0.25);
}

.settings-lang-flag {
    font-family: 'Exo 2', 'Russo One', sans-serif;
    font-weight: 800;
    font-size: 0.7rem;
    line-height: 1;
    flex-shrink: 0;
    min-width: 30px;
    text-align: center;
    background: rgba(255,255,255,0.12);
    border-radius: 4px;
    padding: 3px 5px;
    letter-spacing: 0.05em;
    color: rgba(255,255,255,0.9);
}

.settings-lang-name {
    flex: 1;
    font-family: 'Poppins', sans-serif;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

.settings-lang-check {
    font-size: 1.1rem;
    color: #4ecca3;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.settings-lang-item.active .settings-lang-check {
    opacity: 1;
}

/* ===== SETTINGS RESET BUTTON ===== */
.settings-reset-btn {
    width: 100%;
    padding: 14px 20px;
    border: 3px solid #ff8080;
    border-bottom: 5px solid #8a2020;
    border-radius: 14px;
    background: linear-gradient(180deg, #e05555 0%, #c03030 100%);
    cursor: pointer;
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.8rem, 2.2vw, 0.95rem);
    color: #fff;
    letter-spacing: 0.08em;
    transition: transform 0.1s, border-bottom-width 0.1s;
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.settings-reset-btn:active {
    transform: translateY(3px);
    border-bottom-width: 2px;
}

.settings-reset-btn:hover {
    background: linear-gradient(180deg, #e86565 0%, #d03838 100%);
    border-color: #ff9090;
}

.settings-reset-btn.confirming {
    background: linear-gradient(180deg, #ff5555 0%, #dd2020 100%);
    border-color: #ffaaaa;
    animation: resetPulse 0.6s ease-in-out infinite alternate;
}

@keyframes resetPulse {
    from { box-shadow: 0 0 0 rgba(255, 71, 87, 0); }
    to { box-shadow: 0 0 16px rgba(255, 71, 87, 0.3); }
}

/* ===== ABOUT ROW (no toggle switch) ===== */
.settings-about-row {
    cursor: pointer;
}
.settings-about-row .toggle-switch {
    display: none;
}

/* ===== ABOUT POPUP ===== */
.about-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.about-popup {
    background: linear-gradient(160deg, rgba(22,28,48,0.97) 0%, rgba(10,14,30,0.97) 100%);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    width: clamp(260px, 82vw, 380px);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 36px 28px 24px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.05);
    gap: 24px;
}

.about-popup-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.about-qplaze-logo {
    width: clamp(140px, 60%, 200px);
    height: auto;
    filter: drop-shadow(0 2px 12px rgba(255,255,255,0.15));
}

.about-version {
    color: rgba(255,255,255,0.35);
    font-family: 'Russo One', sans-serif;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    margin: 0;
}

.about-close-btn {
    width: 100%;
    padding: 13px 20px;
    background: linear-gradient(180deg, #3a7bd5 0%, #2558b0 100%);
    border: none;
    border-bottom: 3px solid #1a3f8a;
    border-radius: 12px;
    color: #fff;
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.85rem, 3.5vw, 1rem);
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: filter 0.15s;
}

.about-close-btn:active {
    transform: translateY(2px);
    border-bottom-width: 1px;
}

/* ===== LEVEL COMPLETE ENTRY ANIMATIONS (compositor thread, replaces GSAP) ===== */
@keyframes lc-screen-fade  { from { opacity: 0; } to { opacity: 1; } }
@keyframes lc-title-in     { from { transform: translateY(-50px) scale(1.6); opacity: 0; }
                              to   { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes lc-item-up      { from { transform: translateY(22px); opacity: 0; }
                              to   { transform: translateY(0); opacity: 1; } }
@keyframes lc-star-pop     { from { transform: scale(0); opacity: 0; }
                              to   { transform: scale(1); opacity: 1; } }
@keyframes lc-star-burst   { 0%,100% { transform: scale(1); } 40% { transform: scale(1.5); } }
@keyframes lc-next-pulse   { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }

#levelCompleteScreen.lc-play {
    animation: lc-screen-fade 0.45s ease-out forwards;
}
#levelCompleteScreen.lc-play .lc-title {
    animation: lc-title-in 0.6s cubic-bezier(0.34,1.56,0.64,1) 0.08s both;
}
#levelCompleteScreen.lc-play .lc-stars .lc-star:nth-child(1) {
    animation: lc-star-pop 0.45s cubic-bezier(0.34,1.56,0.64,1) 0.38s both;
}
#levelCompleteScreen.lc-play .lc-stars .lc-star:nth-child(2) {
    animation: lc-star-pop 0.45s cubic-bezier(0.34,1.56,0.64,1) 0.56s both;
}
#levelCompleteScreen.lc-play .lc-stars .lc-star:nth-child(3) {
    animation: lc-star-pop 0.45s cubic-bezier(0.34,1.56,0.64,1) 0.74s both;
}
#levelCompleteScreen.lc-play .lc-info {
    animation: lc-item-up 0.35s ease-out 0.95s both;
}
#levelCompleteScreen.lc-play .lc-coin-stats {
    animation: lc-item-up 0.35s ease-out 1.1s both;
}
#levelCompleteScreen.lc-play #lcNextBtn {
    animation: lc-item-up 0.35s ease-out 1.25s both;
}
#levelCompleteScreen.lc-play #lcReplayBtn {
    animation: lc-item-up 0.35s ease-out 1.35s both;
}
#levelCompleteScreen.lc-play #lcLevelsBtn {
    animation: lc-item-up 0.35s ease-out 1.45s both;
}
.lc-star.lc-star-burst  { animation: lc-star-burst 0.35s ease-out; }
.lc-next-breathe        { animation: lc-next-pulse 0.8s ease-in-out infinite; }

/* ===== LEVEL COMPLETE PARTICLES — CSS-animated (compositor thread) ===== */
@keyframes lc-fw-burst {
    0%   { transform: translate(0,0) scale(1.5); opacity: 1; }
    100% { transform: translate(var(--vx,0px), var(--vy,0px)) scale(0); opacity: 0; }
}
@keyframes lc-fw-flash {
    0%   { transform: translate(-50%,-50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%,-50%) scale(3); opacity: 0; }
}
@keyframes lc-confetti-fall {
    0%   { opacity: 0.9; }
    100% { transform: translateY(var(--vy,110vh)) translateX(var(--vx,0px)) rotate(var(--vr,360deg)); opacity: 0; }
}
.lc-fw-particle, .lc-fw-flash, .lc-confetti-piece {
    will-change: transform, opacity;
}

/* ===== ALL COMPLETE CELEBRATION SCREEN ===== */
#allCompleteScreen {
    background: linear-gradient(180deg, #1a1408 0%, #0a0a0a 100%);
    z-index: 120;
    flex-direction: column;
}

.ac-container {
    width: 90%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(10px, 2vh, 18px);
    text-align: center;
}

.ac-trophy {
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5)) drop-shadow(0 0 40px rgba(255, 165, 0, 0.3));
    animation: goldPulse 2.5s ease-in-out infinite alternate;
}

@keyframes goldPulse {
    0% { filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.4)) drop-shadow(0 0 30px rgba(255, 165, 0, 0.2)); transform: scale(1); }
    100% { filter: drop-shadow(0 0 25px rgba(255, 215, 0, 0.7)) drop-shadow(0 0 50px rgba(255, 165, 0, 0.4)); transform: scale(1.05); }
}

.ac-title {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(1.6rem, 6vw, 2.4rem);
    background: linear-gradient(135deg, #FFD700, #FFA500, #FFD700);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: acTitleShimmer 3s ease-in-out infinite;
    letter-spacing: 0.05em;
    line-height: 1.2;
    margin: 0;
}

@keyframes acTitleShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.ac-msg {
    font-family: 'Poppins', sans-serif;
    font-size: clamp(0.85rem, 2.5vw, 1.05rem);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    margin: 0;
}

.ac-star-card {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 16px 22px;
    background: linear-gradient(180deg, #4a3a10 0%, #352808 100%);
    border: 3px solid #c8a020;
    border-bottom: 5px solid #2a2005;
    border-radius: 18px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.ac-star-icon {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
}

.ac-star-label {
    flex: 1;
    text-align: left;
    font-family: 'Poppins', sans-serif;
    font-size: clamp(0.8rem, 2.2vw, 0.95rem);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.05em;
}

.ac-star-count {
    font-family: 'Russo One', sans-serif;
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    color: #ffd54f;
    text-shadow: 0 0 10px rgba(255, 213, 79, 0.4);
}

.ac-btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.9rem, 2.8vw, 1.05rem);
    letter-spacing: 0.08em;
    transition: transform 0.1s, border-bottom-width 0.1s;
}

.ac-btn:active {
    transform: translateY(3px);
    border-bottom-width: 1px;
}

.ac-btn-primary {
    background: linear-gradient(180deg, #ffe040 0%, #FFA500 100%);
    border: 3px solid #ffe888;
    border-bottom: 5px solid #a07000;
    color: #3e2723;
    box-shadow: 0 4px 15px rgba(255,165,0,0.3);
}

.ac-btn-secondary {
    background: linear-gradient(180deg, #5b7db5 0%, #3d5a8a 100%);
    border: 3px solid #7ba0d4;
    border-bottom: 5px solid #2c4570;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.ac-btn-secondary:active {
    transform: translateY(3px);
    border-bottom-width: 2px;
}

.ac-btn-danger {
    background: linear-gradient(180deg, #e05555 0%, #c03030 100%);
    border: 3px solid #ff8080;
    border-bottom: 5px solid #8a2020;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.ac-btn-danger:active {
    transform: translateY(3px);
    border-bottom-width: 2px;
}

.ac-btn-danger.confirming {
    background: rgba(255, 71, 87, 0.2);
    border-color: rgba(255, 71, 87, 0.6);
    animation: resetPulse 0.6s ease-in-out infinite alternate;
}

/* ===== LEVEL TRANSITION OVERLAY ===== */
.level-transition-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 800;
    pointer-events: none;
}

/* ===== ROTATE SCREEN OVERLAY ===== */
.rotate-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    pointer-events: all;
}

.rotate-icon {
    width: clamp(220px, 65vw, 380px);
    height: auto;
}

.rotate-text {
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Russo One', sans-serif;
    font-size: clamp(0.95rem, 3.5vw, 1.3rem);
    letter-spacing: 0.08em;
    text-align: center;
    padding: 0 20px;
}

