:root {
  --bg: #10151f;
  --panel: rgba(16, 21, 31, 0.92);
  --text: #f4f6fb;
  --muted: #9aa6bd;
  --accent: #ffb020;
  --green: #3dff7a;
  --red: #ff3b3b;
  --blue: #4fc3ff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  --vw: 1vw; --vh: 1vh;
  --sa-top: env(safe-area-inset-top); --sa-right: env(safe-area-inset-right);
  --sa-bottom: env(safe-area-inset-bottom); --sa-left: env(safe-area-inset-left);
}
/* Rotated app (portrait phone): the screen's safe areas land on different app edges. */
html.force-land {
  --sa-top: env(safe-area-inset-right); --sa-right: env(safe-area-inset-bottom);
  --sa-bottom: env(safe-area-inset-left); --sa-left: env(safe-area-inset-top);
}
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  /* Only the 3D canvas swallows gestures; panels must keep native scrolling (iOS Safari). */
  touch-action: manipulation;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; }
html.force-land #app { transform-origin: 0 0; right: auto; bottom: auto; }
#rotate { display: none !important; }
html.need-rotate #rotate { display: flex !important; flex-direction: column; gap: 12px; z-index: 90; padding: 24px; }
#rotate .rot-icon { font-size: 54px; animation: rot-hint 1.6s ease-in-out infinite; }
@keyframes rot-hint { 50% { transform: rotate(-90deg); } }
#rotate small { color: var(--muted); font-size: 14px; font-weight: 600; }
#rotate button { font: inherit; font-weight: 800; font-size: 16px; padding: 12px 20px; border-radius: 12px; border: none; background: var(--accent); color: #2a1a00; }
/* Rotated counter-clockwise: the screen's safe areas land on other app edges. */
html.force-land-ccw {
  --sa-top: env(safe-area-inset-left); --sa-right: env(safe-area-inset-top);
  --sa-bottom: env(safe-area-inset-right); --sa-left: env(safe-area-inset-bottom);
}
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hidden { display: none !important; }

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

#topbar {
  position: absolute;
  top: max(10px, var(--sa-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(60 * var(--vw)), 560px);
}
#progress .track {
  position: relative;
  height: 10px;
  margin: 18px 10px 0;
  background: rgba(10, 14, 24, 0.7);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.finish-flag {
  position: absolute; right: -6px; top: -6px; width: 12px; height: 20px;
  background: repeating-conic-gradient(#fff 0 25%, #111 0 50%) 0 0 / 6px 6px;
  border-radius: 2px;
}
.mark {
  position: absolute; top: -18px; transform: translateX(-50%);
  font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; white-space: nowrap;
}
.mark::after {
  content: ""; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%);
  width: 8px; height: 8px; border-radius: 50%; background: inherit;
}
.mark.player { background: var(--blue); color: #002033; }
.mark.cpu { background: #ff6a3d; color: #2b0a00; top: 14px; }
.mark.cpu::after { bottom: auto; top: -8px; }
#topinfo {
  display: flex; justify-content: space-between; margin: 22px 10px 0;
  font-weight: 800; font-size: 15px; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

#tree {
  position: absolute; top: 80px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; padding: 10px 14px;
  background: rgba(10, 14, 24, 0.8); border-radius: 14px;
}
.lamp { width: 30px; height: 30px; border-radius: 50%; background: #2a2f3a; border: 2px solid #000; }
.lamp.amber.on { background: #ffb020; box-shadow: 0 0 18px #ffb020; }
.lamp.green.on { background: var(--green); box-shadow: 0 0 24px var(--green); }

.callout {
  position: absolute; top: 36%; left: 50%; transform: translate(-50%, -50%) scale(0.6);
  font-size: clamp(22px, calc(5 * var(--vw)), 48px); font-weight: 900; font-style: italic; letter-spacing: 1px;
  opacity: 0; transition: transform 0.15s, opacity 0.15s; white-space: nowrap;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.6), 0 0 18px rgba(0, 0, 0, 0.4);
}
.callout.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.callout.perfect { color: var(--green); }
.callout.good { color: #fff; }
.callout.bad { color: var(--red); }
.callout.nitro { color: var(--blue); }

#hint {
  position: absolute; top: 140px; left: 50%; transform: translateX(-50%);
  background: rgba(10, 14, 24, 0.8); padding: 8px 14px; border-radius: 10px;
  font-size: 14px; font-weight: 600; max-width: calc(70 * var(--vw)); text-align: center;
}

#gauge {
  position: absolute; bottom: max(6px, var(--sa-bottom)); left: 50%; transform: translateX(-50%);
  width: min(calc(42 * var(--vw)), 340px);
}
#tacho { width: 100%; height: auto; display: block; }
#gauge-center {
  position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%); text-align: center;
}
#gear { font-size: clamp(28px, calc(6 * var(--vw)), 52px); font-weight: 900; line-height: 1; color: var(--accent); }
.speed-wrap { font-weight: 800; font-size: clamp(14px, calc(2.6 * var(--vw)), 22px); text-shadow: 0 2px 3px #000; }
.speed-wrap small { font-size: 0.55em; margin-left: 3px; color: var(--muted); }

#btn-gas, #btn-nitro {
  position: absolute; pointer-events: auto; border: none; color: #fff; font-weight: 900;
  font-size: clamp(16px, calc(3 * var(--vw)), 24px); touch-action: none; cursor: pointer;
}
#btn-gas {
  right: max(18px, var(--sa-right)); bottom: max(18px, var(--sa-bottom));
  width: clamp(110px, calc(20 * var(--vw)), 170px); height: clamp(110px, calc(20 * var(--vw)), 170px); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4a556c, #222a3a);
  border: 4px solid rgba(255, 255, 255, 0.3); box-shadow: 0 6px 0 #0a0d14;
}
#btn-gas:active { transform: translateY(4px); box-shadow: 0 2px 0 #0a0d14; }
#btn-gas.shift-mode { background: radial-gradient(circle at 35% 30%, #5a6788, #2a3348); }
#btn-gas.ready {
  background: radial-gradient(circle at 35% 30%, #63ff9a, #12a84a);
  border-color: #b9ffd0; box-shadow: 0 6px 0 #0a5a28, 0 0 30px rgba(61, 255, 122, 0.7);
}
#btn-nitro {
  left: max(18px, var(--sa-left)); bottom: max(18px, var(--sa-bottom));
  width: clamp(96px, calc(16 * var(--vw)), 140px); height: clamp(96px, calc(16 * var(--vw)), 140px); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5fd2ff, #1268a8);
  border: 4px solid rgba(255, 255, 255, 0.35); box-shadow: 0 6px 0 #06304f;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
#btn-nitro:active { transform: translateY(4px); box-shadow: 0 2px 0 #06304f; }
#btn-nitro.active { box-shadow: 0 6px 0 #06304f, 0 0 34px rgba(79, 195, 255, 0.9); }
#btn-nitro.used { filter: grayscale(1) brightness(0.6); }
.nitro-bar { width: 60%; height: 6px; background: rgba(0, 0, 0, 0.4); border-radius: 3px; overflow: hidden; }
#nitro-fill { height: 100%; width: 100%; background: #fff; }

