/* ═══════════════════════════════════════════
   style.css — Top Racer
   Estilização premium com glassmorphism,
   animações e responsividade.
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800;900&display=swap');

/* ─── Reset & Base ─── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background: #0a0a12;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

/* ─── Game Container ─── */
#game-container {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #111;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ═══════════════════════════════════════════
   HUD (heads-up display durante gameplay)
   ═══════════════════════════════════════════ */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 14px 16px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 10;
}

#hud > * {
    pointer-events: auto;
}

#hud-left,
#hud-right {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#hud-right {
    text-align: right;
}

#hud-score {
    font-size: 30px;
    font-weight: 900;
    color: #fff;
    text-shadow:
        0 1px 3px rgba(0, 0, 0, 0.7),
        0 0 12px rgba(255, 255, 255, 0.15);
    letter-spacing: -0.5px;
}

#hud-passed {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

#hud-record {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.hud-online-badge {
    font-size: 12px;
    font-weight: 800;
    color: #00f0ff;
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
    margin-top: 2px;
}

.lobby-info {
    font-size: 13px;
    font-weight: 700;
    color: #00f0ff;
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.25);
    border-radius: 20px;
    padding: 4px 12px;
    display: inline-block;
    margin: 6px 0 10px;
}

/* Botões de Ação do HUD */
#hud-actions {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 11;
}

#btn-pause, #btn-camera {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#btn-pause:hover, #btn-camera:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    transform: scale(1.08);
}

#btn-pause:active, #btn-camera:active {
    transform: scale(0.92);
}

/* Toast Notificação de Câmera */
.toast {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 18, 32, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 240, 255, 0.4);
    box-shadow: 0 4px 20px rgba(0, 240, 255, 0.25);
    color: #00f0ff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    z-index: 150;
    pointer-events: none;
    animation: toastFade 0.3s ease-out;
}

