:root {
  --bg: #0b0f18; --panel: rgba(12, 16, 26, .92); --panel2: #141b2b; --line: #263149; --text: #e6e9f0; --muted: #8a94a8;
  --amber: #ffb648; --amber2: #ffd98a; --red: #d9413a; --green: #6fd39a; --blue: #7cc4ff;
  --fd: 'Barlow Condensed', 'Arial Narrow', sans-serif; --fb: 'Be Vietnam Pro', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 15px/1.55 var(--fb); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font: 600 11px var(--fb); border: 1px solid #ffffff44; border-radius: 4px; padding: 0 5px; background: #ffffff14; }
.muted { color: var(--muted); }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: grab; }

/* HUD */
#hud { position: fixed; left: 0; right: 0; top: 0; display: none; justify-content: space-between; align-items: flex-start; padding: 14px 16px; pointer-events: none; gap: 12px; }
#hud.on { display: flex; }
#hud .hl { background: linear-gradient(90deg, #0b0f18cc, #0b0f1800); padding: 8px 40px 8px 12px; border-left: 3px solid var(--amber); }
#hCase { font: 700 20px/1.1 var(--fd); letter-spacing: .5px; text-transform: uppercase; }
#hPlace { font-size: 13px; color: var(--amber2); }
#hProg { font-size: 12px; color: var(--muted); }
#hud .hr { display: flex; gap: 8px; align-items: center; pointer-events: auto; flex-wrap: wrap; justify-content: flex-end; }
#hCred { display: flex; gap: 4px; margin-right: 6px; }
#hCred i { width: 12px; height: 12px; border-radius: 50%; background: #ffffff22; border: 1px solid #ffffff44; }
#hCred i.on { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 8px #ffb64888; }
.hb { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font-weight: 600; font-size: 14px; }
.hb:hover { border-color: var(--amber); }
.hb.red { background: #5a1a18; border-color: #9a2d28; }
.hb.red:hover { background: #7a221f; }
#cross { position: fixed; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: #ffffff88; display: none; pointer-events: none; }
body.roam #cross { display: block; }
#prompt { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(10px); background: var(--panel); border: 1px solid var(--amber); padding: 8px 16px; border-radius: 999px; opacity: 0; transition: .2s; pointer-events: none; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
#prompt.on { opacity: 1; transform: translateX(-50%); pointer-events: auto; cursor: pointer; }
#prompt b { color: var(--amber2); }
#tip { position: fixed; transform: translate(-50%, -100%); background: #000a; padding: 3px 9px; border-radius: 6px; font-size: 13px; pointer-events: none; opacity: 0; white-space: nowrap; }
#tip.on { opacity: 1; }
#toasts { position: fixed; left: 16px; top: 104px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; pointer-events: none; z-index: 30; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--blue); padding: 8px 12px; border-radius: 6px; max-width: min(380px, calc(100vw - 32px)); font-size: 13.5px; animation: tin .3s; transition: .5s; }
.toast.note { border-left-color: var(--amber); } .toast.claim { border-left-color: var(--red); } .toast.win { border-left-color: var(--green); } .toast.gear { border-left-color: #c9c9d9; }
.toast.out { opacity: 0; transform: translateX(-20px); }
@keyframes tin { from { opacity: 0; transform: translateX(-20px); } }

/* hộp thoại */
#dlg { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(980px, calc(100vw - 24px)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; display: none; gap: 16px; padding: 14px; box-shadow: 0 20px 60px #0009; z-index: 10; cursor: pointer; backdrop-filter: blur(6px); }
#dlg.on { display: flex; }
#dlg.narr .dHead { display: none; }
#dlg.narr #dText { font-style: italic; color: #cfd6e4; }
.dHead { flex: none; width: 132px; height: 132px; border-radius: 10px; overflow: hidden; background: #141b2b; border: 1px solid var(--line); position: relative; }
#dPort { width: 100%; height: 100%; display: block; }
.dIcon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--amber2); background: radial-gradient(circle, #2a2418, #141b2b); }
.dIcon svg { width: 70%; height: 70%; }
.dIcon.me { color: #c9d4e8; background: radial-gradient(circle, #24304a, #0d1220); }
.dMain { flex: 1; min-width: 0; position: relative; padding-right: 8px; }
.dWho { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 4px; }
#dName { font: 700 22px/1.1 var(--fd); color: var(--amber2); letter-spacing: .3px; }
#dRole { font-size: 12.5px; color: var(--muted); }
#dText { font-size: 16.5px; line-height: 1.6; min-height: 78px; }
#dMore { position: absolute; right: 4px; bottom: -4px; color: var(--amber); animation: bob 1s infinite; font-size: 12px; }
@keyframes bob { 50% { transform: translateY(3px); } }
#choices { display: none; position: absolute; right: 14px; bottom: calc(100% + 10px); width: min(470px, calc(100vw - 48px)); max-height: 56vh; overflow: auto; flex-direction: column; gap: 6px; cursor: default; }
#choices.on { display: flex; }
.ch { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 9px 13px; font-size: 14.5px; backdrop-filter: blur(6px); transition: .12s; }
.ch:hover { border-color: var(--amber); transform: translateX(-3px); }
.ch i { font-style: normal; display: inline-block; width: 18px; color: var(--amber); font-weight: 700; }
.ch.done { color: #aab3c4; } .ch.done i { color: var(--green); }
.ch.obj { border-color: #9a2d28; background: #2a1214ee; } .ch.obj i { color: #ff6a5a; }
.ch.bye { color: var(--muted); }

/* modal */
#modal { position: fixed; inset: 0; background: #000a; display: none; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
#modal.on { display: flex; }
.mBox { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 30px 80px #000c; }
#modal.wide .mBox { width: min(900px, 100%); }
.mHead { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.mHead h2 { margin: 0; font: 700 24px var(--fd); letter-spacing: .4px; }
#mClose { background: none; border: 0; font-size: 20px; color: var(--muted); }
#mBody { padding: 16px 18px; overflow: auto; }
.btn { display: inline-block; background: #1d2638; border: 1px solid var(--line); border-radius: 9px; padding: 10px 18px; font-weight: 600; margin: 6px 6px 0 0; }
.btn:hover { border-color: var(--amber); }
.btn.red { background: #7a221f; border-color: #b0342e; } .btn.red:hover { background: #962a26; }
.btn.ghost { background: transparent; }
.evgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.ev { text-align: left; background: #0f1522; border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; grid-template-columns: 44px 1fr; gap: 2px 10px; }
.ev:hover { border-color: var(--amber); }
.ev .ic { grid-row: span 2; color: var(--amber2); }
.ev small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.ic { width: 44px; height: 44px; display: inline-flex; flex: none; }
.ic svg { width: 100%; height: 100%; }
.nb .tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; }
.tab.on { background: var(--amber); color: #1a1206; border-color: var(--amber); font-weight: 600; }
.nbBody .row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid #ffffff10; }
.nbBody .row p { margin: 2px 0; font-size: 14px; color: #cfd5e2; }
.nbBody .row .ic { color: var(--amber2); }
.nbBody .ppl canvas { width: 72px; height: 72px; border-radius: 8px; flex: none; background: #1a2438; }
.nbBody small { color: var(--muted); }
.claim.broken p { text-decoration: line-through; color: var(--muted); }
.claim.broken small { color: var(--green); }
.facts { margin: 0; padding-left: 18px; } .facts li { margin: 6px 0; }
.facts li.key { color: #ffd0c8; } .facts li.key::marker { color: var(--red); }
.nbFoot { margin-top: 14px; text-align: right; }
.acc .q { font: 700 22px var(--fd); margin: 0 0 10px; color: var(--amber2); }
.susp { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.sus { background: #0f1522; border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; align-items: center; }
.sus:hover { border-color: var(--red); }
.sus canvas { width: 100%; aspect-ratio: 1; border-radius: 8px; }
.sus small { color: var(--muted); font-size: 12px; text-align: center; }
.opt { display: block; width: 100%; text-align: left; background: #0f1522; border: 1px solid var(--line); border-radius: 9px; padding: 11px 14px; margin-bottom: 8px; }
.opt:hover { border-color: var(--red); }
.sum { background: #0f1522; border-radius: 10px; padding: 8px 14px; border: 1px solid var(--line); }
.result { text-align: center; }
.result .stars { font-size: 44px; color: var(--amber); letter-spacing: 6px; }
.result .stars.dim { color: #555; }
.result .fin { color: var(--amber2); }
.help p { margin: 8px 0; }

/* loading */
#loading { position: fixed; inset: 0; background: radial-gradient(circle at 50% 40%, #1a2133, #07090f); display: none; align-items: center; justify-content: center; text-align: center; z-index: 50; padding: 16px; }
#loading.on { display: flex; }
#loading h2 { font: 700 34px var(--fd); margin: 16px 0 4px; letter-spacing: .5px; }
#loading p { margin: 2px; color: var(--amber2); }
.spin { width: 46px; height: 46px; margin: auto; border-radius: 50%; border: 3px solid #ffffff22; border-top-color: var(--amber); animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* menu */
#menu { position: fixed; inset: 0; display: none; overflow: auto; z-index: 20; background: linear-gradient(90deg, #07090fee 0%, #07090fcc 45%, #07090f55 100%); }
#menu.on { display: block; }
.mWrap { max-width: 760px; padding: 48px 32px 32px; }
.badge { display: inline-block; font: 600 13px var(--fd); letter-spacing: 3px; text-transform: uppercase; color: var(--red); border: 1px solid var(--red); padding: 2px 10px; border-radius: 3px; }
#menu h1 { font: 700 clamp(54px, 11vw, 104px)/.9 var(--fd); letter-spacing: 4px; margin: 14px 0 8px; background: linear-gradient(180deg, #fff, #c9b48a); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 0 40px #ffb64822; }
.sub { font: 600 21px var(--fd); color: var(--amber2); margin: 0 0 14px; letter-spacing: .4px; }
.lead { color: #c9d0dd; max-width: 600px; }
.mBtns { margin: 18px 0 28px; }
.cases { display: flex; flex-direction: column; gap: 10px; }
.case { display: flex; gap: 14px; align-items: center; text-align: left; background: #0f1522dd; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; transition: .15s; }
.case:hover:not(.locked) { border-color: var(--amber); transform: translateX(4px); }
.case .no { font: 700 34px var(--fd); color: var(--amber); width: 30px; text-align: center; flex: none; }
.case b { font: 700 21px var(--fd); letter-spacing: .3px; }
.case small { display: block; color: var(--amber2); font-size: 12.5px; }
.case p { margin: 4px 0 0; color: #b9c1d0; font-size: 13.5px; }
.case .st { margin-left: auto; color: var(--amber); white-space: nowrap; font-size: 15px; flex: none; }
.case.locked { opacity: .5; cursor: not-allowed; }
.case.solved { border-color: #3a5a3a; }
.gears { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.gears b { color: #d8d8e8; }
#menu footer { margin-top: 36px; color: var(--muted); font-size: 12.5px; }
#menu footer a { color: var(--blue); }
body.inmenu #scene { filter: saturate(.8) brightness(.85); }

/* hồ sơ mở đầu */
#dossier { position: fixed; inset: 0; z-index: 45; display: none; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(circle at 50% 30%, #1a2133ee, #05070bf5); }
#dossier.on { display: flex; }
.dosBox { position: relative; width: min(820px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: #e9e1cf; color: #2a2318; border-radius: 6px; padding: 28px 32px 24px; box-shadow: 0 30px 80px #000c; background-image: linear-gradient(#0000 31px, #b8a98a22 32px); background-size: 100% 32px; }
.dosStamp { position: absolute; right: 70px; top: 26px; transform: rotate(-12deg); border: 3px solid #b0342e; color: #b0342e; font: 700 26px var(--fd); letter-spacing: 6px; padding: 0 10px; opacity: .8; }
#dosClose { position: absolute; right: 14px; top: 12px; background: none; border: 0; font-size: 20px; color: #6a5a40; }
#dosNo { font: 600 14px var(--fd); letter-spacing: 3px; text-transform: uppercase; color: #8a2a24; }
#dosTitle { font: 700 40px/1.05 var(--fd); margin: 4px 0 4px; letter-spacing: .5px; }
#dosPlace { color: #6a5a40; font-size: 14px; margin-bottom: 14px; }
#dosBody p { font: 16px/1.7 'Noto Serif', 'Be Vietnam Pro', serif; margin: 0 0 10px; padding: 2px 8px; border-left: 3px solid transparent; transition: .3s; }
#dosBody p.reading { border-left-color: #b0342e; background: #b0342e14; }
.dosBox h4 { font: 700 15px var(--fd); letter-spacing: 2px; text-transform: uppercase; color: #8a2a24; margin: 16px 0 8px; }
#dosPeople { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.dp { display: flex; flex-direction: column; align-items: center; text-align: center; }
.dp canvas { width: 100%; aspect-ratio: 1; border-radius: 4px; border: 2px solid #fff; box-shadow: 0 2px 6px #0004; transform: rotate(-1deg); }
.dp:nth-child(even) canvas { transform: rotate(1.5deg); }
.dp b { font-size: 12.5px; margin-top: 4px; line-height: 1.2; } .dp small { font-size: 11px; color: #6a5a40; line-height: 1.2; }
.dp.victim b { color: #8a2a24; }
.dosBtns { margin-top: 18px; } .dosBtns .btn.ghost { color: #2a2318; border-color: #b8a98a; }
.season { font: 700 20px var(--fd); color: var(--amber2); margin: 18px 0 4px; letter-spacing: .5px; } .season small { color: var(--muted); font-size: 14px; }
.diff { margin-left: 6px; letter-spacing: 1px; } .diff.d2 { color: #ffb648; } .diff.d3 { color: #ff6a5a; }
.sets { margin-top: 10px; }

@media (max-width: 700px) {
  .dosBox { padding: 20px 16px; } #dosTitle { font-size: 30px; } .dosStamp { right: 44px; font-size: 18px; } #dosBody p { font-size: 14.5px; }
  html, body { font-size: 14px; }
  #hud { padding: 10px; } #hCase { font-size: 16px; } #hProg { display: none; } #hud .hl { padding-right: 10px; }
  .hb { padding: 6px 9px; font-size: 13px; } .hb kbd { display: none; }
  #dlg { gap: 10px; padding: 10px; bottom: 8px; } .dHead { width: 72px; height: 72px; } #dName { font-size: 18px; } #dText { font-size: 14.5px; min-height: 64px; }
  #choices { right: 0; left: 0; width: auto; max-height: 50vh; }
  .mWrap { padding: 28px 16px; } .case .no { font-size: 26px; width: 22px; } .case b { font-size: 18px; }
  #menu { background: #07090fe6; }
  #toasts { top: auto; bottom: 70px; right: 8px; left: 8px; align-items: stretch; }
}
