:root {
  --bg: #0d111c; --panel: #161c2c; --panel2: #1e2639; --line: #2c3650; --text: #e6e9f2; --dim: #8e98b3;
  --amber: #ff9d2e; --teal: #35d0ba; --red: #e5484d; --green: #4cc38a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, sans-serif; }
#app { min-height: 100%; display: flex; flex-direction: column; }
main { flex: 1; display: flex; justify-content: center; padding: 14px; }
.screen { display: none; width: 100%; max-width: 1180px; }
.screen.on { display: block; }
h1, h2, h3 { margin: 0 0 8px; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; }
.dim { color: var(--dim); }
.spacer { flex: 1; }

#topbar { display: flex; align-items: center; gap: 18px; padding: 8px 18px; background: #090c14; border-bottom: 1px solid var(--line); }
.logo { font-weight: 900; letter-spacing: 3px; font-style: italic; cursor: pointer; font-size: 18px; }
.logo span { color: var(--amber); margin-left: 4px; }
#bar-cash { font: 700 18px Consolas, monospace; color: var(--green); }
#bar-day, #bar-car { color: var(--dim); }

.btn { background: var(--amber); color: #1a1205; border: 0; border-radius: 6px; padding: 9px 16px; font: 700 14px inherit; cursor: pointer; }
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.teal { background: var(--teal); }
.btn.red { background: var(--red); color: #fff; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.big { padding: 14px 26px; font-size: 17px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.row { display: flex; gap: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 14px; }
.kv b { color: var(--dim); font-weight: 500; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; color: #111; }
.warn { color: var(--amber); } .bad { color: var(--red); } .good { color: var(--green); }

/* Title */
.title-wrap { text-align: center; padding: 60px 20px; background: radial-gradient(ellipse at 50% 0, #3a2440 0, #0d111c 65%); border-radius: 14px; }
.title-wrap h1 { font-size: 72px; font-style: italic; letter-spacing: 6px; margin: 0; }
.title-wrap h1 span { color: var(--amber); display: block; }
.title-wrap .year { font: 700 22px Consolas, monospace; letter-spacing: 12px; color: var(--teal); margin: 6px 0 30px; }
.title-wrap p { max-width: 560px; margin: 10px auto; color: var(--dim); }

/* Garage */
body.full #app { height: 100%; }
body.full main { padding: 0; min-height: 0; }
#scr-garage { position: relative; max-width: none; min-height: 420px; }
.garage-view { position: absolute; inset: 0; overflow: hidden; background: #0b0d12; }
#garage-cv { width: 100%; display: block; }
#garage-gl { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; position: absolute; inset: 0; }
#garage-gl:active { cursor: grabbing; }
.garage-hint { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: #c4cbdd; background: rgba(4,6,10,.55); padding: 3px 10px; border-radius: 4px; pointer-events: none; }
.garage-info { position: absolute; top: 12px; right: 12px; width: 290px; max-width: 46vw; max-height: calc(100% - 24px); overflow: auto; background: rgba(14,18,29,.82); backdrop-filter: blur(6px); }
#garage-tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.gtag { position: absolute; left: 0; top: 0; padding: 3px 10px; border-radius: 999px; white-space: nowrap; font-size: 12px; color: #e6e9f2; background: rgba(8,10,16,.7); border: 1px solid rgba(255,255,255,.2); }
.gtag small { color: #aab3ca; margin-left: 6px; font-size: 11px; }
.gtag small:empty { display: none; }
.gtag.on { color: var(--amber); border-color: var(--amber); background: rgba(8,10,16,.92); }
#scr-garage .garage-actions { position: absolute; left: 12px; right: 12px; bottom: 40px; margin: 0; }
#scr-garage.g3d .garage-actions { display: none; }
.garage-actions { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-top: 14px; }
.garage-actions .btn { padding: 16px 8px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.garage-actions .btn:hover { border-color: var(--amber); }
.garage-actions .btn.go { background: var(--amber); color: #1a1205; }
.garage-actions .btn small { display: block; font-weight: 400; color: var(--dim); font-size: 11px; margin-top: 2px; }
.garage-actions .btn.go small { color: #5a3a08; }
.carlist div { padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.carlist div:hover { background: var(--panel2); }
.carlist .sel { background: var(--panel2); border-left: 3px solid var(--amber); }

/* Engine bay */
.bay { display: grid; grid-template-columns: 1fr 340px; gap: 14px; }
.bay svg { width: 100%; background: radial-gradient(ellipse at 50% 40%, #232b3f, #111624); border: 1px solid var(--line); border-radius: 10px; }
.bay .part { cursor: pointer; }
.bay .part:hover .shape { filter: brightness(1.2); }
.bay .part.free .shape { animation: pulse 0.9s infinite alternate; }
.bay .part.sel .shape { stroke: #fff; stroke-width: 3; }
.bay .ghost { fill: rgba(255,255,255,.03); stroke: #5b6788; stroke-dasharray: 6 5; cursor: pointer; }
.bay .ghost:hover, .bay .ghost.sel { stroke: var(--amber); fill: rgba(255,157,46,.08); }
.bay .ghost.locked { stroke: #333c55; cursor: default; }
.bay .bolt { cursor: pointer; }
.bay .bolt:hover { stroke: #fff; stroke-width: 3; }
.bay text { fill: #c9d0e4; font: 11px "Segoe UI", sans-serif; pointer-events: none; }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.5); } }
.bay-side { display: flex; flex-direction: column; gap: 12px; }
.bay-side input[type=range] { width: 100%; accent-color: var(--amber); }
.issues { margin: 6px 0 0; padding-left: 18px; color: var(--amber); font-size: 13px; }
.dyno { font: 700 30px Consolas, monospace; color: var(--teal); }
.invrow { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.invrow .nm { flex: 1; }

/* Modal & toast */
#modal { position: fixed; inset: 0; background: rgba(4,6,12,.75); display: none; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
#modal.on { display: flex; }
#modal .box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; max-width: 640px; width: 100%; max-height: 88vh; overflow: auto; }
#toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #000; border: 1px solid var(--amber); color: var(--text); padding: 10px 18px; border-radius: 8px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 30; }
#toast.on { opacity: 1; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches i { width: 30px; height: 30px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.swatches i:hover { border-color: #fff; }

/* Meet */
.meet-head { background: linear-gradient(180deg, #2a1a3a, #161c2c); border-radius: 10px; padding: 18px; margin-bottom: 14px; border: 1px solid var(--line); }
.tiers { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tiers .btn.sel { border-color: var(--amber); color: var(--amber); }
.racers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.racer { display: grid; grid-template-columns: 230px 1fr; gap: 12px; align-items: center; }
.racer canvas { width: 230px; height: 96px; background: #0c0f18; border-radius: 8px; }
.racer .beaten { color: var(--green); font-size: 12px; font-weight: 700; }
.racer q { color: var(--dim); font-style: italic; font-size: 13px; display: block; margin: 3px 0 8px; }

/* Race */
.race-wrap { position: relative; max-width: 1180px; }
#race-gl { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 10px; display: none; }
#race-cv { position: relative; width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; background: #000; }

/* In-game browser + PistonPost site */
.browser { border: 1px solid #3a4258; border-radius: 10px; overflow: hidden; background: #dfe3ea; }
.b-tabs { background: #2a3040; padding: 6px 8px 0; display: flex; gap: 4px; align-items: flex-end; }
.b-tab { background: #dfe3ea; color: #222; padding: 6px 14px; border-radius: 8px 8px 0 0; font-size: 12px; }
.b-close { margin-left: auto; margin-bottom: 4px; }
.b-bar { display: flex; gap: 8px; padding: 6px 8px; background: #dfe3ea; align-items: center; }
.b-bar button { border: 0; background: #c9cfda; border-radius: 50%; width: 28px; height: 28px; cursor: pointer; font-weight: 700; }
.b-url { flex: 1; background: #fff; border-radius: 14px; padding: 5px 14px; color: #333; font: 13px Consolas, monospace; }
.b-page { background: #f4f5f7; color: #1c1f26; min-height: 560px; max-height: calc(100vh - 190px); overflow-y: auto; }
.pp-head { background: #14213d; color: #fff; padding: 12px 22px; display: flex; align-items: center; gap: 22px; position: sticky; top: 0; z-index: 2; }
.pp-logo { font-weight: 900; font-size: 22px; letter-spacing: -0.5px; cursor: pointer; }
.pp-logo b { color: #fca311; }
.pp-nav a { color: #cfd6e6; margin-right: 16px; cursor: pointer; font-weight: 600; font-size: 14px; }
.pp-nav a.on, .pp-nav a:hover { color: #fca311; }
.pp-wallet { margin-left: auto; font: 700 14px Consolas, monospace; background: #22335c; padding: 4px 12px; border-radius: 14px; }
.pp-body { padding: 18px 22px 40px; }
.pp-body h2 { font-size: 20px; }
.pp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.pp-card { background: #fff; border: 1px solid #d8dce4; border-radius: 8px; overflow: hidden; cursor: pointer; }
.pp-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.14); }
.pp-card canvas { width: 100%; display: block; background: linear-gradient(#cfd8e6, #9aa7bb 62%, #6d7482 62%, #868d9a); }
.pp-card .in { padding: 9px 12px 12px; }
.pp-card .t { font-weight: 700; color: #14213d; }
.pp-card .p { font: 800 19px inherit; color: #111; }
.pp-card .m { font-size: 12px; color: #6a7080; }
.pp-pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px; background: #e7eaf0; color: #444; margin: 0 4px 4px 0; cursor: pointer; border: 1px solid transparent; }
.pp-pill.on { background: #14213d; color: #fff; }
.pp-pill.hot { background: #ffe6bf; color: #7a4b00; cursor: default; }
.pp-btn { background: #fca311; border: 0; border-radius: 20px; padding: 9px 20px; font: 700 14px inherit; cursor: pointer; color: #14213d; }
.pp-btn:hover { filter: brightness(1.08); }
.pp-btn:disabled { opacity: .45; cursor: not-allowed; }
.pp-btn.alt { background: #fff; border: 1px solid #14213d; }
.pp-btn.sm { padding: 4px 12px; font-size: 12px; }
.pp-detail { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; }
.pp-detail canvas { width: 100%; border-radius: 8px; background: linear-gradient(#cfd8e6, #9aa7bb 62%, #6d7482 62%, #868d9a); }
.pp-box { background: #fff; border: 1px solid #d8dce4; border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.pp-price { font-size: 32px; font-weight: 800; }
.pp-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.pp-table td, .pp-table th { padding: 7px 10px; border-bottom: 1px solid #e3e6ec; text-align: left; }
.pp-table th { background: #eceff4; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: #555; }
.pp-body input[type=number] { padding: 8px 10px; border: 1px solid #b9c0cd; border-radius: 6px; width: 130px; font: 14px inherit; }
.pp-msg { background: #fff7e6; border-left: 4px solid #fca311; padding: 8px 12px; margin-top: 10px; font-size: 13px; }
.pp-filters { margin-bottom: 12px; }
.pp-filters span { font-size: 12px; color: #666; margin-right: 6px; font-weight: 700; }

@media (max-width: 900px) {
  .bay, .pp-detail { grid-template-columns: 1fr; }
  .garage-actions { grid-template-columns: repeat(3, 1fr); }
  .racers { grid-template-columns: 1fr; }
}
