/**
 * Taxi City 3D
 */
.tx-app [hidden] { display: none !important; }

.tx-app {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    color: #f1f5f9;
    background: #0d0f14;
    overflow-x: hidden;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.tx-stage {
    position: relative;
    width: 100vw;
    height: calc(100vh - 72px);
    min-height: 520px;
    overflow: hidden;
    background: #0d0f14;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}
.tx-stage:fullscreen { height: 100vh; }

#txCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

/* --- HUD in alto -------------------------------------------------------- */
.tx-hud-top {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    pointer-events: none;
    z-index: 5;
}
.tx-chip {
    background: rgba(12, 12, 16, 0.74);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 999px;
    padding: 7px 14px;
    font-weight: 800;
    font-size: 15px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.tx-brand span { color: #facc15; }
.tx-money { color: #86efac; }
.tx-clock.is-low { background: rgba(185, 28, 28, 0.9); animation: tx-blink 0.8s infinite; }
@keyframes tx-blink { 50% { opacity: 0.6; } }
.tx-hud-btns {
    margin-left: auto;
    display: flex;
    gap: 6px;
    pointer-events: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.tx-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.18);
    background: rgba(12, 12, 16, 0.74);
    color: #fff;
    font-size: 19px;
    cursor: pointer;
    display: grid;
    place-items: center;
}
.tx-btn:hover { background: rgba(60, 50, 20, 0.9); }
.tx-btn.is-off { opacity: 0.45; }

/* --- Scheda della corsa ------------------------------------------------ */
.tx-ride {
    position: absolute;
    top: 66px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 340px;
    max-width: min(560px, calc(100vw - 24px));
    padding: 10px 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(250, 204, 21, 0.95), rgba(234, 179, 8, 0.95));
    color: #1c1917;
    box-shadow: 0 8px 26px rgba(0,0,0,0.35);
    pointer-events: none;
    z-index: 4;
}
.tx-ride.is-empty {
    background: rgba(12, 12, 16, 0.74);
    color: #f1f5f9;
    border: 1px solid rgba(255,255,255,0.14);
}
.tx-ride-emoji { font-size: 32px; line-height: 1; }
.tx-ride-main { flex: 1; min-width: 0; }
.tx-ride-name { font-weight: 800; font-size: 15px; }
.tx-ride-dest { font-size: 14px; font-weight: 600; opacity: 0.92; overflow: hidden; text-overflow: ellipsis; }
.tx-ride.is-empty .tx-ride-dest { font-weight: 500; font-size: 13px; opacity: 0.8; }
.tx-ride-side { text-align: right; font-variant-numeric: tabular-nums; }
.tx-ride-time { font-size: 20px; font-weight: 900; }
.tx-ride-time.is-low { color: #b91c1c; animation: tx-blink 0.6s infinite; }
.tx-ride-dist { font-size: 13px; font-weight: 700; }
.tx-ride-tips { font-size: 13px; font-weight: 800; color: #166534; }
.tx-ride-tips.is-neg { color: #b91c1c; }

.tx-bubble {
    position: absolute;
    top: 142px;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    max-width: min(460px, calc(100vw - 32px));
    padding: 9px 16px;
    border-radius: 18px;
    background: #fff;
    color: #111827;
    font-weight: 700;
    font-size: 15px;
    text-align: center;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    z-index: 4;
}
.tx-bubble.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

.tx-pops {
    position: absolute;
    left: 50%;
    top: 38%;
    width: 0;
    pointer-events: none;
    z-index: 4;
}
.tx-pop {
    position: absolute;
    left: 0;
    transform: translateX(-50%);
    white-space: nowrap;
    font-weight: 900;
    font-size: 24px;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 0 #000, 0 0 12px rgba(0,0,0,0.6);
    animation: tx-pop 1.7s ease-out forwards;
}
.tx-pop.is-big { font-size: 34px; }
@keyframes tx-pop {
    0% { opacity: 0; transform: translate(-50%, 20px) scale(0.7); }
    12% { opacity: 1; transform: translate(-50%, 0) scale(1.1); }
    25% { transform: translate(-50%, -6px) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -90px) scale(1); }
}

/* --- Tachimetro -------------------------------------------------------- */
.tx-dash {
    position: absolute;
    right: 14px;
    bottom: 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
    z-index: 3;
}
.tx-speedo {
    background: rgba(12, 12, 16, 0.78);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 16px;
    padding: 6px 14px 8px;
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-variant-numeric: tabular-nums;
}
.tx-speed { font-size: 44px; font-weight: 900; line-height: 1; min-width: 2.2em; text-align: right; }
.tx-unit { font-size: 13px; opacity: 0.75; font-weight: 700; }
.tx-gear {
    margin-left: 6px;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: #facc15;
    color: #111;
    font-weight: 900;
    display: grid;
    place-items: center;
    font-size: 17px;
    align-self: center;
}
.tx-meter {
    background: #111;
    border: 2px solid #3f3f46;
    border-radius: 10px;
    padding: 4px 12px;
    font-family: 'Courier New', monospace;
    color: #7f1d1d;
    font-weight: 900;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tx-meter small { font-size: 10px; color: #71717a; letter-spacing: 1px; }
.tx-meter.is-on { color: #ff4338; text-shadow: 0 0 8px rgba(255, 67, 56, 0.7); }
.tx-nitro {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(12, 12, 16, 0.74);
    border-radius: 999px;
    padding: 5px 10px;
    border: 1px solid rgba(255,255,255,0.14);
}
.tx-nitro-bar { width: 130px; height: 10px; border-radius: 6px; background: rgba(255,255,255,0.15); overflow: hidden; }
.tx-nitro-fill { height: 100%; width: 60%; background: linear-gradient(90deg, #38bdf8, #a78bfa); border-radius: 6px; transition: width 0.15s; }
.tx-nitro.is-on .tx-nitro-fill { background: linear-gradient(90deg, #f97316, #facc15); }

/* --- Minimappa e messaggi ---------------------------------------------- */
.tx-mini {
    position: absolute;
    left: 14px;
    bottom: 14px;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    border: 3px solid rgba(250, 204, 21, 0.85);
    box-shadow: 0 6px 20px rgba(0,0,0,0.45);
    pointer-events: none;
    z-index: 3;
}
.tx-toast {
    position: absolute;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%) translateY(10px);
    max-width: min(560px, calc(100vw - 32px));
    background: rgba(12, 12, 16, 0.86);
    border: 1px solid rgba(255,255,255,0.16);
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    z-index: 6;
}
.tx-toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Comandi touch ----------------------------------------------------- */
.tx-touch { display: none; }
.tx-tbtn {
    border: 2px solid rgba(255,255,255,0.3);
    background: rgba(12, 12, 16, 0.55);
    color: #fff;
    border-radius: 18px;
    font-size: 26px;
    font-weight: 900;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.tx-tbtn small { font-size: 11px; font-weight: 700; opacity: 0.9; }
.tx-tbtn.is-down { background: rgba(250, 204, 21, 0.55); border-color: #facc15; transform: scale(0.97); }

/* comandi touch: la classe is-touch la mette il JS sui dispositivi con il dito */
.tx-app.is-touch .tx-touch { display: block; }
/* sul telefono il gioco prende tutto lo schermo (all'avvio la pagina scorre fin qui) */
.tx-app.is-touch .tx-stage { height: 100vh; height: 100dvh; min-height: 300px; }
.tx-app.is-touch #txCanvas { cursor: default; }
.tx-app.is-touch .tx-steer {
    position: absolute;
    left: 12px;
    bottom: 16px;
    display: flex;
    gap: 12px;
    z-index: 7;
}
.tx-app.is-touch .tx-tbtn-steer { width: 88px; height: 88px; font-size: 34px; }
.tx-app.is-touch .tx-pedals {
    position: absolute;
    right: 12px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    z-index: 7;
}
.tx-app.is-touch .tx-pedals-row { display: flex; gap: 10px; align-items: flex-end; }
.tx-app.is-touch .tx-tbtn-small { width: 64px; height: 56px; font-size: 20px; }
.tx-app.is-touch .tx-tbtn-drift,
.tx-app.is-touch .tx-tbtn-nitro { width: 76px; height: 64px; font-size: 22px; }
.tx-app.is-touch .tx-tbtn-nitro { border-color: rgba(56, 189, 248, 0.7); }
.tx-app.is-touch .tx-tbtn-brake { width: 76px; height: 92px; border-color: rgba(239, 68, 68, 0.7); }
.tx-app.is-touch .tx-tbtn-gas { width: 92px; height: 120px; font-size: 32px; border-color: rgba(34, 197, 94, 0.8); }
.tx-app.is-touch .tx-toast { bottom: auto; top: 46%; }
.tx-app.is-touch .tx-meter { display: none; }
.tx-app.is-touch .tx-speed { font-size: 30px; }
.tx-app.is-touch .tx-nitro-bar { width: 80px; }

/* telefono in verticale: HUD su due righe, scheda corsa sotto, minimappa e
   tachimetro ai lati, comandi in basso */
@media (orientation: portrait) {
    .tx-app.is-touch .tx-ride { top: 112px; width: calc(100vw - 24px); min-width: 0; }
    .tx-app.is-touch .tx-mini { top: 214px; bottom: auto; left: 12px; width: 120px; height: 120px; }
    .tx-app.is-touch .tx-dash { top: 214px; bottom: auto; right: 12px; }
    .tx-app.is-touch .tx-bubble { top: 350px; }
    .tx-app.is-touch .tx-pops { top: 42%; }
}
/* telefono in orizzontale: pedali tutti in fila in basso a destra */
@media (orientation: landscape) {
    .tx-app.is-touch .tx-pedals { flex-direction: row; align-items: flex-end; }
    .tx-app.is-touch .tx-pedals-row { flex-direction: column-reverse; }
    .tx-app.is-touch .tx-pedals-row:last-child { flex-direction: row; }
    .tx-app.is-touch .tx-ride { top: 62px; width: calc(100vw - 340px); min-width: 0; max-width: 520px; }
    .tx-app.is-touch .tx-mini { top: 62px; bottom: auto; left: 12px; width: 120px; height: 120px; }
    .tx-app.is-touch .tx-dash { top: 62px; bottom: auto; right: 12px; }
    .tx-app.is-touch .tx-bubble { top: 140px; }
}

/* --- Schermate --------------------------------------------------------- */
.tx-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: radial-gradient(ellipse at center, rgba(20, 16, 4, 0.55), rgba(5, 5, 8, 0.85));
    z-index: 20;
    overflow-y: auto;
}
.tx-start { background: linear-gradient(180deg, rgba(10, 10, 14, 0.35), rgba(10, 10, 14, 0.82)); }
.tx-card {
    width: min(640px, 100%);
    max-height: 100%;
    overflow-y: auto;
    background: rgba(18, 18, 24, 0.94);
    border: 1px solid rgba(250, 204, 21, 0.35);
    border-radius: 22px;
    padding: 24px 26px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    text-align: center;
}
.tx-card-small { width: min(420px, 100%); }
.tx-card h2 { margin: 0 0 14px; font-size: 26px; color: #facc15; }
.tx-card-kicker { color: #facc15; font-weight: 800; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; }
.tx-title {
    margin: 6px 0 8px;
    font-size: clamp(34px, 6vw, 52px);
    font-weight: 900;
    color: #facc15;
    text-shadow: 0 3px 0 #111, 0 0 30px rgba(250, 204, 21, 0.35);
    letter-spacing: 1px;
}
.tx-lead { margin: 0 auto 16px; max-width: 520px; line-height: 1.5; color: #d4d4d8; }
.tx-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 10px; }
.tx-picks-mode { grid-template-columns: repeat(2, 1fr); margin-bottom: 16px; }
.tx-city-pick, .tx-mode-pick {
    min-height: 64px;
    padding: 10px 8px;
    border-radius: 14px;
    border: 2px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.05);
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.tx-city-pick small, .tx-mode-pick small { font-weight: 500; font-size: 12px; opacity: 0.75; }
.tx-city-pick:hover, .tx-mode-pick:hover { border-color: rgba(250, 204, 21, 0.6); }
.tx-city-pick.is-current, .tx-mode-pick.is-current { border-color: #facc15; background: rgba(250, 204, 21, 0.14); }
.tx-keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; text-align: left; margin: 0 0 18px; }
.tx-keys > div { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: #d4d4d8; }
.tx-k { color: #fff; font-weight: 700; }
.tx-app kbd {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 6px;
    background: #27272a;
    border: 1px solid #52525b;
    border-bottom-width: 3px;
    font-family: inherit;
    font-size: 12px;
    color: #fff;
}
.tx-play {
    min-width: 200px;
    min-height: 54px;
    padding: 12px 30px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #facc15, #f59e0b);
    color: #111;
    font-size: 20px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 6px 0 #92400e, 0 10px 24px rgba(250, 204, 21, 0.3);
}
.tx-play:active { transform: translateY(3px); box-shadow: 0 3px 0 #92400e; }
.tx-link {
    display: block;
    margin: 14px auto 0;
    min-height: 44px;
    padding: 8px 14px;
    background: none;
    border: none;
    color: #a1a1aa;
    text-decoration: underline;
    cursor: pointer;
    font-size: 14px;
}
.tx-note { margin: 12px 0 0; color: #a1a1aa; font-size: 13px; }
.tx-note:empty { display: none; }
.tx-help-text { color: #d4d4d8; line-height: 1.5; font-size: 14px; text-align: left; }
.tx-help-actions { margin-top: 10px; }
.tx-record { color: #facc15; font-weight: 900; font-size: 20px; margin-bottom: 10px; animation: tx-blink 1s infinite; }
.tx-end-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.tx-end-grid div { background: rgba(255,255,255,0.05); border-radius: 12px; padding: 10px 6px; display: flex; flex-direction: column; gap: 4px; }
.tx-end-grid span { font-size: 12px; color: #a1a1aa; }
.tx-end-grid b { font-size: 22px; color: #86efac; }

/* --- Testo informativo ------------------------------------------------- */
.tx-info {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 20px 60px;
    color: #d4d4d8;
    line-height: 1.6;
}
.tx-info h2 { color: #facc15; font-size: 26px; margin: 0 0 12px; }
.tx-info h3 { color: #fff; font-size: 18px; margin: 0 0 6px; }
.tx-info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-top: 24px; }
.tx-info-grid > div { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 16px; padding: 18px; }

@media (max-width: 700px) {
    .tx-ride { top: 112px; width: calc(100vw - 24px); min-width: 0; }
    .tx-bubble { top: 190px; }
}
@media (max-width: 640px) {
    .tx-hud-top { top: 8px; left: 8px; right: 8px; gap: 6px; }
    .tx-brand { display: none; }
    .tx-chip { padding: 6px 10px; font-size: 14px; }
    .tx-picks { grid-template-columns: 1fr; }
    .tx-keys { grid-template-columns: 1fr; }
    .tx-card { padding: 18px 16px; }
}
