:root {
  --bg: #f3ecdf;
  --paper: #fffaf1;
  --ink: #1d2340;          /* matches the navy outline of the art */
  --muted: #6b6a73;
  --line: #e2d7c3;
  --accent: #d9482b;       /* wanted-poster red */
  --ok: #2e8b57;
  --bad: #c0392b;
  --stage: #ebe2d1;
  --radius: 14px;
  --gap: 16px;
  --stage-h: 236px;      /* montage height; the canvas keeps the 160:376 body framing */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}
/* Han characters look different per language; put the matching font first. */
:lang(ja) body { font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif; }
:lang(zh) body { font-family: system-ui, -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif; }
body {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.top, main { max-width: 480px; margin: 0 auto; padding: 0 var(--gap); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 15px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); margin: 0; font-size: 13px; }

button, select { font: inherit; color: inherit; cursor: pointer; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.top-tools { display: flex; gap: 6px; align-items: center; flex: none; }
.ghost.icon { min-width: 36px; min-height: 32px; padding: 4px 8px; font-size: 15px; line-height: 1; }
.lang { appearance: none; -webkit-appearance: none; background: var(--paper); min-height: 32px; padding-right: 12px; }
.ghost.wide { width: 100%; min-height: 44px; font-size: 15px; }
.ghost:disabled { color: var(--muted); cursor: default; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-top: var(--gap); }
.case { margin-top: 10px; }
.case-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.crime { font-size: 18px; font-weight: 700; margin: 0; line-height: 1.3; }
.badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--line); margin-left: 6px; vertical-align: middle; }