/* Overlays */
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(8, 11, 18, 0.55); z-index: 10; padding: 16px;
}
.panel {
  background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 18px;
  padding: 18px 26px; width: min(calc(92 * var(--vw)), 460px); max-height: calc(94 * var(--vh)); overflow: auto; text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
h1 { margin: 0; font-size: clamp(30px, calc(6 * var(--vw)), 46px); font-style: italic; font-weight: 900; letter-spacing: 1px; }
h1 span { color: var(--accent); }
.sub { margin: 4px 0 8px; color: var(--muted); }
.coins { margin-bottom: 12px; font-weight: 700; }
.coins b { color: var(--accent); }
.levels { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }
button { font-family: inherit; }
.panel button {
  border: 2px solid rgba(255, 255, 255, 0.2); background: #222a3a; color: var(--text);
  padding: 10px 18px; border-radius: 12px; font-weight: 800; font-size: 15px; cursor: pointer;
}
.panel button.selected { border-color: var(--accent); color: var(--accent); }
.panel button.primary {
  background: var(--accent); color: #2a1a00; border-color: var(--accent); font-size: 20px; padding: 12px 34px;
}
.help { margin-top: 12px; font-size: 13px; color: var(--muted); text-align: left; }
.help p { margin: 4px 0; }
.help b { color: var(--text); }

#result h2 { margin: 0 0 8px; font-size: 38px; font-style: italic; font-weight: 900; }
#result h2.win { color: var(--green); }
#result h2.lose { color: var(--red); }
#result table { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: 15px; }
#result td { padding: 4px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
#result td:first-child { text-align: left; color: var(--muted); }
#result td:last-child { text-align: right; font-weight: 800; }
#result .coin-row td:last-child { color: var(--accent); }
.row { display: flex; gap: 10px; justify-content: center; }

#loading { background: var(--bg); font-size: 18px; font-weight: 700; }

#rotate { display: none; background: var(--bg); z-index: 50; font-size: 20px; font-weight: 800; text-align: center; }

/* Shared */
.coin-i {
  display: inline-block; width: 0.9em; height: 0.9em; border-radius: 50%; margin-right: 4px; vertical-align: -0.1em;
  background: radial-gradient(circle at 35% 30%, #ffe27a, #e09a00); box-shadow: inset 0 0 0 2px #b97c00;
}
.muted { color: var(--muted); font-size: 13px; }
.level small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.panel button.link { background: none; border: none; color: var(--muted); font-size: 14px; text-decoration: underline; display: block; margin: 8px auto 0; }

/* Garage UI */
#garage-ui { position: absolute; inset: 0; pointer-events: none; }
#garage-ui button { pointer-events: auto; font-family: inherit; cursor: pointer; }
#g-top {
  position: absolute; top: max(10px, var(--sa-top)); left: max(14px, var(--sa-left));
  right: max(14px, var(--sa-right)); display: flex; justify-content: space-between; align-items: center;
}
#garage-ui.panel-open #g-top { right: calc(min(calc(46 * var(--vw)), 440px) + 14px); }
.brand {
  font-size: clamp(20px, calc(3.4 * var(--vw)), 30px); font-weight: 900; font-style: italic; color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 0 12px rgba(0, 0, 0, 0.25);
}
.brand span { color: var(--accent); }
.chips { display: flex; gap: 8px; }
.chip {
  background: var(--panel); border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15); display: flex; align-items: center; gap: 2px;
}
.chip .star { color: var(--accent); margin-right: 4px; }
button.chip.install { background: var(--accent); color: #2a1a00; border-color: var(--accent); cursor: pointer; font-family: inherit; }

#g-car-card {
  position: absolute; left: max(14px, var(--sa-left)); bottom: max(14px, var(--sa-bottom));
  background: var(--panel); border-radius: 14px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12); max-width: calc(40 * var(--vw));
}
#g-car-card small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
#g-car-card b { font-size: 17px; }
#g-car-card span { font-size: 13px; color: var(--accent); font-weight: 700; }

#g-nav {
  position: absolute; right: max(14px, var(--sa-right)); bottom: max(14px, var(--sa-bottom));
  display: flex; gap: 8px; align-items: flex-end;
}
#g-nav button, #decor-bar button {
  background: var(--panel); color: var(--text); border: 2px solid rgba(255, 255, 255, 0.18);
  padding: 12px 18px; border-radius: 14px; font-weight: 800; font-size: 15px;
}
#g-nav button.primary, #decor-bar button.primary {
  background: var(--accent); color: #2a1a00; border-color: var(--accent);
}
#g-nav button.primary { font-size: 20px; padding: 16px 28px; font-style: italic; }

#panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(calc(46 * var(--vw)), 440px); pointer-events: auto;
  background: var(--panel); border-left: 1px solid rgba(255, 255, 255, 0.12);
  display: flex; flex-direction: column; padding: max(10px, var(--sa-top)) max(14px, var(--sa-right)) 10px 14px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-head h3 { margin: 0; font-size: 18px; }
#panel-close { background: none; border: none; color: var(--text); font-size: 20px; padding: 4px 8px; }
#panel-tabs { display: flex; gap: 6px; margin: 8px 0; }
.tab {
  flex: 1; background: #222a3a; color: var(--muted); border: 2px solid transparent; border-radius: 10px;
  padding: 8px 6px; font-weight: 800; font-size: 13px;
}
.tab.on { color: var(--accent); border-color: var(--accent); }
#panel-scroll { overflow-y: auto; flex: 1; min-height: 0; padding-right: 4px; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

