/* Turf: night city. One family (Archivo) at different widths. Colour only carries meaning. */
:root {
  --asphalt: #191d24;
  --panel: #232933;
  --panel-2: #2b323d;
  --line: #3a4350;
  --chalk: #e8eaee;
  --muted: #a7b0bc;
  --sodium: #f5a13b;
  --sodium-ink: #1a1206;
  --siren: #6aa6ff;
  --blood: #ff6b70;
  --money: #7ddc9a;
  --water: #0f2333;
  --park: #1c3327;
  --focus: #ffd43b;
  --radius: 4px;
  --font: "Archivo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--asphalt); color: var(--chalk); font: 400 15px/1.5 var(--font); font-stretch: 100%; -webkit-font-smoothing: antialiased; }
a { color: var(--sodium); }
a:hover { color: #ffbe6b; }
h1, h2, h3 { font-stretch: 75%; font-weight: 700; line-height: 1.1; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.2rem, 6vw, 4.2rem); }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.num, td.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; min-height: 40px; padding: .45em 1em; border: 1px solid var(--line); background: var(--panel-2); color: var(--chalk); border-radius: var(--radius); cursor: pointer; text-decoration: none; font-weight: 600; font-stretch: 87%; }
.btn:hover { border-color: var(--muted); color: var(--chalk); }
.btn-go { background: var(--sodium); border-color: var(--sodium); color: var(--sodium-ink); }
.btn-go:hover { background: #ffb658; color: var(--sodium-ink); }
.btn-danger { border-color: var(--blood); color: var(--blood); }
.btn-sm { min-height: 32px; padding: .2em .7em; font-size: .9rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea { background: var(--asphalt); border: 1px solid var(--line); border-radius: var(--radius); padding: .5em .65em; min-height: 40px; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-weight: 600; margin: 0 0 .25em; font-size: .92rem; }
.field { margin-bottom: 1em; }
.muted { color: var(--muted); }
.err { color: var(--blood); }
.ok { color: var(--money); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .45em .5em; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .85rem; font-stretch: 87%; }
td.num, th.num { text-align: right; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Public pages ---- */
.site-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; border-bottom: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }
.logo { font-weight: 800; font-stretch: 62%; font-size: 1.9rem; color: var(--chalk); text-decoration: none; letter-spacing: .01em; line-height: 1; }
.site-head nav { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.site-head form { margin: 0; }
.hero { position: relative; height: min(78vh, 760px); min-height: 460px; overflow: hidden; border-bottom: 1px solid var(--line); background: var(--water); }
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-copy { position: absolute; left: 0; bottom: 0; padding: 28px 24px 32px; max-width: 620px; background: rgba(25,29,36,.94); border-top: 3px solid var(--sodium); }
.hero-copy p { max-width: 52ch; color: var(--chalk); font-size: 1.08rem; }
.hero-copy .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 40px 24px; }
.narrow { max-width: 460px; margin: 0 auto; padding: 48px 24px; }
.ledger { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 2px solid var(--chalk); margin-bottom: 40px; }
.ledger div { padding: 14px 12px 14px 0; border-bottom: 1px solid var(--line); }
.ledger b { display: block; font-size: 2rem; font-stretch: 75%; font-variant-numeric: tabular-nums; line-height: 1.1; }
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 40px; }
.rules section { border-top: 1px solid var(--line); padding: 16px 0; }
.rules p { max-width: 60ch; color: var(--muted); }
.rules h3 { color: var(--chalk); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -1px; margin-right: 6px; }
.site-foot { padding: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.flash { padding: .7em 1em; border-left: 3px solid var(--sodium); background: var(--panel); margin-bottom: 1em; }
.guide table { margin-bottom: 2em; font-size: .93rem; }
.guide h2 { margin-top: 1.5em; }
.admin-grid { display: grid; gap: 28px; }
.admin-grid form.inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.admin-grid form.inline input { width: 90px; }
.tbl-scroll { overflow-x: auto; }

/* ---- Game ---- */
body.game { overflow: hidden; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }
.topbar { display: flex; align-items: stretch; gap: 0; border-bottom: 1px solid var(--line); background: var(--panel); min-height: 52px; position: relative; z-index: 5; }
.topbar .logo { display: flex; align-items: center; padding: 0 14px; font-size: 1.6rem; border-right: 1px solid var(--line); }
.res { display: flex; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.res::-webkit-scrollbar { display: none; }
.res > div { padding: 6px 14px; border-right: 1px solid var(--line); white-space: nowrap; display: flex; flex-direction: column; justify-content: center; }
.res small { color: var(--muted); font-size: .76rem; line-height: 1.2; }
.res b { font-variant-numeric: tabular-nums; font-stretch: 87%; font-size: 1.02rem; line-height: 1.2; }
.res .heat-bar { width: 96px; height: 6px; background: var(--asphalt); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.res .heat-bar i { display: block; height: 100%; background: var(--sodium); }
.res .heat-4 .heat-bar i { background: var(--blood); }
.stage { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 0; }
.stage > * { min-width: 0; }
#map { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; background: var(--water); }
#map.dragging { cursor: grabbing; }
.mapwrap { position: relative; min-height: 0; overflow: hidden; }
.map-tools { position: absolute; left: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; }
.map-tools .btn { width: 40px; padding: 0; background: rgba(35,41,51,.92); }
.map-legend { position: absolute; left: 12px; bottom: 12px; background: rgba(35,41,51,.92); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; font-size: .8rem; color: var(--muted); max-width: 260px; }
.hover-tip { position: absolute; pointer-events: none; background: rgba(25,29,36,.96); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 9px; font-size: .84rem; white-space: nowrap; transform: translate(12px, 12px); }
nav.views { display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); width: 76px; overflow-y: auto; }
nav.views button { background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--muted); padding: 12px 4px; cursor: pointer; font-size: .82rem; font-weight: 600; font-stretch: 87%; position: relative; min-height: 52px; }
nav.views button[aria-pressed=true] { color: var(--chalk); background: var(--panel-2); box-shadow: inset 3px 0 0 var(--sodium); }
nav.views button .badge { position: absolute; top: 6px; right: 6px; background: var(--blood); color: #fff; font-size: .68rem; border-radius: 8px; padding: 0 5px; min-width: 16px; line-height: 16px; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; transform: translateX(110%); transition: transform .18s ease; z-index: 4; }
.drawer.open { transform: none; }
.drawer header { position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--line); padding: 12px 16px; display: flex; align-items: flex-start; gap: 10px; z-index: 1; }
.drawer header h2 { margin: 0; font-size: 1.35rem; flex: 1; }
.drawer header .close { min-width: 40px; }
.drawer .body { padding: 14px 16px 40px; }
.drawer section { margin-bottom: 22px; }
.drawer h3 { border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.bld { border-bottom: 1px solid var(--line); padding: 8px 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.bld p { margin: 0; color: var(--muted); font-size: .84rem; grid-column: 1; }
.bld .lvl { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 400; }
.bld .btn { grid-row: 1 / span 2; grid-column: 2; }
.queue-item { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.unit-row { display: grid; grid-template-columns: 1fr 72px auto; gap: 6px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.unit-row input { min-height: 34px; padding: .2em .4em; text-align: right; }
.unit-row small { display: block; color: var(--muted); font-size: .78rem; }
.kinds { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.kinds label { margin: 0; font-weight: 600; }
.kinds input { position: absolute; opacity: 0; }
.kinds span { display: inline-block; border: 1px solid var(--line); border-radius: var(--radius); padding: .35em .8em; cursor: pointer; font-stretch: 87%; }
.kinds input:checked + span { border-color: var(--sodium); color: var(--sodium); }
.kinds input:focus-visible + span { outline: 2px solid var(--focus); }
.tag { display: inline-block; font-size: .76rem; border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; color: var(--muted); font-weight: 600; }
.tag.hot { color: var(--sodium); border-color: var(--sodium); }
.tag.bad { color: var(--blood); border-color: var(--blood); }
.tag.law { color: var(--siren); border-color: var(--siren); }
.list-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 9px 2px; color: var(--chalk); cursor: pointer; }
.list-item:hover { background: var(--panel-2); }
.list-item.unread { font-weight: 700; }
.list-item small { color: var(--muted); display: block; font-weight: 400; }
.chat { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; margin-bottom: 8px; background: var(--asphalt); font-size: .9rem; }
.chat p { margin: 0 0 6px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--sodium); padding: 10px 16px; border-radius: var(--radius); z-index: 50; max-width: min(520px, calc(100vw - 32px)); }
.toast.error { border-left-color: var(--blood); }
.modal-back { position: fixed; inset: 0; background: rgba(10,14,20,.7); display: grid; place-items: center; z-index: 30; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; width: min(460px, 100%); max-height: 90vh; overflow-y: auto; }
.colours { display: flex; flex-wrap: wrap; gap: 8px; }
.colours label { margin: 0; }
.colours input { position: absolute; opacity: 0; }
.colours span { display: block; width: 34px; height: 34px; border-radius: var(--radius); border: 2px solid transparent; }
.colours input:checked + span { border-color: var(--chalk); box-shadow: 0 0 0 2px var(--asphalt) inset; }
.colours input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.report-table td, .report-table th { padding: .3em .4em; font-size: .86rem; }
.store-item { border-bottom: 1px solid var(--line); padding: 10px 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; }
.store-item p { margin: 0; color: var(--muted); font-size: .86rem; }
.store-item .btn { grid-row: 1 / span 2; grid-column: 2; }
.diamond { color: #9fe3ff; font-weight: 700; }

@media (max-width: 760px) {
  .topbar .logo { display: none; }
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  nav.views { flex-direction: row; width: auto; border-left: 0; border-top: 1px solid var(--line); overflow-x: auto; }
  nav.views button { flex: 1 0 64px; border-bottom: 0; border-right: 1px solid var(--line); min-height: 48px; padding: 8px 2px; }
  nav.views button[aria-pressed=true] { box-shadow: inset 0 3px 0 var(--sodium); }
  .drawer { right: 0; left: 0; top: auto; width: 100%; height: 74%; bottom: 0; border-left: 0; border-top: 1px solid var(--line); transform: translateY(110%); }
  .drawer.open { transform: none; }
  .map-legend { display: none; }
  .hero-copy { padding: 24px 16px 28px; }
  .wrap { padding: 32px 16px; }
  .site-head { padding: 12px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
