/* ==========================================================================
   BULLI DRIVE — Retro California Surf Aesthetic
   Typography: Righteous (display) + Quicksand (body) + Permanent Marker (accent)
   Palette: Warm sunset tones, vintage postcard colors
   ========================================================================== */

:root {
    --sunset-red: #E84545;
    --sunset-orange: #F5A623;
    --sunset-gold: #FFD54F;
    --cream: #FFF8E7;
    --sand: #F5E6CC;
    --ocean: #2B7A9B;
    --ocean-deep: #1A4F6E;
    --palm: #2E7D32;
    --asphalt: #2C2C2C;
    --asphalt-light: #3D3D3D;

    --glass: rgba(0, 0, 0, 0.35);
    --glass-warm: rgba(232, 69, 69, 0.12);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-border-warm: rgba(245, 166, 35, 0.25);

    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.55);

    --font-display: 'Righteous', cursive;
    --font-body: 'Quicksand', sans-serif;
    --font-accent: 'Permanent Marker', cursive;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-pill: 50px;
}

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

html, body {
    overflow: hidden;
    background-color: var(--asphalt);
    font-family: var(--font-body);
    color: var(--text);
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-text-size-adjust: 100%;
}

canvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

/* ==========================================================================
   LOADING SCREEN
   ========================================================================== */

#loading-screen {
    position: fixed;
    inset: 0;
    background: var(--asphalt);
    background-image:
        radial-gradient(ellipse at 50% 120%, rgba(232, 69, 69, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 20% 80%, rgba(43, 122, 155, 0.1) 0%, transparent 50%);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.6s ease;
}

.loader {
    text-align: center;
    max-width: 300px;
}

/* Animated Bulli SVG Loader */
.bulli-loader {
    width: 180px;
    margin: 0 auto 1.5rem;
    position: relative;
}

.bulli-svg {
    width: 100%;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

.bulli-svg .bulli-body {
    animation: bulli-bounce 1.2s ease-in-out infinite;
    transform-origin: 50% 56px;
}

@keyframes bulli-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.bulli-svg .wheel {
    animation: wheel-spin 0.4s linear infinite;
}

.bulli-svg .wheel-front {
    transform-origin: 78px 48px;
}

.bulli-svg .wheel-rear {
    transform-origin: 28px 48px;
}

@keyframes wheel-spin {
    to { transform: rotate(360deg); }
}

.bulli-svg .road-line {
    animation: road-scroll 0.6s linear infinite;
}

@keyframes road-scroll {
    to { stroke-dashoffset: -14; }
}

.loader-text {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    transition: opacity 0.2s ease;
    margin-bottom: 1.2rem;
}

.loader-bar {
    width: 180px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin: 0 auto;
    overflow: hidden;
}

.loader-bar-fill {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, var(--sunset-red), var(--sunset-orange));
    border-radius: 2px;
    animation: loader-slide 1.4s ease-in-out infinite;
}

@keyframes loader-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* ==========================================================================
   SPLASH SCREEN
   ========================================================================== */

#splash-screen {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
}

#splash-screen.hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.splash-bg {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg,
            #1A1A2E 0%,
            #16213E 25%,
            #0F3460 45%,
            #E84545 75%,
            #F5A623 90%,
            #FFD54F 100%
        );
    background-size: 100% 200%;
    animation: sunset-shift 8s ease-in-out infinite alternate;
}

@keyframes sunset-shift {
    0% { background-position: 50% 0%; }
    100% { background-position: 50% 40%; }
}

.splash-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 50% 85%, rgba(255, 213, 79, 0.3) 0%, transparent 40%),
        radial-gradient(circle at 30% 70%, rgba(232, 69, 69, 0.2) 0%, transparent 30%),
        radial-gradient(circle at 70% 75%, rgba(245, 166, 35, 0.2) 0%, transparent 30%);
    pointer-events: none;
}

.splash-content {
    position: relative;
    text-align: center;
    background: rgba(0, 0, 0, 0.4);
    padding: 2.5rem 3rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    max-width: 90%;
    width: 420px;
    animation: splash-appear 0.5s ease-out;
}

@keyframes splash-appear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
}

.splash-badge {
    display: inline-block;
    font-family: var(--font-body);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--sunset-gold);
    border: 1px solid rgba(255, 213, 79, 0.3);
    padding: 0.3rem 1rem;
    border-radius: var(--radius-pill);
    margin-bottom: 1rem;
    background: rgba(255, 213, 79, 0.08);
}