.stats { background: rgba(255, 255, 255, 0.04); border-radius: 12px; padding: 8px 10px; margin-bottom: 10px; }
.stat { display: grid; grid-template-columns: 56px 1fr auto; gap: 8px; align-items: center; font-size: 12px; margin: 3px 0; }
.stat span { color: var(--muted); }
.stat b { font-size: 12px; min-width: 70px; text-align: right; }
.bar { height: 7px; background: rgba(0, 0, 0, 0.4); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #3dff7a, #ffb020); border-radius: 4px; }
.estimate { font-size: 12px; margin-top: 6px; color: var(--muted); }
.estimate b { color: var(--text); }

.part, .dealer-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.part-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.part-info b { font-size: 15px; }
.part-info em { color: var(--accent); font-style: normal; font-size: 12px; }
.part-info small { color: var(--muted); font-size: 12px; }
.pips { display: flex; gap: 3px; }
.pips i { width: 16px; height: 5px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); }
.pips i.on { background: var(--accent); }
button.buy {
  background: #2e7d4f; color: #fff; border: none; border-radius: 10px; padding: 7px 12px; font-weight: 800;
  font-size: 12px; line-height: 1.3; min-width: 84px;
}
button.buy.sell { background: #7d3a2e; }
button.buy:disabled { background: #3a4252; color: #8992a3; cursor: default; }
.btn-col { display: flex; flex-direction: column; gap: 4px; }
.dealer-row img { width: 72px; height: 72px; object-fit: contain; background: rgba(255, 255, 255, 0.05); border-radius: 10px; }

#panel-body h4 { margin: 10px 0 6px; font-size: 14px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 8px; margin-bottom: 6px; }
.swatch { width: 100%; height: 38px; padding: 0; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.2); justify-self: center; max-width: 44px; }
.swatch.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.swatch.locked { opacity: 0.45; font-size: 14px; color: #fff; }
.glow-dot { border-radius: 50%; width: 30px; height: 30px; border: none; }
.cards { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding-bottom: 6px; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.card {
  flex: 0 0 auto; width: 92px; background: #222a3a; color: var(--text); border: 2px solid transparent;
  border-radius: 12px; padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.card.on { border-color: var(--accent); }
.card img { width: 70px; height: 70px; object-fit: contain; }
.card span { font-size: 12px; font-weight: 800; text-align: center; }
.card small { font-size: 11px; color: var(--muted); }
button.wide {
  width: 100%; margin-top: 10px; background: #222a3a; color: var(--text); border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px; padding: 10px; font-weight: 800;
}
.slider { margin: 8px 0; }
.slider label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 2px; }
.slider label span { color: var(--muted); }
.slider input { width: 100%; accent-color: var(--accent); }
.locked { background: rgba(255, 255, 255, 0.05); border-radius: 10px; padding: 10px; font-size: 13px; color: var(--muted); margin-top: 8px; }

#decor-bar {
  position: absolute; left: 0; right: 0; bottom: 0; pointer-events: auto;
  background: linear-gradient(transparent, rgba(8, 11, 18, 0.85) 30%);
  padding: 20px max(14px, var(--sa-right)) max(10px, var(--sa-bottom)) max(14px, var(--sa-left));
}
#decor-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
#decor-hint { font-size: 14px; font-weight: 700; text-shadow: 0 1px 2px #000; }
#decor-actions { display: flex; gap: 8px; margin-bottom: 8px; }
#decor-actions:empty { display: none; }
#decor-shop { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; touch-action: pan-x; }

#toast {
  position: absolute; top: 64px; left: 50%; transform: translate(-50%, -10px); opacity: 0;
  background: var(--panel); border: 1px solid var(--accent); padding: 8px 16px; border-radius: 10px;
  font-weight: 800; transition: opacity 0.2s, transform 0.2s; pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-color: var(--red); color: #ffb3b3; }

/* Narrow landscape: nav needs the full bottom row, so the active-car card moves under the brand. */
@media (max-width: 980px) {
  #g-car-card { bottom: auto; top: calc(max(10px, var(--sa-top)) + 46px); }
  #g-nav { left: max(14px, var(--sa-left)); justify-content: flex-end; flex-wrap: wrap; }
  #g-nav button { padding: 10px 12px; font-size: 14px; }
  #g-nav button.primary { padding: 12px 20px; font-size: 18px; }
}

/* M5d */
.sticker-icon { display: block; font-size: 30px; line-height: 70px; height: 70px; color: var(--accent); }
.tint-dot { display: inline-block; width: 38px; height: 26px; border-radius: 8px 8px 4px 4px; vertical-align: middle; border: 2px solid #cfd6e0; }
.dealer-row.dim { opacity: 0.55; }
.theme-swatch { display: block; width: 60px; height: 60px; border-radius: 10px; margin: 5px auto; border: 2px solid rgba(255, 255, 255, 0.25); }
.theme-swatch.checker { background: repeating-conic-gradient(#2b2f38 0 25%, #e8e8e8 0 50%) 0 0 / 20px 20px; }
.card.wall-item { border-color: rgba(79, 195, 255, 0.6); }
.rank-kinds { display: flex; gap: 6px; margin-bottom: 8px; }
#confirm-pop { z-index: 60; }
#confirm-pop h3 { margin: 4px 0 8px; font-size: 20px; }
#confirm-pop p { color: var(--muted); margin: 0 0 6px; font-size: 14px; }
#confirm-note { display: block; color: var(--muted); font-size: 12px; margin-bottom: 12px; min-height: 1em; }
#confirm-pop button:disabled { opacity: 0.45; cursor: default; }
.preview-bar {
  display: flex; align-items: center; gap: 8px; background: rgba(79, 195, 255, 0.12); border: 1px solid var(--blue);
  border-radius: 12px; padding: 8px 10px; margin-bottom: 10px;
}
.preview-bar div { flex: 1; display: flex; flex-direction: column; }
.preview-bar small { color: var(--blue); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.swatch.pv, .card.pv { outline: 3px dashed var(--blue); outline-offset: 2px; }
.fx-line { font-size: 11px; color: var(--green); }
.test-row { gap: 8px; }
.test-row button.wide { margin-top: 0; }
.dists { margin-bottom: 8px; }
.dists small { display: inline; margin-left: 4px; font-size: 10px; color: var(--muted); }
.panel button.dist.selected { border-color: var(--blue); color: var(--blue); }
.fx-box { background: rgba(61, 255, 122, 0.08); border: 1px solid rgba(61, 255, 122, 0.3); border-radius: 10px; padding: 6px 10px; margin-bottom: 10px; font-size: 12px; }
.fx-box b { color: var(--green); }
.brand { white-space: nowrap; }
@media (max-width: 980px) {
  #garage-ui.panel-open .brand { display: none; }
  #garage-ui.panel-open #g-top { justify-content: flex-end; }
}

/* M5c: customers, stock, condition */
#g-car-card em { font-style: normal; font-size: 12px; color: var(--green); font-weight: 700; }
#g-car-card em.bad { color: #ffb3b3; }
#cust-pop {
  position: absolute; left: 50%; top: max(64px, calc(var(--sa-top) + 64px)); transform: translateX(-50%);
  z-index: 36; background: var(--panel); border: 2px solid var(--accent); border-radius: 16px; padding: 12px 14px;
  width: min(calc(92 * var(--vw)), 380px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); display: flex; flex-direction: column; gap: 8px;
}
.cust-head { display: flex; justify-content: space-between; align-items: flex-start; }
.cust-head div { display: flex; flex-direction: column; }
.cust-head b { font-size: 17px; }
.cust-head small { color: var(--muted); font-size: 12px; }
#cust-close { background: none; border: none; color: var(--text); font-size: 18px; cursor: pointer; }
#cust-needs, .issue-list { margin: 0; padding-left: 18px; font-size: 14px; }
#cust-stock { display: flex; flex-wrap: wrap; gap: 6px; }
#cust-stock span { font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 8px; }
#cust-stock span.ok { background: rgba(61, 255, 122, 0.15); color: var(--green); }
#cust-stock span.miss { background: rgba(255, 59, 59, 0.15); color: #ffb3b3; }
#cust-reward { font-weight: 800; }
#cust-reason { color: #ffb3b3; font-size: 12px; min-height: 1em; font-weight: 700; }
#cust-reason.ok { color: var(--green); }
#cust-patience { color: var(--muted); font-size: 12px; }
.staff-row .lvl { display: inline-block; background: var(--accent); color: #2a1a00; border-radius: 6px; padding: 0 6px; font-size: 11px; font-weight: 900; margin-left: 4px; }
.staff-row .busy { color: var(--accent); }
.staff-row .idle { color: var(--green); }
.part.dim { opacity: 0.5; }

/* M5b: street traffic */
#passer-pop {
  position: absolute; left: 50%; top: max(64px, calc(var(--sa-top) + 64px)); transform: translateX(-50%);
  z-index: 35; background: var(--panel); border: 2px solid var(--blue); border-radius: 16px; padding: 10px 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); max-width: calc(94 * var(--vw)); flex-wrap: wrap;
}
#passer-pop img { width: 72px; height: 72px; object-fit: contain; background: rgba(255, 255, 255, 0.05); border-radius: 10px; }
.passer-info { display: flex; flex-direction: column; gap: 2px; min-width: 140px; }
.passer-info b { font-size: 17px; }
.passer-info small { color: var(--muted); font-size: 12px; }
#passer-status { font-size: 12px; font-weight: 800; color: var(--muted); }
#passer-status.on { color: var(--green); }
.passer-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.passer-btns button {
  border: 2px solid rgba(255, 255, 255, 0.18); background: #222a3a; color: var(--text); border-radius: 10px;
  padding: 9px 12px; font-weight: 800; cursor: pointer; font-family: inherit; font-size: 13px;
}
.passer-btns button.primary { background: var(--accent); color: #2a1a00; border-color: var(--accent); }
.passer-btns button:disabled { opacity: 0.45; cursor: default; }

/* M5: levels, spots, garage expansion */
.level-chip { gap: 6px; }
.level-chip .lv { color: var(--green); font-size: 12px; }
.lv-bar { width: 46px; height: 6px; background: rgba(0, 0, 0, 0.4); border-radius: 3px; overflow: hidden; }
.lv-bar i { display: block; height: 100%; width: 0; background: var(--green); }
.card.locked { opacity: 0.5; }
.card.spot { border-color: rgba(242, 194, 48, 0.6); }
.card.expand { border-color: var(--green); justify-content: center; }
.card.expand b { font-size: 34px; line-height: 70px; height: 70px; color: var(--green); }
.card:disabled { cursor: default; }

/* M4c: real-time PvP */
#live-ui { z-index: 30; }
#live-ui p { font-weight: 800; font-size: 17px; margin: 12px 0; }
.spinner {
  width: 40px; height: 40px; margin: 4px auto 0; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.15); border-top-color: var(--accent); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#invite-pop {
  position: absolute; top: max(60px, var(--sa-top)); left: 50%; transform: translateX(-50%); z-index: 40;
  background: var(--panel); border: 2px solid var(--accent); border-radius: 14px; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 10px; align-items: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
#invite-pop button {
  border: 2px solid rgba(255, 255, 255, 0.18); background: #222a3a; color: var(--text); border-radius: 10px;
  padding: 8px 18px; font-weight: 800; cursor: pointer; font-family: inherit;
}
#invite-pop button.primary { background: var(--accent); color: #2a1a00; border-color: var(--accent); }

/* M4: car show */
button.wide.primary-wide { background: var(--accent); color: #2a1a00; border-color: var(--accent); font-size: 16px; }
button.wide:disabled { opacity: 0.5; cursor: default; }
.rank-row .rank-num { width: 34px; font-weight: 900; font-size: 16px; color: var(--accent); text-align: center; }
.rank-row img { width: 56px; height: 56px; }
.rank-row.me { background: rgba(79, 195, 255, 0.1); border-radius: 10px; }
#show-ui { position: absolute; inset: 0; pointer-events: none; }
#show-ui button { pointer-events: auto; font-family: inherit; cursor: pointer; }
#show-top {
  position: absolute; top: max(12px, var(--sa-top)); left: 50%; transform: translateX(-50%);
  background: var(--panel); border-radius: 14px; padding: 8px 18px; text-align: center; display: flex; flex-direction: column;
}
#show-top > b { font-size: clamp(18px, calc(3 * var(--vw)), 26px); font-style: italic; }
#show-top span { font-size: 13px; color: var(--muted); }
.show-side {
  position: absolute; bottom: max(70px, calc(var(--sa-bottom) + 70px)); width: min(calc(40 * var(--vw)), 320px);
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-shadow: 0 2px 4px #000;
}
.show-side.left { left: calc(5 * var(--vw)); }
.show-side.right { right: calc(5 * var(--vw)); }
.show-side b { font-size: 18px; }
.show-side small { color: var(--muted); font-size: 13px; }
button.pick {
  margin-top: 6px; border: none; border-radius: 14px; padding: 14px 26px; font-size: 18px; font-weight: 900; color: #fff; width: 100%;
}
button.pick.blue { background: #1f8fd0; box-shadow: 0 5px 0 #0c4f78; }
button.pick.orange { background: #e0871a; box-shadow: 0 5px 0 #7a4508; }
button.pick:disabled, #show-bottom button:disabled { opacity: 0.5; }
#show-bottom {
  position: absolute; bottom: max(12px, var(--sa-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 10px;
}
#show-bottom button {
  background: var(--panel); color: var(--text); border: 2px solid rgba(255, 255, 255, 0.18); border-radius: 12px; padding: 10px 18px; font-weight: 800;
}

/* M3: online */
#nav-online { position: relative; }
.mode-line { font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.mode-line.firebase { color: var(--green); }
.mode-line.mock { color: var(--accent); }
.pvp-box { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 6px; }
.pvp-box div, .code-box {
  background: rgba(255, 255, 255, 0.05); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; align-items: center;
}
.pvp-box small, .code-box small { color: var(--muted); font-size: 11px; }
.pvp-box b { font-size: 18px; }
.code-box b { font-size: 28px; letter-spacing: 4px; color: var(--accent); }
.add-friend { display: flex; gap: 8px; margin: 10px 0 4px; }
.add-friend input {
  flex: 1; min-width: 0; background: #222a3a; border: 2px solid rgba(255, 255, 255, 0.18); border-radius: 10px;
  color: var(--text); padding: 8px 10px; font: inherit; font-weight: 700; text-transform: none; touch-action: auto;
}
#visit-bar {
  position: absolute; left: 50%; bottom: max(14px, var(--sa-bottom)); transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--accent); border-radius: 14px; padding: 10px 14px;
  display: flex; gap: 14px; align-items: center; pointer-events: auto;
}
#visit-bar div { display: flex; flex-direction: column; }
#visit-bar small { color: var(--muted); font-size: 11px; }
#visit-bar b { font-size: 17px; }
#visit-bar span { font-size: 12px; color: var(--accent); }
#visit-bar button {
  background: var(--accent); color: #2a1a00; border: none; border-radius: 10px; padding: 10px 14px; font-weight: 800;
}
#visit-bar button.like-btn { background: #2b2f38; color: #ff7aa8; border: 1px solid #ff7aa8; font-size: 16px; white-space: nowrap; min-width: 64px; }
#visit-bar button.like-btn span { font-size: 15px; color: inherit; }
#visit-bar button.like-btn.on { background: #ff5f95; color: #fff; border-color: #ff5f95; }

/* M2: career, missions, tokens, inventory */
.rating-i { color: var(--blue); margin-right: 4px; }
#nav-missions { position: relative; }
.badge {
  position: absolute; top: -8px; right: -8px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
  background: var(--red); color: #fff; font-size: 12px; line-height: 20px; text-align: center;
}
button.wide.free-race { margin: 0 0 10px; }
.tier-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 6px; font-size: 15px; }
.tier-head .star, .stars i.on { color: var(--accent); }
.stars { display: flex; gap: 1px; font-size: 14px; }
.stars i { font-style: normal; color: rgba(255, 255, 255, 0.2); }
.part-info small.reward { color: #cfd6e4; }
.opp.dim { opacity: 0.45; }
.opp.boss { background: linear-gradient(90deg, rgba(255, 176, 32, 0.12), transparent); border-radius: 10px; }
.mission { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.mission .bar { margin: 4px 0; }
.mission.claimed { opacity: 0.55; }
.mission.bonus { border: 1px dashed rgba(255, 176, 32, 0.5); border-radius: 12px; padding: 10px; margin-top: 10px; }
button.buy.token { background: #7a4fd8; }
.card.inv { border-color: var(--blue); }
#res-stars { font-size: 34px; letter-spacing: 4px; margin: -4px 0 4px; }
#res-stars span { color: rgba(255, 255, 255, 0.18); }
#res-stars span.on { color: var(--accent); text-shadow: 0 0 12px rgba(255, 176, 32, 0.6); }
#res-stars small { display: block; font-size: 11px; letter-spacing: 0; color: var(--muted); }
#res-rewards {
  background: rgba(255, 176, 32, 0.12); border: 1px solid rgba(255, 176, 32, 0.4); border-radius: 10px;
  padding: 6px 10px; margin-bottom: 10px; font-weight: 700; font-size: 14px;
}

@media (max-height: 420px), (orientation: portrait) and (max-width: 420px) {
  .panel { padding: 12px 18px; }
  #g-nav button { padding: 9px 12px; font-size: 13px; }
  #g-nav button.primary { font-size: 16px; padding: 12px 20px; }
  .card { width: 80px; }
  .card img { width: 56px; height: 56px; }
  #result table { font-size: 13px; }
  #result td { padding: 2px 6px; }
  #tree { top: 64px; }
  #hint { top: 116px; font-size: 12px; }
}

/* Home screen + guided tour */
button.chip.help-chip { color: var(--accent); cursor: pointer; font-family: inherit; min-width: 36px; justify-content: center; }
body.home-open #garage-ui { visibility: hidden; }
#home {
  position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: flex-start;
  padding: max(20px, var(--sa-left)); pointer-events: auto;
  background: linear-gradient(90deg, rgba(10, 14, 22, 0.92) 0%, rgba(10, 14, 22, 0.7) 45%, rgba(10, 14, 22, 0.05) 100%);
}
#home.hidden { display: none; }
.home-card { width: min(380px, calc(46 * var(--vw))); display: flex; flex-direction: column; gap: 10px; }
.home-logo { font-size: clamp(38px, calc(7 * var(--vw)), 64px); font-weight: 900; font-style: italic; line-height: 1; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.4); }
.home-logo span { color: var(--accent); }
.home-tag { color: var(--muted); font-weight: 700; letter-spacing: 2px; text-transform: uppercase; font-size: 13px; }
#home-info { margin: 6px 0 0; color: var(--text); font-size: 15px; }
#home-name-row { display: flex; flex-direction: column; gap: 4px; }
#home-name-row.hidden { display: none; }
#home-name-row label { font-size: 12px; color: var(--muted); }
#home-name { font: inherit; font-size: 17px; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.08); color: var(--text); }
#home-play {
  font: inherit; font-size: 24px; font-weight: 900; font-style: italic; padding: 14px; border: none; border-radius: 14px;
  background: var(--accent); color: #2a1a00; cursor: pointer; box-shadow: 0 6px 0 #b77400; margin-top: 6px;
}
#home-play:active { transform: translateY(3px); box-shadow: 0 3px 0 #b77400; }
#home-tour { background: none; border: none; color: var(--muted); text-decoration: underline; font: inherit; font-size: 14px; cursor: pointer; align-self: flex-start; }
#home-tour.hidden { display: none; }

#tut { position: absolute; inset: 0; z-index: 45; pointer-events: auto; }
#tut.hidden { display: none; }
#tut-spot {
  position: absolute; border-radius: 14px; border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(5, 8, 14, 0.62), 0 0 18px rgba(255, 176, 32, 0.8);
  transition: all 0.25s ease; pointer-events: none;
}
#tut-card {
  position: absolute; width: min(400px, calc(90 * var(--vw))); background: var(--panel); border: 1px solid var(--accent);
  border-radius: 16px; padding: 14px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); transition: left 0.25s, top 0.25s;
}
#tut-card small { color: var(--muted); font-weight: 700; }
#tut-card h3 { margin: 4px 0 6px; font-size: 19px; color: var(--accent); }
#tut-card p { margin: 0 0 8px; font-size: 14px; line-height: 1.45; }
#tut-reward { display: block; color: var(--green); margin-bottom: 6px; }
#tut-card .row { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
#tut-card button { font: inherit; font-weight: 800; padding: 8px 14px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08); color: var(--text); cursor: pointer; }
#tut-card button.primary { background: var(--accent); color: #2a1a00; border-color: var(--accent); }
#tut-card button.link { background: none; border: none; color: var(--muted); text-decoration: underline; margin-right: auto; }
#tut-card button:disabled { opacity: 0.4; }
@media (max-height: 420px), (orientation: portrait) and (max-width: 420px) {
  #tut-card { padding: 10px 12px; }
  #tut-card p { font-size: 13px; }
  .home-card { gap: 6px; }
}