.statements { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.statements li { display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: start; }
.statements p { margin: 0; }
.clues { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; overflow: auto; max-height: var(--stage-h); }
.stage-row .statements li { grid-template-columns: 28px 1fr; gap: 8px; }
.stage-row .avatar { width: 28px; height: 28px; font-size: 12px; }
.stage-row .statements p { font-size: 15px; line-height: 1.4; }
.clues .statements { gap: 6px; }
.clues .who { display: block; line-height: 1.3; }
.habit { color: var(--accent); }
.warning { margin: 4px 0 0; font-size: 13px; font-weight: 600; color: var(--accent); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 14px; }
.avatar.granny { background: #9b59b6; }
.avatar.kid { background: #e67e22; }
.avatar.guard { background: #34495e; }
.who { font-size: 12px; color: var(--muted); display: block; }

.stage-wrap { position: sticky; top: 0; z-index: 2; background: var(--bg); padding-top: 8px; }
.stage-row { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: stretch; }
.stage { background: var(--stage); border-radius: var(--radius); height: var(--stage-h); padding: 4px 8px; position: relative; }
.stage canvas { display: block; height: calc(var(--stage-h) - 8px); width: auto; }
.stage .hint { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 8px; text-align: center; font-size: 12px; line-height: 1.4; color: var(--muted); }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.tab { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; font-size: 14px; font-weight: 600; display: flex; justify-content: center; gap: 6px; align-items: center; min-height: 44px; }
.tab[aria-selected="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.mark { font-size: 13px; width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; }
.mark.ok { background: var(--ok); }
.mark.bad { background: var(--bad); }
.mark.none { background: var(--line); }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.tile { aspect-ratio: 1; background: var(--paper); border: 2px solid transparent; border-radius: 12px; padding: 4px; position: relative; display: grid; place-items: center; }
.tile canvas { width: 100%; height: 100%; }
.tile[aria-pressed="true"] { border-color: var(--ink); background: #fff; }
.tile:disabled { opacity: 0.35; cursor: not-allowed; }
.tile .x { position: absolute; top: 2px; right: 6px; color: var(--bad); font-weight: 700; }
.note { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }

.bar { position: fixed; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 16px var(--gap) calc(12px + env(safe-area-inset-bottom)); z-index: 3; }
.bar-inner { max-width: 448px; margin: 0 auto; }
.primary { width: 100%; min-height: 54px; border: 0; border-radius: var(--radius); background: var(--accent); color: #fff; font-size: 17px; font-weight: 700; }
.primary:disabled { background: #c9b9a6; cursor: default; }
.primary small { display: block; font-size: 12px; font-weight: 500; opacity: 0.9; }

.toast { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 14px; }

.reveal { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: center; }
.reveal canvas { display: block; height: 240px; width: auto; max-width: 100%; margin: 0 auto; background: var(--stage); border-radius: 12px; }
.reveal .cap { font-size: 13px; color: var(--muted); }
.score { font-size: 28px; font-weight: 800; text-align: center; margin: 12px 0 0; }
.verdict { text-align: center; font-weight: 700; color: var(--accent); margin: 0; }
.rates { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--muted); justify-content: center; margin-top: 8px; }
.habits { margin: 0; padding-left: 18px; font-size: 14px; }
.loading, .error { text-align: center; padding: 48px 0; color: var(--muted); }

/* Short phones (SE-class): keep the first row of candidates above the submit bar. */
@media (max-height: 700px) { :root { --stage-h: 200px; } #tagline { display: none; } }
@media (min-height: 720px) { :root { --stage-h: 256px; } }
@media (min-height: 800px) { :root { --stage-h: 280px; } }

/* ---- Act 2 trial (GAME_PLAN 7.5) ---- */
.trial .lead { margin: 0 0 4px; font-weight: 600; }
.chat { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.bubble { max-width: 88%; padding: 8px 12px; border-radius: 14px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.bubble b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.bubble.judge { align-self: flex-start; background: var(--stage); border-bottom-left-radius: 4px; }
.bubble.me { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.bubble.me b { color: #c9cbe0; }
.bubble.thinking { color: var(--muted); font-style: italic; }
.delta { display: inline-block; margin-left: 8px; padding: 0 6px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #ffffff33; }
.delta.up { background: var(--ok); }
.delta.down { background: var(--bad); }
.say { position: relative; margin: 12px 0 10px; }
.say textarea { width: 100%; min-height: 84px; resize: none; padding: 10px 12px 22px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font: inherit; font-size: 16px; }
.say .count { position: absolute; right: 10px; bottom: 6px; font-size: 12px; color: var(--muted); }
.sentence { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); text-align: center; }
.sentence p { margin: 4px 0; }
.verdict-big { font-size: 28px; font-weight: 800; color: var(--accent); }
.verdict-big.acquitted { color: var(--ok); }

/* ---- support (GAME_PLAN 10.5.1) ---- */
.support p { margin: 0 0 8px; font-size: 14px; }
.support .promise { font-weight: 700; }
.support-link { display: flex; align-items: center; justify-content: center; min-height: 50px; margin-top: 10px; border-radius: var(--radius); background: var(--ink); color: #fff; font-size: 16px; font-weight: 700; text-decoration: none; }
.support-qr { display: none; align-items: center; gap: 12px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.support-qr img { image-rendering: pixelated; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 4px; }
/* Wide screens with a mouse = probably a computer, so offer the phone a QR to scan. */
@media (min-width: 720px) and (hover: hover) { .support-qr { display: flex; } }

/* ---- trial popup, gauge and pictures (GAME_PLAN 7.5) ---- */
.court { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 12px; margin-bottom: 10px; background: var(--stage); }
.modal-back { position: fixed; inset: 0; z-index: 10; background: #1d234099; display: grid; place-items: center; padding: var(--gap); }
.modal { width: 100%; max-width: 420px; max-height: calc(100dvh - 32px); overflow: auto; background: var(--paper); border-radius: var(--radius); padding: 16px; text-align: center; animation: pop 0.25s ease-out; }
.modal h3 { margin: 4px 0 6px; font-size: 22px; color: var(--accent); }
.modal p { margin: 0 0 6px; }
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: none; opacity: 1; } }

.gauge-wrap { display: flex; gap: 10px; align-items: center; margin: 4px 0 12px; padding: 10px; background: var(--stage); border-radius: 12px; }
.judge-face { width: 64px; height: 64px; object-fit: contain; flex: none; }
.gauge-main { flex: 1; min-width: 0; }
.gauge-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.gauge-head .pct { font-size: 20px; font-weight: 800; }
.gauge { position: relative; height: 16px; margin-top: 4px; border-radius: 999px; background: #fff; border: 2px solid var(--ink); overflow: hidden; }
.gauge .fill { height: 100%; background: var(--bad); transition: width 0.7s cubic-bezier(.2,.9,.3,1.2), background-color 0.3s; }
.gauge .fill.unsure { background: #e0a020; }
.gauge .fill.pleased { background: var(--ok); }
.gauge .mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); }
.gauge-scale { position: relative; height: 16px; font-size: 11px; color: var(--muted); }
.gauge-scale span { position: absolute; top: 2px; transform: translateX(-50%); white-space: nowrap; }
.gauge-scale span:last-child { transform: translateX(-100%); }
.mood { margin: 2px 0 0; font-size: 13px; font-weight: 600; }
.mood.stern { color: var(--bad); }
.mood.unsure { color: #b07a10; }
.mood.pleased { color: var(--ok); }
.judge-verdict { display: block; width: 140px; height: 140px; object-fit: contain; margin: 0 auto 4px; }

@media (prefers-reduced-motion: reduce) {
  .modal { animation: none; }
  .gauge .fill { transition: none; }
}
