/* css/drift.css — Romanian Drifts
   A pseudo-3D, behind-the-vehicle arena drift game. Everything lives inside
   #drift-stage; overlays + touch controls are absolutely positioned on top of
   the canvas. Designed landscape-first for mobile but works on desktop too. */

#drift-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;            /* prevent scroll/zoom while playing */
    user-select: none;
    -webkit-user-select: none;
}

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

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

/* ---- HUD ---- */
#drift-hud {
    position: absolute;
    inset: 0;
    pointer-events: none;       /* let touches pass through to controls */
    z-index: 5;
}

.hud-top {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.hud-box {
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border-radius: 8px;
    padding: 0.25rem 0.7rem;
    min-width: 70px;
    text-align: center;
    font-weight: 800;
    font-size: 1.15rem;
    line-height: 1.1;
    backdrop-filter: blur(2px);
}

.hud-label {
    display: block;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #ffcf33;
    opacity: 0.9;
}

.hud-combo {
    background: rgba(220, 53, 69, 0.0);
    color: #ff7e33;
    transition: transform 0.1s;
    opacity: 0;
}
.hud-combo.active {
    opacity: 1;
    background: rgba(0, 0, 0, 0.35);
}
.hud-combo #hud-combo { font-size: 1rem; letter-spacing: 0.06em; }
.hud-combo #hud-pending { display: block; font-size: 0.8rem; color: #ffd60a; }

.hud-input-badge {
    position: absolute;
    top: 52px;
    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;
}

.drift-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;
}

.drift-cam-btn { top: 54px; }
.drift-fs-btn { top: 100px; }
.drift-sound-btn { top: 146px; }
.drift-music-btn { top: 192px; }
.drift-icon-btn.music-off { opacity: 0.55; }
.drift-icon-btn.music-off::after,
.home-music-btn.music-off::after {
    content: ""; position: absolute; left: 18%; right: 18%; top: 50%;
    height: 2px; background: #ff5252; transform: translateY(-50%) rotate(-45deg); border-radius: 2px;
}
.home-music-btn {
    position: relative; flex: none; margin-left: 8px;
    width: 36px; height: 36px; border-radius: 8px; border: 0;
    background: rgba(255,255,255,0.12); color: #fff; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.home-music-btn.music-off { opacity: 0.6; }
.home-music-btn.is-active { color: #ffcf33; background: rgba(255,207,51,0.18); }

/* In-game music bar: prev / repeat / next + current song name. Top-centre, below the score
   row AND below the objective timer, centred to match them. Hidden entirely when the music is
   muted (see updateMusicBtn). */
.music-bar {
    position: absolute; top: 96px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 3px;
    max-width: 72%; padding: 2px 10px 2px 4px;
    background: rgba(0, 0, 0, 0.55); border-radius: 999px;
    pointer-events: auto;
}
.music-mini {
    width: 26px; height: 26px; flex: none; border: 0; border-radius: 50%;
    background: transparent; color: #fff; font-size: 0.8rem; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; pointer-events: auto;
}
.music-mini:hover { background: rgba(255, 255, 255, 0.14); }
.music-mini.is-active { color: #ffcf33; background: rgba(255, 207, 51, 0.18); }
.song-name {
    color: #fff; font-size: 0.78rem; font-weight: 600; margin-left: 4px; max-width: 210px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.home-song { margin-top: 4px; color: #cfd6e0; font-size: 0.82rem; display: flex; align-items: center; gap: 6px; }
.home-song i { color: #ffcf33; }

/* True fullscreen (desktop + Android) */
#drift-stage:fullscreen,
#drift-stage:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
    aspect-ratio: auto;
}
/* iOS Safari fallback (no element fullscreen) — pin the stage over everything */
#drift-stage.faux-fs {
    position: fixed;
    inset: 0;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none;
    border-radius: 0;
    aspect-ratio: auto;
    z-index: 99999;
}
body.faux-fs-body { overflow: hidden; }

.drift-cam-name {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    background: rgba(0, 0, 0, 0.6);
    color: #ffcf33;
    font-weight: 800;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.95rem;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}
.drift-cam-name.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---- Touch controls ---- */
#drift-touch {
    position: absolute;
    inset: 0;
    z-index: 6;
    pointer-events: none;
}

.touch-left, .touch-right {
    position: absolute;
    bottom: 14px;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    pointer-events: none;
}
.touch-left { left: 14px; }
.touch-right { right: 14px; }

.touch-btn {
    pointer-events: auto;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    transition: transform 0.05s, background 0.05s;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;            /* allow simultaneous multi-touch (gas + drift) */
}
.touch-btn:active, .touch-btn.pressed {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.3);
}
.touch-btn.gas { background: rgba(46, 204, 113, 0.35); border-color: rgba(46, 204, 113, 0.7); width: 90px; height: 90px; }
.touch-btn.brake { background: rgba(231, 76, 60, 0.3); border-color: rgba(231, 76, 60, 0.6); }
.touch-btn.handbrake { background: rgba(241, 196, 15, 0.3); border-color: rgba(241, 196, 15, 0.7); font-size: 0.85rem; }

/* ---- Overlays (menu / game over / rotate) ---- */
.drift-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: flex-start;   /* top-anchor: tall menus aren't clipped + stay scrollable */
    justify-content: center;
    background: rgba(8, 10, 18, 0.82);
    backdrop-filter: blur(3px);
    overflow-y: auto;
}