/* Workshop mini-game */
#mini { z-index: 42; }
.mini-panel { width: min(760px, calc(96 * var(--vw))); max-height: calc(96 * var(--vh)); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.mini-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; text-align: left; }
.mini-head h3 { margin: 0; color: var(--accent); font-size: 20px; }
.mini-head small { color: var(--muted); }
.mini-head button { background: rgba(255, 255, 255, 0.1); border: none; color: var(--text); border-radius: 10px; width: 36px; height: 36px; font-size: 18px; cursor: pointer; }
#mini-canvas { width: 100%; max-height: calc(58 * var(--vh)); aspect-ratio: 720 / 340; border-radius: 12px; touch-action: none; cursor: crosshair; background: #d8e6f2; }
#mini-canvas.hidden { display: none; }
.mini-bar { display: flex; align-items: center; gap: 10px; }
.mini-track { flex: 1; height: 10px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.mini-track i { display: block; height: 100%; width: 0; background: var(--green); transition: width 0.15s; }
#mini-result { text-align: center; }
#mini-result.hidden { display: none; }
#mini-result p { margin: 4px 0; font-size: 16px; font-weight: 700; }
#mini-result button { margin-top: 6px; font: inherit; font-weight: 800; padding: 10px 28px; border-radius: 10px; border: none; background: var(--accent); color: #2a1a00; cursor: pointer; }

.btn-row { display: flex; gap: 8px; margin: 6px 0; }
.btn-row button { flex: 1; }


/* Character picker */
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 6px; max-height: calc(38 * var(--vh)); overflow-y: auto; padding: 2px; }
.avatar-card { background: rgba(255, 255, 255, 0.07); border: 2px solid transparent; border-radius: 12px; padding: 4px 2px; color: var(--text); font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; }
.avatar-card img { width: 60px; height: 60px; object-fit: contain; }
.avatar-card small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70px; }
.avatar-card.on { border-color: var(--accent); background: rgba(255, 176, 32, 0.15); }
#home-avatar-row { display: flex; flex-direction: column; gap: 4px; }
#home-avatar-row.hidden { display: none; }
#home-avatar-row label { font-size: 12px; color: var(--muted); }
#home-avatars .avatar-grid { max-height: calc(30 * var(--vh)); }