.splash-title {
    margin-bottom: 0.5rem;
    line-height: 1;
}

.title-bulli {
    display: block;
    font-family: var(--font-accent);
    font-size: 4rem;
    color: var(--cream);
    text-shadow:
        3px 3px 0 var(--sunset-red),
        6px 6px 0 rgba(232, 69, 69, 0.3);
    letter-spacing: 2px;
    transform: rotate(-2deg);
}

.title-drive {
    display: block;
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--sunset-orange);
    letter-spacing: 8px;
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(245, 166, 35, 0.4);
}

.splash-tagline {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    letter-spacing: 0.5px;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-align: left;
    padding-left: 1.5rem;
}

#splash-name-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-pill);
    padding: 0.9rem 1.5rem;
    color: white;
    font-size: 1.05rem;
    font-family: var(--font-body);
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
    outline: none;
}

#splash-name-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
    font-weight: 400;
}

#splash-name-input:focus {
    border-color: var(--sunset-orange);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.15);
}

/* ==========================================================================
   CAR SELECTOR
   ========================================================================== */

.car-selector {
    margin-bottom: 1.5rem;
}

.car-selector .input-label {
    margin-bottom: 0.7rem;
}

.car-selector-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.car-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 0.4rem 0.4rem;
    border-radius: var(--radius-md);
    border: 2px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: all 0.25s ease;
    width: 68px;
    color: var(--sunset-red);
}

.car-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.car-card.selected {
    border-color: var(--sunset-orange);
    background: rgba(245, 166, 35, 0.12);
    box-shadow: 0 0 16px rgba(245, 166, 35, 0.25), inset 0 0 8px rgba(245, 166, 35, 0.08);
    transform: scale(1.08);
}

.car-icon {
    width: 52px;
    height: 32px;
}

.car-name {
    font-family: var(--font-body);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.car-card.selected .car-name {
    color: var(--sunset-orange);
}

#start-btn {
    background: linear-gradient(135deg, var(--sunset-red) 0%, #D63031 100%);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow:
        0 8px 25px rgba(232, 69, 69, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.2);
    font-family: var(--font-display);
    letter-spacing: 2px;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    position: relative;
    overflow: hidden;
}

#start-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: left 0.5s ease;
}

#start-btn:hover {
    transform: translateY(-3px);
    box-shadow:
        0 12px 35px rgba(232, 69, 69, 0.5),
        0 4px 12px rgba(0, 0, 0, 0.3);
}

#start-btn:hover::before {
    left: 100%;
}

#start-btn:active {
    transform: translateY(0);
    box-shadow:
        0 4px 15px rgba(232, 69, 69, 0.4);
}

.btn-icon {
    font-size: 0.8rem;
}

.splash-controls-preview {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.preview-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.preview-keys {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 1px;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.7);
}

.preview-desc {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.35);
}

.preview-sep {
    color: rgba(255, 255, 255, 0.15);
    margin: 0 0.2rem;
}

/* ==========================================================================
   POWERUP PANEL
   ========================================================================== */

#powerup-panel {
    position: fixed;
    top: 2rem;
    left: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
    z-index: 20;
}

.powerup-indicator {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-pill);
    padding: 0.45rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: white;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.8rem;
    animation: powerup-slide-in 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.powerup-icon {
    font-size: 1.1rem;
}

.powerup-bar-bg {
    width: 70px;
    height: 5px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    overflow: hidden;
}

.powerup-bar-fill {
    height: 100%;
    transform-origin: left;
    border-radius: 3px;
    transition: transform 0.1s linear;
}

@keyframes powerup-slide-in {
    from { transform: translateX(-30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   UI OVERLAY / HUD
   ========================================================================== */

#ui-overlay {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    pointer-events: none;
    z-index: 10;
}

/* Score Display */
#score-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 0.45rem 1.4rem;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.score-coin-icon {
    font-size: 1.2rem;
    color: var(--sunset-gold);
    filter: drop-shadow(0 0 4px rgba(255, 213, 79, 0.5));
    line-height: 1;
}

#score-display {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--sunset-gold);
    text-shadow: 0 0 12px rgba(255, 213, 79, 0.4);
    line-height: 1;
}

