:root {
  --bg: #f4f2ec;
  --paper: #fbfaf6;
  --ink: #1b1a18;
  --ink2: #5f5c56;
  --ink3: #9c9890;
  --rule: #d9d5cb;
  --red: #b23a2e;
  --yellow: #f2c84b;
  --who: #3f5f8f;
  --time: #7a4fa0;
  --what: #8a5a1e;
  --ok: #3f7d4f;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --serif: 'Noto Serif TC', 'Songti TC', serif;
  --panelW: 360px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html[lang="ja"] { --sans: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif; --serif: 'Noto Serif JP', serif; }
html[lang="ko"] { --sans: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif; --serif: 'Noto Serif KR', serif; }
html[lang="en"] { --sans: 'Inter', system-ui, 'Segoe UI', sans-serif; --serif: 'Noto Serif', Georgia, serif; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); }
canvas#c { position: fixed; inset: 0; display: block; cursor: grab; touch-action: none; }
canvas#c:active { cursor: grabbing; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:disabled { opacity: .35; cursor: default; }
.mono { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: var(--ink2); }

/* ---------- top HUD ---------- */
.hud {
  position: fixed; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(12px + env(safe-area-inset-top)) 16px 8px; pointer-events: none; z-index: 5;
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand b { font-family: var(--serif); font-weight: 900; font-size: 26px; letter-spacing: .04em; line-height: 1.05; }
.brand #caseLabel { color: var(--red); font-size: 10px; margin-top: 4px; }
.brand #caseTitle { font-size: 13px; font-weight: 500; max-width: 46vw; }
.hbtns { display: flex; gap: 6px; pointer-events: auto; }
.hb {
  height: 36px; padding: 0 12px; border: 1px solid var(--rule); background: rgba(251,250,246,.85); border-radius: 18px;
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; backdrop-filter: blur(6px);
}
.hb i { font-style: normal; font-weight: 700; font-family: var(--mono); }
.hb:hover { border-color: var(--ink); }
.hb.lang i { font-family: var(--serif); font-size: 13px; }
.langs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.langs button { border: 1px solid var(--rule); background: rgba(255,255,255,.75); border-radius: 16px; padding: 5px 12px; font-size: 13px; }
.langs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.pitem.cur { border-color: var(--ink); background: #f3efe4; }

/* ---------- investigation panel ---------- */
#panel {
  position: fixed; right: 14px; top: 70px; bottom: 80px; width: var(--panelW); z-index: 4;
  background: rgba(251,250,246,.94); border: 1px solid var(--rule); border-radius: 14px;
  padding: 16px 16px 10px; overflow-y: auto; backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(40,30,10,.06);
}
.eyebrow { color: var(--red); }
#ptitle { font-family: var(--serif); font-weight: 900; font-size: 24px; margin: 4px 0 6px; letter-spacing: .02em; }
#pdesc { font-size: 13px; line-height: 1.7; color: var(--ink2); margin: 0 0 12px; }
#plist { display: flex; flex-direction: column; gap: 6px; }
.pi {
  display: flex; align-items: center; gap: 10px; text-align: left; padding: 9px 10px; border-radius: 10px;
  border: 1px solid var(--rule); background: #fff; min-height: 46px; transition: border-color .15s, transform .1s;
}
.pi:hover { border-color: var(--ink); }
.pi:active { transform: scale(.98); }
.pi span { flex: 1; font-size: 14px; font-weight: 500; display: flex; flex-direction: column; }
.pi small { font-size: 11.5px; font-weight: 400; color: var(--ink2); }
.pi small.note, .mk .note { color: var(--red); font-weight: 700; }
.mk .note { margin-left: 6px; font-size: 11px; }
.pi em { font-style: normal; font-family: var(--mono); font-size: 11px; background: var(--yellow); border-radius: 10px; padding: 1px 8px; }
.pi em.ok { background: none; color: var(--ok); }
.pi em.dot { width: 9px; height: 9px; padding: 0; border-radius: 50%; background: var(--red); }
.pi.dim { opacity: .62; }
.pi i { font-style: normal; flex: none; }
.pi .fl, .pi .rm { width: 34px; height: 30px; display: grid; place-items: center; font-family: var(--mono); font-size: 12px; border: 1px solid var(--ink); border-radius: 6px; }
.pi .q { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--yellow); font-weight: 700; font-family: var(--mono); }
.pi.clue.done .q { background: #e4e1d8; color: var(--ok); }
.pi.clue.done span { color: var(--ink2); }
.pi.who { border-color: #cfc6b2; background: #fffdf6; }
.pt { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-style: normal; font-weight: 700; font-size: 14px; flex: none; font-family: var(--serif); }
.pt.big { width: 54px; height: 54px; font-size: 24px; }
.pt.huge { width: 92px; height: 92px; font-size: 42px; }

/* ---------- bottom bar ---------- */
.bar {
  position: fixed; left: 14px; right: calc(var(--panelW) + 28px); bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: center; gap: 8px; z-index: 5; pointer-events: none;
}
.bar > * { pointer-events: auto; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav #where { margin-left: 8px; }
.nb, .ab {
  height: 44px; min-width: 44px; padding: 0 12px; border: 1px solid var(--rule); background: rgba(251,250,246,.92); border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13.5px; backdrop-filter: blur(6px);
}
.nb i, .ab i { font-style: normal; }
.nb:hover:not(:disabled), .ab:hover { border-color: var(--ink); }
.acts { display: flex; gap: 6px; }
.ab em { font-style: normal; font-family: var(--mono); font-size: 10.5px; background: var(--ink); color: #fff; border-radius: 9px; padding: 1px 6px; }
.ab.accuse { background: var(--ink); color: #fff; border-color: var(--ink); }
.ab.accuse.ready { background: var(--red); border-color: var(--red); animation: pulse 1.6s ease-in-out infinite; }
.ab.accuse.done { background: var(--ok); border-color: var(--ok); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(178,58,46,.18); } }

/* ---------- 3D markers ---------- */
#markers { position: fixed; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.mk { position: absolute; left: 0; top: 0; pointer-events: auto; translate: -50% -50%; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.mk span { font-size: 12px; font-weight: 500; background: rgba(251,250,246,.92); border: 1px solid var(--rule); border-radius: 8px; padding: 2px 7px; }
.mk.clue { translate: -15px -50%; }
.mk.clue i {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 700; font-family: var(--mono);
  background: var(--yellow); border: 2px solid var(--ink); box-shadow: 0 2px 0 var(--ink); animation: bob 2.2s ease-in-out infinite;
}
.mk.clue.done i { background: #ece9e1; color: var(--ok); border-color: var(--ink3); box-shadow: none; animation: none; width: 24px; height: 24px; font-size: 12px; }
.mk.clue.done span { opacity: 0; transition: opacity .15s; }
.mk.clue.done:hover span { opacity: 1; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.mk.person b { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: var(--serif); font-size: 14px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.mk.person span { border-color: var(--ink); }
.mk.person.small b { width: 24px; height: 24px; font-size: 12px; }
.mk.person.small span { font-size: 11px; }
.mk.floor { translate: 0 -50%; }
.mk.floor i { font-style: normal; font-family: var(--mono); font-weight: 500; font-size: 12px; background: var(--ink); color: #fff; border-radius: 6px; padding: 3px 6px; }
.mk.floor em { font-style: normal; font-family: var(--mono); font-size: 11px; background: var(--yellow); border: 1px solid var(--ink); border-radius: 10px; padding: 0 7px; }
.mk.floor.clear i { background: var(--ink3); }
.mk.room span { font-size: 11.5px; background: rgba(255,255,255,.88); border-color: var(--ink3); }
.mk.room em { width: 9px; height: 9px; border-radius: 50%; background: var(--red); margin-left: -10px; margin-top: -16px; border: 1.5px solid #fff; }
.mk:hover span { border-color: var(--ink); }

/* ---------- modal + picker + toasts ---------- */
#modal { position: fixed; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; background: rgba(30,26,20,.32); padding: 16px; }
#modal.open { display: flex; animation: fade .18s ease; }
#sheet {
  width: 100%; max-width: 560px; max-height: calc(100% - 20px); overflow-y: auto; background: var(--paper);
  border-radius: 16px; padding: 22px 22px 18px; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: rise .22s ease;
}
#modal.boardm #sheet, #modal.notebook #sheet { max-width: 720px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
#sheet h2, #sheet h3 { font-family: var(--serif); font-weight: 900; margin: 4px 0 12px; letter-spacing: .02em; }
#sheet h2 { font-size: 26px; }
#sheet h3 { font-size: 21px; }
#sheet p { line-height: 1.8; font-size: 14.5px; }
.kicker { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; color: var(--red); margin: 0; }
.muted { color: var(--ink2); font-size: 13px !important; }
.primary, .ghost, .mini, .menu button, .row button {
  border-radius: 12px; min-height: 46px; padding: 0 18px; font-size: 15px; font-weight: 500; border: 1px solid var(--ink);
}
.primary { background: var(--ink); color: #fff; }
.primary:hover { background: #333; }
.ghost { border-color: var(--rule); color: var(--ink2); }
.wide { width: 100%; margin-top: 12px; }
.mini { min-height: 32px; padding: 0 12px; font-size: 13px; border-color: var(--ink); background: #fff; }
.x { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--rule); font-size: 15px; flex: none; }
.link { text-decoration: underline; color: var(--ink2); font-size: 12px; }
.chip { display: inline-block; font-size: 13px; font-weight: 500; border-radius: 6px; padding: 2px 8px; margin: 2px; border: 1px solid; background: #fff; }
.chip.who { color: var(--who); border-color: color-mix(in srgb, var(--who) 45%, white); }
.chip.time { color: var(--time); border-color: color-mix(in srgb, var(--time) 45%, white); font-family: var(--mono); }
.chip.what { color: var(--what); border-color: color-mix(in srgb, var(--what) 45%, white); }
.chip.new { background: var(--yellow); }
.stamp { display: inline-block; font-family: var(--serif); font-weight: 900; color: var(--red); border: 2px solid var(--red); border-radius: 4px; padding: 0 6px; transform: rotate(-4deg); font-size: 13px; }
.stamp.ok { color: var(--ok); border-color: var(--ok); }

#picker { position: fixed; inset: 0; z-index: 30; display: none; align-items: flex-end; justify-content: center; background: rgba(30,26,20,.28); }
#picker.open { display: flex; animation: fade .15s ease; }
.pick { width: 100%; max-width: 560px; max-height: 72%; display: flex; flex-direction: column; background: var(--paper); border-radius: 16px 16px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); animation: rise .2s ease; }
.pick header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.pick header b { font-size: 15px; }
.plist { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.pitem { display: flex; flex-direction: column; text-align: left; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 10px; background: #fff; min-height: 46px; justify-content: center; }
.pitem:hover { border-color: var(--ink); }
.pitem small { color: var(--ink2); font-size: 12px; }
.plist:has(.wpick) { flex-direction: row; flex-wrap: wrap; }
.pitem.wpick { flex-direction: row; padding: 6px; min-height: 0; border: 0; background: none; }
.pitem.wpick .chip { font-size: 15px; padding: 6px 12px; }
.empty { color: var(--ink2); font-size: 14px; padding: 8px; }

#toasts { position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(92vw, 520px); }
.toast { background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 14px; font-size: 14px; line-height: 1.6; opacity: 0; transform: translateY(-8px); transition: .3s; text-align: center; }
.toast.in { opacity: 1; transform: none; }
.toast .chip { font-size: 12px; }
.toast .stamp { background: #fff; }

/* ---------- clue card ---------- */
.cluecard .ctext { white-space: pre-line; background: #fff; border: 1px solid var(--rule); border-left: 4px solid var(--yellow); border-radius: 8px; padding: 12px 14px; }
.words { margin-top: 4px; }

/* ---------- talk ---------- */
.talk header, .hint header, .pp header { display: flex; gap: 12px; align-items: flex-start; }
.talk header b, .hint header b { font-family: var(--serif); font-size: 20px; }
.talk header small, .hint header small { display: block; color: var(--red); font-family: var(--mono); font-size: 11px; }
.talk header p { margin: 4px 0 0; font-size: 13px !important; color: var(--ink2); line-height: 1.6 !important; }
.lines { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.line { background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 10px 12px; position: relative; }
.line p { margin: 0 0 6px; }
.line.new::before { content: 'NEW'; position: absolute; right: 8px; top: -8px; font-family: var(--mono); font-size: 10px; background: var(--yellow); border: 1px solid var(--ink); border-radius: 6px; padding: 0 5px; }
.line.broken > p { color: var(--ink3); text-decoration: line-through; text-decoration-color: var(--red); }
.present { font-size: 13px; color: var(--red); border: 1px solid var(--red); border-radius: 8px; padding: 4px 10px; min-height: 32px; }
.present:hover { background: var(--red); color: #fff; }
.reply { font-size: 14px; line-height: 1.7; background: #fff8e6; border-radius: 8px; padding: 8px 10px; }
.reply .stamp { margin-right: 6px; }
.tip { color: var(--ink2); font-size: 12.5px !important; margin: 10px 0 0; }

/* ---------- notebook ---------- */
.tabs { display: flex; gap: 6px; align-items: center; position: sticky; top: -22px; background: var(--paper); padding: 6px 0 10px; z-index: 1; }
.tabs button[data-tab] { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--rule); font-size: 14px; }
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs .x { margin-left: auto; }
.tabp { display: none; }
.tabp.on { display: grid; gap: 8px; }
.ev { background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.ev:hover { border-color: var(--ink); }
.ev small { font-family: var(--mono); font-size: 10.5px; color: var(--red); }
.ev b { display: block; font-size: 15px; margin: 2px 0; }
.ev p { margin: 0; font-size: 13.5px !important; line-height: 1.7 !important; white-space: pre-line; color: var(--ink2); }
.pp { background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 10px 12px; }
.pp header > div { flex: 1; }
.pp header b { font-size: 16px; display: block; }
.pp header small { color: var(--ink2); font-size: 12px; }
.pp .bio { margin: 6px 0 0; font-size: 13px !important; line-height: 1.6 !important; color: var(--ink2); }
.pp .bio b { color: var(--red); }
.pp ul { margin: 8px 0 0; padding-left: 18px; font-size: 13.5px; line-height: 1.7; }
.pp li.broken { color: var(--ink3); }
.pp li span { display: block; color: var(--ink); }
.pp.unmet { opacity: .7; }
.wgroup { margin-bottom: 8px; }
.wgroup > b { font-size: 12px; font-family: var(--mono); color: var(--ink2); display: block; margin-bottom: 2px; }

/* ---------- board ---------- */
.bh { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.bsec { background: #fff; border: 1px solid var(--rule); border-radius: 12px; padding: 12px 14px; margin-top: 10px; }
.bsec header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.bsec header span { font-family: var(--mono); color: var(--red); font-size: 12px; }
.bsec header b { flex: 1; font-size: 16px; }
.bsec header em { font-style: normal; color: var(--ok); font-size: 13px; font-weight: 700; }
.bsec p { margin: 6px 0; line-height: 2.3 !important; font-size: 15px !important; }
.bsec.solved { border-color: var(--ok); background: #f3f8f2; }
.blank {
  display: inline-block; min-width: 70px; min-height: 32px; padding: 0 10px; margin: 0 3px; border-radius: 6px; vertical-align: middle;
  border: 1.5px dashed currentColor; font-size: 14px; font-weight: 500; line-height: 30px; background: #fff;
}
.blank.who { color: var(--who); } .blank.time { color: var(--time); font-family: var(--mono); } .blank.what { color: var(--what); }
.blank:not(.filled) { opacity: .75; font-size: 12px; }
.blank.filled { border-style: solid; }
.blank:disabled { opacity: 1; border-style: solid; background: #e6f0e4; }
.fb { margin: 2px 0 0 !important; font-size: 13.5px !important; min-height: 0; }
.fb.close { color: #b07a10; } .fb.bad, .fb.warn { color: var(--red); }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---------- confrontation ---------- */
.trust { display: flex; gap: 3px; font-size: 16px; color: #d8d3c6; }
.trust .on { color: var(--red); }
.prog { display: flex; gap: 5px; margin: 6px 0 14px; }
.prog i { flex: 1; height: 5px; border-radius: 3px; background: #e2ded4; }
.prog i.on { background: var(--ok); } .prog i.cur { background: var(--red); }
.stage { display: flex; gap: 14px; align-items: center; }
.bubble { flex: 1; background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 14px 16px; font-size: 16.5px; line-height: 1.75; position: relative; font-weight: 500; }
.confront.fin .bubble { border-color: var(--red); }
.hint .bubble { margin-top: 14px; font-size: 15px; }

/* ---------- intro / ending / menu ---------- */
.intro p { margin: 0 0 10px; }
.startev { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.startev b { width: 100%; font-size: 12px; font-family: var(--mono); color: var(--ink2); }
.startev span { border: 1px solid var(--rule); background: #fff; border-radius: 8px; padding: 4px 10px; }
.ending { position: relative; }
.stampbig { position: absolute; right: 0; top: -6px; font-family: var(--serif); font-weight: 900; font-size: 30px !important; color: var(--red); border: 3px solid var(--red); border-radius: 8px; padding: 0 12px; transform: rotate(8deg); margin: 0; line-height: 1.5 !important; }
.ending h4 { font-family: var(--serif); margin: 18px 0 6px; font-size: 17px; }
.ending ol { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.75; }
.score { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 18px 0 8px; padding: 12px; background: #fff; border-radius: 12px; border: 1px solid var(--rule); font-size: 13px; color: var(--ink2); }
.stars { font-size: 30px; color: #d39b1c; letter-spacing: 4px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row button { flex: 1; min-width: 120px; }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu .danger { color: var(--red); border-color: var(--red); }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; z-index: 15; display: none; overflow-y: auto; background: linear-gradient(180deg, rgba(244,242,236,.55), rgba(244,242,236,.9) 55%); }
#title.open { display: block; }
body.titled .hud, body.titled #panel, body.titled .bar, body.titled #markers, body.titled #loading { display: none; }
.tbox { max-width: 760px; margin: 0 auto; padding: calc(40px + env(safe-area-inset-top)) 20px 40px; }
.tbox .kicker { font-size: 12px; }
.tbox h1 { font-family: var(--serif); font-weight: 900; font-size: clamp(52px, 12vw, 92px); margin: 4px 0 6px; letter-spacing: .06em; line-height: 1.05; }
.tbox .sub { font-size: 16px; line-height: 1.8; color: var(--ink2); margin: 0 0 22px; }
.cases { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.case { text-align: left; background: rgba(251,250,246,.96); border: 1.5px solid var(--ink); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 6px; transition: transform .15s, box-shadow .15s; }
.case:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--ink); }
.case .no { font-family: var(--mono); font-size: 11px; color: var(--red); letter-spacing: .1em; }
.case b { font-family: var(--serif); font-size: 22px; }
.case p { margin: 0; color: var(--ink2); font-size: 14px; line-height: 1.7; flex: 1; }
.case .st { font-size: 12px; font-family: var(--mono); color: var(--ink2); }
.case .st.done { color: var(--ok); }
.case .go { font-weight: 700; font-size: 15px; }
.how { font-size: 13.5px; line-height: 1.8; color: var(--ink2); margin: 20px 0 8px; background: rgba(255,255,255,.7); border-radius: 12px; padding: 10px 14px; }
.credits { font-size: 11.5px; color: var(--ink3); line-height: 1.8; }

#loading { position: fixed; left: 50%; bottom: 50%; transform: translateX(-50%); font-family: var(--mono); font-size: 11px; letter-spacing: .14em; color: var(--ink2); transition: opacity .5s; pointer-events: none; z-index: 16; }
#loading::after { content: '…'; }
body.ready #loading { opacity: 0; }

/* ---------- landscape phones / small tablets ---------- */
@media (max-width: 1000px) and (orientation: landscape) {
  :root { --panelW: min(340px, 40vw); }
  .hud { padding-top: calc(8px + env(safe-area-inset-top)); }
  .brand b { font-size: 20px; }
  .brand #caseTitle { display: none; }
  #panel { top: 8px; bottom: 8px; padding: 12px; }
  #ptitle { font-size: 19px; }
  #pdesc { font-size: 12px; margin-bottom: 8px; }
  .hbtns { margin-right: calc(var(--panelW) + 14px); }
  .bar { bottom: calc(8px + env(safe-area-inset-bottom)); }
  .nb, .ab { height: 40px; }
  .nb span, .ab span { display: none; }
  #where { display: none; }
}

/* ---------- portrait phones: panel becomes a sheet above the bar ---------- */
@media (orientation: portrait) and (max-width: 900px) {
  .hud { padding: calc(10px + env(safe-area-inset-top)) 12px 6px; }
  .brand b { font-size: 21px; }
  .brand #caseTitle { font-size: 12px; }
  .hb { height: 34px; padding: 0 10px; font-size: 12.5px; }
  .hb span { display: none; }
  .hb i { font-size: 15px; }
  #panel {
    left: 8px; right: 8px; width: auto; top: auto; bottom: calc(64px + env(safe-area-inset-bottom));
    max-height: 36vh; padding: 10px 12px 8px; border-radius: 14px;
  }
  .eyebrow { font-size: 9.5px; }
  #ptitle { font-size: 18px; margin: 2px 0 2px; }
  #pdesc { font-size: 12px; line-height: 1.55; margin-bottom: 8px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  #plist { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
  .pi { min-height: 42px; padding: 6px 8px; gap: 7px; }
  .pi span { font-size: 13px; }
  .pi small { font-size: 10.5px; }
  .pi .fl, .pi .rm { width: 30px; height: 26px; font-size: 11px; }
  .pi .q, .pt { width: 26px; height: 26px; font-size: 12px; }
  .bar { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); }
  .nb, .ab { height: 46px; padding: 0 10px; font-size: 13px; }
  .nb span { display: none; }
  #where { display: none; }
  .ab { flex-direction: column; gap: 0; padding: 0 9px; font-size: 11.5px; position: relative; }
  .ab i { font-size: 15px; line-height: 1; }
  .ab em { position: absolute; top: -6px; right: -4px; font-size: 9.5px; padding: 0 5px; }
  #modal { padding: 0; align-items: flex-end; }
  #sheet { border-radius: 18px 18px 0 0; max-height: 92%; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
  .tabs { top: -18px; flex-wrap: wrap; }
  .tabs button[data-tab] { padding: 7px 9px; font-size: 13px; }
  .bsec p { font-size: 14px !important; }
  .pt.huge { width: 64px; height: 64px; font-size: 30px; }
  .bubble { font-size: 15px; }
}
@media (max-width: 360px) {
  #plist { grid-template-columns: 1fr; }
  .ab { padding: 0 6px; }
}

/* ---------- other languages ---------- */
html[lang="ko"] body { word-break: keep-all; }
html:not([lang^="zh"]) .tbox h1 { font-size: clamp(40px, 10.5vw, 78px); letter-spacing: .01em; }
html:is([lang="ko"], [lang="ja"]) :is(.kicker, .case .no, #caseLabel, .eyebrow, .ev small) { letter-spacing: .03em; }
html[lang="en"] .brand b { letter-spacing: 0; }

/* ---------- Detective Pass + legal links ---------- */
.case.locked { border-style: dashed; }
.case.locked .st { color: var(--red); }
.legal { font-size: 12.5px; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.legal a { color: var(--ink2); }
.legal i { font-style: normal; color: var(--ink3); }
.credits a { color: inherit; }
.perks { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 4px; }
.perks > div { display: grid; grid-template-columns: 30px 1fr; column-gap: 8px; background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 10px 12px; }
.perks i { font-style: normal; font-size: 20px; grid-row: span 2; }
.perks b { font-size: 14.5px; }
.perks span { font-size: 13px; color: var(--ink2); line-height: 1.6; }
.ulkey { display: flex; gap: 6px; margin-top: 6px; }
.ulkey input { flex: 1; min-width: 0; height: 46px; border: 1px solid var(--rule); border-radius: 12px; padding: 0 12px; font: inherit; font-size: 15px; background: #fff; }
.ulkey input:focus { outline: 2px solid var(--ink); }
.ulmsg { min-height: 1.4em; color: var(--red); font-size: 13.5px !important; margin: 6px 0 0; }
.ul-ok { background: #f3f8f2; border: 1px solid var(--ok); border-radius: 12px; padding: 14px; font-weight: 700; display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.ul-ok small { font-weight: 400; color: var(--ink2); font-family: var(--mono); font-size: 12px; }

body.og :is(#title, .hud, #panel, .bar, #markers, #loading, #toasts, #modal) { display: none !important; }
