/* ==========================================================================
   Málaga Libre — open-world game. Uses the design tokens from site.css.
   ========================================================================== */

.ml {
    position: relative;
    height: calc(100vh - var(--header-h) - var(--status-h));
    height: calc(100dvh - var(--header-h) - var(--status-h) - env(safe-area-inset-bottom, 0px));
    min-height: 460px;
    overflow: hidden;
    background: #0b0d12 radial-gradient(ellipse at 50% 120%, #2a1a12 0%, #0b0d12 60%);
    font-family: var(--font-mono);
    color: #e8e6e3;
    user-select: none;
    -webkit-user-select: none;
}
.ml:fullscreen { height: 100vh; }
.ml-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; opacity: 0; transition: opacity 1.2s ease; }
.ml.is-live .ml-canvas { opacity: 1; }

/* ---------- overlays (start, pause) ---------- */
.ml-overlay {
    position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; overflow-y: auto;
    background: color-mix(in srgb, #08080a 62%, transparent);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.ml-overlay[hidden] { display: none; }
.ml-card { width: min(680px, 100%); padding: 28px 30px 22px; background: color-mix(in srgb, #121216 94%, transparent); border-color: #2c2c35; }
.ml-card-wide { width: min(980px, 100%); }
.ml-title { font: 700 clamp(40px, 7vw, 68px)/0.95 var(--font-display); text-transform: uppercase; letter-spacing: 0.01em; margin: 10px 0 14px; color: #f3f1ee; }
.ml-title em { font-style: normal; color: #ff6b35; }
.ml-title-sm { font-size: clamp(26px, 4vw, 36px); margin: 0; }
.ml-lead { font: 400 15px/1.6 var(--font-body); color: #b9b5b0; max-width: 60ch; }

.ml-quality { border: 0; margin: 20px 0 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ml-quality legend { float: left; margin-right: 12px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: #8a8580; padding: 0; }
.ml-quality label { cursor: pointer; }
.ml-quality input { position: absolute; opacity: 0; pointer-events: none; }
.ml-quality span { display: block; padding: 6px 14px; border: 1px solid #35353f; font-size: 12px; color: #b9b5b0; }
.ml-quality input:checked + span { border-color: #ff6b35; color: #ff6b35; background: color-mix(in srgb, #ff6b35 10%, transparent); }
.ml-quality input:focus-visible + span { outline: 2px solid #ff6b35; outline-offset: 2px; }

.ml-actions { margin-top: 20px; display: flex; align-items: center; gap: 16px; min-height: 48px; }
.ml-play {
    font: 700 16px var(--font-display); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
    padding: 13px 34px; border: 0; background: #ff6b35; color: #1a0a02;
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
    transition: transform 0.12s ease, filter 0.12s ease;
}
.ml-play:hover { filter: brightness(1.12); transform: translateY(-1px); }
.ml-play:disabled { filter: grayscale(0.7) brightness(0.7); cursor: progress; transform: none; }
.ml-progress { position: relative; flex: 1; height: 26px; border: 1px solid #35353f; overflow: hidden; }
.ml-progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: color-mix(in srgb, #ff6b35 35%, transparent); transition: width 0.3s ease; }
.ml-progress span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: #d6d2cd; }
.ml-error { margin-top: 12px; color: #ff3b6b; font-size: 13px; }

.ml-keys { margin: 22px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 18px; font-size: 12px; }
.ml-keys div { display: flex; align-items: baseline; gap: 10px; }
.ml-keys dt { flex: none; min-width: 74px; }
.ml-keys dd { margin: 0; color: #a09c98; }
.ml kbd { font: 500 11px var(--font-mono); padding: 2px 6px; border: 1px solid #3a3a45; border-bottom-width: 2px; color: #e8e6e3; background: #18181d; white-space: nowrap; }
.ml-credits { margin-top: 18px; padding-top: 12px; border-top: 1px solid #26262d; font-size: 10.5px; line-height: 1.6; color: #77736f; }
.ml-credits a { color: #a09c98; }

/* ---------- pause ---------- */
.ml-pause-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.ml-pause-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(220px, 1fr); gap: 22px; }
.ml-bigmap canvas { width: 100%; height: auto; aspect-ratio: 1; display: block; border: 1px solid #2c2c35; background: #0d0e12; cursor: crosshair; }
.ml-hint { margin-top: 8px; font-size: 11px; color: #77736f; }
.ml-side h3 { font: 500 10px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: #8a8580; margin: 0 0 8px; }
.ml-side h3::before { content: "// "; color: #ff6b35; }
.ml-side h3:not(:first-child) { margin-top: 18px; }
.ml-places { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; max-height: 250px; overflow-y: auto; scrollbar-width: thin; }
.ml-places button { width: 100%; text-align: left; font: 500 12.5px var(--font-mono); color: #d6d2cd; background: none; border: 1px solid transparent; padding: 6px 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.ml-places button:hover, .ml-places button:focus-visible { border-color: #ff6b35; color: #ff6b35; }
.ml-places small { color: #77736f; font-size: 10.5px; }
.ml-range { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.ml-range input { flex: 1; accent-color: #ff6b35; }
.ml-check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; color: #b9b5b0; cursor: pointer; }
.ml-check input { accent-color: #ff6b35; }

/* ---------- HUD ---------- */
.ml-hud { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.ml-hud[hidden] { display: none; }
.ml-hud > * { position: absolute; }

.ml-radar { top: 16px; right: 16px; width: 176px; height: 176px; border: 1px solid #35353f; background: #0d0e12; clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px); }
.ml-radar canvas { width: 100%; height: 100%; display: block; }
.ml-north { position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px; display: grid; place-items: center; font: 700 10px var(--font-mono); color: #ff6b35; text-shadow: 0 0 4px #000; }

.ml-where { left: 18px; bottom: 18px; display: grid; gap: 2px; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85); }
.ml-district { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: #ff6b35; }
.ml-street { font: 600 clamp(18px, 2.6vw, 26px)/1.1 var(--font-display); color: #f3f1ee; }
.ml-coords { font-size: 10.5px; color: #b9b5b0; font-variant-numeric: tabular-nums; }

.ml-status { top: 200px; right: 16px; width: 176px; display: flex; justify-content: space-between; font-size: 13px; font-variant-numeric: tabular-nums; padding: 5px 9px; background: color-mix(in srgb, #0d0e12 80%, transparent); border: 1px solid #2c2c35; }
.ml-clock { color: #e8e6e3; }
.ml-cash { color: #ffd166; font-weight: 700; }

.ml-speed { right: 18px; bottom: 16px; display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: 8px; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85); }
.ml-speed[hidden] { display: none; }
.ml-speed b { font: 700 clamp(40px, 6vw, 60px)/0.9 var(--font-display); color: #f3f1ee; font-variant-numeric: tabular-nums; min-width: 2.1ch; text-align: right; }
.ml-speed span { font-size: 11px; letter-spacing: 0.12em; color: #b9b5b0; }
.ml-speed i { grid-column: 1 / -1; justify-self: end; font-style: normal; font-size: 11px; color: #ff6b35; letter-spacing: 0.2em; }

.ml-job { top: 16px; left: 18px; max-width: min(360px, 60vw); padding: 10px 12px; font-size: 12.5px; line-height: 1.5; background: color-mix(in srgb, #0d0e12 84%, transparent); border: 1px solid #2c2c35; border-left: 3px solid #ff6b35; }
.ml-job[hidden] { display: none; }
.ml-job b { display: block; font: 600 14px var(--font-display); letter-spacing: 0.04em; text-transform: uppercase; color: #ff6b35; }
.ml-job small { color: #a09c98; }

.ml-prompt { left: 50%; bottom: 20%; transform: translateX(-50%); padding: 8px 14px; font-size: 13px; background: color-mix(in srgb, #0d0e12 84%, transparent); border: 1px solid #35353f; white-space: nowrap; }
.ml-prompt[hidden] { display: none; }
.ml-toast { left: 50%; top: 18%; transform: translateX(-50%); font: 600 clamp(18px, 3vw, 28px) var(--font-display); letter-spacing: 0.06em; text-transform: uppercase; color: #f3f1ee; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9); opacity: 0; transition: opacity 0.5s ease; text-align: center; white-space: nowrap; }
.ml-toast.is-on { opacity: 1; }
.ml-toast small { display: block; font: 500 12px var(--font-mono); letter-spacing: 0.14em; color: #ff6b35; margin-top: 4px; }
.ml-fps { left: 18px; top: 50%; font-size: 11px; color: #8fb8ff; white-space: pre; text-shadow: 0 1px 4px #000; }
.ml-fps[hidden] { display: none; }

/* ---------- touch controls: a stick on the left, the actions under the right thumb ---------- */
.ml-canvas { touch-action: none; }
.ml-touch { display: none; position: absolute; inset: 0; z-index: 6; pointer-events: none; -webkit-touch-callout: none; }
.ml.is-touch.is-live .ml-touch { display: block; }
.ml-touch > * { position: absolute; pointer-events: auto; touch-action: none; }
.ml-keys-touch, .ml.is-touch .ml-keys-desk { display: none; }
.ml.is-touch .ml-keys-touch { display: grid; }
.ml.is-touch .ml-keys dt { min-width: 0; }

.ml-stick { left: max(22px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom)); width: 132px; height: 132px; border-radius: 50%; border: 1px solid color-mix(in srgb, #f3f1ee 34%, transparent); background: color-mix(in srgb, #0d0e12 38%, transparent); transition: border-color 0.12s ease; }
.ml-stick::before { content: ""; position: absolute; inset: -22px; border-radius: 50%; }      /* a wider target than the ring that shows */
.ml-stick i { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px; border-radius: 50%; background: color-mix(in srgb, #f3f1ee 30%, transparent); border: 1px solid color-mix(in srgb, #f3f1ee 55%, transparent); pointer-events: none; }
.ml-stick.is-on i { background: color-mix(in srgb, #ff6b35 55%, transparent); border-color: #ff6b35; }
.ml-stick.is-sprint { border-color: #ff6b35; box-shadow: 0 0 0 3px color-mix(in srgb, #ff6b35 30%, transparent); }

.ml-btn { display: grid; place-items: center; padding: 0; border-radius: 50%; border: 1px solid color-mix(in srgb, #f3f1ee 34%, transparent); background: color-mix(in srgb, #0d0e12 46%, transparent); color: #f3f1ee; font: 700 9.5px var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ml-btn.is-down { background: color-mix(in srgb, #ff6b35 60%, transparent); border-color: #ff6b35; color: #1a0a02; }
.ml-pad { right: max(18px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); width: 176px; height: 168px; pointer-events: none; }
.ml-pad .ml-btn { position: absolute; width: 60px; height: 60px; pointer-events: auto; touch-action: none; }
.ml-pad .ml-btn-main { right: 0; bottom: 0; width: 82px; height: 82px; font-size: 11px; border-color: color-mix(in srgb, #ff6b35 70%, transparent); }
.ml-pad .ml-btn-car { right: 96px; bottom: 6px; }
.ml-pad .ml-btn-job { right: 6px; bottom: 96px; }
.ml-pad .ml-btn-horn { right: 86px; bottom: 82px; }
.ml .in-car, .ml.in-car .on-foot, .ml .on-job, .ml.has-job .no-job { display: none; }
.ml.in-car span.in-car, .ml:not(.in-car) span.on-foot { display: inline; }
.ml.in-car .ml-btn.in-car, .ml.has-job .ml-btn.on-job { display: grid; }
.ml-top { top: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.ml-btn-sm { width: 42px; height: 42px; border-radius: 0; font-size: 12px; }
.ml-btn[hidden] { display: none; }

/* with thumbs on the bottom corners, the labels that lived there move up and to the middle */
.ml.is-touch .ml-where { left: 12px; top: 10px; bottom: auto; max-width: calc(50% - 60px); }
.ml.is-touch .ml-street { font-size: 16px; }
.ml.is-touch .ml-coords { display: none; }
.ml.is-touch .ml-job { top: 62px; left: 12px; max-width: min(300px, 56vw); font-size: 11.5px; }
.ml.is-touch .ml-speed { right: auto; left: 50%; bottom: 10px; transform: translateX(-50%); }
.ml.is-touch .ml-speed b { font-size: 34px; }
.ml.is-touch .ml-prompt { bottom: 204px; font-size: 11.5px; }
.ml.is-touch .ml-radar { width: 120px; height: 120px; top: 10px; right: 10px; }
.ml.is-touch .ml-status { top: 136px; right: 10px; width: 120px; font-size: 11px; }
/* a phone held sideways: little height, so the radar shrinks, the clock sits beside it and the prompt drops between the thumbs */
@media (max-height: 480px) {
    .ml.is-touch .ml-radar { width: 92px; height: 92px; }
    .ml.is-touch .ml-status { top: 10px; right: 110px; width: 112px; }
    .ml.is-touch .ml-prompt { bottom: 58px; }
    .ml.is-touch .ml-toast { top: 24%; }
}
@media (pointer: coarse) {
    .ml { min-height: 300px; }
}

@media (max-width: 720px) {
    .ml-card { padding: 20px 18px 16px; }
    .ml-pause-grid { grid-template-columns: 1fr; }
    .ml-radar { width: 120px; height: 120px; top: 10px; right: 10px; }
    .ml-status { top: 136px; right: 10px; width: 120px; font-size: 11px; }
    .ml-keys { grid-template-columns: 1fr 1fr; }
    .ml.is-touch .ml-keys { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    .ml-canvas, .ml-toast, .ml-play { transition: none; }
}