/* Health Bar */
#health-bar-container {
    position: fixed;
    top: 3.2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 100;
    pointer-events: none;
}

#health-bar-bg {
    width: 120px;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

#health-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 5px;
    transition: width 0.3s ease;
}

#health-bar-text {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--cream);
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
    min-width: 24px;
}

/* Controls Hint */
.controls-hint {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 1rem 1.2rem;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.hint-title {
    font-family: var(--font-body);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    text-align: center;
}

.hint-grid {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.hint-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.key-cluster {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.key-row {
    display: flex;
    gap: 3px;
}

.key {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 3px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1;
}

.key.wide {
    width: auto;
    padding: 0 12px;
}

.hint-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Interaction Prompt */
#interaction-prompt {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--sunset-red), #D63031);
    color: white;
    padding: 0.8rem 2rem;
    border-radius: var(--radius-pill);
    font-family: var(--font-display);
    font-size: 0.95rem;
    letter-spacing: 1px;
    box-shadow:
        0 8px 25px rgba(232, 69, 69, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.27), opacity 0.35s;
    z-index: 20;
}

#interaction-prompt.hidden {
    transform: translate(-50%, 80px);
    opacity: 0;
    pointer-events: none;
}

/* ==========================================================================
   SPEEDOMETER
   ========================================================================== */

#speedometer {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 140px;
    height: 140px;
    background: var(--glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

#speedo-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 140px;
    height: 140px;
}

#speedo-value {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--cream);
    text-shadow: 0 0 10px rgba(255, 248, 231, 0.3);
    line-height: 1;
    position: relative;
    z-index: 1;
    margin-top: 4px;
}

#speedo-unit {
    font-family: var(--font-body);
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    position: relative;
    z-index: 1;
}

#speedo-turbo {
    position: absolute;
    bottom: 18px;
    font-family: var(--font-display);
    font-size: 0.6rem;
    letter-spacing: 2px;
    color: var(--sunset-gold);
    text-shadow: 0 0 8px rgba(255, 213, 79, 0.6);
    animation: turbo-pulse 0.5s ease-in-out infinite alternate;
    z-index: 1;
}

#speedo-turbo.hidden {
    display: none;
}

@keyframes turbo-pulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

/* ==========================================================================
   NAMETAGS
   ========================================================================== */

.nametag {
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    color: white;
    padding: 0.2rem 0.7rem;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    pointer-events: none;
    transform: translate(-50%, -100%);
    white-space: nowrap;
    opacity: 0.85;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.nametag.local {
    background: linear-gradient(135deg, var(--sunset-red), rgba(232, 69, 69, 0.8));
    border-color: rgba(255, 255, 255, 0.15);
    opacity: 1;
    box-shadow: 0 2px 10px rgba(232, 69, 69, 0.3);
}

/* Health bar inside nametag */
.nametag-hp {
    width: 40px;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 3px auto 0;
    overflow: hidden;
}

.nametag-hp-fill {
    height: 100%;
    width: 100%;
    background: #4CAF50;
    border-radius: 2px;
    transition: width 0.3s, background 0.3s;
}

/* ==========================================================================
   HITMARKER
   ========================================================================== */

#hitmarker {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: white;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.8), 0 0 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 150;
    opacity: 0;
    transition: opacity 0.15s;
    font-family: var(--font-body);
    font-weight: 700;
}

#hitmarker.visible {
    opacity: 1;
}

/* ==========================================================================
   KILLFEED
   ========================================================================== */

#killfeed {
    position: fixed;
    top: 2rem;
    right: 250px;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    pointer-events: none;
    z-index: 20;
    max-width: 300px;
}

.killfeed-entry {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.8rem;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s, transform 0.3s;
}

.killfeed-entry.visible {
    opacity: 1;
    transform: translateX(0);
}

.killfeed-entry.fading {
    opacity: 0;
    transform: translateX(20px);
}

.kf-killer {
    color: var(--sunset-red);
}

.kf-action {
    color: var(--text-muted);
}

.kf-victim {
    color: var(--sunset-gold);
}

/* AFK badge */
.afk-badge {
    color: var(--sunset-gold);
    font-size: 0.65rem;
    letter-spacing: 1px;
    animation: afk-pulse 1.5s ease-in-out infinite;
}