@keyframes toastFade {
    from { opacity: 0; transform: translate(-50%, -10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ═══════════════════════════════════════════
   Achievement Pop-up Toast
   ═══════════════════════════════════════════ */
.achievement-toast {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(18, 18, 35, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1.5px solid #ffd700;
    box-shadow: 0 8px 32px rgba(255, 215, 0, 0.35), 0 0 15px rgba(255, 215, 0, 0.2) inset;
    border-radius: 16px;
    padding: 12px 18px;
    max-width: 320px;
    z-index: 300;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.achievement-toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.achievement-header {
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 1.5px;
    color: #ffd700;
    text-transform: uppercase;
    margin-bottom: 6px;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.achievement-body {
    display: flex;
    align-items: center;
    gap: 12px;
}

.achievement-icon {
    font-size: 28px;
    line-height: 1;
}

.achievement-text {
    text-align: left;
}

.achievement-title {
    font-size: 15px;
    font-weight: 800;
    color: #ffffff;
}

.achievement-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 2px;
}

/* ═══════════════════════════════════════════
   Missions Modal & List
   ═══════════════════════════════════════════ */
.modal-large {
    max-width: 480px !important;
    width: 92% !important;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.missions-progress-text {
    font-size: 14px;
    font-weight: 800;
    color: #f4a261;
    margin-bottom: 12px;
}

.missions-list {
    max-height: 380px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
    margin-bottom: 14px;
}

.mission-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 14px;
    text-align: left;
    transition: all 0.2s ease;
}

.mission-card.unlocked {
    background: rgba(244, 162, 97, 0.08);
    border-color: rgba(244, 162, 97, 0.4);
}

.mission-card.locked {
    opacity: 0.7;
}

.mission-icon {
    font-size: 26px;
    flex-shrink: 0;
}

.mission-info {
    flex: 1;
}

.mission-title {
    font-size: 14px;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
}

.mission-card.unlocked .mission-title {
    color: #f4a261;
}

.mission-desc {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.65);
    margin: 2px 0 6px;
}

.mission-bar-container {
    height: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.mission-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #e63946, #f4a261);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.mission-status {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 3px;
    text-align: right;
}

.mission-card.unlocked .mission-status {
    color: #00f0ff;
}

/* ═══════════════════════════════════════════
   Overlays (Start, Pause, Game Over)
   ═══════════════════════════════════════════ */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 5, 15, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    animation: overlayFadeIn 0.35s ease-out;
}

.overlay-content {
    background: rgba(18, 18, 32, 0.88);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    padding: 36px 30px;
    text-align: center;
    max-width: 340px;
    width: 88%;
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

/* ─── Tipografia dos overlays ─── */
.overlay-content h1 {
    font-size: 38px;
    font-weight: 900;
    margin-bottom: 6px;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #e63946 0%, #f4a261 50%, #e63946 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite;
}

.overlay-content h2 {
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 18px;
    letter-spacing: -0.5px;
}

.overlay-content p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 10px;
}

/* ─── Botões ─── */
.btn-primary {
    display: block;
    width: 100%;
    padding: 15px 24px;
    margin: 18px 0 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #e63946, #c1121f);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    box-shadow: 0 4px 16px rgba(230, 57, 70, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(230, 57, 70, 0.45);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(230, 57, 70, 0.3);
}

.btn-secondary {
    display: block;
    width: 100%;
    padding: 13px 24px;
    margin: 8px 0;
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.btn-secondary:active {
    transform: scale(0.98);
}

/* ═══════════════════════════════════════════
   Start Screen
   ═══════════════════════════════════════════ */
.name-input-container {
    margin: 12px 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.name-input-container label {
    font-size: 12px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 1px;
}

#player-name-input {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    width: 150px;
    outline: none;
    transition: all 0.2s ease;
}

#player-name-input:focus {
    border-color: #e63946;
    box-shadow: 0 0 12px rgba(230, 57, 70, 0.4);
    background: rgba(255, 255, 255, 0.14);
}

#start-record {
    font-size: 15px;
    font-weight: 700;
    color: #f4a261;
    margin: 10px 0;
    text-shadow: 0 0 8px rgba(244, 162, 97, 0.3);
}

.controls-info {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.controls-info p {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
    margin: 3px 0;
    line-height: 1.6;
}

/* ═══════════════════════════════════════════
   Game Over Screen
   ═══════════════════════════════════════════ */
#go-new-record {
    font-size: 20px;
    font-weight: 900;
    color: #f4a261;
    margin-bottom: 6px;
    text-shadow: 0 0 12px rgba(244, 162, 97, 0.5);
    animation: recordPulse 1.2s ease-in-out infinite;
}

#go-score {
    font-size: 52px;
    font-weight: 900;
    color: #fff;
    margin: 6px 0 14px;
    letter-spacing: -2px;
    text-shadow: 0 2px 12px rgba(255, 255, 255, 0.15);
}

#go-stats {
    text-align: left;
    margin: 16px 0;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

#go-stats > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 0;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
}

#go-stats > div + div {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

#go-stats > div span:last-child {
    font-weight: 700;
    color: #fff;
}

/* ═══════════════════════════════════════════
   Mobile Touch Controls — Joystick + Botões
   ═══════════════════════════════════════════ */
#mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40%;
    display: flex;
    z-index: 105;
    pointer-events: none;
}

.touch-zone {
    pointer-events: auto;
    position: relative;
}

#touch-left {
    flex: 1;
}

#touch-right {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
    gap: 16px;
    padding-bottom: 110px;
}

#joystick-knob {
    position: absolute;
    bottom: 110px;
    left: 100px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.05) 100%);
    border: 2px solid rgba(255,255,255,0.2);
    transform: translate(-50%, -50%);
    pointer-events: none;
    transition: none;
}

.touch-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #fff;
    cursor: pointer;
    pointer-events: auto;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

.accelerate-btn {
    background: radial-gradient(circle at 40% 40%, rgba(74, 222, 128, 0.4), rgba(34, 197, 94, 0.6));
    border: 2px solid rgba(74, 222, 128, 0.6);
    box-shadow: 0 0 20px rgba(74, 222, 128, 0.2);
}