.home-card { max-height: calc(94 * var(--vh)); overflow-y: auto; }


/* Bottom bar: icon over label, each button with its own colour */
#g-nav { gap: 6px; align-items: stretch; }
#g-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 64px; padding: 6px 10px 7px; border-radius: 16px; font-size: 12px; position: relative; border-width: 2px; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }
#g-nav button i { font-style: normal; font-size: 22px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4)); }
#g-nav button span:not(.badge) { line-height: 1.1; }
#g-nav button:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
#g-nav .c-modif { background: linear-gradient(#5b6bff, #3a46c9); border-color: #8f9aff; }
#g-nav .c-dealer { background: linear-gradient(#ff7a45, #d94f1c); border-color: #ffab85; }
#g-nav .c-decor { background: linear-gradient(#b05bff, #7d34cc); border-color: #d3a1ff; }
#g-nav .c-shop { background: linear-gradient(#1fb5a8, #12857b); border-color: #7fe3da; }
#g-nav .c-missions { background: linear-gradient(#ff5fa8, #d6327f); border-color: #ffa3cd; }
#g-nav .c-online { background: linear-gradient(#2f8fff, #1d63c4); border-color: #8cc2ff; }
#g-nav .c-show { background: linear-gradient(#f2c230, #c79410); border-color: #ffe48a; color: #2a1a00; }
#g-nav button.primary { min-width: 92px; font-size: 18px; padding: 6px 16px; color: #2a1a00; background: linear-gradient(#ffd25a, #ffa31a); }
#g-nav button.primary i { font-size: 26px; }
@media (max-width: 900px) {
  #g-nav button { min-width: 54px; padding: 5px 7px 6px; font-size: 11px; }
  #g-nav button i { font-size: 19px; }
  #g-nav button.primary { min-width: 74px; font-size: 15px; }
}