@keyframes afk-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* ==========================================================================
   SCOREBOARD / PLAYER LIST
   ========================================================================== */

#player-list {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: var(--glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--glass-border);
    padding: 1rem 1.2rem;
    border-radius: var(--radius-md);
    z-index: 10;
    min-width: 220px;
    pointer-events: auto;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

#player-list h3 {
    margin-bottom: 0.6rem;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.trophy-icon {
    font-size: 0.9rem;
}

#scoreboard-list {
    list-style: none;
    max-height: 280px;
    overflow-y: auto;
}

.scoreboard-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.3rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    transition: background 0.15s ease;
}

.scoreboard-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.scoreboard-row.me {
    background: var(--glass-warm);
    border: 1px solid rgba(232, 69, 69, 0.15);
}

.scoreboard-row .rank {
    width: 18px;
    text-align: center;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.scoreboard-row.me .rank {
    color: var(--sunset-red);
}

.player-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    box-shadow: 0 0 6px currentColor;
}

.player-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    font-size: 0.8rem;
}

.player-score {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--sunset-gold);
    text-shadow: 0 0 6px rgba(255, 213, 79, 0.3);
    min-width: 30px;
    text-align: right;
}

/* Name Change UI */
.name-change {
    margin-top: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 0.6rem;
}

.name-toggle-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.name-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-color: rgba(255, 255, 255, 0.25);
}

.name-form {
    display: flex;
    gap: 0.4rem;
    flex: 1;
    overflow: hidden;
    transition: all 0.25s ease;
}

.name-form.hidden {
    max-width: 0;
    opacity: 0;
    pointer-events: none;
}

#name-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    color: white;
    padding: 0.3rem 0.5rem;
    font-size: 0.78rem;
    font-family: var(--font-body);
    flex: 1;
    min-width: 0;
    outline: none;
    user-select: auto;
}

#name-input:focus {
    border-color: var(--sunset-orange);
    box-shadow: 0 0 0 2px rgba(245, 166, 35, 0.15);
}

#name-submit {
    background: var(--sunset-red);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    font-size: 0.78rem;
    font-family: var(--font-body);
    font-weight: 700;
    transition: filter 0.15s;
}

#name-submit:hover {
    filter: brightness(1.15);
}

/* ==========================================================================
   MOBILE CONTROLS
   ========================================================================== */

#mobile-controls {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

/* Joystick Zones */
.joystick-zone {
    position: absolute;
    bottom: max(20px, env(safe-area-inset-bottom, 20px));
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.joystick-zone.left {
    left: max(20px, env(safe-area-inset-left, 20px));
}

.joystick-zone.right {
    right: max(20px, env(safe-area-inset-right, 20px));
}

.joystick-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.joystick-base {
    width: 140px;
    height: 140px;
    background: rgba(0, 0, 0, 0.25);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    position: relative;
}

.joystick-base.small {
    width: 90px;
    height: 90px;
}

.joystick-stick {
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 35% 35%,
        rgba(255, 255, 255, 0.35),
        rgba(232, 69, 69, 0.6));
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    position: absolute;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 2px rgba(255, 255, 255, 0.2);
    transition: transform 0.05s ease-out;
}

.joystick-stick.small {
    width: 40px;
    height: 40px;
}

