/**
 * Nitro Machines - corse arcade viste dall'alto
 */
.nm-app [hidden] { display: none !important; }

.nm-app {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    color: #f8fafc;
    background: #0d0f16;
    overflow-x: hidden;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --nm-hot: #ff7a00;
    --nm-yel: #ffd400;
    --nm-panel: rgba(12, 12, 20, 0.78);
}
.nm-stage {
    position: relative;
    width: 100vw;
    height: calc(100vh - 72px);
    height: calc(100dvh - 72px);
    min-height: 480px;
    overflow: hidden;
    background: #0d0f16;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}
.nm-stage:fullscreen { height: 100vh; }
#nmCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.nm-flash { position: absolute; inset: 0; pointer-events: none; z-index: 3; opacity: 0; }

/* --- HUD: visibile solo in gara ------------------------------------------- */
.nm-hud { position: absolute; inset: 0; pointer-events: none; z-index: 4; display: none; }
.nm-app.is-racing .nm-hud { display: block; }
.nm-hud-top {
    position: absolute; top: 10px; left: 10px; right: 10px;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.nm-posbox {
    display: flex; align-items: baseline; gap: 3px;
    background: linear-gradient(180deg, #ffd400, #ff7a00);
    color: #1a0e00; border-radius: 14px; padding: 4px 12px 4px 10px;
    box-shadow: 0 4px 0 #8a3b00, 0 8px 20px rgba(0,0,0,0.35);
    font-weight: 900;
}
.nm-posbox small { font-size: 11px; letter-spacing: 0.08em; margin-right: 3px; }
.nm-posbox b { font-size: 34px; line-height: 1; font-family: Impact, 'Arial Black', system-ui, sans-serif; }
.nm-posbox span { font-size: 16px; }
.nm-chip {
    background: var(--nm-panel);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 999px; padding: 7px 13px;
    font-weight: 800; font-size: 15px;
    white-space: nowrap; font-variant-numeric: tabular-nums;
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.nm-chip-money { color: #fde047; }
.nm-hud-btns { margin-left: auto; display: flex; gap: 6px; pointer-events: auto; flex-wrap: wrap; justify-content: flex-end; }
.nm-btn {
    width: 44px; height: 44px; border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.18);
    background: var(--nm-panel); color: #fff;
    font-size: 19px; cursor: pointer; display: grid; place-items: center;
}
.nm-btn:hover { background: rgba(140, 60, 0, 0.85); }
.nm-btn.is-off { opacity: 0.45; }
.nm-hud-level {
    position: absolute; top: 64px; left: 12px;
    font-size: 12px; font-weight: 700; opacity: 0.8; text-shadow: 0 1px 3px #000;
}

.nm-board {
    position: absolute; top: 86px; left: 10px;
    display: flex; flex-direction: column; gap: 3px;
    min-width: 170px;
}
.nm-brow {
    display: flex; align-items: center; gap: 7px;
    background: rgba(12, 12, 20, 0.62); border-radius: 8px;
    padding: 3px 9px; font-size: 13px; font-weight: 700;
}
.nm-brow b { width: 14px; text-align: right; color: #cbd5e1; }
.nm-brow i { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.5); flex: none; }
.nm-brow span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.nm-brow small { opacity: 0.75; font-variant-numeric: tabular-nums; }
.nm-brow.is-me { background: rgba(255, 170, 0, 0.9); color: #1a0e00; }
.nm-brow.is-me b { color: #1a0e00; }

.nm-mini {
    position: absolute; top: 66px; right: 10px;
    width: 170px; height: 170px;
    background: rgba(12, 12, 20, 0.45); border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.12);
}

.nm-dash {
    position: absolute; left: 12px; bottom: 14px;
    display: flex; align-items: flex-end; gap: 10px;
}
.nm-speed {
    background: var(--nm-panel); border-radius: 14px; padding: 6px 12px 8px;
    border: 1px solid rgba(255,255,255,0.14); min-width: 118px;
}
.nm-speed b { font-size: 30px; font-family: Impact, 'Arial Black', system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.nm-speed small { margin-left: 4px; opacity: 0.8; font-weight: 700; }
.nm-speed-bar { height: 6px; border-radius: 4px; background: rgba(255,255,255,0.15); overflow: hidden; margin-top: 2px; }
.nm-speed-bar div { height: 100%; width: 0; background: linear-gradient(90deg, #22c55e, #facc15 70%, #ef4444); }
.nm-nitro {
    display: flex; align-items: center; gap: 6px;
    background: var(--nm-panel); border-radius: 14px; padding: 8px 12px;
    border: 2px solid rgba(255, 122, 0, 0.6);
}
.nm-nitro b { font-size: 26px; font-family: Impact, 'Arial Black', system-ui, sans-serif; color: #ffb000; min-width: 22px; }
.nm-nitro-ico { font-size: 22px; }
.nm-nitro-bar { width: 70px; height: 8px; border-radius: 5px; background: rgba(255,255,255,0.15); overflow: hidden; }
.nm-nitro-bar div { height: 100%; width: 0; background: linear-gradient(90deg, #ff3d00, #ffd400); }
.nm-nitro.is-on { border-color: #ffd400; box-shadow: 0 0 22px rgba(255, 150, 0, 0.8); }
.nm-nitro.is-empty { opacity: 0.5; }

.nm-msg {
    position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%) scale(0.6);
    font-family: Impact, 'Arial Black', system-ui, sans-serif; font-size: clamp(30px, 6vw, 64px);
    letter-spacing: 0.03em; color: #fff; text-align: center; white-space: nowrap;
    -webkit-text-stroke: 2px #1a0e00; text-shadow: 0 5px 0 #1a0e00, 0 0 30px rgba(255,140,0,0.6);
    opacity: 0; transition: opacity 0.2s, transform 0.25s cubic-bezier(.2,1.6,.4,1);
}
.nm-msg.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.nm-msg.is-nitro { color: #ffb000; }
.nm-msg.is-last { color: #ff4d4d; }
.nm-msg.is-win { color: #ffd400; }
.nm-msg.is-title { font-size: clamp(22px, 4vw, 40px); color: #e0f2fe; top: 22%; }

.nm-pops { position: absolute; left: 50%; top: 44%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.nm-pop {
    font-weight: 900; font-size: 22px; padding: 4px 14px; border-radius: 12px;
    background: rgba(12, 12, 20, 0.7); color: #fff;
    animation: nm-pop 1.5s ease-out forwards; white-space: nowrap;
}
.nm-pop.is-money { color: #fde047; }
.nm-pop.is-nitro, .nm-pop.is-boost { color: #ffb000; }
.nm-pop.is-warn { color: #fca5a5; }
.nm-pop.is-time { color: #a5f3fc; font-variant-numeric: tabular-nums; }
.nm-pop.is-info { color: #e2e8f0; font-size: 16px; }
@keyframes nm-pop {
    0% { opacity: 0; transform: translateY(14px) scale(0.8); }
    12% { opacity: 1; transform: translateY(0) scale(1.08); }
    25% { transform: scale(1); }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-40px); }
}
.nm-count {
    position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%);
    font-family: Impact, 'Arial Black', system-ui, sans-serif; font-size: clamp(70px, 14vw, 150px);
    color: #ffd400; -webkit-text-stroke: 3px #1a0e00; text-shadow: 0 8px 0 #1a0e00;
}
.nm-count.is-anim { animation: nm-count 0.9s ease-out; }
@keyframes nm-count { 0% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; } 25% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.9; } }
.nm-wrong {
    position: absolute; top: 58%; left: 50%; transform: translateX(-50%);
    background: #dc2626; color: #fff; font-weight: 900; font-size: 22px;
    padding: 8px 20px; border-radius: 12px; animation: nm-blink 0.5s infinite alternate;
}
@keyframes nm-blink { to { opacity: 0.5; } }

/* --- Comandi touch ----------------------------------------------------------- */
.nm-touch { display: none; }
body.nm-touchmode .nm-touch { display: block; }
/* sul telefono il nitro sta nel suo tasto: niente cruscotto, niente classifica */
body.nm-touchmode .nm-dash,
body.nm-touchmode .nm-board,
body.nm-touchmode .nm-hud-level { display: none; }
body.nm-touchmode .nm-mini { top: 62px; width: 120px; height: 120px; }
.nm-tleft, .nm-tright {
    position: absolute; bottom: 16px;
    display: flex; gap: 12px; align-items: flex-end; pointer-events: auto;
}
.nm-tleft { left: 14px; }
.nm-tright { right: 14px; }
.nm-tcol { display: flex; flex-direction: column; gap: 10px; }
.nm-tbtn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: 22px; border: 2px solid rgba(255,255,255,0.35);
    background: rgba(12, 12, 20, 0.5); color: #fff; font-weight: 900;
    touch-action: none; -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.nm-tbtn small { font-size: 11px; font-weight: 800; margin-top: 2px; }
.nm-tbtn.is-down { background: rgba(255, 122, 0, 0.6); border-color: #ffd400; transform: scale(0.97); }
.nm-tbtn-steer { width: 96px; height: 96px; font-size: 38px; }
.nm-tbtn-gas { width: 96px; height: 96px; font-size: 32px; border-color: rgba(34, 197, 94, 0.85); }
.nm-tbtn-brake { width: 96px; height: 72px; font-size: 26px; border-color: rgba(239, 68, 68, 0.85); }
.nm-tbtn-nitro { width: 96px; height: 96px; font-size: 34px; border-color: rgba(255, 170, 0, 0.9); background: rgba(120, 40, 0, 0.5); }

/* --- Finestre ----------------------------------------------------------------- */
.nm-overlay {
    position: absolute; inset: 0; z-index: 10;
    display: flex; align-items: center; justify-content: center;
    padding: 16px; overflow-y: auto;
    background: rgba(5, 6, 12, 0.45);
}
.nm-menu { background: linear-gradient(90deg, rgba(5,6,12,0.75), rgba(5,6,12,0.1) 70%); justify-content: flex-start; }
.nm-card {
    width: min(620px, 100%); max-height: 100%; overflow-y: auto;
    background: rgba(14, 15, 26, 0.94);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 22px; padding: 22px 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.nm-card-small { width: min(420px, 100%); text-align: center; }
.nm-card-wide { width: min(980px, 100%); }
.nm-card-menu { width: min(460px, 100%); margin-left: clamp(0px, 5vw, 80px); background: rgba(14, 15, 26, 0.86); }
.nm-card h2 { margin: 0 0 10px; font-size: 24px; color: var(--nm-yel); }
.nm-card h3 { margin: 16px 0 8px; font-size: 16px; color: #fdba74; }
.nm-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nm-card-head h2 { margin: 0 auto 0 0; }
.nm-card-foot { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.nm-pill { background: rgba(255,255,255,0.08); border-radius: 999px; padding: 7px 14px; font-weight: 800; color: #fde047; }
.nm-sub, .nm-small { opacity: 0.8; font-size: 14px; margin: 6px 0; }

.nm-logo {
    font-family: Impact, 'Arial Black', system-ui, sans-serif;
    font-size: clamp(46px, 9vw, 72px); line-height: 0.92; letter-spacing: 0.02em;
    color: var(--nm-yel); -webkit-text-stroke: 2px #3b1500;
    text-shadow: 0 6px 0 #c2410c, 0 10px 0 #3b1500, 0 0 40px rgba(255,120,0,0.5);
    font-style: italic; transform: skewX(-6deg);
}
.nm-logo span { color: #fff; font-size: 0.62em; letter-spacing: 0.12em; text-shadow: 0 4px 0 #1e3a8a, 0 7px 0 #0b1024; -webkit-text-stroke: 1.5px #0b1024; }
.nm-lead { font-size: 15px; line-height: 1.5; opacity: 0.9; margin: 18px 0 12px; }
.nm-wallet { display: flex; gap: 16px; font-size: 16px; margin-bottom: 14px; }
.nm-wallet b { color: #fde047; }

.nm-play {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 100%; min-height: 64px; border: 0; border-radius: 16px; cursor: pointer;
    font-family: Impact, 'Arial Black', system-ui, sans-serif; font-size: 28px; letter-spacing: 0.04em;
    color: #1a0e00; background: linear-gradient(180deg, #ffe14d, #ff8a00);
    box-shadow: 0 5px 0 #9a3c00, 0 10px 24px rgba(255, 120, 0, 0.35);
    transition: transform 0.1s, filter 0.1s;
}
.nm-play small { font-family: system-ui, sans-serif; font-size: 13px; font-weight: 700; letter-spacing: 0; margin-top: 2px; }
.nm-play:hover { filter: brightness(1.07); }
.nm-play:active { transform: translateY(3px); box-shadow: 0 2px 0 #9a3c00; }
.nm-play-inline { width: auto; min-height: 52px; padding: 0 24px; font-size: 22px; }
.nm-menu-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.nm-sec {
    min-height: 48px; padding: 0 16px; border-radius: 14px; cursor: pointer;
    border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.07);
    color: #fff; font-weight: 800; font-size: 15px;
}
.nm-sec:hover { background: rgba(255, 140, 0, 0.25); }
.nm-sec-full { width: 100%; margin-top: 8px; }
.nm-card-small .nm-play { margin-top: 6px; }

/* livelli */
.nm-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px 18px; margin-top: 8px; }
.nm-world h3 { margin: 10px 0 6px; }
.nm-lvgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.nm-lv {
    min-height: 52px; border-radius: 12px; cursor: pointer;
    border: 1px solid rgba(255,255,255,0.18); background: rgba(255,255,255,0.08); color: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.nm-lv b { font-size: 17px; }
.nm-lv small { font-size: 13px; }
.nm-lv:hover:not(:disabled) { background: rgba(255, 140, 0, 0.3); }
.nm-lv.is-next { border: 2px solid var(--nm-yel); box-shadow: 0 0 14px rgba(255, 212, 0, 0.4); }
.nm-lv.is-locked { opacity: 0.35; cursor: not-allowed; }

/* garage */
.nm-gmsg { min-height: 0; font-weight: 800; color: #86efac; transition: opacity 0.3s; opacity: 0; }
.nm-gmsg.is-on { opacity: 1; margin-top: 6px; }
.nm-garage { display: grid; grid-template-columns: 1fr 1.25fr; gap: 6px 22px; }
.nm-gsec-full { grid-column: 1 / -1; }
.nm-stats { display: flex; flex-direction: column; gap: 6px; }
.nm-stat { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; }
.nm-stat-bar { height: 10px; border-radius: 6px; background: rgba(255,255,255,0.1); overflow: hidden; }
.nm-stat-bar div { height: 100%; background: linear-gradient(90deg, #22d3ee, #a3e635); border-radius: 6px; transition: width 0.4s; }
.nm-colors { display: flex; gap: 8px; flex-wrap: wrap; }
.nm-color { width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.25); background: var(--c); cursor: pointer; }
.nm-color.is-sel { border-color: #fff; box-shadow: 0 0 0 3px var(--nm-hot); }
.nm-nitro-buy { display: flex; gap: 10px; }
.nm-ups { display: flex; flex-direction: column; gap: 8px; }
.nm-up { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,0.05); border-radius: 14px; padding: 8px 12px; }
.nm-up-emo { font-size: 28px; }
.nm-up-txt { flex: 1; min-width: 0; }
.nm-up-txt b { display: block; font-size: 15px; }
.nm-up-txt small { display: block; font-size: 12px; opacity: 0.75; }
.nm-pips { display: flex; gap: 4px; margin-top: 5px; }
.nm-pips i { width: 20px; height: 8px; border-radius: 3px; background: rgba(255,255,255,0.14); }
.nm-pips i.is-on { background: linear-gradient(90deg, #ff7a00, #ffd400); }
.nm-gbtn {
    min-width: 96px; min-height: 46px; padding: 0 14px; border-radius: 12px; cursor: pointer;
    border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.1); color: #fff;
    font-weight: 900; font-size: 15px; white-space: nowrap;
}
.nm-gbtn.is-buy { background: linear-gradient(180deg, #22c55e, #15803d); border-color: #4ade80; }
.nm-gbtn.is-buy[data-poor] { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.15); color: #94a3b8; }
.nm-gbtn.is-ok { background: transparent; color: #86efac; cursor: default; }
.nm-vehs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.nm-veh {
    background: rgba(255,255,255,0.05); border: 2px solid transparent; border-radius: 14px;
    padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
}
.nm-veh.is-sel { border-color: var(--nm-yel); background: rgba(255, 212, 0, 0.08); }
.nm-veh-emo { font-size: 34px; }
.nm-veh b { font-size: 14px; }
.nm-veh small { font-size: 11px; opacity: 0.75; min-height: 28px; }
.nm-veh .nm-gbtn { min-width: 0; width: 100%; }

/* risultati */
.nm-res-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.nm-res-pos { font-size: 56px; line-height: 1; font-family: Impact, 'Arial Black', sans-serif; color: var(--nm-yel); }
.nm-res-head h2 { margin: 0; font-family: Impact, 'Arial Black', sans-serif; font-size: 34px; letter-spacing: 0.03em; }
.nm-res-head small { opacity: 0.8; }
.nm-res-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.nm-res-table th { text-align: left; font-size: 12px; opacity: 0.6; font-weight: 700; padding: 4px 6px; }
.nm-res-table td { padding: 6px; border-top: 1px solid rgba(255,255,255,0.07); }
.nm-res-table tr.is-me td { background: rgba(255, 170, 0, 0.18); font-weight: 900; }
.nm-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 7px; vertical-align: -1px; }
.nm-earn { margin-top: 14px; background: rgba(255,255,255,0.05); border-radius: 14px; padding: 10px 14px; }
.nm-earn div { display: flex; justify-content: space-between; padding: 3px 0; font-size: 14px; }
.nm-earn b { color: #fde047; }
.nm-earn .nm-earn-tot { border-top: 1px solid rgba(255,255,255,0.12); margin-top: 4px; padding-top: 7px; font-size: 17px; font-weight: 900; }
.nm-earn .nm-earn-nitro b { color: #ffb000; }
.nm-res-wallet { margin-top: 8px; font-size: 14px; opacity: 0.9; }
.nm-res-note { margin-top: 10px; padding: 10px 14px; border-radius: 12px; background: rgba(34, 197, 94, 0.15); border: 1px solid rgba(34, 197, 94, 0.4); font-weight: 700; }
.nm-res-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.nm-res-btns .nm-play-inline { flex: 1 1 100%; }
.nm-res-btns .nm-sec { flex: 1; }

/* aiuto */
.nm-keys { display: flex; flex-direction: column; gap: 8px; }
.nm-keys div { display: grid; grid-template-columns: 170px 1fr; gap: 10px; align-items: center; font-size: 14px; }
.nm-keys kbd {
    display: inline-block; min-width: 26px; padding: 3px 7px; border-radius: 7px; text-align: center;
    background: #1f2937; border: 1px solid #475569; border-bottom-width: 3px; font-family: inherit; font-size: 13px; color: #fff;
}
.nm-help-text { font-size: 14px; line-height: 1.55; opacity: 0.9; }
.nm-spin { width: 46px; height: 46px; border-radius: 50%; border: 5px solid rgba(255,255,255,0.15); border-top-color: var(--nm-hot); margin: 6px auto 12px; animation: nm-spin 0.8s linear infinite; }
@keyframes nm-spin { to { transform: rotate(360deg); } }

/* testo per Google */
.nm-info { max-width: 1060px; margin: 0 auto; padding: 40px 20px 60px; color: #cbd5e1; }
.nm-info h2 { color: #fff; font-size: 26px; }
.nm-info p { line-height: 1.65; }
.nm-info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; margin-top: 20px; }
.nm-info-grid div { background: rgba(255,255,255,0.04); border-radius: 16px; padding: 16px 18px; }
.nm-info h3 { margin: 0 0 6px; color: #fdba74; font-size: 17px; }

@media (max-width: 760px) {
    .nm-garage { grid-template-columns: 1fr; }
    .nm-vehs { grid-template-columns: repeat(2, 1fr); }
    .nm-card { padding: 18px 16px; }
    .nm-menu { justify-content: center; background: rgba(5,6,12,0.45); }
    .nm-card-menu { margin-left: 0; }
    .nm-keys div { grid-template-columns: 1fr; gap: 2px; }
    .nm-chip { padding: 6px 10px; font-size: 13px; }
    .nm-posbox b { font-size: 28px; }
    .nm-hud-btns .nm-btn { width: 44px; height: 44px; }
    .nm-mini { width: 120px; height: 120px; }
    .nm-board { display: none; }
}
@media (orientation: portrait) {
    body.nm-touchmode .nm-chip-money { display: none; }
    body.nm-touchmode .nm-hud-btns { position: absolute; top: 52px; right: 0; flex-direction: column; }
    body.nm-touchmode .nm-mini { left: 10px; right: auto; top: 62px; }
    body.nm-touchmode .nm-tright { flex-direction: column; align-items: flex-end; }
    body.nm-touchmode .nm-tbtn-steer { width: 84px; height: 100px; }
    body.nm-touchmode .nm-msg { top: 36%; }
}
