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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0f172a;
    color: #e2e8f0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}

/* ---------- Loading ---------- */
#loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
    z-index: 100;
}
.loader-box { text-align: center; padding: 24px; }
.loader-title { font-size: 28px; font-weight: 800; margin-bottom: 16px; letter-spacing: 1px; }
.loader-bar {
    width: 240px;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 999px;
    overflow: hidden;
    margin: 0 auto 12px;
}
.loader-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #84cc16);
    transition: width 200ms ease-out;
}
.loader-tip { font-size: 13px; opacity: 0.6; }

/* ---------- Game wrap ---------- */
#game-wrap {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

#renderCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    outline: none;
    touch-action: none;
}

/* ---------- HUD ---------- */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 10;
    gap: 8px;
}
#hud-left, #hud-center, #hud-right { display: flex; gap: 8px; pointer-events: auto; }

.hud-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    opacity: 0.5;
    letter-spacing: 1px;
}

#lap-box, #time-box, #coins-box {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 8px 14px;
    border-radius: 12px;
    text-align: center;
    min-width: 72px;
}

#speedometer {
    position: relative;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 14px;
    padding: 8px 10px 4px;
    width: 110px;
    text-align: center;
}
#speedometer svg { display: block; margin: 0 auto; }
#speedometer .speed-num {
    margin-top: -8px;
    line-height: 1;
}
#speedometer #speed {
    font-size: 22px;
    font-weight: 900;
    color: #f1f5f9;
    font-variant-numeric: tabular-nums;
}
#speedometer .speed-unit {
    font-size: 9px;
    opacity: 0.55;
    margin-left: 3px;
    letter-spacing: 1px;
    text-transform: uppercase;
}
#speed-needle {
    transition: transform 120ms cubic-bezier(0.34, 1.2, 0.6, 1);
    transform-origin: 50px 52px;
}
#speed-arc {
    transition: stroke-dashoffset 150ms ease-out;
}
#lap { font-size: 18px; font-weight: 800; line-height: 1; color: #fbbf24; }
#time { font-size: 18px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }

#coins-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    min-width: auto;
}
.coin-icon {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fde68a, #f59e0b 60%, #b45309);
    box-shadow: inset -2px -2px 0 rgba(120,53,15,0.4), 0 1px 2px rgba(0,0,0,0.3);
    flex-shrink: 0;
}
#coins { font-size: 18px; font-weight: 800; line-height: 1; color: #fbbf24; font-variant-numeric: tabular-nums; }

#hud-right button {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(15,23,42,0.7);
    backdrop-filter: blur(8px);
    color: #e2e8f0;
    font-size: 18px;
    cursor: pointer;
}

/* ---------- Touch controls ---------- */
#touch-controls {
    position: absolute;
    inset: auto 0 0 0;
    padding: 16px;
    display: none;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 10;
}

@media (hover: none) and (pointer: coarse) {
    #touch-controls { display: flex; }
}

#joystick-zone {
    width: 140px;
    height: 140px;
    pointer-events: auto;
    position: relative;
}
#joystick-base {
    position: absolute;
    inset: 20px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.5);
    border: 2px solid rgba(255,255,255,0.12);
}
#joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.8);
    border: 2px solid rgba(255,255,255,0.4);
    pointer-events: none;
}

#action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: auto;
}
#action-buttons button {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.18);
    background: rgba(15, 23, 42, 0.7);
    color: #e2e8f0;
    font-size: 22px;
    font-weight: 800;
    cursor: pointer;
    backdrop-filter: blur(8px);
}
#btn-boost { background: rgba(34, 197, 94, 0.7); }
#btn-brake { background: rgba(239, 68, 68, 0.7); }

/* ---------- Overlays ---------- */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    z-index: 20;
    animation: fadeIn 200ms ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.overlay-card {
    background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 32px 40px;
    border-radius: 20px;
    text-align: center;
    min-width: 280px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    position: relative;
}
.overlay-card.big-card { min-width: 320px; max-width: 360px; }

/* Último botão (geralmente VOLTAR) gruda no fundo do card mesmo com scroll,
   pra usuário sempre conseguir sair sem rolar até o fim. */