/* Decoration shop: compact 3-column grid, scroll down for more */
#decor-shop { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; overflow-x: hidden; overflow-y: auto; touch-action: pan-y;
  width: min(360px, calc(52 * var(--vw))); max-height: min(300px, calc(46 * var(--vh))); margin-left: auto; padding: 6px; background: rgba(16, 21, 31, 0.92); border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.15); }
#decor-shop .card { width: auto; min-width: 0; padding: 5px 4px 6px; border-radius: 10px; gap: 1px; font-size: 11px; border-width: 2px; }
#decor-shop .card img { width: 40px; height: 40px; }
#decor-shop .card > span { font-size: 11px; line-height: 1.15; white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 25px; }
#decor-shop .card small { font-size: 10px; }
#decor-shop .card small.fx-line { font-size: 9px; color: #9fe6ff; line-height: 1.1; }
#decor-shop .card em.up { color: #ff8a8a; font-style: normal; }
#decor-shop > :first-child:not(.card) { grid-column: 1 / -1; }

#decor-shop .card.expand { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 8px; }
#decor-shop .card.expand > span { min-height: 0; }


#decor-shop .card.expand { padding: 4px 8px; }
#decor-shop .card.expand b { font-size: 20px; line-height: 24px; height: 24px; }
#decor-shop { max-height: min(330px, calc(50 * var(--vh))); }
#decor-shop .card { padding: 3px 3px 4px; }
#decor-shop .card > span { min-height: 0; }


/* Decoration shop: three boxes (Building / Workshop / Customers) */
#decor-shop { display: flex; flex-direction: column; gap: 6px; width: min(1080px, calc(96 * var(--vw))); max-height: none; overflow: visible; padding: 0; background: none; border: none; margin-left: auto; }
.decor-tabs { display: none; gap: 6px; }
#decor-shop .decor-tab { flex: 1; background: var(--panel); color: var(--text); border: 2px solid rgba(255, 255, 255, 0.18); border-radius: 12px; padding: 7px 6px; font: inherit; font-weight: 800; font-size: 13px; }
#decor-shop .decor-tab.on { border-color: var(--accent); background: rgba(255, 176, 32, 0.18); }
.decor-boxes { display: flex; gap: 8px; align-items: stretch; }
.decor-box { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; background: rgba(16, 21, 31, 0.93); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 14px; padding: 6px; }
.decor-box-head { display: flex; flex-direction: column; padding: 2px 4px 6px; }
.decor-box-head b { font-size: 14px; }
.decor-box-head small { font-size: 10px; color: var(--muted); line-height: 1.2; }
.decor-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; overflow-y: auto; max-height: min(300px, calc(44 * var(--vh))); touch-action: pan-y; padding-right: 2px; }
#decor-shop .decor-grid .card { width: auto; min-width: 0; padding: 3px 3px 4px; border-radius: 10px; gap: 1px; font-size: 11px; border-width: 2px; }
#decor-shop .decor-grid .card img { width: 38px; height: 38px; }
#decor-shop .decor-grid .card > span { font-size: 10.5px; line-height: 1.15; white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#decor-shop .decor-grid .card small { font-size: 10px; }
#decor-shop .decor-grid .card small.fx-line { font-size: 9px; color: #9fe6ff; line-height: 1.1; }
#decor-shop .decor-grid .card small.sell-line { color: #ffd24a; }
#decor-shop .decor-grid .card em.up { color: #ff8a8a; font-style: normal; }
#decor-shop .decor-grid .card.expand { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 8px; padding: 4px 8px; }
#decor-shop .decor-grid .card.expand b { font-size: 20px; line-height: 24px; height: 24px; }
#decor-shop .decor-grid .card.owner-item { border-color: rgba(255, 176, 32, 0.7); }
.decor-grid .theme-card .theme-swatch { width: 38px; height: 26px; border-radius: 8px; display: block; margin: 4px 0; border: 2px solid rgba(255, 255, 255, 0.3); }
@media (max-width: 1000px) {
  #decor-shop { width: min(400px, calc(60 * var(--vw))); }
  .decor-tabs { display: flex; }
  .decor-box { display: none; }
  .decor-box.on { display: flex; }
  .decor-box-head b { display: none; }
}

