/* Car Lot Simulator. Light + dark (auto follows the OS) with an era skin on top (body[data-era]). */
:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #eef1f5; --fg: #1b2330; --muted: #566074; --panel: #fff; --line: #d5dbe4;
  --accent: #c0392b; --accent-fg: #fff; --link: #a52a1d; --good: #16794a; --bad: #b42318; --warn: #8a5a00;
  --radius: 12px; --gap: 10px; --head: linear-gradient(90deg, var(--accent), var(--accent));
}
body[data-theme="dark"] { --bg: #11151c; --fg: #e8ecf3; --muted: #a2adc0; --panel: #1b222d; --line: #2b3442; --good: #4cc38a; --bad: #ff8a80; --warn: #e3b341; --link: #ff9d8f; }
@media (prefers-color-scheme: dark) {
  body[data-theme="auto"] { --bg: #11151c; --fg: #e8ecf3; --muted: #a2adc0; --panel: #1b222d; --line: #2b3442; --good: #4cc38a; --bad: #ff8a80; --warn: #e3b341; --link: #ff9d8f; }
}
/* era skins: accent colour, corner style and a header gradient */
body[data-era="e80"] { --accent: #c2185b; --link: #ad1457; --radius: 6px; --head: linear-gradient(90deg, #c2185b, #e65100); --font: "Trebuchet MS", system-ui, sans-serif; }
body[data-era="e90"] { --accent: #00796b; --link: #00695c; --radius: 2px; --head: linear-gradient(90deg, #00796b, #6a1b9a); --font: Verdana, system-ui, sans-serif; }
body[data-era="e00"] { --accent: #1565c0; --link: #0d47a1; --radius: 7px; --head: linear-gradient(180deg, #4a90d9, #1565c0); --font: "Segoe UI", Tahoma, system-ui, sans-serif; }
body[data-era="e10"] { --accent: #2e7d32; --link: #1b5e20; --radius: 12px; --head: linear-gradient(90deg, #2e7d32, #2e7d32); }
body[data-era="e20"] { --accent: #00796b; --link: #00695c; --radius: 16px; --head: linear-gradient(90deg, #0b7a75, #1565c0); }
body[data-theme="dark"][data-era="e80"], body[data-theme="dark"][data-era="e90"], body[data-theme="dark"][data-era="e00"], body[data-theme="dark"][data-era="e10"], body[data-theme="dark"][data-era="e20"] { --link: #8fd3c8; }
@media (prefers-color-scheme: dark) { body[data-theme="auto"][data-era] { --link: #8fd3c8; } body[data-theme="auto"][data-era="e80"] { --link: #ff9fc4; } }
body[data-theme="dark"][data-era="e80"] { --link: #ff9fc4; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 16px; }
a { color: var(--link); }
small { color: var(--muted); display: block; }
.muted { color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--bad); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#app { max-width: 760px; margin: 0 auto; padding: 8px 8px 88px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: var(--gap); }
#top .title { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; font-weight: 700; background: var(--head); color: #fff; border-radius: var(--radius) var(--radius) 0 0; }
#top .era { color: #fff; opacity: .92; font-weight: 400; }
#clock { padding: 8px 12px; display: grid; gap: 6px; border-color: var(--accent); }
.clockrow { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.clockrow small { flex: 1 1 220px; }
.clock .segs { margin: 0; }
.plan { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px 12px; align-items: end; }
.plan .field { margin: 0; }
label.chk { display: flex; gap: 8px; align-items: center; min-height: 44px; }
label.chk input { width: 22px; min-height: 22px; height: 22px; flex: none; }
.card.car.col .acts { flex-direction: row; justify-content: flex-start; min-width: 0; }
h2.sec { margin: 0; padding: 8px 12px; font-size: 1rem; border-bottom: 1px solid var(--line); }
h3 { margin: 12px 0 4px; font-size: .95rem; }
.pbody, .topbody { padding: 10px 12px; }
.topbody { display: flex; gap: 14px; flex-wrap: wrap; }
.stat b { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.stat.grow { flex: 1; }
.minis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.mini { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
.mini b { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.card { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; margin-bottom: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card.col { flex-direction: column; align-items: stretch; }
.card .info { display: grid; gap: 2px; min-width: 0; }
.card.locked { opacity: 1; background: transparent; border-style: dashed; }
.card.afford { outline: 2px solid var(--good); outline-offset: -2px; }
.acts, .opts, .segs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.opts { justify-content: flex-start; margin: 8px 0; }
.segs { justify-content: flex-start; margin: 6px 0; }
.card.car .acts, .card.offer .acts { flex-direction: column; align-items: stretch; min-width: 128px; }
@media (max-width: 560px) { .card.car, .card.offer { flex-direction: column; align-items: stretch; } .card.car .acts, .card.offer .acts { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; } }
.tag { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 999px; font-size: .78rem; color: var(--good); font-weight: 700; }
.tag.warn { color: var(--warn); } .tag.bad { color: var(--bad); } .tag.shop { color: var(--link); }
small.inline { display: inline; }
.bar { display: inline-block; width: 70px; height: 8px; background: var(--line); border-radius: 4px; vertical-align: middle; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar.good i { background: var(--good); } .bar.mid i { background: var(--warn); } .bar.bad i { background: var(--bad); }
button { font: inherit; min-height: 44px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); cursor: pointer; }
button.sm { min-height: 36px; padding: 4px 10px; font-size: .9rem; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.seg[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: transparent; font-weight: 700; }
button:disabled { opacity: .6; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input, select { font: inherit; min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); width: 100%; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; } .toolbar select { width: auto; }
.field { display: grid; gap: 4px; margin-bottom: 8px; }
.list { display: grid; gap: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.alert { padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: var(--gap); background: var(--panel); }
.alert.bad { border-color: var(--bad); color: var(--bad); }
.alert.warn { border-color: var(--warn); color: var(--warn); }
.panel.decision { border-color: var(--accent); border-width: 2px; }
ul.goals, ul.news { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
ul.goals { list-style: none; padding-left: 0; }
.goals li.done { color: var(--good); }
.news li.bad { color: var(--bad); } .news li.good { color: var(--good); } .news li.event { color: var(--link); } .news li.warn { color: var(--warn); }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.tbl td.r { text-align: right; }
svg.bars { width: 100%; max-width: 420px; height: 64px; } svg.bars .pos { fill: var(--good); } svg.bars .neg { fill: var(--bad); }
#nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 2px; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
#nav button { flex: 1; max-width: 110px; display: grid; justify-items: center; gap: 0; padding: 4px 2px; min-height: 52px; border: 0; background: none; }
#nav button i { font-style: normal; font-size: 1.25rem; }
#nav button span { font-size: .72rem; }
#nav button.on { color: var(--link); font-weight: 700; box-shadow: inset 0 -3px 0 var(--accent); }
#toasts { position: fixed; top: 10px; left: 0; right: 0; display: grid; justify-items: center; gap: 6px; pointer-events: none; z-index: 20; }
.toast { background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 999px; }
#modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; padding: 16px; z-index: 30; overflow: auto; }
#modal[hidden] { display: none; }
#modal .box { max-width: 520px; width: 100%; margin: 0; max-height: 92vh; overflow: auto; }
.authwrap { min-height: 100vh; display: grid; align-items: center; }
.authbox { max-width: 420px; margin: 0 auto; width: 100%; }
.authbox .title { display: flex; justify-content: space-between; padding: 8px 12px; font-weight: 700; background: var(--head); color: #fff; border-radius: var(--radius) var(--radius) 0 0; }

/* ---------- the lot scene and car art ---------- */
#sceneWrap { position: relative; margin-bottom: var(--gap); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #223; line-height: 0; }
#sceneWrap[hidden] { display: none; }
#scene { display: block; width: 100%; height: clamp(165px, 42vw, 250px); }
#sceneBtn { position: absolute; right: 6px; top: 6px; min-height: 28px; padding: 2px 9px; font-size: .75rem; opacity: .92; line-height: 1.4; background: rgba(0,0,0,.55); color: #fff; border: 1px solid rgba(255,255,255,.4); }
#sceneShow { margin-bottom: var(--gap); }
#fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; line-height: 1.2; }
.pop { position: absolute; font-weight: 800; font-size: 1.05rem; color: #fff; text-shadow: 0 1px 3px #000, 0 0 8px rgba(0,0,0,.6); animation: popUp 1.9s ease-out forwards; white-space: nowrap; }
.pop.big { font-size: 1.35rem; color: #ffe27a; }
.pop .tagsold { display: inline-block; background: #e53935; color: #fff; border-radius: 4px; padding: 0 5px; font-size: .75rem; margin-right: 4px; transform: rotate(-6deg); }
@keyframes popUp { 0% { transform: translateY(8px) scale(.7); opacity: 0; } 12% { transform: translateY(0) scale(1.1); opacity: 1; } 100% { transform: translateY(-46px) scale(1); opacity: 0; } }
.sc-walk { animation: scWalk 28s linear infinite; transform: translate(-20px, 146px); }
.sc-w0 { --y: 146px; animation-duration: 30s; animation-delay: -4s; } .sc-w1 { --y: 151px; animation-duration: 24s; animation-delay: -15s; animation-direction: reverse; }
.sc-w2 { --y: 144px; animation-duration: 36s; animation-delay: -22s; } .sc-w3 { --y: 153px; animation-duration: 27s; animation-delay: -9s; animation-direction: reverse; } .sc-w4 { --y: 148px; animation-duration: 33s; animation-delay: -28s; }
@keyframes scWalk { from { transform: translate(-20px, var(--y, 146px)); } to { transform: translate(420px, var(--y, 146px)); } }
.sc-bob { animation: scBob .55s ease-in-out infinite alternate; } @keyframes scBob { from { transform: translateY(0); } to { transform: translateY(-1.4px); } }
.sc-drive { animation: scDrive 17s linear infinite; } @keyframes scDrive { from { transform: translateX(-130px); } to { transform: translateX(430px); } }
.sc-flags { animation: scSway 2.2s ease-in-out infinite alternate; transform-origin: 200px 96px; } @keyframes scSway { from { transform: skewX(-3deg); } to { transform: skewX(3deg); } }
.sc-cloud { animation: scCloud 70s ease-in-out infinite alternate; } .sc-cloud2 { animation: scCloud 90s ease-in-out infinite alternate-reverse; } @keyframes scCloud { from { transform: translateX(-30px); } to { transform: translateX(50px); } }
.sc-wheel { animation: scSpin 26s linear infinite; } @keyframes scSpin { to { transform: rotate(360deg); } }
.sc-neon { animation: scNeon 2.8s ease-in-out infinite alternate; } @keyframes scNeon { from { opacity: .72; } to { opacity: 1; } }
#sceneWrap.paused *, #sceneWrap.paused { animation-play-state: paused; }
body.reduce-motion #sceneWrap *, body.reduce-motion .pop, body.reduce-motion .confetti i { animation: none !important; }
body.reduce-motion .sc-walk { transform: translate(120px, var(--y, 146px)); }
.carimg { display: block; flex: none; }
.thumb { flex: none; width: 84px; display: grid; align-items: center; }
.cardhead { display: flex; gap: 10px; align-items: center; min-width: 0; }
.cardhead .info { min-width: 0; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; opacity: .95; animation: confFall 2.6s ease-in forwards; }
@keyframes confFall { to { transform: translateY(105vh) rotate(540deg); opacity: .9; } }
button { transition: transform .08s ease, box-shadow .15s ease, filter .15s ease; }
button:not(:disabled):hover { filter: brightness(1.06); box-shadow: 0 2px 6px rgba(0,0,0,.18); }
button:not(:disabled):active { transform: scale(.96); }
.card { transition: box-shadow .15s ease, transform .15s ease; }
.card:hover { box-shadow: 0 3px 10px rgba(0,0,0,.12); }
#modal .box { animation: boxIn .18s ease-out; } @keyframes boxIn { from { transform: translateY(10px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.toast { animation: toastIn .2s ease-out; } @keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.stat b.bump { animation: bump .35s ease-out; } @keyframes bump { 40% { transform: scale(1.12); color: var(--good); } }

/* ---------- era looks: page backdrop and header dressing ---------- */
.cardhead { flex: 1; }
body[data-era="e80"] { background-image: linear-gradient(180deg, rgba(255, 61, 139, .10), rgba(255, 61, 139, 0) 260px); }
body[data-era="e80"] #top .title { background-image: var(--head), repeating-linear-gradient(-45deg, rgba(255,255,255,.14) 0 6px, transparent 6px 12px); background-blend-mode: normal; text-shadow: 0 0 8px rgba(255, 61, 139, .8), 1px 1px 0 rgba(0,0,0,.35); letter-spacing: .5px; }
body[data-era="e90"] { background-image: radial-gradient(rgba(106, 27, 154, .10) 1.6px, transparent 1.7px), radial-gradient(rgba(0, 150, 136, .10) 1.6px, transparent 1.7px); background-size: 18px 18px, 18px 18px; background-position: 0 0, 9px 9px; }
body[data-era="e90"] .panel { border-width: 2px; }
body[data-era="e90"] #top .title { text-shadow: 2px 2px 0 rgba(0,0,0,.3); }
body[data-era="e00"] { background-image: linear-gradient(180deg, rgba(21, 101, 192, .12), rgba(21, 101, 192, 0) 300px); }
body[data-era="e00"] .panel { box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 1px 3px rgba(0,0,0,.10); }
body[data-era="e00"] #top .title { background-image: var(--head), linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0) 55%); }
body[data-era="e10"] .panel { box-shadow: none; }
body[data-era="e10"] h2.sec { font-size: 1.05rem; letter-spacing: .2px; }
body[data-era="e20"] { background-image: radial-gradient(900px 260px at 50% -40px, rgba(24, 224, 200, .14), rgba(24, 224, 200, 0)); }
body[data-era="e20"] .panel { box-shadow: 0 0 0 1px rgba(24, 224, 200, .18), 0 6px 18px rgba(0, 0, 0, .18); }
body[data-era="e20"] h2.sec { letter-spacing: .6px; text-transform: uppercase; font-size: .88rem; }
body[data-era="e20"] #top .title { box-shadow: 0 0 16px rgba(24, 224, 200, .35); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