.drift-menu-inner {
    text-align: center;
    color: #fff;
    padding: 1rem;
    width: 100%;
    max-width: 640px;
    /* auto vertical margins centre short menus but collapse when the content is
       taller than the stage, so it top-aligns and scrolls (title stays visible). */
    margin: auto 0;
}

.drift-title {
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: linear-gradient(90deg, #ffcf33, #ff7e33, #e74c3c);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 0.75rem;
}

.drift-carousel { margin-bottom: 0.6rem; }
.carousel-label {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    color: #ffcf33;
    font-weight: 700;
    margin-bottom: 0.15rem;
}
.carousel-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.carousel-center { min-width: 190px; }
.carousel-name { font-weight: 800; font-size: 1.05rem; margin-top: 0.1rem; }
#veh-preview, #trk-preview {
    background: #11151f;
    border-radius: 8px;
    max-width: 100%;
}
.carousel-arrow {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    flex: 0 0 auto;
}
.carousel-arrow:hover { background: rgba(255, 255, 255, 0.2); }

.stat-bars {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 0.4rem;
    font-size: 0.62rem;
}
.stat-row { display: flex; align-items: center; gap: 6px; }
.stat-row .stat-name { width: 52px; text-align: right; color: #bbb; letter-spacing: 0.04em; }
.stat-track { flex: 1; height: 7px; background: rgba(255, 255, 255, 0.12); border-radius: 4px; overflow: hidden; }
.stat-fill { display: block; height: 100%; background: linear-gradient(90deg, #2ecc71, #ffcf33); }

.drift-start { margin-top: 0.4rem; font-weight: 800; letter-spacing: 0.05em; }
.drift-controls-hint { margin-top: 0.5rem; font-size: 0.75rem; color: #9fb3c8; }

.over-score { font-size: 1.4rem; }
.over-best { color: #ffcf33; }

/* ---- Rotate prompt ---- */
.rotate-inner { color: #fff; text-align: center; }
.rotate-icon {
    font-size: 3rem;
    color: #ffcf33;
    animation: rotate-wiggle 1.5s ease-in-out infinite;
    margin-bottom: 0.6rem;
}
@keyframes rotate-wiggle {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-90deg); }
}

/* ---- Mobile landscape: make the stage fill the viewport for an immersive feel ---- */
@media (max-height: 520px) and (orientation: landscape) {
    #drift-section .container > h2,
    #drift-section .container > .divider-custom,
    #drift-section .container > .lead,
    #drift-section .container > .text-muted { display: none; }
    #drift-section { margin-top: 0 !important; padding: 0 !important; }
    #drift-stage {
        max-width: none;
        width: 100vw;
        height: 100vh;
        aspect-ratio: auto;
        border-radius: 0;
        margin: 0;
    }
}

/* Smaller phones: shrink the thumb buttons a touch */
@media (max-width: 700px) {
    .touch-btn { width: 60px; height: 60px; font-size: 1.2rem; }
    .touch-btn.gas { width: 76px; height: 76px; }
}

/* ===== Career / Garage / Home / Result / HUD extras ===== */

/* HUD gearbox + indicators */
.hud-gearbox {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    padding: 4px 8px;
    color: #fff;
}
.hud-gear { font-weight: 900; font-size: 1.3rem; min-width: 18px; text-align: center; transition: color 0.1s; }
.hud-gear.gear-grind { color: #ff3b30; }   /* flashes when you shift without the clutch */
.hud-trans { font-size: 0.7rem; background: rgba(255,255,255,0.18); border-radius: 4px; padding: 1px 5px; }
.hud-rpm { width: 70px; height: 8px; background: rgba(255,255,255,0.15); border-radius: 4px; overflow: hidden; }
.hud-rpm-fill { display: block; height: 100%; width: 10%; background: #2ecc71; transition: width 0.08s linear; }
.hud-ind { opacity: 0.25; font-weight: 800; font-size: 0.9rem; }
.hud-ind.on { opacity: 1; color: #ffae00; }
#hud-lights.on { color: #fff7cc; }

.hud-objective {
    position: absolute;
    top: 58px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-weight: 800;
    padding: 0.2rem 0.8rem;
    border-radius: 999px;
    font-size: 0.95rem;
    white-space: nowrap;
}

/* touch extras */
/* signals/horn/lights — a compact 2x2 cluster on the right so it clears the centred SCOR/KM HUD */
.touch-aux { position: absolute; top: 8px; right: 54px; width: 100px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; pointer-events: none; }
.touch-mini {
    pointer-events: auto;
    width: 46px; height: 46px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.12);
    color: #fff; font-size: 1rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    touch-action: none; -webkit-tap-highlight-color: transparent;
}
.touch-mini:active, .touch-mini.pressed { background: rgba(255,255,255,0.3); transform: scale(0.92); }
.touch-gears { display: flex; flex-direction: column; gap: 8px; justify-content: flex-end; }

/* Home */
.home-wallet-line { color: #ffcf33; font-weight: 700; margin-bottom: 0.8rem; }
.home-buttons { display: flex; flex-direction: column; gap: 0.5rem; max-width: 320px; margin: 0 auto; }
.ctrl-status-line { margin-top: 0.8rem; font-size: 0.8rem; color: #9fb3c8; }
.home-volume { display: flex; align-items: center; gap: 0.5rem; justify-content: center; max-width: 320px; margin: 0.7rem auto 0; color: #cdd6e0; }
.home-volume input[type="range"] { flex: 1; accent-color: #ffcf33; }
.home-volume span { min-width: 28px; text-align: right; font-weight: 700; }

/* shared screen header + scroll */
.drift-scroll { max-height: 92%; overflow-y: auto; }
.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.6rem; position: sticky; top: 0; }
.wallet-chip { color: #ffcf33; font-weight: 800; }

/* class badges */
.cls-badge { display: inline-block; min-width: 18px; text-align: center; font-weight: 900; border-radius: 4px; padding: 0 5px; color: #111; }
.cls-E { background: #b0bec5; } .cls-D { background: #4fc3f7; } .cls-C { background: #aed581; }
.cls-B { background: #ffb74d; } .cls-A { background: #ff8a65; }
.cls-S { background: linear-gradient(135deg, #111, #d4af37); color: #fff; }   /* premium hypercar tier */
.career-tier { margin: 14px 0 8px; padding: 8px 12px; text-align: center; font-weight: 900; letter-spacing: 0.04em; border-radius: 8px; color: #fff; background: linear-gradient(135deg, #111, #d4af37); }
.screen-head-spacer { width: 32px; flex-shrink: 0; }

/* Controls / how-to-play legend */
.controls-legend { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; text-align: left; margin-top: 6px; }
.ctl-section { flex: 1 1 280px; min-width: 250px; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.09); border-radius: 12px; padding: 12px 14px; }
.ctl-head { display: flex; align-items: center; gap: 8px; font-weight: 800; color: #ffd34d; letter-spacing: 0.03em; margin-bottom: 8px; }
.ctl-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.ctl-row:last-child { border-bottom: none; }
.ctl-section.touch .ctl-row { justify-content: flex-start; }
.ctl-act { font-size: 0.88rem; color: #e8e8ea; }
.ctl-keys { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.controls-legend kbd { display: inline-block; min-width: 22px; text-align: center; padding: 3px 6px; font: 600 0.78rem/1 ui-monospace, monospace; color: #fff; background: #2a2d33; border: 1px solid #44474d; border-bottom-width: 2px; border-radius: 5px; }
.controls-legend kbd.wide { min-width: auto; padding: 3px 11px; }
.ctl-or { color: #888; font-size: 0.78rem; }
.ctl-btn { display: inline-flex; align-items: center; justify-content: center; gap: 3px; min-width: 44px; height: 30px; padding: 0 9px; border-radius: 8px; font-weight: 800; font-size: 0.78rem; color: #fff; background: #3a3d44; border: 1px solid rgba(255, 255, 255, 0.16); flex-shrink: 0; }
.ctl-btn.gas { background: #2f8f4a; } .ctl-btn.brake { background: #b6362f; } .ctl-btn.hand { background: #d9a93a; color: #1a1a1a; }
.ctl-tip { margin-top: 10px; font-size: 0.82rem; color: #9aa3ad; }
.ctl-tip i { margin-right: 5px; }

/* Settings / graphics */
.settings-list { text-align: left; margin-top: 4px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.set-label { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #e8e8ea; }
.set-label small { color: #8a929c; font-weight: 500; }
.seg { display: inline-flex; border-radius: 9px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.16); }
.seg button { background: #2a2d33; color: #cfd2d6; border: none; border-left: 1px solid rgba(255, 255, 255, 0.1); padding: 7px 13px; font-size: 0.85rem; font-weight: 700; cursor: pointer; }
.seg button:first-child { border-left: none; }
.seg button.active { background: #d9a93a; color: #1a1a1a; }
.set-tip { margin-top: 12px; font-size: 0.82rem; color: #9aa3ad; }
.set-tip i { margin-right: 5px; }
.build-tag { margin-top: 8px; text-align: center; font-size: 0.66rem; letter-spacing: 0.08em; color: #5a6472; }

/* Career */
.career-car { color: #fff; margin-bottom: 0.6rem; font-size: 0.9rem; }
.chapter { background: rgba(255,255,255,0.06); border-radius: 10px; padding: 0.5rem 0.6rem; margin-bottom: 0.5rem; text-align: left; }
.chapter.locked { opacity: 0.55; }
.chapter-head { display: flex; justify-content: space-between; color: #fff; font-weight: 800; font-size: 0.9rem; margin-bottom: 0.4rem; }
.chapter-req { font-size: 0.75rem; color: #cdd6e0; }
.chapter-events { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.ev-btn {
    display: flex; align-items: center; gap: 0.4rem;
    background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.12);
    color: #fff; border-radius: 8px; padding: 0.45rem 0.5rem; cursor: pointer; font-size: 0.8rem;
}
.ev-btn:hover:not(.disabled) { border-color: #ffcf33; }
.ev-btn.disabled { opacity: 0.4; cursor: not-allowed; }
.ev-btn .ev-name { flex: 1; }
.ev-btn .ev-medal { font-size: 1rem; }
.chapter-warn { color: #ffb74d; font-size: 0.72rem; margin-top: 0.4rem; }
.chapter { display: flex; gap: 0.6rem; align-items: center; }
.chapter-main { flex: 1; min-width: 0; }
.chapter-curve { flex-shrink: 0; width: 120px; height: 60px; border-radius: 6px; background: #11141b; border: 1px solid rgba(255, 255, 255, 0.08); }
@media (max-width: 560px) { .chapter-curve { width: 92px; height: 48px; } }

/* Garage */
.garage-class { color: #ffcf33; font-weight: 800; text-align: left; margin: 0.5rem 0 0.3rem; }
.garage-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.5rem; }
.car-card { background: rgba(255,255,255,0.06); border: 2px solid transparent; border-radius: 10px; padding: 0.5rem; text-align: center; color: #fff; }
.car-card.selected { border-color: #2ecc71; }
.car-canvas { width: 100%; height: auto; background: linear-gradient(180deg,#1a2030,#0e1118); border-radius: 8px; display: block; margin-bottom: 0.3rem; }
.car-name { font-size: 0.8rem; font-weight: 700; min-height: 2.2em; }
.car-meta { font-size: 0.8rem; margin-bottom: 0.35rem; }
.car-card .stat-bars { margin-bottom: 0.4rem; }
.car-card .btn { width: 100%; font-size: 0.75rem; }
.car-card .btn + .btn { margin-top: 0.3rem; }
.stat-fill--drift { background: linear-gradient(90deg, #ff7e33, #ffcf33) !important; }
.garage-row { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

/* Result */
.result-body { color: #fff; }
.result-medal { font-size: 3.2rem; }
.result-name { font-weight: 900; letter-spacing: 0.05em; font-size: 1.3rem; }
.result-metric { font-size: 1.4rem; font-weight: 800; }
.result-targets { color: #9fb3c8; font-size: 0.85rem; margin: 0.3rem 0; }
.result-lei { color: #ffcf33; font-weight: 800; font-size: 1.1rem; }
.result-lei.result-fail { color: #ff8a80; font-weight: 600; font-size: 0.95rem; }
.result-wallet { margin-top: 0.4rem; color: #cdd6e0; font-size: 0.85rem; }

/* Calibration */
.calib-device { color: #9fe7ff; font-weight: 700; margin-bottom: 0.4rem; }
.calib-step-title { font-weight: 800; color: #ffcf33; }
.calib-text { color: #fff; margin: 0.3rem 0; }
.calib-readout { color: #9fb3c8; font-size: 0.85rem; min-height: 1.2em; }
.calib-dots { display: flex; gap: 4px; justify-content: center; margin: 0.5rem 0; }
.cdot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.2); }
.cdot.cur { background: #ffcf33; } .cdot.done { background: #2ecc71; }
