/* Car City: pixel-art UI. Bundled pixel fonts, hard black borders, flat colours, no blur or gradients. */
@font-face { font-family: 'Press Start 2P'; src: url('/games/city/fonts/press-start-2p.woff2') format('woff2'); font-display: block; }
@font-face { font-family: 'VT323'; src: url('/games/city/fonts/vt323.woff2') format('woff2'); font-display: block; }
:root {
  --bg: #20263f; --panel: #2c3a6b; --panel2: #1c2547; --ink: #1c1d1d; --paper: #fafdff; --sub: #b9bcd8;
  --yellow: #f0d43a; --green: #3bd16f; --red: #d6453d; --blue: #46b8e0; --orange: #e2a328; --pink: #e86aa5;
  --safe-t: env(safe-area-inset-top); --safe-b: env(safe-area-inset-bottom); --safe-l: env(safe-area-inset-left); --safe-r: env(safe-area-inset-right);
  --pix: 'Press Start 2P', monospace; --txt: 'VT323', monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; border-radius: 0 !important; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--paper); overscroll-behavior: none; font-family: var(--txt); }
body { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#app { position: absolute; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
img.pix { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; image-rendering: pixelated; }

/* a chunky pixel box */
.box { background: var(--panel); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }

/* ---------- HUD */
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
.topbar { position: absolute; left: 0; right: 0; top: 0; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: calc(6px + var(--safe-t)) calc(6px + var(--safe-r)) 6px calc(6px + var(--safe-l)); background: var(--panel2); border-bottom: 3px solid var(--ink); }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; background: var(--yellow); border: 3px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.icon-btn img { width: 24px; height: 24px; filter: none; }
#btnPause img { filter: invert(1) brightness(0.1); }
.pill { display: flex; align-items: center; gap: 5px; height: 38px; padding: 0 8px; background: var(--ink); border: 3px solid #3b4a86; font-family: var(--pix); font-size: 11px; }
.pill .ic { width: 20px; height: 20px; }
.pill b { font-weight: normal; color: var(--yellow); }
.pill small { font-family: var(--txt); font-size: 17px; color: var(--green); }
.pill small.neg { color: var(--red); }
.pill.warn { border-color: var(--red); animation: blink 0.8s steps(1) infinite; }
.pill.clock { flex-direction: row; }
.pill.clock small { color: var(--sub); }
.pill.clock.rush { border-color: var(--orange); }
.pill.clock.rush small { color: var(--orange); }
@keyframes blink { 50% { background: #4a1414; } }
.speed { display: flex; gap: 3px; margin-left: auto; }
.speed button { width: 36px; height: 36px; display: grid; place-items: center; background: var(--paper); border: 3px solid var(--ink); }
.speed button img { width: 20px; height: 20px; }
.speed button.on { background: var(--green); }
.speed button[data-speed="0"].on { background: var(--pink); }
.goalcard { position: absolute; left: calc(6px + var(--safe-l)); top: var(--hud-h, calc(56px + var(--safe-t))); max-width: min(440px, calc(100% - 66px)); background: var(--paper); color: var(--ink); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 5px 8px; font-size: 19px; line-height: 1; }
.goalcard:empty { display: none; }
.goalcard .k { font-family: var(--pix); font-size: 8px; background: var(--ink); color: var(--yellow); padding: 3px 4px; margin-right: 5px; vertical-align: 2px; }
.goalcard .p { color: #1f63b5; }
.goalcard .rw { color: #1d8a45; }
.side { position: absolute; right: calc(6px + var(--safe-r)); top: var(--hud-h, calc(56px + var(--safe-t))); display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.fab { width: 42px; height: 42px; display: grid; place-items: center; background: var(--paper); border: 3px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.fab img { width: 24px; height: 24px; }
.fab.on { background: var(--yellow); }
.layers { display: flex; flex-direction: column; gap: 3px; background: var(--paper); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 3px; }
.layers button { font-family: var(--pix); font-size: 9px; color: var(--ink); padding: 9px 10px; text-align: left; border: 2px solid transparent; }
.layers button.on { background: var(--yellow); border-color: var(--ink); }

/* ---------- toolbar */
.toolbar { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px calc(6px + var(--safe-r)) calc(6px + var(--safe-b)) calc(6px + var(--safe-l)); background: var(--panel2); border-top: 3px solid var(--ink); }
body.ios-browser .toolbar { padding-bottom: 84px; }
.hint { margin: 2px 4px 4px; font-size: 18px; line-height: 1; color: var(--sub); min-height: 18px; }
.hint b { color: var(--yellow); font-weight: normal; }
.tools { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 7px; scrollbar-width: none; touch-action: pan-x; -webkit-overflow-scrolling: touch; }
.tools::-webkit-scrollbar { display: none; }
.tool { flex: 0 0 auto; width: 76px; height: 78px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.tool .ti { width: 32px; height: 32px; object-fit: contain; }
.tool .tn { font-family: var(--pix); font-size: 7px; max-width: 70px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool .tc { font-size: 15px; line-height: 1; color: #1d8a45; max-width: 70px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool.on { background: var(--yellow); }
.tool.locked { background: #8d93a8; }
.tool.locked img { opacity: 0.35; }
.tool.locked .tc { color: var(--ink); }
.cats { display: flex; gap: 3px; }
.cats button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 1px; background: var(--ink); border: 3px solid #3b4a86; font-family: var(--pix); font-size: 7px; color: var(--sub); }
.cats button .ci { width: 24px; height: 24px; object-fit: contain; }
.cats button.on { background: var(--pink); border-color: var(--ink); color: var(--ink); }

/* ---------- toast */
.toast { position: absolute; left: 50%; top: calc(104px + var(--safe-t)); transform: translateX(-50%); display: none; background: var(--yellow); color: var(--ink); padding: 8px 10px; border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); font-family: var(--pix); font-size: 9px; line-height: 1.5; text-align: center; max-width: min(90vw, 440px); pointer-events: none; z-index: 40; text-transform: uppercase; }
.toast.show { display: block; }
.toast.warn { background: var(--orange); }
.toast.rush { background: var(--pink); }
.toast.good { background: var(--green); }

/* ---------- screens */
.screen { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--bg); overflow-y: auto; touch-action: pan-y; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
.menu { align-items: center; justify-content: center; gap: 28px; padding: 20px; }
.logo { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.logo img { width: 96px; height: 96px; }
.logo h1 { margin: 0; font-family: var(--pix); font-size: clamp(26px, 8vw, 46px); color: var(--yellow); text-shadow: 4px 4px 0 var(--ink); font-weight: normal; }
.logo p { margin: 0; font-family: var(--pix); font-size: 8px; color: var(--sub); }
.menu-btns, .card-list { display: flex; flex-direction: column; gap: 12px; width: min(420px, 100%); }
.card-list { margin: 0 auto; padding: 16px; }
.big { width: 100%; text-align: left; padding: 14px 16px; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); font-family: var(--pix); font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.big small { font-family: var(--txt); font-size: 18px; color: #4a5070; }
.big.primary { background: var(--green); }
.big.ghost { background: var(--panel); color: var(--paper); }
.big.ghost small { color: var(--sub); }
.big.danger { background: var(--red); color: var(--paper); }
.big:active, .btn:active, .tool:active, .fab:active { transform: translate(2px, 2px); box-shadow: none; }
.tiny { font-size: 17px; color: var(--sub); text-align: center; margin: 6px 0; }
.screen-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; position: sticky; top: 0; background: var(--panel2); border-bottom: 3px solid var(--ink); z-index: 1; }
.screen-head h2 { margin: 0; flex: 1; font-family: var(--pix); font-size: 16px; font-weight: normal; color: var(--yellow); }
.stars-total { display: flex; gap: 6px; align-items: center; font-family: var(--pix); font-size: 11px; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 14px; }
.level { background: var(--paper); color: var(--ink); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); padding: 10px; text-align: left; display: flex; flex-direction: column; gap: 8px; min-height: 130px; }
.level .li img { height: 48px; width: auto; }
.level .ln { font-family: var(--pix); font-size: 9px; line-height: 1.5; }
.level .ls { display: flex; gap: 4px; }
.level .ls img.off, .stars img.off { opacity: 0.2; filter: grayscale(1); }
.level.locked { background: #8d93a8; }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); font-family: var(--pix); font-size: 11px; }
.toggle input { width: 26px; height: 26px; accent-color: var(--green); }

/* ---------- modal + sheet */
.modal { position: absolute; inset: 0; z-index: 50; background: rgba(16, 10, 40, 0.7); display: grid; place-items: center; padding: 16px; }
.modal-card { width: min(440px, 100%); max-height: 90%; overflow-y: auto; background: var(--paper); color: var(--ink); border: 4px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); padding: 18px; text-align: center; touch-action: pan-y; }
.modal-card h2 { margin: 6px 0 10px; font-family: var(--pix); font-size: 16px; font-weight: normal; line-height: 1.4; }
.modal-card p { font-size: 20px; line-height: 1.1; margin: 8px 0; color: #3a4060; }
.modal-card .bigicon { display: flex; justify-content: center; }
.modal-card .bigicon img { height: 64px; width: auto; }
.modal-card .stars { display: flex; justify-content: center; gap: 8px; margin: 8px 0; }
.modal-card .stars img { width: 48px; height: 48px; }
.modal-card .goal-list { text-align: left; background: #e8ebf5; border: 3px solid var(--ink); padding: 8px 10px; margin: 10px 0; font-size: 20px; line-height: 1.1; }
.modal-card .goal-list div { padding: 3px 0; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn { flex: 1; padding: 12px 6px; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); font-family: var(--pix); font-size: 10px; text-transform: uppercase; }
.btn.primary { background: var(--green); }
.btn.good { background: var(--green); }
.btn.danger { background: var(--red); color: var(--paper); }
.sheet-wrap { position: absolute; inset: 0; z-index: 45; background: rgba(16, 10, 40, 0.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet { position: relative; width: min(520px, 100%); max-height: 78%; overflow-y: auto; background: var(--paper); color: var(--ink); border: 4px solid var(--ink); border-bottom: 0; padding: 14px 16px calc(16px + var(--safe-b)); touch-action: pan-y; }
body.ios-browser .sheet { padding-bottom: 96px; }
.grab { display: none; }
.sheet-x { position: absolute; right: 10px; top: 10px; width: 34px; height: 34px; display: grid; place-items: center; background: var(--paper); border: 3px solid var(--ink); }
.sheet-x img { width: 18px; height: 18px; }
.sheet h2 { margin: 0 0 10px; font-family: var(--pix); font-size: 13px; font-weight: normal; padding-right: 42px; line-height: 1.5; }
.sheet h3 { font-family: var(--pix); font-size: 9px; font-weight: normal; color: #4a5070; margin: 14px 0 6px; }
.sheet p { margin: 6px 0; font-size: 19px; line-height: 1.05; color: #3a4060; }
.row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 2px dashed #c9cde0; font-size: 20px; }
.row:last-child { border-bottom: 0; }
.row b { font-weight: normal; font-family: var(--pix); font-size: 10px; }
.pos { color: #1d8a45; } .neg { color: #b5241c; }
.bar { height: 14px; background: #d8dbe8; border: 3px solid var(--ink); margin: 6px 0; }
.bar i { display: block; height: 100%; background: var(--green); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; padding: 10px 8px; background: var(--paper); border: 3px solid var(--ink); font-family: var(--pix); font-size: 9px; text-transform: uppercase; }
.seg button.on { background: var(--blue); }
.seg button.locked { background: #b5b9c9; color: #555; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 14px; font-family: var(--pix); font-size: 13px; }
.stepper button { width: 42px; height: 42px; background: var(--paper); border: 3px solid var(--ink); font-family: var(--pix); font-size: 16px; }
.slider { display: grid; grid-template-columns: 86px 1fr 52px; gap: 8px; align-items: center; padding: 4px 0; font-size: 20px; }
.slider input { width: 100%; accent-color: var(--blue); height: 30px; }
.slider b { text-align: right; font-weight: normal; font-family: var(--pix); font-size: 10px; }
#rulesCv { width: min(240px, 70vw); aspect-ratio: 1; display: block; margin: 6px auto; border: 3px solid var(--ink); image-rendering: pixelated; touch-action: none; }
.ms { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 2px dashed #c9cde0; font-size: 19px; line-height: 1.05; }
.ms .msi img { width: 24px; height: 24px; }
.ms.done { opacity: 0.55; }

@media (max-width: 560px) {
  .pill { height: 34px; padding: 0 6px; font-size: 9px; gap: 4px; }
  .pill .ic { width: 16px; height: 16px; }
  .pill small { font-size: 15px; }
  .icon-btn, .speed button { width: 32px; height: 32px; }
  .speed button img { width: 16px; height: 16px; }
  .tool { width: 68px; height: 72px; }
  .goalcard { top: var(--hud-h, calc(92px + var(--safe-t))); font-size: 17px; }
  .side { top: var(--hud-h, calc(92px + var(--safe-t))); }
  .toast { top: calc(var(--hud-h, calc(92px + var(--safe-t))) + 48px); }
}
/* pixel range sliders */
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 30px; }
input[type=range]::-webkit-slider-runnable-track { height: 12px; background: #d8dbe8; border: 3px solid var(--ink); }
input[type=range]::-moz-range-track { height: 6px; background: #d8dbe8; border: 3px solid var(--ink); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 24px; margin-top: -9px; background: var(--yellow); border: 3px solid var(--ink); }
input[type=range]::-moz-range-thumb { width: 12px; height: 18px; background: var(--yellow); border: 3px solid var(--ink); border-radius: 0; }
input[type=checkbox] { -webkit-appearance: none; appearance: none; width: 28px; height: 28px; background: var(--paper); border: 3px solid var(--ink); display: grid; place-items: center; }
input[type=checkbox]:checked { background: var(--green); }
input[type=checkbox]:checked::after { content: ''; width: 10px; height: 10px; background: var(--ink); }
.want-menu { width: 100%; }
.want-menu .want-btn { width: 100%; font-size: 12px; padding: 14px; box-shadow: 4px 4px 0 var(--ink); }
.want-menu .want-n { color: var(--sub); }

.fab.move { height: 52px; flex-direction: column; gap: 2px; display: flex; align-items: center; justify-content: center; }
.fab.move img { width: 20px; height: 20px; }
.fab.move span { font-family: var(--pix); font-size: 6px; color: var(--ink); }
.fab.move.on { background: var(--green); }

/* ---------- cozy style: warm, soft palette (same pixel shapes) */
html.cozy {
  --bg: #2b2433; --panel: #574a66; --panel2: #3a3046; --ink: #2e2428; --paper: #fff6e8; --sub: #d8c8c0;
  --yellow: #f2c879; --green: #8cc78a; --red: #d9807a; --blue: #8fb9d6; --orange: #e7a86a; --pink: #e8a3b8;
}
html.cozy #map { filter: saturate(0.74) sepia(0.14) brightness(1.03) contrast(0.95); }
.set-sub { display: block; font-family: var(--txt); font-size: 16px; color: var(--sub); text-transform: none; margin-top: 4px; line-height: 1; }