.friend-link { cursor: pointer; }
.friend-link b { color: #9fe6ff; text-decoration: underline; }


.dealer-row img.avatar-photo { border-radius: 50%; background: rgba(255,255,255,0.08); }
.dot-on { color: #3dff7a; font-size: 12px; font-weight: 800; }
.dot-off { color: var(--muted); font-size: 12px; }


/* Decoration shop v3: full-width strip, tabs + sub-tabs on one line, compact cards */
#decor-shop { display: flex; flex-direction: column; gap: 5px; width: 100%; margin: 0; padding: 6px; background: rgba(16, 21, 31, 0.93); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 14px; }
#decor-shop .decor-head { display: flex; gap: 8px; align-items: center; min-width: 0; }
#decor-shop .decor-tabs { display: flex; gap: 4px; flex: 0 0 auto; }
#decor-shop .decor-tab { flex: 0 0 auto; padding: 6px 10px; font-size: 12px; border-radius: 10px; }
#decor-shop .decor-subs { display: flex; gap: 4px; overflow-x: auto; flex: 1 1 auto; min-width: 0; touch-action: pan-x; scrollbar-width: none; }
#decor-shop .decor-subs::-webkit-scrollbar { display: none; }
#decor-shop .decor-sub { flex: 0 0 auto; background: rgba(255, 255, 255, 0.07); color: var(--text); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 999px; padding: 5px 10px; font: inherit; font-size: 11px; font-weight: 700; white-space: nowrap; }
#decor-shop .decor-sub.on { background: rgba(79, 195, 255, 0.22); border-color: var(--blue); }
#decor-shop .decor-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); max-height: min(196px, calc(34 * var(--vh))); gap: 4px; }
#decor-shop .decor-grid .card img { width: 34px; height: 34px; }
#decor-shop .decor-grid .card > span { font-size: 10px; }
#decor-shop .decor-grid .card.expand { grid-column: span 2; }
@media (max-width: 1000px) {
  #decor-shop { width: 100%; }
  #decor-shop .decor-head { flex-wrap: wrap; }
  #decor-shop .decor-tabs { width: 100%; }
  #decor-shop .decor-tab { flex: 1; }
}

/* Developer panel */
.admin-head { display: flex; gap: 6px; margin-bottom: 6px; }
.admin-head input { flex: 1; font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08); color: var(--text); }
.admin-row { display: flex; gap: 8px; align-items: center; padding: 6px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); margin-bottom: 6px; border: 1px solid transparent; }
.admin-row img { width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); }
.admin-row .part-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.admin-row.flagged { border-color: rgba(255, 90, 90, 0.7); }
.admin-row.banned { opacity: 0.6; }
.admin-row .flag { color: #ff8a8a; }
.admin-row .ok { color: #3dff7a; }
.admin-row .uid { color: var(--muted); font-size: 9px; word-break: break-all; }
.admin-row em.ban { color: #ff5a5a; font-style: normal; font-size: 11px; }
#banned { z-index: 60; }
#banned .panel { text-align: center; }

/* Profile button (bottom-left) and profile panel */
#g-car-card { display: none !important; }
#nav-profile { position: absolute; left: max(12px, var(--sa-left)); bottom: max(12px, var(--sa-bottom)); display: flex; align-items: center; gap: 8px; padding: 5px 14px 5px 5px; border-radius: 999px; background: var(--panel); border: 2px solid rgba(255, 255, 255, 0.2); color: var(--text); font: inherit; pointer-events: auto; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }
#nav-profile img { width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(#3a4a6a, #1f2738); border: 2px solid var(--accent); object-fit: cover; }
#nav-profile span { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
#nav-profile small { font-size: 10px; color: var(--muted); }
#nav-profile b { font-size: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#garage-ui.panel-open #nav-profile, #garage-ui.decor-open #nav-profile { display: none; }
.profile-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.profile-photo { width: 84px; height: 84px; border-radius: 50%; border: 3px solid var(--accent); background: linear-gradient(#3a4a6a, #1f2738); }
.profile-name { font-size: 20px; }
@media (max-width: 900px) {
  #nav-profile b { max-width: 80px; font-size: 12px; }
  #nav-profile img { width: 38px; height: 38px; }
}

#nav-profile.hidden { display: none; }


/* Rotated app: let the browser pan scrollers in any direction (axis names follow the screen). */
html.force-land #decor-shop, html.force-land .decor-grid, html.force-land #decor-shop .decor-subs { touch-action: pan-x pan-y; }

/* Street racing (balap liar) */
.street-head { display: flex; gap: 10px; align-items: stretch; margin-bottom: 8px; flex-wrap: wrap; }
.street-rank { flex: 1 1 160px; background: linear-gradient(135deg, #2a1240, #44173a); border: 1px solid #ff2a6d; border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.street-rank b { font-size: 17px; color: #ff7ab0; }
.street-rank small { color: var(--muted); font-size: 11px; }
.street-rank .bar i { background: linear-gradient(90deg, #ff2a6d, #ffb020); }
.street-stats { flex: 1 1 180px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.street-stats div { background: rgba(255, 255, 255, 0.05); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.street-stats small { font-size: 10px; color: var(--muted); }
.street-stats b { font-size: 15px; }
.street-stats b.pos { color: var(--green); }
.street-stats b.neg { color: #ff8a8a; }
button.wide.waiting { background: #44173a; border-color: #ff2a6d; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.7; } }
.ai-tag, .on-tag, .park-tag { align-self: flex-start; display: inline-block; white-space: nowrap; font-style: normal; font-size: 10px; padding: 1px 6px; border-radius: 999px; margin-left: 4px; vertical-align: 2px; }
.ai-tag { background: #3a4252; color: #cfd6e0; }
.on-tag, .part-info em.on-tag { background: rgba(61, 255, 122, 0.18); color: var(--green); }
.part-info em.ai-tag { color: #cfd6e0; }
.park-tag { background: rgba(255, 176, 32, 0.18); color: var(--accent); }
#street-pop { z-index: 55; }
.street-panel { width: min(440px, calc(94 * var(--vw))); text-align: left; padding: 14px 16px; }
.street-top { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.street-top img { width: 64px; height: 64px; object-fit: contain; background: rgba(255, 255, 255, 0.05); border-radius: 10px; }
#street-opp { flex: 1; display: flex; flex-direction: column; gap: 2px; }
#street-opp small { color: var(--muted); font-size: 12px; }
#street-round { color: var(--accent); font-weight: 800; font-size: 12px; white-space: nowrap; }
#street-log { background: rgba(0, 0, 0, 0.25); border-radius: 10px; padding: 6px 10px; max-height: calc(26 * var(--vh)); overflow-y: auto; margin-bottom: 8px; }
#street-log p { margin: 3px 0; font-size: 13px; }
#street-log p.me { color: var(--accent); text-align: right; }
#street-log p.them { color: #ff9cc4; }
#street-log p.sys { color: var(--muted); font-style: italic; }
#street-bets { display: flex; gap: 8px; margin-bottom: 10px; }
#street-bets:empty { display: none; }
.panel #street-bets button.bet { flex: 1; padding: 10px 6px; font-size: 16px; }
.panel #street-bets button.bet.cur { border-color: #ff2a6d; color: #ff9cc4; }
.panel #street-bets button.bet:disabled { opacity: 0.4; }
.street-panel .row button { flex: 1; }
.street-panel .row button.primary { font-size: 17px; padding: 12px 10px; }

/* Night market (pasar malam) */
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.market-card {
  display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; padding: 8px 6px;
  background: linear-gradient(160deg, #2b1640, #1b2233); color: var(--text); border: 2px solid rgba(255, 210, 31, 0.35); border-radius: 12px;
}
.market-card i { font-style: normal; font-size: 28px; line-height: 1.1; }
.market-card b { font-size: 13px; }
.market-card small { font-size: 10.5px; color: var(--muted); line-height: 1.25; }
.market-card em { font-style: normal; font-size: 11px; font-weight: 800; color: var(--accent); margin-top: 2px; }
.market-card.cool { opacity: 0.55; border-color: rgba(255, 255, 255, 0.12); }
.market-card.cool em { color: var(--muted); }
#market { z-index: 42; }
.market-panel { width: min(780px, calc(97 * var(--vw))); max-height: calc(97 * var(--vh)); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
.market-panel .mini-head button { flex-shrink: 0; padding: 6px 10px; margin: 0; display: inline-block; font-size: 14px; }
.market-panel .mini-head { min-width: 0; }
.market-panel h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#market-hint { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.market-panel .mini-head { display: flex; align-items: center; gap: 10px; text-align: left; }
.market-panel .mini-head > div:first-child { flex: 1; min-width: 0; }
.market-panel h3 { margin: 0; font-size: 17px; }
.market-panel small { color: var(--muted); font-size: 12px; }
.market-score { display: flex; flex-direction: column; align-items: center; min-width: 52px; }
.market-score b { font-size: 18px; color: var(--accent); }
#market-canvas { width: 100%; max-height: calc(78 * var(--vh)); aspect-ratio: 720 / 340; border-radius: 12px; touch-action: none; display: block; object-fit: contain; }
@media (max-height: 420px), (orientation: portrait) and (max-width: 420px) {
  .market-panel { padding: 6px 8px; gap: 4px; }
  .market-panel h3 { font-size: 15px; }
  .market-panel .mini-head small { display: none; }
}

/* Short screens (phones in landscape): more compact tabs, stats and option cards. */
@media (max-height: 520px), (orientation: portrait) and (max-width: 520px) {
  #panel-tabs { margin: 6px 0; }
  .tab { padding: 6px 4px; font-size: 12px; }
  .stats { padding: 6px 8px; margin-bottom: 6px; }
  .stat { margin: 1px 0; font-size: 11px; }
  .card { width: 78px; padding: 4px; }
  .card img { width: 54px; height: 54px; }
  .sticker-icon { font-size: 24px; line-height: 54px; height: 54px; }
  .swatches { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 6px; }
  .swatch { height: 34px; max-width: 38px; }
}

.tune-help { margin: -4px 0 8px; font-size: 11px; }

/* Separate maps */
#district-ui { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
#district-ui button { pointer-events: auto; font-family: inherit; cursor: pointer; }
.d-top { position: absolute; top: max(10px, var(--sa-top)); left: max(12px, var(--sa-left)); right: max(12px, var(--sa-right)); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.d-top #d-exit { background: var(--panel); color: var(--text); border: 2px solid rgba(255, 255, 255, 0.2); border-radius: 12px; padding: 8px 14px; font-weight: 800; font-size: 14px; }
#d-title { font-size: 18px; font-style: italic; font-weight: 900; text-shadow: 0 2px 4px #000; }
#d-info { display: flex; gap: 6px; flex-wrap: wrap; }
#d-info span { background: var(--panel); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 800; }
#d-tools { margin-left: auto; display: flex; gap: 6px; }
#d-tools button { background: #44173a; color: #fff; border: 2px solid #ff2a6d; border-radius: 12px; padding: 8px 12px; font-weight: 800; font-size: 13px; }
#d-hint { position: absolute; left: 50%; transform: translateX(-50%); top: calc(max(10px, var(--sa-top)) + 52px); background: rgba(16, 21, 31, 0.8); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 700; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis; }
#d-act { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(18px, var(--sa-bottom)); background: var(--accent); color: #2a1a00; border: none; border-radius: 16px; padding: 14px 26px; font-size: 18px; font-weight: 900; box-shadow: 0 6px 0 #b77400; }
#d-act:active { transform: translate(-50%, 3px); box-shadow: 0 3px 0 #b77400; }
#d-pop { pointer-events: auto; z-index: 30; }
.d-pop-panel { width: min(420px, calc(92 * var(--vw))); text-align: left; }
.d-pop-panel h3 { margin: 0 0 8px; font-size: 20px; }
.d-pop-panel .row button { flex: 1; }
.d-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.d-stats div { background: rgba(255, 255, 255, 0.06); border-radius: 10px; padding: 6px; text-align: center; display: flex; flex-direction: column; }
.d-stats small { font-size: 10px; color: var(--muted); }
.d-list { margin: 0; padding-left: 20px; font-size: 14px; }
.d-list li { margin: 4px 0; }
/* Race history */
.hist { display: flex; flex-direction: column; gap: 4px; max-height: calc(50 * var(--vh)); overflow-y: auto; }
.hist-row { display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, 0.05); border-radius: 10px; padding: 6px 8px; border-left: 4px solid var(--red); }
.hist-row.win { border-left-color: var(--green); }
.hist-row > b { font-size: 11px; min-width: 56px; }
.hist-row.win > b { color: var(--green); }
.hist-row.lose > b { color: #ff8a8a; }
.hist-row > div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.hist-row span { font-weight: 800; font-size: 13px; }
.hist-row small { color: var(--muted); font-size: 11px; }
.hist-row em { font-style: normal; font-weight: 900; }
.hist-row em.pos { color: var(--green); }
.hist-row em.neg { color: #ff8a8a; }
#toast { z-index: 70; }
#d-pop-close { display: none; }
#d-stick { position: absolute; left: max(22px, var(--sa-left)); bottom: max(22px, var(--sa-bottom)); width: 128px; height: 128px; border-radius: 50%; background: rgba(16, 21, 31, 0.45); border: 3px solid rgba(255, 255, 255, 0.35); pointer-events: auto; touch-action: none; }
#d-stick i { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255, 210, 31, 0.9); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4); }
#d-zoom { position: absolute; right: max(14px, var(--sa-right)); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 8px; }
#d-zoom button { width: 44px; height: 44px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, 0.25); background: var(--panel); color: #fff; font-size: 22px; font-weight: 900; }
.look-subs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; touch-action: pan-x pan-y; scrollbar-width: none; }
.look-sub { flex: 0 0 auto; background: #222a3a; color: var(--muted); border: 2px solid transparent; border-radius: 999px; padding: 6px 12px; font-weight: 800; font-size: 12.5px; white-space: nowrap; }
.look-sub.on { color: #2a1a00; background: var(--accent); }
.look-groups { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; touch-action: pan-x pan-y; scrollbar-width: none; }
.look-group { flex: 0 0 auto; background: rgba(255, 255, 255, 0.06); color: var(--text); border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 999px; padding: 4px 10px; font-weight: 700; font-size: 11.5px; white-space: nowrap; }
.look-group.on { border-color: var(--blue); color: var(--blue); background: rgba(79, 195, 255, 0.12); }
.look-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.look-grid .card { width: auto; }
.look-note { background: rgba(79, 195, 255, 0.08); border: 1px solid rgba(79, 195, 255, 0.3); border-radius: 10px; padding: 6px 10px; font-size: 12px; margin-bottom: 8px; }
.card img.sticker-img { width: 70px; height: 54px; object-fit: contain; background: rgba(255, 255, 255, 0.08); border-radius: 8px; }
.weekly-bonus { align-items: center; gap: 8px; }
.weekly-rim { width: 56px; height: 56px; object-fit: contain; background: rgba(255, 201, 58, 0.12); border-radius: 12px; border: 2px solid #ffc93a; }
.weekly-bonus small.excl { color: #ffc93a; }
.card.exclusive { border-color: #ffc93a; background: linear-gradient(160deg, #3a2a00, #222a3a); }
h4.admin-sec { margin: 12px 0 6px; font-size: 13px; color: var(--accent); }
.admin-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.admin-tool { background: #222a3a; color: var(--text); border: 2px solid rgba(255, 255, 255, 0.15); border-radius: 10px; padding: 8px 6px; font-weight: 800; font-size: 12px; }
.gift-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; background: rgba(255, 176, 32, 0.08); border: 1px solid rgba(255, 176, 32, 0.4); border-radius: 10px; padding: 8px; margin: -2px 0 8px; }
.gift-form select, .gift-form input { font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.25); background: #1b2233; color: var(--text); max-width: 100%; }