.overlay-card .ghost-btn:last-child {
    position: sticky;
    bottom: -32px;        /* compensa padding-bottom do card */
    margin-bottom: -16px;
    margin-top: 12px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    z-index: 2;
}
.overlay-title { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.overlay-sub { font-size: 13px; opacity: 0.6; margin-bottom: 24px; }
.overlay-hint { font-size: 12px; opacity: 0.5; margin-top: 16px; line-height: 1.6; }
.overlay-stat {
    margin: 16px 0 24px;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
}
.overlay-stat .hud-label { font-size: 11px; margin-bottom: 4px; }
#final-time { font-size: 32px; font-weight: 800; color: #fbbf24; font-variant-numeric: tabular-nums; }

.best-time {
    margin: 12px 0 20px;
    padding: 8px 12px;
    background: rgba(251,191,36,0.1);
    border: 1px solid rgba(251,191,36,0.3);
    border-radius: 10px;
    font-size: 14px;
    color: #fbbf24;
    font-variant-numeric: tabular-nums;
}

.big-btn {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(34, 197, 94, 0.4);
    transition: transform 100ms;
}
.big-btn:active { transform: scale(0.96); }

.ghost-btn {
    margin-top: 10px;
    background: transparent;
    color: #cbd5e1;
    border: 1px solid rgba(255,255,255,0.15);
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: background 100ms;
    display: block;
    width: 100%;
}
.ghost-btn:hover { background: rgba(255,255,255,0.05); }
.ghost-btn:active { transform: scale(0.97); }

.equipped-row {
    margin: 0 0 14px;
    font-size: 13px;
    opacity: 0.85;
}
.equipped-row .hud-label { display: inline; margin-right: 6px; opacity: 0.5; font-size: 10px; }
#equipped-name { font-weight: 800; color: #fbbf24; }
#player-name-display { font-weight: 800; color: #86efac; margin-right: 4px; }
.rename-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 11px;
    opacity: 0.7;
    color: inherit;
}
.rename-btn:hover { opacity: 1; background: rgba(255,255,255,0.05); }

