/* DRUGLORD STRATEGY — interface over the map canvas. Phone first (portrait), a side panel on wide screens.
   Style: the design system JAPAN MANIACKERS DESIGN MKS (art/SPEC.md): white paper, ink, the identity colours blue
   (task force) and red (drug lord), flat colour fields, square corners, no shadows or gradients.
   Fonts (SIL Open Font License, subsets in fonts/): Monomaniac One and Darumadrop One by Maniackers Design for
   headings, names, numbers and the title; DotGothic16, a Japanese dot font, for text and dialogue. */
@font-face { font-family: "Monomaniac One"; src: url("../fonts/MonomaniacOne.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Darumadrop One"; src: url("../fonts/DarumadropOne.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "DotGothic16"; src: url("../fonts/DotGothic16.woff2") format("woff2"); font-display: swap; }

:root {
  --paper: #ffffff; --paper2: #eef2fa; --paper3: #dfe6f5; --ink: #333333; --ink2: #1f1f2b; --muted: #666666; --track: #dfe6f5;
  --blue: #0066ff; --blueD: #0033ff; --red: #ff3333; --redUI: #d81e2b; --yellow: #ffcc00; --pink: #ff2975; --orange: #ff6600;
  --green: #36b44a; --greenD: #1f7a34; --gold: #8a6a00;
  --side: var(--red); --sideUI: var(--redUI); --sideTint: #ffecec;
  --px: "Monomaniac One", "DotGothic16", ui-sans-serif, system-ui, sans-serif;
  --body: "DotGothic16", "Monomaniac One", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --title: "Darumadrop One", "Monomaniac One", ui-sans-serif, system-ui, sans-serif;
  --fs: 16px; --top: max(6px, env(safe-area-inset-top)); --bot: max(6px, env(safe-area-inset-bottom));
}
:root.large { --fs: 19px; }
body.law { --side: var(--blue); --sideUI: var(--blue); --sideTint: #e8f0ff; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d3a8c; color: var(--ink); overscroll-behavior: none;
  font-family: var(--body); font-size: var(--fs); line-height: 1.4; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
#map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#map:active { cursor: grabbing; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
/* iOS Safari zooms the page on a double tap unless the element says otherwise; panels keep vertical scrolling */
#ui, #ui *, #modal, #modal *, #title, #title * { touch-action: manipulation; }
#sheet .body, #modal, #title { touch-action: pan-y; }
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; border-radius: 0; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--yellow); outline-offset: 1px; }
.px { font-family: var(--px); letter-spacing: 0.01em; }
.muted { color: var(--muted); }
.gold { color: var(--gold); } .red { color: #c8102e; } .green { color: var(--greenD); } .blue { color: var(--blueD); }
.hidden { display: none !important; }
.face { display: inline-block; flex: none; background-image: url("../assets/faces.png"); background-repeat: no-repeat; image-rendering: pixelated; image-rendering: crisp-edges; vertical-align: middle; }

/* ---------------------------------------------------------------------------------------------------------------
   Top bar: white paper, a colour rule in the side's colour */
#hud { position: fixed; top: 0; left: 0; right: 0; padding: var(--top) 8px 4px; background: var(--paper); display: flex; flex-direction: column; gap: 3px; z-index: 7;
  box-shadow: inset 0 -4px 0 var(--side); padding-bottom: 8px; }
#hud .row { display: flex; align-items: center; gap: 6px; min-height: 38px; }
#hud .date { font-family: var(--px); font-size: 17px; line-height: 1.05; color: var(--ink2); }
#hud .date small { display: block; color: var(--muted); font-size: 11px; }
#hud .money { margin-left: auto; text-align: right; font-family: var(--px); font-size: 19px; line-height: 1.05; color: var(--ink2); }
#hud .money small { display: block; font-size: 11px; color: var(--muted); }
.ibtn { min-width: 42px; height: 38px; border: 0; background: var(--paper2); color: var(--ink2); display: inline-grid;
  place-items: center; padding: 0 8px; font-family: var(--px); font-size: 15px; }
.ibtn.on { background: var(--side); color: #fff; }
.speed { display: flex; gap: 3px; }
.speed .ibtn { min-width: 36px; padding: 0 5px; }
.meters { display: flex; gap: 10px; align-items: center; font-family: var(--px); font-size: 11px; color: var(--muted); overflow: hidden; }
.meter { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.meter b { color: var(--ink2); font-size: 14px; font-weight: 400; }
.bar { width: 54px; height: 8px; background: var(--track); position: relative; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--yellow); }
.bar.red i { background: var(--red); } .bar.green i { background: var(--green); } .bar.blue i { background: var(--blue); }
.bar .mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink2); }

/* the news ticker: a yellow band with the red BALITA tag */
#ticker { position: fixed; left: 0; right: 0; height: 26px; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 0; z-index: 4;
  background: var(--yellow); color: var(--ink2); font-size: 14px; white-space: nowrap; overflow: hidden; }
