@font-face { font-family: 'Oswald'; src: url('assets/fonts/oswald.woff') format('woff'); font-weight: 200 700; font-display: block; }
@font-face { font-family: 'RobotoC'; src: url('assets/fonts/robotocondensed.woff') format('woff'); font-weight: 100 900; font-display: block; }

:root {
  --bg: #16130f; --panel: rgba(24, 21, 18, 0.92); --panel2: rgba(36, 32, 27, 0.95); --line: rgba(255, 240, 220, 0.08);
  --text: #ddd4c6; --dim: #9a9082; --faint: #6d655a;
  --rust: #c9602c; --rust2: #e0773c; --green: #6f8f34; --green2: #88ab45; --red: #a8392c; --red2: #c64a3a; --blue: #3f6f9a; --gold: #d8a93a;
  --ok: #8fb24a; --warn: #d8a93a; --bad: #c7503c;
  --r: 3px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --u: min(1vw, 1.6vh);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: 'RobotoC', 'Arial Narrow', sans-serif; font-size: clamp(13px, calc(var(--u) * 1.55), 17px); touch-action: none; overscroll-behavior: none; }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.55) 100%); z-index: 1; }
#grain { position: fixed; inset: -50%; pointer-events: none; z-index: 2; opacity: 0.06; background-image: url('assets/tex/ui_noise.webp'); background-size: 256px; animation: grain 0.6s steps(4) infinite; mix-blend-mode: overlay; }
@keyframes grain { 0% { transform: translate(0,0) } 25% { transform: translate(-7%,4%) } 50% { transform: translate(5%,-6%) } 75% { transform: translate(-3%,-3%) } }
#ui { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#ui > * { pointer-events: auto; }
/* full-screen overlay layers must never swallow taps meant for the HUD or the 3D view */
#ui > .marker-layer, #ui > .toasts, #ui > .floaty, #ui > .caption, #ui > .letterbox { pointer-events: none; }
#ui svg { fill: currentColor; }
.days .d svg { width: 34px; height: 34px; color: var(--gold); }
#ui .pass { pointer-events: none; }
#ui .pass > * { pointer-events: auto; }

