:root {
  --bg: #0d0c0b;
  --panel: #191714;
  --panel-2: #221f1b;
  --line: #34302a;
  --ink: #ece5d6;
  --muted: #8f877a;
  --hazard: #f2c230;
  --blood: #e0463a;
  --cash: #8fd16f;
  --paper: #e9e0c9;
  --paper-ink: #2a241b;
  --display: "Bebas Neue", Impact, "Arial Narrow", sans-serif;
  --type: "Special Elite", "Courier New", monospace;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tabbar: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--ui);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px);
}
/* Grime: dark brick + film grain, fixed behind everything */
body::before, body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
}
body::before {
  background: url(/static/images/white_brick_wall.jpg) 0 0 / 220px repeat;
  filter: invert(1) contrast(1.4) brightness(.55);
  opacity: .22;
}
body::after {
  background-image:
    radial-gradient(ellipse at 50% -10%, rgba(242,194,48,.10), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(0,0,0,.9), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  opacity: .5;
}

button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: .04em; margin: 0; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.cash { color: var(--cash); }
.debt { color: var(--blood); }
.hot { color: var(--hazard); font-weight: 700; }
[hidden] { display: none !important; }

/* Everything sits in a phone-width column, even on desktop */
.hud, .tabs, .fight, .over, .pinpad { max-width: 520px; margin: 0 auto; padding: 0 16px; }

/* ---------- HUD ---------- */
.hud {
  position: sticky; top: 0; z-index: 5;
  padding-top: calc(env(safe-area-inset-top) + 10px);
  padding-bottom: 10px;
  background: linear-gradient(var(--bg) 70%, rgba(13,12,11,.92));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.hud-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.kicker { font: 12px/1 var(--type); color: var(--hazard); text-transform: uppercase; letter-spacing: .12em; }
.loc {
  font-size: 40px; line-height: .95; margin-top: 4px;
  text-shadow: 0 0 1px rgba(236,229,214,.6), 2px 2px 0 rgba(0,0,0,.6);
}
.who { font: 13px var(--type); color: var(--muted); text-align: right; padding-bottom: 4px; }
.daybar { height: 4px; margin: 10px 0 10px; background: var(--line); }
.daybar span { display: block; height: 100%; background: repeating-linear-gradient(-45deg, var(--hazard) 0 6px, #1b1a17 6px 10px); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0; }
.stats > div { background: var(--panel); border: 1px solid var(--line); padding: 6px 8px; min-width: 0; }
.stats dt { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.meter { position: relative; height: 22px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; background: rgba(143,209,111,.28); }
.meter.low i { background: rgba(224,70,58,.4); }
.meter.coat i { background: rgba(242,194,48,.22); }
.meter span { position: relative; z-index: 1; font-size: 12px; font-weight: 600; padding-left: 8px; line-height: 20px; letter-spacing: .03em; }

/* ---------- Sections ---------- */
.tab { padding-top: 14px; animation: in .18s ease-out; }
@keyframes in { from { opacity: 0; transform: translateY(4px); } }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 8px; }
.section-head h2 { font-size: 28px; }
.section-head span { font-size: 12px; color: var(--muted); text-align: right; }

/* Newspaper clipping for the day's events */
.clipping {
  background: var(--paper); color: var(--paper-ink);
  font-family: var(--type); font-size: 15px;
  padding: 14px 16px 10px; margin: 2px 4px 18px;
  transform: rotate(-.6deg);
  box-shadow: 0 6px 18px rgba(0,0,0,.5);
  position: relative;
  clip-path: polygon(0 2%, 4% 0, 30% 1.5%, 60% 0, 96% 1%, 100% 0, 99% 50%, 100% 98%, 70% 100%, 40% 98%, 8% 100%, 0 97%);
}
.clipping::before {
  content: ""; position: absolute; top: -6px; left: 50%; width: 70px; height: 18px; margin-left: -35px;
  background: rgba(242,194,48,.55); transform: rotate(2deg);
}
.clip-head { font: 20px var(--display); letter-spacing: .08em; border-bottom: 2px solid var(--paper-ink); margin-bottom: 6px; }
.clipping p { margin: 6px 0; }

/* Market rows */
.market { display: flex; flex-direction: column; gap: 4px; }
.drug {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; min-height: 56px; padding: 8px 14px;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--line);
  text-align: left; cursor: pointer;
}
.drug:active { background: var(--panel-2); }
.drug.held { border-left-color: var(--hazard); }
.drug.dead { opacity: .5; cursor: default; }
.d-name { font: 24px/1 var(--display); letter-spacing: .05em; }
.d-name small { display: block; font: 12px/1.5 var(--ui); color: var(--muted); letter-spacing: 0; margin-top: 2px; }
.d-name b.up { color: var(--cash); } .d-name b.down { color: var(--blood); }
.d-price { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.d-price em { font-weight: 400; font-style: normal; font-size: 13px; color: var(--muted); }
.tr { font-style: normal; font-size: 11px; width: 12px; text-align: center; }
.tr.up { color: var(--cash); } .tr.down { color: var(--blood); }

/* Travel */
.stops { display: flex; flex-direction: column; gap: 6px; }
.stop {
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: center;
  width: 100%; padding: 12px 14px; min-height: 64px;
  background: var(--panel); border: 1px solid var(--line); text-align: left; cursor: pointer;
}
.stop:active { background: var(--panel-2); border-color: var(--hazard); }
.stop-name { font: 28px/1 var(--display); letter-spacing: .04em; }
.stop-tag { grid-row: 2; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-top: 3px; }
.svc-shark { color: var(--blood); } .svc-guns { color: #d58b4c; } .svc-hospital { color: #7fb3d5; } .svc-bank { color: var(--cash); }
.arrow { grid-row: 1 / 3; grid-column: 2; font-size: 22px; color: var(--hazard); }
.pin { grid-row: 1 / 3; grid-column: 2; font: 12px var(--type); color: var(--bg); background: var(--hazard); padding: 3px 7px; transform: rotate(-3deg); }
.stop.here { opacity: .65; cursor: default; border-style: dashed; }

/* Cards / services */
.card { background: var(--panel); border: 1px solid var(--line); padding: 16px; margin-bottom: 10px; }
.card h3 { font-size: 22px; margin-bottom: 8px; }
.blurb { font: 15px var(--type); color: var(--muted); margin: 0 0 12px; }
.bigline { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.bigline span { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.bigline b { font: 34px var(--display); letter-spacing: .03em; }
.moneyform { margin-top: 14px; }
.moneyform + .moneyform { border-top: 1px dashed var(--line); padding-top: 14px; }
.moneyform label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.moneyform input, .qty input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  font: 700 22px var(--ui); font-variant-numeric: tabular-nums;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 0;
}
.row2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 8px; }
.shop .item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px dashed var(--line); }
.shop .item:first-of-type { border-top: 0; }
.shop small { display: block; font-size: 12px; color: var(--muted); }
.owned { font: 13px var(--type); color: var(--hazard); }
.directory { list-style: none; padding: 0; margin: 14px 0 0; font-size: 14px; }
.directory li { display: flex; justify-content: space-between; padding: 7px 2px; border-bottom: 1px dashed var(--line); }
.directory span { color: var(--muted); }
.directory b { font-weight: 600; }
.lastcall { border-color: var(--hazard); }
.lastcall h2 { font-size: 34px; color: var(--hazard); }

/* Notebook */
.notebook { list-style: none; padding: 14px 16px; margin: 0; background: var(--paper); color: var(--paper-ink); font: 14px/1.6 var(--type);
  background-image: repeating-linear-gradient(transparent 0 21px, rgba(42,36,27,.15) 21px 22px); }
.notebook li { padding: 1px 0; }
.notebook li:first-child { font-weight: 700; }
.newgame { margin-top: 20px; text-align: center; }

/* Buttons */
.btn {
  display: inline-flex; justify-content: center; align-items: center; min-height: 48px; padding: 0 18px;
  background: var(--hazard); color: #15130f; border: 0; cursor: pointer;
  font: 22px var(--display); letter-spacing: .06em;
  box-shadow: 3px 3px 0 #000;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.btn:disabled { background: var(--line); color: var(--muted); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.danger { background: var(--blood); color: #fff; }
.btn.big { width: 100%; min-height: 56px; font-size: 26px; }
.btn.sm { min-height: 40px; font-size: 18px; padding: 0 12px; }

/* Bottom tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: #0a0908; border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--hazard); box-shadow: inset 0 2px 0 var(--hazard); }

/* Deal sheet */
.sheet {
  width: 100%; max-width: 520px; margin: auto auto 0; padding: 0;
  background: var(--panel); color: var(--ink); border: 0; border-top: 3px solid var(--hazard);
  max-height: 92dvh;
}
.sheet[open] { animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet::backdrop { background: rgba(0,0,0,.7); }
.sheet form { padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); }
.grab { width: 40px; height: 4px; background: var(--line); margin: 0 auto 10px; }
.sheet header { display: flex; justify-content: space-between; align-items: baseline; }
.sheet h2 { font-size: 40px; }
.sheet header span { font-weight: 700; font-variant-numeric: tabular-nums; }
.s-info { color: var(--muted); font-size: 14px; margin: 2px 0 12px; min-height: 1.4em; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); margin-bottom: 12px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 10px; font: 22px var(--display); letter-spacing: .06em; cursor: pointer; color: var(--muted); }
.seg input:checked + span { background: var(--ink); color: var(--bg); }
.seg input:disabled + span { opacity: .3; cursor: default; }
.qty { display: grid; grid-template-columns: 56px 1fr 56px; gap: 6px; }
.qty input { margin: 0; text-align: center; font-size: 28px; }
.qty button { background: var(--panel-2); border: 1px solid var(--line); font-size: 28px; cursor: pointer; }
input[type=range] { width: 100%; margin: 16px 0 8px; accent-color: var(--hazard); height: 28px; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.quick button { min-height: 40px; background: transparent; border: 1px solid var(--line); cursor: pointer; font-weight: 600; }
.total { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 4px; padding-top: 10px; border-top: 1px dashed var(--line); }
.total span { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .1em; }
.total b { font: 34px var(--display); letter-spacing: .03em; }
#s-go.sellmode { background: var(--cash); }

/* Toast */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); z-index: 20;
  transform: translateX(-50%) rotate(-1deg); width: max-content; max-width: calc(100% - 32px);
  background: var(--hazard); color: #15130f; padding: 10px 16px; font: 15px var(--type);
  box-shadow: 4px 4px 0 #000; transition: opacity .4s, transform .4s;
}
.toast.gone { opacity: 0; transform: translateX(-50%) translateY(-20px); pointer-events: none; }

/* Cop encounter */
.fight { padding-top: 16px; }
.tape {
  margin: 0 -16px 16px; padding: 6px 0; overflow: hidden; white-space: nowrap;
  background: var(--hazard); color: #000; font: 18px var(--display); letter-spacing: .2em; transform: rotate(-2deg);
  box-shadow: 0 4px 0 #000;
}
.fight h1 { font-size: 76px; line-height: .9; color: var(--blood); text-shadow: 3px 3px 0 #000; animation: flash 1.2s steps(2) infinite; }
@keyframes flash { 50% { color: #5a8be0; } }
.fight-who { font: 16px var(--type); margin: 6px 0 14px; }
.fight-log { background: var(--panel); border-left: 3px solid var(--blood); padding: 8px 14px; margin-bottom: 16px; font-size: 15px; }
.fight-log p { margin: 6px 0; }
.fight-log p:last-child { font-weight: 700; }
.fight-actions { display: grid; gap: 8px; margin-bottom: 12px; }

/* Game over */
.over { padding-top: calc(env(safe-area-inset-top) + 40px); text-align: center; }
.over h1 { font-size: 84px; line-height: .9; margin-top: 6px; }
.rating { font: 18px var(--type); color: var(--hazard); margin: 6px 0 18px; }
.final { font: 64px var(--display); letter-spacing: .02em; }
.breakdown { margin: 8px auto 24px; max-width: 280px; text-align: left; }
.breakdown div { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.breakdown dd { margin: 0; font-variant-numeric: tabular-nums; }
.notebook.short { margin-top: 24px; text-align: left; max-height: 40vh; overflow: auto; }

/* PIN gate */
.gate { padding-bottom: 0; display: flex; }
.pinpad { width: 100%; padding-top: calc(env(safe-area-inset-top) + 7vh); padding-bottom: 24px; text-align: center; }
.logo {
  font-size: 104px; line-height: .82; margin: 10px 0 26px; color: var(--ink);
  text-shadow: 0 0 2px rgba(236,229,214,.5), 4px 4px 0 var(--blood);
  transform: rotate(-3deg);
}
#pin { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.dots { display: flex; justify-content: center; gap: 18px; }
.dots i { width: 16px; height: 16px; border: 2px solid var(--muted); border-radius: 50%; transition: background .1s; }
.dots i.on { background: var(--hazard); border-color: var(--hazard); }
.pin-msg { font: 15px var(--type); color: var(--muted); min-height: 1.5em; margin: 16px 0 18px; }
.pin-msg.err { color: var(--blood); }
.keys { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; justify-content: center; }
.keys button {
  height: 76px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line);
  font: 34px var(--display); cursor: pointer;
}
.keys button:active { background: var(--hazard); color: #000; }
.keys button:disabled { opacity: .3; }