.accelerate-btn:active,
.accelerate-btn.active {
    background: radial-gradient(circle at 40% 40%, rgba(74, 222, 128, 0.7), rgba(34, 197, 94, 0.9));
    box-shadow: 0 0 30px rgba(74, 222, 128, 0.5);
    transform: scale(0.92);
}

.brake-btn {
    background: radial-gradient(circle at 40% 40%, rgba(239, 68, 68, 0.4), rgba(220, 38, 38, 0.6));
    border: 2px solid rgba(239, 68, 68, 0.6);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.brake-btn:active,
.brake-btn.active {
    background: radial-gradient(circle at 40% 40%, rgba(239, 68, 68, 0.7), rgba(220, 38, 38, 0.9));
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.5);
    transform: scale(0.92);
}

/* ═══════════════════════════════════════════
   Utility Classes
   ═══════════════════════════════════════════ */
.hidden {
    display: none !important;
}

/* ═══════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════ */
@keyframes overlayFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(6px);
    }
}

@keyframes shimmer {
    0% { background-position: 200% center; }
    100% { background-position: -200% center; }
}

@keyframes recordPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.06); opacity: 0.85; }
}

/* ═══════════════════════════════════════════
   Responsive (telas pequenas)
   ═══════════════════════════════════════════ */
@media (max-width: 380px) {
    .overlay-content {
        padding: 24px 18px;
        border-radius: 18px;
    }

    .overlay-content h1 {
        font-size: 30px;
    }

    .overlay-content h2 {
        font-size: 22px;
    }

    #hud-score {
        font-size: 24px;
    }

    #hud-speed {
        font-size: 16px;
    }

    #go-score {
        font-size: 40px;
    }

    .btn-primary {
        padding: 13px 20px;
        font-size: 15px;
    }
}

@media (max-height: 600px) {
    .overlay-content {
        padding: 20px 18px;
    }

    .overlay-content h1 {
        font-size: 28px;
        margin-bottom: 4px;
    }

    #go-score {
        font-size: 36px;
        margin: 4px 0 10px;
    }

    .controls-info {
        margin-top: 10px;
        padding-top: 8px;
    }

    .btn-primary {
        margin-top: 12px;
        padding: 12px 20px;
    }
}

/* Boosting HUD Style */
#hud-speed.boosting {
    color: #ff5500 !important;
    text-shadow: 
        0 0 12px rgba(255, 85, 0, 0.95),
        0 0 20px rgba(255, 30, 0, 0.6),
        0 1px 3px rgba(0, 0, 0, 0.8) !important;
    animation: speedShake 0.06s infinite alternate;
}

@keyframes speedShake {
    0% { transform: translate(1px, 1px); }
    100% { transform: translate(-1px, -1px); }
}

/* ═══════════════════════════════════════════
   AdMob Banner Placeholder
   ═══════════════════════════════════════════ */
#admob-banner-placeholder {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(10, 10, 18, 0.95);
    border-top: 1px solid rgba(230, 57, 70, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.65);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    z-index: 100;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.6);
    pointer-events: auto;
    font-family: 'Outfit', sans-serif;
}

/* ═══════════════════════════════════════════
   Results Section (Menu)
   ═══════════════════════════════════════════

/* Results Section */
#results-section {
    margin: 12px 0;
    padding: 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    max-height: 170px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    pointer-events: auto;
}

#results-list {
    max-height: 130px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    pointer-events: auto;
}

#results-section h3 {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
    font-weight: 700;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 4px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.result-row + .result-row {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.result-num {
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    min-width: 24px;
}

.result-name {
    font-weight: 700;
    color: #00f0ff;
    flex: 1;
    text-align: left;
    margin-left: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-time {
    font-weight: 700;
    color: #fff;
}

#results-section::-webkit-scrollbar,
#results-list::-webkit-scrollbar {
    width: 5px;
}

#results-section::-webkit-scrollbar-thumb,
#results-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 3px;
}