.joystick-label {
    font-family: var(--font-body);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Action Buttons */
.action-buttons {
    position: absolute;
    right: max(20px, env(safe-area-inset-right, 20px));
    bottom: calc(180px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: auto;
}

.control-btn {
    background: rgba(0, 0, 0, 0.35);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:active, .control-btn.active {
    background: rgba(232, 69, 69, 0.6);
    transform: scale(0.92);
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 20px rgba(232, 69, 69, 0.4);
}

.control-btn.action {
    width: 70px;
    height: 70px;
    font-size: 1.8rem;
}

.control-btn.action.honk {
    background: rgba(245, 166, 35, 0.25);
    border-color: rgba(245, 166, 35, 0.4);
}

.control-btn.action.honk:active, .control-btn.action.honk.active {
    background: rgba(245, 166, 35, 0.6);
    box-shadow: 0 0 25px rgba(245, 166, 35, 0.5);
}

.control-btn.action.flip {
    background: rgba(43, 122, 155, 0.25);
    border-color: rgba(43, 122, 155, 0.4);
}

.control-btn.action.flip:active, .control-btn.action.flip.active {
    background: rgba(43, 122, 155, 0.6);
    box-shadow: 0 0 25px rgba(43, 122, 155, 0.5);
}

/* ==========================================================================
   RESPONSIVE — LANDSCAPE
   ========================================================================== */

@media (max-width: 900px) and (orientation: landscape) {
    .joystick-base {
        width: 100px;
        height: 100px;
    }

    .joystick-stick {
        width: 45px;
        height: 45px;
    }

    .joystick-base.small {
        width: 65px;
        height: 65px;
    }

    .joystick-stick.small {
        width: 30px;
        height: 30px;
    }

    .control-btn.action {
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
    }

    .action-buttons {
        bottom: calc(120px + env(safe-area-inset-bottom, 0px));
        gap: 8px;
    }

    .joystick-zone {
        bottom: max(10px, env(safe-area-inset-bottom, 10px));
    }

    .joystick-zone.left {
        left: max(10px, env(safe-area-inset-left, 10px));
    }

    .joystick-zone.right {
        right: max(10px, env(safe-area-inset-right, 10px));
    }

    #score-container {
        top: 0.5rem;
        padding: 0.3rem 1rem;
    }

    #score-display {
        font-size: 1.2rem;
    }

    .score-coin-icon {
        font-size: 1rem;
    }
}

/* ==========================================================================
   RESPONSIVE — MOBILE / TOUCH
   ========================================================================== */

@media (max-width: 768px), (pointer: coarse) {
    #mobile-controls {
        display: block;
    }

    .controls-hint {
        display: none;
    }

    #speedometer {
        display: none;
    }

    #player-list {
        top: max(0.5rem, env(safe-area-inset-top, 0.5rem));
        right: max(0.5rem, env(safe-area-inset-right, 0.5rem));
        transform: scale(0.75);
        transform-origin: top right;
        padding: 0.6rem;
        min-width: 150px;
    }

    #player-list h3 {
        font-size: 0.9rem;
    }

    #score-container {
        top: max(0.5rem, env(safe-area-inset-top, 0.5rem));
    }

    .splash-content {
        padding: 2rem 1.8rem;
        width: 360px;
    }

    .title-bulli {
        font-size: 3rem;
    }

    .title-drive {
        font-size: 1.5rem;
        letter-spacing: 6px;
    }

    .car-card {
        width: 56px;
        padding: 0.35rem 0.3rem 0.3rem;
    }

    .car-icon {
        width: 42px;
        height: 26px;
    }

    .car-name {
        font-size: 0.5rem;
    }
}

/* ==========================================================================
   SCROLLBAR STYLING
   ========================================================================== */

#scoreboard-list::-webkit-scrollbar {
    width: 3px;
}

#scoreboard-list::-webkit-scrollbar-track {
    background: transparent;
}

#scoreboard-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

/* ==========================================================================
   MODAL (unused but preserved for compatibility)
   ========================================================================== */

#modal-container {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

#modal-container.hidden {
    pointer-events: none;
    opacity: 0;
}

.modal-backdrop {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 600px;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: 2rem;
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.27);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

#modal-container.hidden .modal-content {
    transform: scale(0.9);
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: white;
}

#modal-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--sunset-orange);
}

#modal-body {
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.75);
    max-height: 65vh;
    overflow-y: auto;
}

#about-link {
    display: inline-block;
    margin-top: 1rem;
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-muted);
    text-decoration: none;
    text-transform: uppercase;
    transition: color 0.2s ease;
}

#about-link:hover {
    color: var(--sunset-orange);
}

.modal-desc {
    font-family: var(--font-body);
    font-size: 0.95rem;
    margin-bottom: 1.2rem;
}

.modal-section-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--sunset-gold);
    margin: 1.2rem 0 0.6rem;
}

.modal-controls-grid {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.modal-control-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
}

.modal-key {
    display: inline-block;
    min-width: 80px;
    padding: 0.2rem 0.5rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
}

.modal-powerup-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.modal-powerup-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
}

.powerup-icon {
    font-size: 1.4rem;
    min-width: 28px;
    text-align: center;
}

/* ==========================================================================
   FPS COUNTER
   ========================================================================== */

#fps-counter {
    position: fixed;
    top: 1rem;
    left: 1rem;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    pointer-events: none;
    z-index: 10;
    letter-spacing: 0.5px;
}