#ticker .tag { font-family: var(--px); font-size: 15px; background: var(--redUI); color: #fff; padding: 0 8px; height: 26px; line-height: 26px; flex: none; }
#ticker .scroll { flex: 1; overflow: hidden; position: relative; height: 26px; }
#ticker .line { position: absolute; left: 0; top: 4px; white-space: nowrap; will-change: transform; font-family: var(--px); font-size: 15px; }

/* the event tray: chips on the left, under the ticker */
#tray { position: fixed; left: 6px; display: flex; flex-direction: column; gap: 6px; z-index: 4; max-width: 50vw; }
.chip { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 10px 4px 6px; text-align: left; border: 0;
  background: var(--paper); color: var(--ink2); font-family: var(--px); font-size: 14px; line-height: 1.1; box-shadow: inset 5px 0 0 var(--muted); padding-left: 11px; }
.chip canvas { width: 22px; height: 22px; image-rendering: pixelated; flex: none; }
.chip.sev3 { box-shadow: inset 5px 0 0 var(--red); background: #ffecec; animation: pulse 0.7s steps(2) infinite; }
.chip.sev2 { box-shadow: inset 5px 0 0 var(--yellow); }
.chip.sev1 { box-shadow: inset 5px 0 0 var(--green); }
@keyframes pulse { 50% { background: var(--red); color: #fff; } }
@media (prefers-reduced-motion: reduce) { .chip.sev3 { animation: none; } }

/* map buttons on the right */
#mapbtns { position: fixed; right: 8px; display: flex; flex-direction: column; gap: 6px; z-index: 4; }
#mapbtns .ibtn { width: 50px; height: 46px; font-size: 13px; padding: 0; text-align: center; line-height: 1.0; background: var(--paper); }

/* ---------------------------------------------------------------------------------------------------------------
   Bottom tabs and the sheet above them */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 4px 6px var(--bot); gap: 4px; background: var(--paper); z-index: 6; box-shadow: inset 0 4px 0 var(--side); padding-top: 8px; }
#tabs button { height: 48px; border: 0; background: transparent; font-family: var(--px); font-size: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--ink); position: relative; }
#tabs button.on { color: #fff; background: var(--side); }
#tabs button canvas { width: 20px; height: 20px; image-rendering: pixelated; }
#tabs .dot { position: absolute; top: 2px; right: calc(50% - 24px); min-width: 18px; height: 18px; background: var(--redUI);
  color: #fff; font-size: 12px; display: grid; place-items: center; padding: 0 4px; font-family: var(--px); }

#sheet { position: fixed; left: 0; right: 0; z-index: 5; background: var(--paper); display: flex; flex-direction: column; max-height: 62vh;
  transform: translateY(0); transition: transform 0.18s steps(4); }
#sheet.closed { transform: translateY(110%); }
#sheet .handle { flex: none; height: 18px; display: grid; place-items: center; cursor: pointer; border: 0; background: var(--side); width: 100%; }
#sheet .handle::before { content: ""; width: 44px; height: 4px; background: #ffffffaa; }
#sheet .head { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 12px 8px; background: var(--side); color: #fff; }
#sheet .head h2 { margin: 0; font-family: var(--px); font-size: 21px; font-weight: 400; line-height: 1.05; }
#sheet .head .sub { font-size: 14px; color: #ffffffd9; font-family: var(--px); }
#sheet .head .x { margin-left: auto; background: #ffffff33; color: #fff; }
#sheet .body { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 4px 12px 16px; touch-action: pan-y; }
.sec { margin: 12px 0 0; }
.sec > h3 { margin: 0 0 6px; font-family: var(--px); font-size: 15px; color: var(--ink2); font-weight: 400; display: flex; align-items: center; gap: 6px; }
.sec > h3::before { content: ""; width: 10px; height: 10px; background: var(--side); flex: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 15px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; color: var(--ink2); }
.cards { display: grid; gap: 8px; }
.card { background: var(--paper2); padding: 10px; }
.card h4 { margin: 0 0 4px; font-family: var(--px); font-size: 16px; font-weight: 400; line-height: 1.15; color: var(--ink2); }
.card p { margin: 0 0 8px; font-size: 15px; }
.card.warn { background: #fff6cc; } .card.danger { background: #ffe5e5; } .card.good { background: #e3f5e6; }
.card .says { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 8px; }
.card .says q { quotes: none; font-size: 15px; color: var(--ink2); }
.card .says q b { display: block; font-family: var(--px); font-weight: 400; font-size: 14px; color: var(--muted); }
.acts { display: flex; flex-wrap: wrap; gap: 6px; }
.btn { min-height: 46px; padding: 6px 12px; border: 0; background: var(--paper3); color: var(--ink2); text-align: left;
  font-family: var(--px); font-size: 17px; line-height: 1.1; flex: 1 1 140px; }
.btn small { display: block; font-family: var(--body); font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.2; }
.btn.primary { background: var(--sideUI); color: #fff; font-size: 19px; } .btn.primary small { color: #ffffffe0; }
.btn.danger { background: var(--redUI); color: #fff; } .btn.danger small { color: #ffe1e1; }
.btn.good { background: var(--greenD); color: #fff; } .btn.good small { color: #d8f2dc; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--paper3); flex: 0 1 auto; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.row2 { display: flex; gap: 8px; align-items: center; }
.pill { display: inline-block; padding: 0 6px; font-family: var(--px); font-size: 13px; background: var(--paper3); color: var(--ink2); vertical-align: middle; }
.pill.red { background: var(--redUI); color: #fff; } .pill.gold { background: var(--yellow); color: var(--ink2); } .pill.green { background: var(--greenD); color: #fff; } .pill.blue { background: var(--blue); color: #fff; }
.shares { display: flex; height: 14px; background: var(--track); margin: 4px 0; }
.shares i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; }
.legend span::before { content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 4px; background: var(--c); vertical-align: -1px; }
.list { display: grid; gap: 6px; }
.item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--paper2); border: 0; text-align: left; width: 100%; color: var(--ink2); }
.item canvas { width: 22px; height: 22px; image-rendering: pixelated; flex: none; }
.item .t { flex: 1; min-width: 0; } .item .t b { display: block; font-weight: 400; font-family: var(--px); font-size: 16px; } .item .t small { color: var(--muted); font-size: 13px; }
.item .r { text-align: right; font-family: var(--px); font-size: 14px; }
.ev { height: 7px; background: var(--track); position: relative; margin-top: 3px; }
.ev i { position: absolute; left: 0; top: 0; bottom: 0; } .ev .m { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink2); left: 60%; }
.src { display: inline-flex; gap: 3px; margin-left: 4px; } .src i { width: 9px; height: 9px; background: var(--paper3); display: inline-block; } .src i.on { background: var(--green); }
.note { font-size: 14px; color: var(--muted); margin: 6px 0 0; }

/* ---------------------------------------------------------------------------------------------------------------
   Modals: setup, menu, rules, the end */
#modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: calc(var(--top) + 8px) 12px calc(var(--bot) + 8px);
  background: #1f1f2bb8; overflow-y: auto; }
#modal.hidden { display: none; }
.dlg { width: min(540px, 100%); background: var(--paper); padding: 0 16px 16px; }
.dlg h1 { margin: 0 -16px 12px; padding: 12px 16px 10px; font-family: var(--px); font-size: 26px; font-weight: 400; line-height: 1.05; background: var(--side); color: #fff; }
.dlg p { margin: 0 0 10px; }
.dlg .stamp, .tk-stamp { display: inline-block; font-family: var(--px); font-size: 14px; color: #fff; background: var(--redUI); padding: 2px 8px; margin: 12px 0 6px; }
.dlg h3.px { font-size: 17px; font-weight: 400; color: var(--ink2); }

/* title screen: the logo on a blue field over the living map, the two sides as big colour fields */
#title { position: fixed; inset: 0; z-index: 15; display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  padding: calc(var(--top) + 8px) 12px calc(var(--bot) + 10px); overflow-y: auto; }
#title .logo { background: var(--blue); color: #fff; padding: 12px 12px 10px; text-align: center; position: relative; }
#title .logo h1 { margin: 0; font-family: var(--title); font-weight: 400; font-size: clamp(46px, 15vw, 92px); line-height: 0.9; letter-spacing: 0.01em; color: #fff; }
#title .logo h1 span { display: block; font-family: var(--px); font-size: 0.42em; letter-spacing: 0.08em; color: var(--yellow); margin-top: 4px; }
#title .logo .kana { font-family: var(--title); font-size: clamp(15px, 4.6vw, 24px); color: #fff; margin: 4px 0 0; letter-spacing: 0.06em; }
#title .tag { font-family: var(--px); font-size: 14px; color: #ffffffd9; text-align: center; margin: 6px 0 0; }
#title .cast { display: flex; justify-content: center; align-items: flex-end; gap: 4px; margin: 10px auto 0; flex-wrap: nowrap; overflow: hidden; }
#title .cast .face { box-shadow: inset 0 -6px 0 #0000; }
#title .hello { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 8px auto 0; max-width: 520px; text-align: left; }
#title .hello q { quotes: none; background: var(--paper); color: var(--ink2); padding: 6px 10px; font-size: 15px; position: relative; }
#title .pick { display: grid; gap: 8px; width: min(540px, 100%); margin: 0 auto; }
.side { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 0; text-align: left; min-height: 84px; color: #fff; }
.side .face { flex: none; }
.side b { display: block; font-family: var(--px); font-weight: 400; font-size: 23px; line-height: 1.05; } .side small { color: #ffffffe6; font-size: 14px; line-height: 1.3; display: block; margin-top: 3px; }
.side.lord { background: var(--redUI); } .side.law { background: var(--blue); } .side.cont { background: var(--ink2); }
#title .acts .ibtn { background: var(--paper); }
.foot { text-align: center; font-size: 13px; color: var(--ink2); margin: 8px 0 0; background: var(--paper); padding: 8px; }
.foot a { color: var(--blueD); }
.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.opt { min-height: 58px; border: 0; background: var(--paper2); padding: 6px; font-size: 13px; text-align: center; color: var(--ink2); }
.opt b { display: block; font-family: var(--px); font-size: 16px; font-weight: 400; }
.opt.on { background: var(--side); color: #fff; }

/* the front page at the end, and dossiers */
.paper { background: var(--paper); color: var(--ink2); padding: 14px; }
.paper .mast { font-family: var(--title); font-size: 40px; text-align: center; letter-spacing: 0.04em; color: var(--redUI); line-height: 1; padding-bottom: 6px; box-shadow: inset 0 -3px 0 var(--ink2); }
.paper .mast small { font-family: var(--px); font-size: 14px; color: var(--ink2); vertical-align: super; }
.paper .ed { font-family: var(--px); font-size: 13px; text-align: center; padding: 4px 0; margin-bottom: 8px; box-shadow: inset 0 -1px 0 var(--ink2); }
.paper h1 { font-family: var(--px); font-weight: 400; font-size: 27px; line-height: 1.08; margin: 4px 0 8px; background: none; color: var(--ink2); padding: 0; }
.paper p { font-size: 16px; }
.paper .stats { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 15px; padding-top: 6px; box-shadow: inset 0 1px 0 var(--paper3); }
.paper .stats b { font-family: var(--px); font-weight: 400; }
.paper .fine { font-size: 12px; color: var(--muted); margin-top: 8px; }
.paper .stamp { margin-top: 4px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); z-index: 30; background: var(--ink2); color: #fff;
  padding: 7px 12px; font-size: 15px; line-height: 1.3; width: max-content; max-width: min(94vw, 560px); text-align: center; pointer-events: none; transition: opacity 0.2s; }
#toast.hidden { display: block !important; opacity: 0; }

/* the coach (tutorial): a character says each step */
#coach { position: fixed; z-index: 12; left: 8px; right: 8px; max-width: 520px; margin: 0 auto; background: var(--paper); color: var(--ink2);
  padding: 10px; font-size: 15px; box-shadow: inset 0 5px 0 var(--side); padding-top: 13px; }
#coach .co-row { display: flex; gap: 10px; align-items: flex-start; }
#coach .co-name { display: block; font-family: var(--px); font-weight: 400; font-size: 16px; }
#coach .co-name small { font-size: 12px; color: var(--muted); margin-left: 4px; }
#coach p { margin: 2px 0 0; }
#coach .acts { margin-top: 8px; }
#coach .btn { flex: 0 1 auto; min-height: 42px; }
#coach .btn.skip { background: transparent; color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------------------------------------------------------
   The cast speaks: the dialogue box (stops the game) and chat bubbles (do not) */
#talkveil { position: fixed; inset: 0; z-index: 18; background: #1f1f2b40; }
#talk { position: fixed; z-index: 19; left: 8px; right: 8px; bottom: calc(var(--bot) + 64px); max-width: 640px; margin: 0 auto; background: var(--paper);
  color: var(--ink2); padding: 10px 12px 12px; --who: var(--side); box-shadow: inset 0 6px 0 var(--who); padding-top: 14px; }
#talk .tk-row { display: flex; gap: 12px; align-items: flex-start; }
#talk .tk-face { flex: none; margin-top: -40px; }
#talk .tk-main { flex: 1; min-width: 0; }
#talk .tk-name b { display: inline-block; font-family: var(--px); font-weight: 400; font-size: 19px; background: var(--who); color: #fff; padding: 1px 8px; }
#talk .tk-name small { display: block; font-family: var(--px); font-size: 13px; color: var(--muted); margin-top: 2px; }
#talk .tk-text { margin: 6px 0 0; font-size: 16px; line-height: 1.5; min-height: 4.5em; white-space: pre-wrap; }
#talk .tk-facts { margin: 8px 0 0; padding: 6px 8px; background: var(--paper2); font-family: var(--px); font-size: 14px; line-height: 1.3; color: var(--ink2); }
#talk .tk-stamp { margin: 0 0 8px; }
#talk .tk-acts { margin-top: 10px; }
#talk .tk-more { position: absolute; right: 12px; bottom: 6px; font-size: 14px; color: var(--who); visibility: hidden; }
#talk.wait .tk-more { visibility: visible; animation: more 0.6s steps(2) infinite; }
@keyframes more { 50% { transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { #talk.wait .tk-more { animation: none; } }
body.talking #coach { display: none; }
#bubble { position: fixed; z-index: 9; left: 8px; bottom: calc(var(--bot) + 70px); max-width: min(440px, calc(100vw - 72px)); display: flex; gap: 8px; align-items: flex-end;
  cursor: pointer; --who: var(--side); }
#bubble .bb { background: var(--paper); color: var(--ink2); padding: 7px 10px 8px; font-size: 15px; line-height: 1.35; box-shadow: inset 4px 0 0 var(--who); padding-left: 12px; }
#bubble .bb b { display: block; font-family: var(--px); font-weight: 400; font-size: 14px; color: var(--who); }
#bubble .bb small { display: block; font-family: var(--px); font-size: 12px; color: var(--muted); margin-top: 3px; }
#bubble:not(.hidden) { animation: pop 0.18s steps(3); }
@keyframes pop { from { transform: translateY(12px); opacity: 0; } }
body.sheetopen #bubble { bottom: auto; top: calc(var(--hudH, 96px) + 10px); }

/* ---------------------------------------------------------------------------------------------------------------
   Wide screens: the sheet becomes a side panel */
@media (min-width: 900px) and (min-height: 520px) {
  #sheet { left: auto; right: 0; top: var(--sheetTop, 100px); bottom: 0; width: 420px; max-height: none; padding-bottom: 10px; }
  #sheet.closed { transform: translateX(110%); }
  #sheet .handle { display: none; }
  #tabs { right: auto; width: 540px; left: 8px; bottom: 8px; }
  #mapbtns { right: 432px; }
  body.nosheet #mapbtns { right: 8px; }
  #talk { bottom: 80px; }
  #bubble { bottom: 84px; }
  body.sheetopen #bubble { top: auto; bottom: 84px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  #sheet { max-height: 70vh; }
  #tabs button { height: 40px; }
  #talk { bottom: calc(var(--bot) + 8px); }
  #talk .tk-face { margin-top: 0; }
}
#coach .co-row + .co-row { margin-top: 8px; }
#talk .tk-skip { position: absolute; top: 10px; right: 8px; border: 0; background: var(--paper2); color: var(--ink2); font-family: var(--px); font-size: 13px; padding: 3px 8px; min-height: 28px; }
#talk.stamped .tk-face { margin-top: 0; }
#talk.stamped .tk-stamp { margin-right: 56px; }
