/* css/autobuz.css — Autobuzul de Munte
   A pseudo-3D, behind-the-bus hill-climb game. Everything lives inside #ab-stage;
   overlays + touch controls are absolutely positioned on top of the canvas.
   Landscape-first for mobile, works on desktop too. */

#ab-stage {
    position: relative;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    aspect-ratio: 16 / 9;
    background: #0b0d12;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

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

.ab-hidden { display: none !important; }

/* ---- HUD ---- */
#ab-hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.ab-hud-top {
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 0.5rem; align-items: stretch;
}
.ab-box {
    background: rgba(0, 0, 0, 0.55); color: #fff; border-radius: 8px;
    padding: 0.25rem 0.7rem; min-width: 80px; text-align: center;
    font-weight: 800; font-size: 1.15rem; line-height: 1.1; backdrop-filter: blur(2px);
}
.ab-label {
    display: block; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em;
    color: #ffcf33; opacity: 0.9;
}

/* progress-to-finish bar, top-centre under the boxes */
.ab-progress {
    position: absolute; top: 56px; left: 50%; transform: translateX(-50%);
    width: 46%; height: 6px; background: rgba(0, 0, 0, 0.45); border-radius: 999px; overflow: hidden;
}
.ab-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #2ecc71, #ffcf33); border-radius: 999px; }

.ab-input-badge {
    position: absolute; top: 8px; left: 8px; background: rgba(0, 0, 0, 0.5);
    color: #9fe7ff; border-radius: 6px; padding: 0.15rem 0.45rem; font-size: 0.95rem; font-weight: 700;
}

/* wrong-way (contrasens) warning banner */
.ab-warn {
    position: absolute; top: 70px; left: 50%; transform: translateX(-50%);
    background: rgba(200, 30, 30, 0.82); color: #fff; font-weight: 800;
    padding: 0.3rem 0.9rem; border-radius: 8px; font-size: 0.95rem; white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45); pointer-events: none; z-index: 7;
    animation: ab-warn-pulse 0.7s ease-in-out infinite;
}
@keyframes ab-warn-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ran-a-red-light warning (distinct from contrasens; sits a bit lower) */
.ab-redlight {
    position: absolute; top: 104px; left: 50%; transform: translateX(-50%);
    background: rgba(214, 40, 40, 0.9); color: #fff; font-weight: 800;
    padding: 0.3rem 0.9rem; border-radius: 8px; font-size: 0.95rem; white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45); pointer-events: none; z-index: 7;
    animation: ab-warn-pulse 0.4s ease-in-out infinite;
}