#countdown-num {
    font-size: 180px;
    font-weight: 900;
    color: white;
    text-shadow: 0 4px 30px rgba(0,0,0,0.5), 0 0 60px rgba(34,197,94,0.6);
    animation: countPop 1s ease-out;
}
@keyframes countPop {
    0%   { transform: scale(0.4); opacity: 0; }
    20%  { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* ---------- PB badge ---------- */
.pb-badge {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #422006;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
    margin: 0 0 16px;
    box-shadow: 0 4px 20px rgba(251,191,36,0.5);
    animation: pbPulse 1.4s ease-in-out infinite;
}
@keyframes pbPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

/* ---------- Ranking ---------- */
#ranking-section { margin-bottom: 20px; }
.ranking-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.6;
    margin-bottom: 8px;
}
.ranking-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    overflow: hidden;
}
.ranking-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.ranking-list li:last-child { border-bottom: none; }
.ranking-list li.is-me {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
    font-weight: 700;
}
.rank-num { opacity: 0.5; min-width: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.rank-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-time { font-variant-numeric: tabular-nums; opacity: 0.85; }
.ranking-empty { padding: 12px; opacity: 0.4; font-size: 12px; }

.my-rank-row {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 8px;
    font-size: 12px;
    color: #86efac;
}
#my-rank { font-weight: 800; }

/* ---------- Garagem ---------- */
.garage-balance {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: -8px 0 14px;
    padding: 8px 12px;
    background: rgba(251, 191, 36, 0.10);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: 10px;
    color: #fbbf24;
    font-size: 13px;
    font-weight: 700;
}
.garage-balance .coin-icon { width: 18px; height: 18px; }
#garage-balance-num { font-variant-numeric: tabular-nums; font-weight: 800; }

.garage-summary {
    margin: 8px 0 16px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    text-align: left;
}
.summary-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.5;
    margin-bottom: 6px;
}
.summary-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px 12px;
    font-size: 11px;
}
.summary-stats .stat-row { font-size: 11px; }
.summary-stats .stat-name { width: 36px; }
.summary-value {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    width: 18px;
    text-align: right;
    color: #fbbf24;
}
.summary-value.boosted { color: #4ade80; }
.summary-value.nerfed  { color: #f87171; }

.garage-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 0 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.garage-tab {
    flex: 1 1 70px;
    padding: 8px 6px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #cbd5e1;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 100ms, border-color 100ms;
    white-space: nowrap;
}
.garage-tab:hover { opacity: 0.9; }
.garage-tab.active {
    opacity: 1;
    border-bottom-color: #22c55e;
    color: #ffffff;
}

.garage-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
}
.garage-card {
    display: flex;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    border: 2px solid transparent;
    text-align: left;
    cursor: pointer;
    transition: background 120ms, border-color 120ms;
}
.garage-card:hover { background: rgba(255,255,255,0.07); }
.garage-card.equipped {
    border-color: #22c55e;
    background: rgba(34,197,94,0.1);
}
.garage-card.locked {
    opacity: 0.7;
}
.garage-card.locked:hover { background: rgba(255,255,255,0.04); }

.garage-color {
    width: 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

.garage-info { flex: 1; min-width: 0; }
.garage-name {
    font-weight: 800;
    font-size: 15px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.garage-name .equipped-badge {
    background: #22c55e;
    color: #052e16;
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 999px;
    font-weight: 800;
    letter-spacing: 0.5px;
}
.garage-tagline {
    font-size: 11px;
    opacity: 0.6;
    margin-bottom: 6px;
}

.garage-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 10px;
    font-size: 10px;
}
.stat-row { display: flex; align-items: center; gap: 6px; }
.stat-name { width: 32px; opacity: 0.55; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-bar {
    flex: 1;
    height: 5px;
    background: rgba(255,255,255,0.1);
    border-radius: 999px;
    overflow: hidden;
}
.stat-fill {
    height: 100%;
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
    border-radius: 999px;
    transition: width 200ms;
}

.garage-action {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
    min-width: 80px;
}
.garage-price {
    font-weight: 800;
    color: #fbbf24;
    font-size: 14px;
    white-space: nowrap;
}
.garage-status {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
}
.garage-status.owned { color: #22c55e; opacity: 1; }
.garage-status.locked-coins { color: #ef4444; }

.garage-msg {
    margin: 8px 0;
    padding: 8px 12px;
    background: rgba(239,68,68,0.15);
    border: 1px solid rgba(239,68,68,0.4);
    border-radius: 8px;
    font-size: 12px;
    color: #fca5a5;
    text-align: center;
}
.garage-msg.success {
    background: rgba(34,197,94,0.15);
    border-color: rgba(34,197,94,0.4);
    color: #86efac;
}

/* ---------- Editor ---------- */
.editor-palette {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin: 12px 0;
}
.editor-palette button {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    color: #e2e8f0;
    padding: 12px 6px;
    border-radius: 10px;
    font-size: 22px;
    cursor: pointer;
    transition: background 100ms, transform 100ms;
}
.editor-palette button:hover { background: rgba(255,255,255,0.1); }
.editor-palette button:active { transform: scale(0.94); }
.editor-palette .pl-label {
    display: block;
    font-size: 9px;
    margin-top: 4px;
    opacity: 0.6;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.editor-list-wrap {
    margin: 14px 0 8px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    text-align: left;
}
.editor-list-wrap .hud-label { display: block; margin-bottom: 6px; }
.editor-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 30px;
    align-items: center;
}
.editor-list .empty { font-size: 11px; opacity: 0.4; }
.editor-list .e-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 999px;
    font-size: 13px;
    color: #d1fae5;
    cursor: pointer;
}
.editor-list .e-tag:last-child {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fecaca;
}
.editor-list .e-tag.conflict {
    background: rgba(251, 191, 36, 0.18);
    border-color: rgba(251, 191, 36, 0.45);
    color: #fde68a;
}
.editor-list .e-tag .x { opacity: 0.5; font-size: 11px; }

.editor-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}
.editor-actions-row {
    display: flex;
    gap: 8px;
}
.editor-actions-row .ghost-btn { flex: 1; margin-top: 0; padding: 10px 8px; font-size: 11px; }

/* ---------- Share code overlay ---------- */
.share-code {
    display: inline-block;
    margin: 12px 0 18px;
    padding: 14px 22px;
    background: rgba(34, 197, 94, 0.12);
    border: 2px dashed rgba(34, 197, 94, 0.4);
    border-radius: 12px;
    font-family: Menlo, Monaco, Consolas, monospace;
    font-size: 26px;
    font-weight: 800;
    color: #86efac;
    letter-spacing: 2px;
    user-select: all;
}

.code-input {
    display: block;
    width: 100%;
    margin: 14px 0;
    padding: 14px;
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.15);
    color: #e2e8f0;
    font-family: Menlo, Monaco, Consolas, monospace;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
    outline: none;
}
.code-input:focus { border-color: rgba(34,197,94,0.6); }

/* ---------- Ligas oficiais ---------- */
.league-section {
    margin: 14px 0;
    padding: 12px 14px;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    border-left: 4px solid #22c55e;
    text-align: left;
}
.league-section.locked { opacity: 0.45; border-left-color: #475569; }
.league-section.locked .league-tracks { filter: grayscale(0.6); }

.league-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}
.league-title {
    font-weight: 800;
    font-size: 15px;
}
.league-tagline {
    font-size: 11px;
    opacity: 0.55;
}
.league-lock {
    font-size: 11px;
    opacity: 0.7;
    margin-left: auto;
}

.league-tracks {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.league-track {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.06);
    cursor: pointer;
    transition: background 100ms;
    text-align: left;
}
.league-track:hover { background: rgba(255,255,255,0.09); }
.league-track.completed { border-color: rgba(34,197,94,0.4); }
.league-track.locked   { cursor: not-allowed; opacity: 0.5; }
.league-track.locked:hover { background: rgba(255,255,255,0.05); }

.lt-emoji { font-size: 22px; flex-shrink: 0; }
.lt-info { flex: 1; min-width: 0; }
.lt-name { font-weight: 800; font-size: 13px; }
.lt-tagline { font-size: 10px; opacity: 0.55; }
.lt-status { font-size: 10px; text-align: right; flex-shrink: 0; min-width: 70px; }
.lt-status.completed { color: #86efac; font-weight: 700; }
.lt-status.locked    { color: #94a3b8; }
.lt-best-time {
    font-size: 11px;
    color: #fbbf24;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

/* ---------- Galeria UGC ---------- */
.gallery-tabs {
    display: flex;
    gap: 4px;
    margin: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.gallery-tab {
    flex: 1;
    padding: 8px 4px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.6;
    cursor: pointer;
}
.gallery-tab:hover { opacity: 0.85; }
.gallery-tab.active { opacity: 1; border-bottom-color: #22c55e; color: #fff; }

.gallery-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    max-height: 50vh;
    overflow-y: auto;
}
.gallery-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: background 100ms;
}
.gallery-item:hover { background: rgba(255,255,255,0.09); }
.gi-info { flex: 1; min-width: 0; }
.gi-name { font-weight: 800; font-size: 13px; }
.gi-meta { font-size: 11px; opacity: 0.6; margin-top: 2px; }
.gi-stats { font-size: 11px; opacity: 0.7; }
.gi-stats .gi-stat { margin-left: 8px; }
.gallery-empty { padding: 20px; opacity: 0.45; font-size: 12px; text-align: center; }
.gallery-loading { padding: 16px; opacity: 0.55; font-size: 12px; text-align: center; }

/* ---------- Lap popup (centro grande) ---------- */
.lap-popup {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 30;
    font-size: 80px;
    font-weight: 900;
    color: #fbbf24;
    text-shadow:
        0 4px 18px rgba(0, 0, 0, 0.8),
        0 0 36px rgba(251, 191, 36, 0.7);
    letter-spacing: 2px;
}
.lap-popup.show {
    display: flex;
    animation: lapBlast 1100ms ease-out forwards;
}
@keyframes lapBlast {
    0%   { transform: scale(0.3); opacity: 0; }
    18%  { transform: scale(1.18); opacity: 1; }
    35%  { transform: scale(1); opacity: 1; }
    80%  { opacity: 1; }
    100% { transform: scale(0.95); opacity: 0; }
}

/* ---------- Coin popup (flutua da HUD) ---------- */
.coin-popup {
    position: fixed;
    z-index: 50;
    color: #fbbf24;
    font-weight: 800;
    font-size: 16px;
    pointer-events: none;
    text-shadow: 0 2px 6px rgba(0,0,0,0.6);
    animation: coinFloat 1s ease-out forwards;
}
@keyframes coinFloat {
    0%   { opacity: 0; transform: translateY(0); }
    20%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(-40px); }
}

/* ---------- Toast achievement / mission ---------- */
.achievement-toast {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translate(-50%, -120%);
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #422006;
    padding: 12px 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    transition: transform 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 60;
    min-width: 240px;
    max-width: 90vw;
}
.achievement-toast.show { transform: translate(-50%, 0); }
.achievement-toast.mission-toast { background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%); color: white; }
.ach-icon { font-size: 28px; }
.ach-text { line-height: 1.3; }
.ach-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.8; }
.ach-name { font-weight: 800; font-size: 14px; }
.ach-reward { font-size: 11px; margin-top: 2px; opacity: 0.85; }