/* ---------- boot ---------- */
#boot { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 40%, #2a221b 0%, #110e0b 70%); transition: opacity .6s; }
#boot.hide { opacity: 0; pointer-events: none; }
.boot-inner { width: min(460px, 80vw); text-align: center; }
.boot-logo { font-family: 'Oswald'; font-weight: 700; line-height: .9; letter-spacing: .04em; }
.boot-logo .l1 { display: block; font-size: clamp(42px, 9vw, 86px); color: #d9c7a8; text-shadow: 0 4px 0 #3a2618; }
.boot-logo .l2 { display: block; font-size: clamp(56px, 12vw, 116px); color: var(--rust); text-shadow: 0 5px 0 #3a1a0c; }
.boot-sub { margin-top: 10px; font-family: 'Oswald'; letter-spacing: .3em; text-transform: uppercase; color: var(--dim); font-size: 14px; }
.boot-bar { margin: 34px auto 12px; height: 6px; background: rgba(255,255,255,.06); position: relative; overflow: hidden; }
#bootFill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #8a3c1a, var(--rust2)); transition: width .25s; }
.boot-tip { font-size: 13px; color: var(--faint); min-height: 1.4em; }

/* ---------- common ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 10px 40px rgba(0,0,0,.5); position: relative; }
.panel::before { content: ''; position: absolute; inset: 0; background: url('assets/tex/ui_noise.webp'); opacity: .05; pointer-events: none; border-radius: inherit; }
.h1 { font-family: 'Oswald'; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: 1.9em; color: #e8dcc8; }
.h2 { font-family: 'Oswald'; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; font-size: 1.25em; color: #e0d4c0; }
.h3 { font-family: 'Oswald'; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; font-size: .95em; color: var(--dim); }
.dim { color: var(--dim); } .faint { color: var(--faint); } .ok { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--warn); } .gold { color: var(--gold); }
.row { display: flex; align-items: center; gap: .6em; } .col { display: flex; flex-direction: column; gap: .5em; } .grow { flex: 1; } .wrap { flex-wrap: wrap; }
.sep { height: 1px; background: var(--line); margin: .6em 0; }

.btn { font-family: 'Oswald'; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; font-size: 1em; color: #efe6d6; background: #3a342c; border: 0; border-radius: var(--r); padding: .7em 1.2em; min-height: 44px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .5em; position: relative; transition: filter .12s, transform .08s, background .12s; box-shadow: inset 0 -3px 0 rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.06); white-space: nowrap; }
.btn:hover { filter: brightness(1.18); } .btn:active { transform: translateY(1px); filter: brightness(.95); }
.btn.green { background: var(--green); } .btn.red { background: var(--red); } .btn.rust { background: var(--rust); } .btn.blue { background: var(--blue); } .btn.gold { background: #9a7424; }
.btn.ghost { background: rgba(255,255,255,.05); }
.btn.big { font-size: 1.25em; padding: .8em 1.8em; min-height: 56px; }
.btn.small { font-size: .85em; padding: .45em .8em; min-height: 36px; }
.btn.icon { padding: 0; width: 48px; height: 48px; min-height: 48px; }
.btn[disabled], .btn.disabled { opacity: .4; pointer-events: none; filter: grayscale(.6); }
.btn .ad { display: inline-flex; align-items: center; justify-content: center; background: rgba(0,0,0,.35); border-radius: 2px; font-size: .7em; padding: .15em .4em; letter-spacing: .05em; }
.btn svg, .ico svg { width: 1.3em; height: 1.3em; fill: currentColor; }
.ico { display: inline-flex; width: 1.3em; height: 1.3em; align-items: center; justify-content: center; }
.pill { display: inline-flex; align-items: center; gap: .35em; background: rgba(0,0,0,.35); border-radius: 20px; padding: .25em .7em; font-weight: 600; }
.tag { display: inline-block; font-size: .75em; font-family: 'Oswald'; letter-spacing: .06em; text-transform: uppercase; padding: .1em .5em; border-radius: 2px; background: rgba(255,255,255,.08); color: var(--dim); }
.tag.new { background: #2f4a1c; color: #b8d884; } .tag.used { background: #4a3a1c; color: #e0c080; } .tag.old { background: #4a221c; color: #e09080; } .tag.restored { background: #1c3a4a; color: #88c8e0; }

.bar { height: 8px; background: rgba(255,255,255,.08); border-radius: 1px; overflow: hidden; position: relative; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--rust); transition: width .3s; }
.bar.green > i { background: var(--green2); } .bar.gold > i { background: var(--gold); }
.cond { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- HUD ---------- */
.hud-top { position: absolute; top: calc(8px + var(--safe-t)); left: 8px; right: 8px; display: flex; align-items: flex-start; gap: 8px; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.res { display: flex; gap: 6px; flex-wrap: wrap; }
.res .chip { display: flex; align-items: center; gap: .4em; background: var(--panel); border: 1px solid var(--line); padding: .35em .75em .35em .45em; border-radius: var(--r); font-family: 'Oswald'; font-size: 1.05em; min-height: 38px; }
.res .chip .ico { color: var(--gold); } .res .chip.scrap .ico { color: #b0a898; } .res .chip.rep .ico { color: #e08a4a; }
.res .chip.lvl { gap: .5em; } .res .chip.lvl .bar { width: 70px; height: 6px; }
.hud-right { margin-left: auto; display: flex; gap: 6px; }
.day-card { background: var(--panel); border: 1px solid var(--line); padding: .35em .8em; border-radius: var(--r); font-family: 'Oswald'; min-height: 38px; display: flex; flex-direction: column; justify-content: center; line-height: 1.15; }
.day-card small { font-family: 'RobotoC'; color: var(--dim); font-size: .78em; }
.goal { position: absolute; top: calc(58px + var(--safe-t)); left: 8px; max-width: min(360px, 60vw); background: linear-gradient(90deg, rgba(24,21,18,.9), rgba(24,21,18,.55)); border-left: 3px solid var(--rust); padding: .45em .8em; border-radius: 0 var(--r) var(--r) 0; font-size: .95em; pointer-events: auto; }
.goal b { font-family: 'Oswald'; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--rust2); font-size: .85em; display: block; }
.hud-bottom { position: absolute; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); display: flex; align-items: flex-end; gap: 8px; pointer-events: none; }
.hud-bottom > * { pointer-events: auto; }
.dock { display: flex; gap: 6px; flex-wrap: wrap; }
.dock .btn { flex-direction: column; gap: 2px; min-width: 74px; padding: .4em .5em; font-size: .78em; min-height: 62px; }
.dock .btn svg { width: 24px; height: 24px; }
.dock .btn .dot { position: absolute; top: 5px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--red2); box-shadow: 0 0 0 2px #1a1714; }
.bigaction { margin-left: auto; }

/* ---------- windows ---------- */
.modal-back { position: absolute; inset: 0; background: rgba(8,6,4,.55); display: flex; align-items: center; justify-content: center; padding: 12px; animation: fadein .18s; z-index: 20; }
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
.win { width: min(900px, 96vw); max-height: min(92vh, 900px); display: flex; flex-direction: column; animation: pop .2s cubic-bezier(.2,1.4,.4,1); }
.win.narrow { width: min(520px, 96vw); }
@keyframes pop { from { transform: scale(.94); opacity: 0 } to { transform: none; opacity: 1 } }
.win-head { display: flex; align-items: center; gap: .6em; padding: .7em .9em; border-bottom: 1px solid var(--line); background: rgba(0,0,0,.2); }
.win-head .h2 { flex: 1; }
.win-body { padding: .9em; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.win-foot { padding: .7em .9em; border-top: 1px solid var(--line); display: flex; gap: .6em; justify-content: flex-end; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; padding: 0 .9em; background: rgba(0,0,0,.2); overflow-x: auto; }
.tabs .t { font-family: 'Oswald'; text-transform: uppercase; letter-spacing: .06em; padding: .7em 1em; color: var(--dim); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; position: relative; }
.tabs .t.on { color: #efe4d2; border-color: var(--rust); }
.tabs .t .dot { position: absolute; top: 8px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--red2); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: .6em; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: .7em; display: flex; flex-direction: column; gap: .45em; position: relative; }
.card.locked { opacity: .55; } .card.owned { border-color: rgba(143,178,74,.35); } .card.sel { border-color: var(--rust); box-shadow: 0 0 0 1px var(--rust) inset; }
.card .title { font-family: 'Oswald'; font-weight: 500; letter-spacing: .03em; font-size: 1.05em; color: #eadfcc; }
.card .desc { color: var(--dim); font-size: .9em; line-height: 1.3; }
.card .icon-big { width: 44px; height: 44px; border-radius: var(--r); background: rgba(0,0,0,.3); display: flex; align-items: center; justify-content: center; color: var(--rust2); flex: none; }
.card .icon-big svg { width: 28px; height: 28px; fill: currentColor; }
.list .item { display: flex; align-items: center; gap: .7em; padding: .55em .6em; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.list .item.click { cursor: pointer; } .list .item.click:hover { background: rgba(255,255,255,.03); }
.price { font-family: 'Oswald'; color: var(--gold); white-space: nowrap; }

/* ---------- repair side panel ---------- */
.side { position: absolute; top: calc(56px + var(--safe-t)); right: 8px; width: min(330px, 42vw); max-height: calc(100% - 150px - var(--safe-t) - var(--safe-b)); display: flex; flex-direction: column; }
.side .win-body { padding: .5em .6em; }
.order-card { padding: .6em .7em; border-bottom: 1px solid var(--line); }
.order-card .who { font-family: 'Oswald'; font-size: 1.05em; color: #eadfcc; }
.order-card .complaint { color: var(--text); font-style: italic; line-height: 1.3; margin: .25em 0; }
.plist .grp { font-family: 'Oswald'; text-transform: uppercase; letter-spacing: .07em; font-size: .78em; color: var(--faint); margin: .7em 0 .25em; display: flex; align-items: center; gap: .4em; }
.plist .p { display: flex; align-items: center; gap: .5em; padding: .42em .5em; border-radius: var(--r); cursor: pointer; background: rgba(255,255,255,.02); margin-bottom: 3px; }
.plist .p:hover { background: rgba(255,255,255,.06); } .plist .p.sel { background: rgba(201,96,44,.22); box-shadow: inset 3px 0 0 var(--rust); }
.plist .p.lock { opacity: .45; } .plist .p.gone { opacity: .6; font-style: italic; }
.plist .p .n { flex: 1; font-size: .95em; }
.plist .p .c { font-family: 'Oswald'; font-size: .95em; min-width: 3em; text-align: right; }
.plist .p .flag { width: 8px; height: 8px; border-radius: 50%; background: transparent; flex: none; }
.plist .p .flag.fault { background: var(--red2); box-shadow: 0 0 6px var(--red2); }
.act-pop { position: absolute; left: calc((100% - min(330px, 42vw) - 16px) / 2); bottom: calc(92px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 6px; padding: 6px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - min(330px, 42vw) - 30px); }
.act-pop .lbl { width: 100%; text-align: center; font-family: 'Oswald'; letter-spacing: .05em; text-transform: uppercase; font-size: .9em; color: #eadfcc; }

/* ---------- 3D markers ---------- */
.marker-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.bolt { position: absolute; width: 58px; height: 58px; margin: -29px 0 0 -29px; pointer-events: auto; cursor: pointer; touch-action: none; }
.bolt svg { width: 100%; height: 100%; overflow: visible; }
.bolt .bg { fill: rgba(20,16,12,.55); stroke: rgba(255,230,200,.8); stroke-width: 2; }
.bolt .ring { fill: none; stroke: var(--rust2); stroke-width: 5; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }
.bolt .hex { fill: #d8d0c0; }
.bolt.done { opacity: 0; transform: scale(1.6); transition: all .3s; }
.bolt.pulse .bg { animation: boltp 1.1s infinite; }
@keyframes boltp { 0%,100% { stroke: rgba(255,230,200,.8) } 50% { stroke: var(--rust2); } }
.poi { position: absolute; transform: translate(-50%, -100%); pointer-events: auto; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.poi .lab { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--rust); padding: .3em .6em; font-family: 'Oswald'; text-transform: uppercase; letter-spacing: .05em; font-size: .85em; white-space: nowrap; border-radius: var(--r); }
.poi .stem { width: 2px; height: 14px; background: rgba(255,230,200,.5); }
.poi.alert .lab { border-left-color: var(--gold); animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-4px) } }
.hold { position: absolute; width: 90px; height: 90px; margin: -45px 0 0 -45px; pointer-events: none; }

/* ---------- dialog ---------- */
.dialog { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--safe-b)); width: min(860px, 96vw); display: flex; gap: .9em; padding: .9em; align-items: flex-start; cursor: pointer; animation: slideup .25s; z-index: 30; }
@keyframes slideup { from { transform: translate(-50%, 20px); opacity: 0 } to { transform: translate(-50%, 0); opacity: 1 } }
.dialog .portrait { width: 92px; height: 92px; flex: none; border-radius: var(--r); background: #2a241e center/cover; border: 2px solid rgba(255,255,255,.08); }
.dialog .name { font-family: 'Oswald'; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--rust2); }
.dialog .text { font-size: 1.12em; line-height: 1.4; margin-top: .25em; min-height: 3em; }
.dialog .next { position: absolute; right: 12px; bottom: 8px; font-size: .8em; color: var(--faint); animation: bob 1s infinite; }
.dialog .choices { display: flex; gap: .5em; flex-wrap: wrap; margin-top: .6em; }
.letterbox::before, .letterbox::after { content: ''; position: fixed; left: 0; right: 0; height: 9vh; background: #000; z-index: 4; animation: lb .5s forwards; }
.letterbox::before { top: 0; } .letterbox::after { bottom: 0; }
@keyframes lb { from { height: 0 } to { height: 9vh } }
.skip { position: absolute; top: calc(12px + var(--safe-t)); right: 12px; z-index: 31; }
.caption { position: absolute; top: 14vh; left: 0; right: 0; text-align: center; font-family: 'Oswald'; font-size: clamp(22px, 4vw, 44px); letter-spacing: .12em; text-transform: uppercase; color: #eadfcc; text-shadow: 0 3px 12px rgba(0,0,0,.8); animation: capin 3.5s forwards; pointer-events: none; z-index: 32; }
.caption small { display: block; font-size: .45em; letter-spacing: .3em; color: var(--rust2); margin-top: .3em; }
@keyframes capin { 0% { opacity: 0; transform: translateY(10px) } 15%, 80% { opacity: 1; transform: none } 100% { opacity: 0 } }

/* ---------- toasts ---------- */
.toasts { position: absolute; left: 50%; top: calc(64px + var(--safe-t)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 40; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--rust); padding: .5em .9em; border-radius: var(--r); font-size: .98em; animation: toast 2.8s forwards; box-shadow: 0 6px 20px rgba(0,0,0,.5); display: flex; align-items: center; gap: .5em; max-width: 90vw; }
.toast.good { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); } .toast.gold { border-left-color: var(--gold); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-10px) } 8%, 85% { opacity: 1; transform: none } 100% { opacity: 0; transform: translateY(-6px) } }
.floaty { position: absolute; font-family: 'Oswald'; font-size: 1.6em; color: var(--gold); text-shadow: 0 2px 6px #000; pointer-events: none; animation: floaty 1.4s forwards; z-index: 41; white-space: nowrap; }
@keyframes floaty { from { transform: translate(-50%, 0); opacity: 1 } to { transform: translate(-50%, -70px); opacity: 0 } }

/* ---------- menu ---------- */
.menu { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 6vh 7vw; background: linear-gradient(90deg, rgba(10,8,6,.85) 0%, rgba(10,8,6,.55) 38%, rgba(10,8,6,0) 70%); }
.menu .logo { font-family: 'Oswald'; font-weight: 700; line-height: .88; margin-bottom: 4vh; }
.menu .logo .l1 { display: block; font-size: clamp(38px, 7vw, 92px); color: #d9c7a8; text-shadow: 0 4px 0 #3a2618; }
.menu .logo .l2 { display: block; font-size: clamp(50px, 9.5vw, 124px); color: var(--rust); text-shadow: 0 5px 0 #3a1a0c; }
.menu .logo small { display: block; font-size: clamp(12px, 1.4vw, 18px); letter-spacing: .4em; color: var(--dim); margin-top: .7em; font-weight: 400; }
.menu .btns { display: flex; flex-direction: column; gap: 8px; width: min(320px, 70vw); }
.menu .btns .btn { justify-content: flex-start; font-size: 1.15em; }
.menu .foot { position: absolute; left: 7vw; bottom: calc(3vh + var(--safe-b)); color: var(--faint); font-size: .85em; }

/* ---------- settings ---------- */
.setrow { display: flex; align-items: center; gap: 1em; padding: .55em 0; border-bottom: 1px solid var(--line); }
.setrow label { flex: 1; }
input[type=range] { -webkit-appearance: none; appearance: none; width: min(220px, 40vw); height: 30px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; background: rgba(255,255,255,.1); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; background: var(--rust2); border-radius: 2px; border: 2px solid #1a1612; }
input[type=range]::-moz-range-track { height: 6px; background: rgba(255,255,255,.1); }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; background: var(--rust2); border-radius: 2px; border: 2px solid #1a1612; }
.seg { display: inline-flex; background: rgba(0,0,0,.3); border-radius: var(--r); padding: 2px; }
.seg span { padding: .45em .8em; cursor: pointer; font-family: 'Oswald'; text-transform: uppercase; font-size: .85em; letter-spacing: .05em; color: var(--dim); border-radius: 2px; }
.seg span.on { background: var(--rust); color: #fff; }

/* ---------- daily ---------- */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.days .d { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: .5em .2em; text-align: center; display: flex; flex-direction: column; gap: .3em; align-items: center; font-size: .85em; }
.days .d.got { opacity: .5; } .days .d.today { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset, 0 0 18px rgba(216,169,58,.25); }
.days .d .n { font-family: 'Oswald'; color: var(--dim); }
.days .d .rw { font-family: 'Oswald'; color: var(--gold); font-size: 1.05em; }
@media (max-width: 560px) { .days { grid-template-columns: repeat(4, 1fr); } }

/* ---------- minigame ---------- */
.mg-hint { position: absolute; top: calc(64px + var(--safe-t)); left: 50%; transform: translateX(-50%); background: var(--panel); padding: .5em 1em; border-radius: var(--r); font-family: 'Oswald'; letter-spacing: .04em; text-align: center; max-width: 90vw; }
.meter { position: absolute; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); width: min(420px, 80vw); }
.meter .bar { height: 14px; }
.gearbox { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: calc(40px + var(--safe-b)); gap: 12px; }
.tacho { width: min(420px, 86vw); height: 26px; background: rgba(0,0,0,.5); border: 1px solid var(--line); position: relative; border-radius: 2px; overflow: hidden; }
.tacho .zone { position: absolute; top: 0; bottom: 0; background: rgba(143,178,74,.45); }
.tacho .zone.perfect { background: rgba(216,169,58,.75); }
.tacho .needle { position: absolute; top: -2px; bottom: -2px; width: 4px; background: #fff; box-shadow: 0 0 8px #fff; }

/* ---------- misc ---------- */
.hidden { display: none !important; }
.center { text-align: center; }
.big-num { font-family: 'Oswald'; font-size: 2.2em; color: var(--gold); }
.portrait-sm { width: 46px; height: 46px; border-radius: var(--r); background: #2a241e center/cover; flex: none; }
.badge-ico { width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 35% 30%, #fff5, #0000 60%), var(--c, #555); border: 3px solid #0006; box-shadow: 0 2px 6px #0008; }
.badge-ico svg { width: 28px; height: 28px; fill: #fff8; }
.badge-ico.no { background: #2a2622; } .badge-ico.no svg { fill: #fff2; }
.rotate-hint { position: fixed; inset: 0; background: #110e0b; z-index: 100; display: none; align-items: center; justify-content: center; text-align: center; padding: 20px; font-family: 'Oswald'; font-size: 20px; color: var(--dim); }
@media (max-height: 460px) { .dock .btn { min-width: 60px; min-height: 52px; font-size: .7em; } .dock .btn svg { width: 20px; height: 20px; } .dialog .portrait { width: 64px; height: 64px; } }
::-webkit-scrollbar { width: 6px; } ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); } ::-webkit-scrollbar-track { background: transparent; }
.ib { width: 42px; height: 42px; flex: none; border-radius: var(--r); background: rgba(0,0,0,.3); display: flex; align-items: center; justify-content: center; color: var(--rust2); }
.ib svg { width: 26px; height: 26px; }
@media (max-height: 500px) {
  .side { top: calc(52px + var(--safe-t)); max-height: calc(100% - 60px - var(--safe-t) - var(--safe-b)); width: min(300px, 42vw); }
  .order-card { padding: .4em .55em; }
  .order-card .complaint { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .88em; }
  .order-card .portrait-sm { width: 34px; height: 34px; }
  .side .win-foot { padding: .4em .5em; gap: .3em; }
  .side .win-foot .btn { padding: .3em .55em; min-height: 34px; font-size: .78em; }
  .plist .p { padding: .3em .45em; }
  .act-pop { bottom: calc(64px + var(--safe-b)); left: calc((100% - min(300px, 42vw) - 16px) / 2); max-width: calc(100vw - min(300px, 42vw) - 30px); padding: 4px; }
  .act-pop .pdesc { display: none; }
  .act-pop .lbl { font-size: .8em; }
  .act-pop .btn { min-height: 42px; }
  .res .chip { min-height: 34px; padding: .25em .6em .25em .4em; font-size: .95em; }
  .btn.icon { width: 42px; height: 42px; min-height: 42px; }
  .day-card { min-height: 34px; }
  .win { max-height: 96vh; }
  .win-head { padding: .45em .7em; } .win-body { padding: .6em; } .win-foot { padding: .45em .7em; }
  .btn.big { font-size: 1.05em; padding: .55em 1.2em; min-height: 46px; }
}

/* ---------- touch controls ---------- */
.vstick { position: fixed; left: 0; top: 0; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; z-index: 6; pointer-events: none;
  background: radial-gradient(circle, rgba(20,16,12,.25) 0%, rgba(20,16,12,.45) 70%); border: 2px solid rgba(255,230,200,.35); box-shadow: 0 0 0 1px rgba(0,0,0,.3); }
.vstick .knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #e8874e, #b0501f 70%); border: 2px solid rgba(255,235,210,.8); box-shadow: 0 3px 10px rgba(0,0,0,.5); }
.vstick.hidden { display: none; }
.stick-ghost { display: none; position: absolute; left: calc(26px + var(--safe-l, 0px)); bottom: calc(26px + var(--safe-b)); width: 104px; height: 104px; border-radius: 50%; pointer-events: none !important;
  border: 2px dashed rgba(255,230,200,.35); background: rgba(20,16,12,.18); }
.stick-ghost .knob { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(232,135,78,.45); border: 2px solid rgba(255,235,210,.45); animation: ghostknob 2.4s ease-in-out infinite; }
.stick-ghost span { position: absolute; left: 0; right: 0; bottom: -22px; text-align: center; font-family: 'Oswald'; text-transform: uppercase; letter-spacing: .1em; font-size: 12px; color: rgba(255,235,210,.7); text-shadow: 0 1px 3px #000; }
@keyframes ghostknob { 0%,100% { transform: translate(0,0) } 25% { transform: translate(0,-22px) } 50% { transform: translate(20px,0) } 75% { transform: translate(-18px,8px) } }
body.touch .stick-ghost { display: block; }
body.touch .stick-ghost.used { display: none; }
body.touch.stick-on .stick-ghost { display: none; }
/* context action: use what is next to you */
.ctx { position: absolute; right: calc(8px + var(--safe-r, 0px)); bottom: calc(86px + var(--safe-b)); pointer-events: none; }
.ctx > * { pointer-events: auto; }
.ctx-btn { gap: .5em; padding: .5em 1em .5em .7em; min-height: 50px; font-size: 1em; border-color: rgba(216,169,58,.6) !important; animation: ctxin .2s ease-out; }
.ctx-btn svg { width: 24px; height: 24px; color: var(--gold); }
.ctx-btn kbd { font-family: 'Oswald'; font-size: .72em; border: 1px solid var(--line); border-radius: 3px; padding: 0 .35em; color: var(--faint); margin-left: .2em; }
body.touch .ctx-btn kbd { display: none; }
@keyframes ctxin { from { transform: translateY(8px); opacity: 0 } to { transform: none; opacity: 1 } }
/* bigger touch targets for world markers */
body.touch .poi .lab { padding: .5em .8em; font-size: .9em; min-height: 34px; display: flex; align-items: center; }
body.touch .poi { padding: 6px; }
/* phone HUD: stick area bottom-left, tools + main action bottom-right */
body.touch .hud-bottom .dock { margin-left: auto; flex-wrap: nowrap; }
body.touch .hud-bottom .dock.left { margin-left: 0; }
body.touch .bigaction { margin-left: 0; }
body.touch .plist .p { min-height: 36px; }
/* controls help */
.ctrl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7em; }
.ctrl-grid .c { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: .7em; display: flex; flex-direction: column; align-items: center; gap: .4em; text-align: center; }
.ctrl-grid .c svg { width: 40px; height: 40px; color: var(--rust2); }
.ctrl-grid .c b { font-family: 'Oswald'; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: #eadfcc; }
.ctrl-grid .c span { color: var(--dim); font-size: .9em; line-height: 1.3; }
@media (max-height: 500px) {
  body.touch .dock .btn { min-width: 50px; min-height: 50px; padding: .3em .35em; font-size: .6em; }
  body.touch .dock .btn svg { width: 20px; height: 20px; }
  body.touch .bigaction .btn.big { min-height: 50px; padding: .4em 1em; font-size: 1em; }
  .goal { display: block; top: calc(50px + var(--safe-t)); font-size: .8em; padding: .3em .6em; max-width: min(300px, 44vw); }
  .goal.hidden { display: none !important; }
  .ctx { bottom: calc(66px + var(--safe-b)); }
  .ctrl-grid .c { padding: .45em; } .ctrl-grid .c svg { width: 30px; height: 30px; }
  .stick-ghost { width: 90px; height: 90px; left: 22px; bottom: 30px; }
}
@media (max-height: 500px) {
  .menu { padding: 3vh 5vw; justify-content: center; }
  .menu .logo { margin-bottom: 2.5vh; }
  .menu .logo .l1 { font-size: clamp(30px, 11vh, 60px); }
  .menu .logo .l2 { font-size: clamp(38px, 14vh, 78px); }
  .menu .logo small { margin-top: .4em; }
  .menu .btns { gap: 6px; width: min(300px, 44vw); }
  .menu .btns .btn { min-height: 40px; padding: .45em 1em; font-size: 1em; }
  .menu .btns .btn.big { min-height: 44px; }
  .menu .foot { bottom: 6px; font-size: .75em; }
}

/* ---------- portrait phones: the game is fully playable held upright ---------- */
@media (orientation: portrait) {
  .hud-top { flex-wrap: wrap; gap: 5px; }
  .res { gap: 4px; }
  .res .chip { min-height: 34px; padding: .25em .55em .25em .4em; font-size: .95em; }
  .res .chip.lvl .bar { width: 36px; }
  .hud-right { gap: 4px; }
  .day-card { min-height: 34px; padding: .2em .55em; font-size: .9em; }
  .day-card small { display: none; }
  .btn.icon { width: 40px; height: 40px; min-height: 40px; }
  .goal { display: block; top: calc(52px + var(--safe-t)); font-size: .82em; max-width: 70vw; padding: .3em .6em; }
  .goal.hidden { display: none !important; }
  .hud-bottom { flex-direction: column; align-items: stretch; gap: 8px; }
  .hud-bottom .bigaction { order: -1; margin-left: auto; align-self: flex-end; }
  body.touch .hud-bottom .dock, .hud-bottom .dock { margin-left: 0; flex-wrap: nowrap; justify-content: space-between; gap: 4px; }
  .dock .btn, body.touch .dock .btn { flex: 1 1 0; min-width: 0; min-height: 52px; padding: .3em .1em; font-size: .6em; }
  .dock .btn svg { width: 20px; height: 20px; }
  .dock .btn span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .ctx { bottom: calc(136px + var(--safe-b)); }
  .stick-ghost { bottom: calc(160px + var(--safe-b)); left: 26px; width: 96px; height: 96px; }
  .btn.big, body.touch .bigaction .btn.big { min-height: 50px; padding: .45em 1.1em; font-size: 1.05em; }
  /* repair: the part list becomes a bottom sheet, the car sits above it */
  .side { top: auto; bottom: calc(8px + var(--safe-b)); left: 8px; right: 8px; width: auto; max-height: 44vh; }
  .side .order-card .complaint { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .88em; }
  .act-pop { left: 50%; bottom: calc(44vh + 16px + var(--safe-b)); width: max-content; max-width: 94vw; padding: 4px; }
  .act-pop .pdesc { display: none; }
  .dock.left { display: none; }
  .dialog { width: 96vw; padding: .7em; gap: .6em; }
  .dialog .portrait { width: 58px; height: 58px; }
  .dialog .text { font-size: 1em; }
  .menu { padding: 8vh 7vw; background: linear-gradient(180deg, rgba(10,8,6,.2) 0%, rgba(10,8,6,.7) 45%, rgba(10,8,6,.9) 100%); justify-content: flex-end; }
  .menu .logo .l1 { font-size: 13vw; } .menu .logo .l2 { font-size: 17vw; }
  .menu .btns { width: 100%; }
  .menu .foot { left: 7vw; }
  .win { max-height: 88vh; }
  .mg-hint { top: calc(96px + var(--safe-t)); }
  .toasts { top: calc(100px + var(--safe-t)); }
}

.subtitle { position: absolute; left: 50%; transform: translateX(-50%); top: 24%; max-width: min(640px, 70vw); background: rgba(12,10,8,.72); padding: .4em .9em; border-radius: var(--r); font-size: 1em; text-align: center; pointer-events: none !important; z-index: 12; animation: fadein .2s; transition: opacity .4s; }
.subtitle b { color: var(--rust2); font-family: 'Oswald'; font-weight: 500; letter-spacing: .04em; }
.subtitle.out { opacity: 0; }
.dialog.speaking .portrait { box-shadow: 0 0 0 2px var(--rust2), 0 0 14px rgba(224,120,60,.45); }
@media (orientation: portrait) { .subtitle { top: 20%; max-width: 92vw; } }

/* radio */
.radio-face { display: flex; gap: .8em; align-items: center; background: linear-gradient(180deg, #3a2a1c, #22180f); border: 1px solid #5a4028; border-radius: var(--r); padding: .7em .8em; box-shadow: inset 0 2px 10px rgba(0,0,0,.5); }
.radio-face .dial { position: relative; flex: 1; height: 38px; border-radius: 3px; background: repeating-linear-gradient(90deg, rgba(255,220,160,.35) 0 1px, transparent 1px 12px), linear-gradient(180deg, #e8c890, #b89050); box-shadow: inset 0 0 12px rgba(80,40,0,.6); }
.radio-face .dial i { position: absolute; top: 3px; bottom: 3px; width: 3px; background: #c02a18; box-shadow: 0 0 6px #f04020; transition: left .5s cubic-bezier(.3,1.4,.5,1); }
.radio-face .np { min-width: 44%; }
.radio-face .np small { display: block; color: #c8a878; font-size: .78em; text-transform: uppercase; letter-spacing: .08em; }
.radio-face .np b { font-family: 'Oswald'; font-weight: 500; color: #f0dcb8; font-size: 1.05em; }
.st-grid { grid-template-columns: repeat(2, 1fr); }
.card.st { cursor: pointer; padding: .55em .7em; gap: .15em; }

.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); box-shadow: 0 1px 3px #0008; flex: none; }
.paints { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.paint-chip { display: flex; flex-direction: column; align-items: center; gap: .35em; padding: .55em .3em; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; font-size: .85em; text-align: center; position: relative; }
.paint-chip i { width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(255,255,255,.2); box-shadow: inset -6px -8px 12px rgba(0,0,0,.35), inset 4px 5px 8px rgba(255,255,255,.25); }
.paint-chip.want { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.paint-chip.want::after { content: '★'; position: absolute; top: 4px; right: 7px; color: var(--gold); }

/* map */
.mapwin { width: min(1000px, 97vw); }
.mapwrap { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: .8em; height: min(68vh, 620px); }
.mapcv { width: 100%; height: 100%; border-radius: var(--r); border: 1px solid var(--line); cursor: crosshair; touch-action: manipulation; }
.maplist { overflow-y: auto; touch-action: pan-y; }
.maplist .item { padding: .4em .5em; }
.maplist .item.alert { box-shadow: inset 3px 0 0 var(--gold); }
.grp-t { font-family: 'Oswald'; text-transform: uppercase; letter-spacing: .07em; font-size: .78em; color: var(--faint); margin: .6em 0 .2em; }
@media (orientation: portrait) { .mapwrap { grid-template-columns: 1fr; grid-template-rows: 46vh auto; height: auto; } .maplist { max-height: 30vh; } }
@media (max-height: 500px) { .mapwrap { height: 70vh; } }

/* ---------- driving ---------- */
.drive-ui { position: absolute; inset: 0; pointer-events: none !important; }
.drive-ui > * { pointer-events: auto; }
.dz-steer { position: absolute; left: calc(14px + var(--safe-l, 0px)); bottom: calc(14px + var(--safe-b)); width: min(44vw, 260px); height: min(42vh, 190px); display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: none; }
.dz-steer .ring { width: 120px; height: 120px; border-radius: 50%; border: 3px solid rgba(255,230,200,.35); background: rgba(20,16,12,.3); display: flex; align-items: center; justify-content: center; }
.dz-steer .knob { width: 92px; height: 92px; border-radius: 50%; border: 10px solid rgba(40,34,28,.9); box-shadow: inset 0 0 0 3px rgba(255,235,210,.35), 0 3px 10px #0008; position: relative; transition: transform .08s; }
.dz-steer .knob::before { content: ''; position: absolute; left: 50%; top: 50%; width: 70%; height: 10px; margin: -5px 0 0 -35%; background: rgba(40,34,28,.9); }
.dz-steer .knob::after { content: ''; position: absolute; left: 50%; top: 4px; width: 6px; height: 12px; margin-left: -3px; background: var(--rust2); border-radius: 2px; }
.dz-steer span { margin-top: 6px; font-family: 'Oswald'; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,235,210,.7); text-shadow: 0 1px 3px #000; }
.dz-right { position: absolute; right: calc(14px + var(--safe-r, 0px)); bottom: calc(14px + var(--safe-b)); display: flex; align-items: flex-end; gap: 12px; }
.pedal { width: 86px; height: 120px; border-radius: 10px; border: 2px solid rgba(255,235,210,.3); background: linear-gradient(180deg, #3a342c, #24201a); color: #e8dccb; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-family: 'Oswald'; text-transform: uppercase; letter-spacing: .06em; font-size: 13px; touch-action: none; box-shadow: inset 0 -4px 0 rgba(0,0,0,.4), 0 4px 12px #0007; }
.pedal svg { width: 34px; height: 34px; fill: currentColor; }
.pedal.gas { height: 140px; background: linear-gradient(180deg, #4a6a2a, #2c4218); }
.pedal.brake { background: linear-gradient(180deg, #7a2a1a, #4a1a10); }
.pedal.on { transform: translateY(3px) scale(.97); filter: brightness(1.25); }
.dbtn { width: 56px; height: 56px; }
.dz-top { position: absolute; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; }
.speedo { background: rgba(14,12,10,.75); border: 1px solid var(--line); border-radius: var(--r); padding: .2em .8em; font-family: 'Oswald'; display: flex; align-items: baseline; gap: .3em; }
.speedo b { font-size: 1.8em; color: #f0dcb8; min-width: 2.2ch; text-align: right; }
.speedo small { color: var(--dim); }
@media (max-height: 500px) { .pedal { width: 72px; height: 96px; } .pedal.gas { height: 112px; } .dz-steer .ring { width: 104px; height: 104px; } .dz-steer .knob { width: 80px; height: 80px; } }
@media (orientation: portrait) { .dz-steer { bottom: calc(150px + var(--safe-b)); } .dz-right { bottom: calc(20px + var(--safe-b)); } }

/* v3 (2026-10-31): touch-scroll fixes — header/tabs/footer never shrink, only the body scrolls */
.win-head, .tabs, .win-foot { flex: none; }
.win-body { flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
.tabs { touch-action: pan-x; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.maplist { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
@media (max-height: 500px) { .modal-back { padding: 8px; } .win { max-height: calc(100vh - 16px); } }
@supports (height: 100dvh) {
  .win { max-height: min(92dvh, 900px); }
  @media (max-height: 500px) { .win { max-height: calc(100dvh - 16px); } }
}