/* top-right icon buttons */
.ab-icon-btn {
    position: absolute; top: 8px; right: 8px; width: 40px; height: 40px;
    border-radius: 8px; border: 0; background: rgba(0, 0, 0, 0.55); color: #fff;
    font-size: 1.1rem; pointer-events: auto; cursor: pointer;
}
.ab-fs-btn { top: 54px; }
.ab-look-btn { top: 100px; }
.ab-icon-btn.is-on { background: rgba(255, 207, 51, 0.40); color: #ffcf33; }
.ab-icon-btn.is-orbit { background: rgba(46, 204, 113, 0.55); color: #eafff1; }   /* free-rotation view */
.ab-doors-btn { top: 146px; }
.ab-icon-btn.doors-closed { background: rgba(214, 40, 40, 0.6); color: #fff; }     /* red = doors closed */
.ab-icon-btn.doors-open { background: rgba(46, 204, 113, 0.6); color: #eafff1; }   /* green = doors open */

/* mission status banner (pickup/deliver instructions) — bottom-centre, clear of the other banners */
.ab-status {
    position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
    max-width: 82%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: rgba(20, 110, 180, 0.88); color: #fff; font-weight: 700;
    padding: 0.35rem 1rem; border-radius: 10px; font-size: 0.95rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4); pointer-events: none; z-index: 6;
}
.ab-music-toast {   /* transient "now playing" pill (cassette track name) */
    position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
    max-width: 82%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: rgba(15, 15, 20, 0.84); color: #ffd76b; font-weight: 700; letter-spacing: 0.02em;
    padding: 0.35rem 1.1rem; border-radius: 999px; font-size: 0.95rem;
    border: 1px solid rgba(255, 215, 107, 0.35);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5); pointer-events: none; z-index: 8;
    animation: ab-toast-in 0.25s ease-out;
}
@keyframes ab-toast-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---- overlays (menu / win / lose / rotate) ---- */
.ab-overlay {
    position: absolute; inset: 0; z-index: 8;
    display: flex; overflow-y: auto; -webkit-overflow-scrolling: touch;   /* scrollable so tall panels (settings) reach their buttons */
    background: radial-gradient(ellipse at center, rgba(12, 16, 24, 0.78), rgba(8, 10, 14, 0.94));
    color: #fff; text-align: center; padding: 1rem;
}
.ab-menu-inner { max-width: 620px; width: 100%; margin: auto; display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }   /* margin:auto centres when it fits, scrolls when it doesn't */
.ab-title { font-weight: 900; letter-spacing: 0.02em; margin: 0; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }
.ab-sub { color: #cfd6e0; font-size: 0.95rem; max-width: 540px; margin: 0 0 0.3rem; }
.ab-hint { color: #9fe7ff; font-size: 0.85rem; min-height: 1em; }
.ab-result { color: #ffd34d; font-size: 1.05rem; font-weight: 700; }
.build-tag { color: rgba(255, 255, 255, 0.35); font-size: 0.7rem; margin-top: 0.4rem; }
.ab-money { color: #ffd23b; font-weight: 800; font-size: 1rem; }

/* traseu (route) selector */
.ab-traseu-sel { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.ab-traseu-btn {
    position: relative;
    width: 46px; height: 46px; border-radius: 10px; border: 2px solid rgba(255, 255, 255, 0.25);
    background: rgba(0, 0, 0, 0.4); color: #fff; font-weight: 800; font-size: 1.1rem; cursor: pointer;
}
.ab-traseu-btn.active { background: rgba(231, 59, 59, 0.55); border-color: #ffcf33; color: #ffcf33; }
.ab-traseu-btn.locked { opacity: 0.6; border-style: dashed; font-size: 0.95rem; }   /* 🔒 locked route — click to buy with lei */
.ab-traseu-btn.done { border-color: #2ecc71; color: #eafff1; background: rgba(46, 204, 113, 0.28); }   /* CARIERĂ: route completed */
.ab-traseu-btn.done::after { content: '✓'; position: absolute; top: -6px; right: -5px; width: 16px; height: 16px; line-height: 15px; text-align: center; font-size: 0.72rem; border-radius: 50%; background: #2ecc71; color: #06331c; font-weight: 900; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
.ab-traseu-btn.done.active { border-color: #ffcf33; }   /* selected + completed */
.ab-traseu-name { color: #9fe7ff; font-size: 0.9rem; min-height: 1em; }

.rotate-inner { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.rotate-icon { font-size: 2.6rem; color: #ffcf33; animation: ab-rot 1.4s ease-in-out infinite; }
@keyframes ab-rot { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-90deg); } }

/* ---- touch controls ---- */
#ab-touch { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.ab-touch-left { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 10px; }
.ab-touch-right { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 10px; }
.ab-touch-btn {
    width: 72px; height: 72px; border-radius: 50%; border: 0; pointer-events: auto; cursor: pointer;
    background: rgba(255, 255, 255, 0.16); color: #fff; font-size: 1.5rem;
    display: inline-flex; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
.ab-touch-btn:active { background: rgba(255, 255, 255, 0.34); }
.ab-touch-btn.steer { width: 94px; height: 94px; font-size: 2rem; background: rgba(255, 255, 255, 0.22); }   /* bigger left/right steering buttons — easier to turn */
.ab-touch-btn.gas { background: rgba(46, 204, 113, 0.30); }
.ab-touch-btn.brake { background: rgba(231, 76, 60, 0.28); }
.ab-touch-btn.drift { background: rgba(155, 89, 182, 0.34); }
.ab-touch-btn.drift.is-on { background: rgba(155, 89, 182, 0.75); box-shadow: 0 0 0 3px rgba(255, 207, 51, 0.6) inset; }   /* handbrake engaged */

/* desktop (no coarse pointer): no on-screen touch controls — keyboard / wheel only */
#ab-stage:not(.is-touch) #ab-touch { display: none !important; }

/* on touch devices, keep the action buttons clear of the bottom thumb zones (steer bottom-left, gas/brake bottom-right) */
/* the THREE most-used buttons (turn signals + doors) sit in a big, reachable row directly ABOVE the gas/brake cluster */
.is-touch .ab-sig-btn-l,
.is-touch .ab-doors-btn,
.is-touch .ab-sig-btn-r { top: auto; bottom: 96px; width: 54px; height: 54px; font-size: 1.35rem; z-index: 7; }
.is-touch .ab-sig-btn-l { right: 134px; }   /* ◄ left signal  */
.is-touch .ab-doors-btn { right: 74px;  }   /* 🚪 doors        */
.is-touch .ab-sig-btn-r { right: 14px;  }   /* ► right signal */
/* camera + engine → reachable bottom-right column, stacked above the turn-signal/door row (engine above the camera) */
.is-touch .ab-look-btn   { top: auto; bottom: 156px; right: 14px; width: 54px; height: 54px; font-size: 1.35rem; z-index: 7; }
.is-touch .ab-engine-btn { top: auto; bottom: 214px; right: 14px; width: 54px; height: 54px; font-size: 1.35rem; z-index: 7; }
/* less-used buttons keep the top-right rows */
.is-touch .ab-hand-btn { top: 54px; bottom: auto; right: 54px; }
.is-touch .ab-horn-btn { top: 54px; bottom: auto; right: 100px; }
.is-touch .ab-cassette-btn { top: 54px; bottom: auto; right: 146px; }
.is-touch .ab-vol-btn { top: 54px; bottom: auto; right: 192px; }
.is-touch .ab-winch-btn { top: auto; bottom: 156px; right: 74px; width: 54px; height: 54px; font-size: 1.35rem; z-index: 7; }   /* left of the camera-switch button, easy thumb reach */
.is-touch .ab-lift-btn { top: auto; bottom: 214px; right: 74px; width: 54px; height: 54px; font-size: 1.3rem; z-index: 7; }   /* air suspension — left of the engine button, easy thumb reach */

/* mobile bus steering wheel — fixed bottom-left; GRAB & ROTATE to steer (shown instead of the chevrons in "Volan" mode) */
.ab-wheel {
    display: none; width: 158px; height: 158px; border-radius: 50%;
    border: 16px solid #23262c;                          /* thick dark tyre-like rim */
    background: rgba(15, 17, 22, 0.22);
    position: relative; pointer-events: auto; touch-action: none; cursor: grab;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.55), inset 0 0 0 4px #34383f, inset 0 0 16px rgba(0, 0, 0, 0.55);
    will-change: transform;
}
.ab-wheel:active { cursor: grabbing; }
.ab-wheel-spoke { position: absolute; background: linear-gradient(#3c4047, #2a2d33); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.ab-wheel-h { left: 2px; right: 2px; top: 50%; height: 16px; margin-top: -8px; border-radius: 8px; }      /* left + right spokes */
.ab-wheel-v { top: 50%; bottom: 2px; left: 50%; width: 16px; margin-left: -8px; border-radius: 8px; }     /* bottom spoke (3-spoke bus wheel) */
.ab-wheel-hub { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; background: radial-gradient(#4a4f57, #2b2e34); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6), inset 0 0 0 2px rgba(255, 255, 255, 0.12); }
.ab-wheel-mark { position: absolute; left: 50%; top: -11px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: #ffcf33; box-shadow: 0 0 8px rgba(255, 207, 51, 0.85); }   /* 12-o'clock marker → see the rotation */
#ab-touch.wheel-steer .ab-touch-left .steer { display: none; }   /* wheel mode → hide the chevrons */
#ab-touch.wheel-steer .ab-wheel { display: block; }              /* …and show the wheel */

/* turn-signal arrows (blink via JS opacity) + next-crossing semaphore dot, top-centre */
.ab-sig {
    position: absolute; top: 82px; font-size: 1.7rem; font-weight: 900; color: #ffae00;
    text-shadow: 0 0 8px rgba(255, 174, 0, 0.85); pointer-events: none; z-index: 7;
}
.ab-sig-l { left: calc(50% - 78px); }
.ab-sig-r { left: calc(50% + 56px); }
.ab-sema {
    position: absolute; top: 84px; left: 50%; transform: translateX(-50%);
    width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, 0.55);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.6); pointer-events: none; z-index: 7;
}
/* extra HUD icon buttons continue down the right column */
.ab-sig-btn-l { top: 192px; }
.ab-sig-btn-r { top: 238px; }
.ab-horn-btn { top: 284px; }
.ab-engine-btn { top: 330px; }
.ab-icon-btn.engine-on { background: rgba(46, 204, 113, 0.55); color: #eafff1; }    /* engine running */
.ab-icon-btn.engine-off { background: rgba(120, 120, 128, 0.55); color: #e8e8ec; }  /* engine off */
.ab-hand-btn { top: 376px; background: rgba(155, 89, 182, 0.55); }                  /* handbrake — hold to lock the rear wheels */
.ab-hand-btn:active { background: rgba(155, 89, 182, 0.9); }
.ab-cassette-btn { top: 422px; }                                                     /* dashboard cassette — toggle the theme song */
.ab-vol-btn { top: 468px; }                                                          /* quick volume popover (game + music) */
.ab-lift-btn { top: 560px; background: rgba(52, 152, 219, 0.52); color: #eaf6ff; }   /* air suspension — raise the body to clear curve cuts/ridges */
.ab-winch-btn { top: 514px; background: rgba(214, 40, 40, 0.62); color: #fff; }      /* troliu — appears only when bogged down */
.ab-winch-btn.is-armed { animation: ab-warn-pulse 0.5s ease-in-out infinite; box-shadow: 0 0 0 3px rgba(255, 207, 51, 0.55), 0 0 16px rgba(255, 207, 51, 0.7); }

/* dirt / snow build-up meter (top-left, under the progress bar) */
.ab-dirt {
    position: absolute; top: 96px; left: 12px; display: flex; align-items: center; gap: 6px;
    color: #d8c4a0; font-size: 0.95rem; pointer-events: none; z-index: 7; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.ab-dirt-bar { width: 86px; height: 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.ab-dirt-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, #8a6a3a, #4a3520); transition: width 0.25s ease; }
.ab-vol-panel {
    position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
    background: rgba(15, 15, 20, 0.94); border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px; padding: 0.55rem 0.7rem; z-index: 9; pointer-events: auto;
    display: flex; flex-direction: column; gap: 0.45rem; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.55);
    animation: ab-toast-in 0.2s ease-out;
}
.ab-vol-row { display: flex; align-items: center; gap: 0.7rem; justify-content: space-between; }
.ab-vol-row > span { color: #fff; font-weight: 700; font-size: 0.85rem; min-width: 72px; white-space: nowrap; text-align: left; }

/* settings & controls panel */
.ab-settings-inner { max-width: 560px; gap: 0.45rem; }
.ab-set-row { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 0.6rem; }
.ab-set-label { color: #cfd6e0; font-size: 0.9rem; white-space: nowrap; }
.ab-set-opts { display: flex; gap: 4px; flex-wrap: wrap; }
.ab-set-opts button {
    border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(0, 0, 0, 0.4); color: #fff;
    border-radius: 7px; padding: 0.2rem 0.55rem; font-size: 0.8rem; cursor: pointer;
}
.ab-set-opts button.active { background: rgba(231, 59, 59, 0.55); border-color: #ffcf33; color: #ffcf33; }
.ab-controls-list { width: 100%; margin: 0.5rem 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
.ab-ctl-row { display: flex; justify-content: space-between; font-size: 0.8rem; color: #aeb6c2; border-bottom: 1px solid rgba(255, 255, 255, 0.07); padding: 1px 0; }
.ab-ctl-row b { color: #9fe7ff; font-weight: 700; }

/* wheel / controller calibration wizard */
.ab-wheelcfg-status { color: #9fe7ff; font-weight: 700; font-size: 1rem; }
.ab-wheelcfg-step { color: #ffcf33; font-weight: 800; font-size: 1.15rem; min-height: 1.3em; margin: 0.2rem 0; }
.ab-wheelcfg-readout { color: #9fe7ff; font-size: 0.85rem; min-height: 1.1em; font-family: monospace; }

/* garage — 3D bus preview + specs */
.ab-garage-preview { position: relative; width: 100%; max-width: 540px; height: 190px; margin: 0.3rem 0; background: rgba(0, 0, 0, 0.35); border-radius: 12px; overflow: hidden; }
.ab-garage-preview canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.ab-garage-preview canvas:active { cursor: grabbing; }
.ab-gp-view { position: absolute; top: 8px; right: 8px; border: 0; border-radius: 8px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 0.78rem; font-weight: 700; padding: 5px 10px; cursor: pointer; }
.ab-garage-specs { color: #cfd6e0; font-size: 0.86rem; line-height: 1.55; margin: 0.1rem 0 0.4rem; min-height: 3.4em; }
#btn-ab-garage-buy.ab-cant { opacity: 0.55; }

/* garage — bus catalog cards */
.ab-garage-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; max-width: 540px; margin: 0.4rem 0; }
.ab-bus-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2); border-left: 7px solid var(--bus, #888);
    background: rgba(0, 0, 0, 0.4); color: #fff; border-radius: 10px; padding: 0.5rem 0.7rem;
}
.ab-bus-card b { font-size: 0.92rem; }
.ab-bus-card small { color: #aeb6c2; font-size: 0.76rem; }
.ab-bus-card em { font-style: normal; font-weight: 800; color: #ffd23b; font-size: 0.82rem; margin-top: 3px; }
.ab-bus-card.active { border-color: #ffcf33; box-shadow: 0 0 0 2px rgba(255, 207, 51, 0.4) inset; }
.ab-bus-card.locked em { color: #ff9a9a; }

/* winch-point selector — a little column just above the winch button (multi-point buses) */
.ab-winchpts { position: absolute; right: 134px; bottom: 162px; display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 5px; z-index: 7; pointer-events: none; }   /* a VERTICAL stack just LEFT of the ⚓ button — buttons one above another, growing upward */
.ab-winchpt { pointer-events: auto; border: 0; border-radius: 8px; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 0.72rem; font-weight: 700; padding: 5px 8px; cursor: pointer; white-space: nowrap; }
.ab-winchpt.is-on { background: rgba(255, 207, 51, 0.9); color: #1a1c22; }

/* fullscreen: stage fills the viewport */
#ab-stage:fullscreen, #ab-stage:-webkit-full-screen {
    max-width: none; width: 100vw; height: 100vh; aspect-ratio: auto; border-radius: 0;
}
