:root { --dark: #0b1a24; --glass: rgba(11, 26, 36, .86); --line: rgba(255, 255, 255, .14); --cream: #efede8; --orange: #ff5a1f; --muted: #9fb0bb;
  --red: #ff4d3d; --yellow: #f5c518; --green: #2bd47d; --gray: #c9cdd0;
  --display: "Montserrat", system-ui, sans-serif; --mono: "JetBrains Mono", ui-monospace, monospace; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--dark); color: #fff; font-family: var(--display); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
#app { position: fixed; inset: 0; }
#app canvas { display: block; }
.labels { position: absolute !important; inset: 0; }

/* top bar */
.top { position: fixed; z-index: 10; top: 14px; left: 14px; right: 14px; display: flex; gap: 12px; align-items: center; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { display: flex; gap: 12px; align-items: center; background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px 10px 12px; }
.brand i { width: 26px; height: 26px; border: 3px solid #fff; border-radius: 50%; position: relative; flex: none; }
.brand i::after { content: ""; position: absolute; left: 50%; top: -6px; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: var(--orange); }
.brand b { display: block; font-weight: 900; letter-spacing: .04em; font-size: 16px; }
.brand small { display: block; font: 500 11px/1.3 var(--mono); color: var(--muted); }
.stats { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.stats span { background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; font: 500 12px var(--mono); color: var(--muted); white-space: nowrap; }
.stats b { color: #fff; font-weight: 700; }
.stats .bad b { color: #ffb4a8; }
.ctrl { display: flex; gap: 4px; background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; padding: 5px; }
.ctrl button { min-width: 38px; height: 36px; border-radius: 9px; font: 700 13px var(--mono); padding: 0 10px; }
.ctrl button:hover { background: rgba(255,255,255,.08); }
.ctrl button.on { background: #fff; color: var(--dark); }
.ctrl .map-btn { background: var(--orange); color: #fff; }
body[data-mode="overview"] .map-btn { display: none; }

/* process toggle + comparison */
.warn { margin-top: 12px; background: rgba(255,90,31,.15); border: 1px solid rgba(255,90,31,.4); border-radius: 10px; padding: 9px 12px; font-size: 13px; }
.flows { display: grid; gap: 6px; margin-top: 14px; }
.flows div { border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.flows div b { display: block; font-size: 12px; margin-bottom: 2px; }
.flows div.on { color: #fff; border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.06); }

/* labels in the scene */
.st-label, .f-label, .chip, .p-label, .b-label, .stamp, .devpop { font-family: var(--display); white-space: nowrap; }
.st-label { pointer-events: auto; display: flex; align-items: center; gap: 8px; background: var(--dark); color: #fff; border: 1.5px solid rgba(255,255,255,.25); border-radius: 12px; padding: 7px 12px 7px 7px; font-size: 14px; box-shadow: 0 8px 22px rgba(0,0,0,.35); transition: transform .15s; }
.st-label:hover, .st-label.on, .st-label.hover { transform: scale(1.06); border-color: var(--orange); }
.st-label .n { background: var(--orange); border-radius: 7px; padding: 3px 6px; font: 700 11px var(--mono); }
.st-label b { font-weight: 800; }
.st-label .cnt { font: 700 11px var(--mono); font-style: normal; background: #fff; color: var(--dark); border-radius: 999px; padding: 2px 7px; }
.b-label { display: flex; align-items: center; gap: 5px; background: #0b1a24; color: #bffbff; border: 1px solid #5ff3ff; border-radius: 999px; padding: 2px 9px 2px 3px; font-size: 11px; font-weight: 700; box-shadow: 0 0 12px rgba(95,243,255,.45); }
.b-label i { font: 800 9px var(--mono); font-style: normal; background: #5ff3ff; color: #0b1a24; border-radius: 999px; padding: 2px 5px; }
body.far .p-label, body.far .b-label { display: none; }
.useralert { pointer-events: auto; display: flex; gap: 8px; align-items: center; background: var(--dark); color: #fff; border: 1.5px solid #2bd47d; border-radius: 12px; padding: 6px 10px; font: 700 13px var(--display); white-space: nowrap; box-shadow: 0 8px 22px rgba(0,0,0,.35); }
.useralert .b { background: #2bd47d; color: #0b1a24; border-radius: 8px; padding: 3px 8px; font: 800 12px var(--mono); }
.useralert.hot { border-color: #ff3b1f; } .useralert.hot .b { background: #ff3b1f; color: #fff; animation: sos 0.9s infinite; }
.useralert.flash { animation: jump .6s ease-out 3; }
@keyframes sos { 50% { box-shadow: 0 0 0 6px rgba(255,59,31,.35); } }
@keyframes jump { 30% { translate: 0 -10px; scale: 1.12; } }
.devpop.sos { background: #ff3b1f; color: #fff; }
.badges span.hot { background: #ff3b1f; color: #fff; }
.p-label { background: #3a6ff0; color: #fff; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 700; }
.chip { pointer-events: auto; display: flex; align-items: center; gap: 6px; background: rgba(11,26,36,.9); border: 1px solid var(--line); color: #fff; border-radius: 9px; padding: 4px 9px; font-size: 12px; box-shadow: 0 6px 16px rgba(0,0,0,.3); }
.chip b { font: 700 12px var(--mono); }
.chip span { color: #dbe3e8; font-weight: 600; }
.chip.on { border-color: var(--orange); box-shadow: 0 0 0 2px var(--orange); }
body.far .chip span, body.far .f-label small, body.far .f-label .bar { display: none; }
body.far .chip:hover span { display: inline; }
body.far .chip { padding: 3px 7px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; background: var(--gray); }
.dot.red { background: var(--red); } .dot.yellow { background: var(--yellow); } .dot.green { background: var(--green); }
.stamp { font: 900 26px var(--display); letter-spacing: .04em; padding: 6px 14px; border: 4px solid; border-radius: 10px; background: rgba(11,26,36,.85); animation: stamp 1.7s ease-out forwards; }
.stamp.ok { color: var(--green); } .stamp.no { color: var(--orange); }
@keyframes stamp { 0% { rotate: -10deg; scale: 2.4; opacity: 0; } 12% { rotate: -10deg; scale: 1; opacity: 1; } 80% { rotate: -10deg; opacity: 1; } 100% { rotate: -10deg; translate: 0 -30px; opacity: 0; } }
.devpop { background: #fff; color: var(--dark); font-weight: 800; font-size: 14px; border-radius: 10px; padding: 7px 12px; animation: pop 2.6s ease-out forwards; }
@keyframes pop { 0% { translate: 0 10px; scale: .7; opacity: 0; } 10% { translate: 0 0; scale: 1; opacity: 1; } 85% { opacity: 1; } 100% { translate: 0 -30px; opacity: 0; } }

/* detail panel */
#panel { position: fixed; z-index: 12; top: 82px; right: 14px; bottom: 14px; width: 360px; background: var(--glass); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 18px; padding: 22px 22px 18px; overflow: auto; transform: translateX(calc(100% + 30px)); transition: transform .45s cubic-bezier(.2,.8,.2,1); }
#panel.open { transform: none; }
#panel .x { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 9px; font-size: 22px; line-height: 1; }
#panel .x:hover { background: rgba(255,255,255,.1); }
.kicker { font: 600 11px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--orange); }
#panel h2 { font-weight: 900; font-size: 26px; line-height: 1.1; margin: 8px 0 10px; letter-spacing: -.01em; }
#panel p { color: #d3dde3; font-size: 14px; line-height: 1.55; }
#panel h4 { font: 700 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 20px 0 8px; display: flex; gap: 8px; align-items: center; }
#panel h4 em { font-style: normal; background: #fff; color: var(--dark); border-radius: 999px; padding: 1px 7px; }
.muted { color: var(--muted) !important; font-size: 13px; }
.tasks { list-style: none; display: grid; gap: 6px; }
.tasks button { width: 100%; display: flex; gap: 8px; align-items: center; text-align: left; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 13px; }
.tasks button:hover { border-color: var(--orange); }
.tasks b { font: 700 12px var(--mono); }
.tasks span { margin-left: auto; color: var(--muted); font-size: 12px; }
.feats { list-style: none; display: grid; grid-template-columns: 1fr; gap: 4px; font-size: 13px; }
.feats li { display: flex; gap: 8px; align-items: center; }
.feats b { font: 700 11px var(--mono); color: #ffd2bf; }
.feats span { margin-left: auto; color: var(--muted); font-size: 12px; }
.pains { padding-left: 18px; color: #d3dde3; font-size: 14px; line-height: 1.6; }
.tip { margin-top: 16px; background: rgba(255,90,31,.12); border: 1px solid rgba(255,90,31,.35); border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.5; }
.tip b { color: var(--orange); margin-right: 6px; }
.nav { display: flex; gap: 6px; margin-top: 18px; }
.nav button { flex: 1; background: rgba(255,255,255,.08); border-radius: 10px; padding: 10px 8px; font-weight: 700; font-size: 13px; }
.nav button:hover { background: rgba(255,255,255,.16); }
.now { background: rgba(255,90,31,.12); border: 1px solid rgba(255,90,31,.45); border-radius: 12px; padding: 10px 12px; margin: 10px 0; font-size: 14px; line-height: 1.45; }
.now b { display: block; font: 700 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--orange); margin-bottom: 3px; }
.now small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badges span { display: inline-flex; gap: 6px; align-items: center; background: rgba(255,255,255,.08); border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 600; }
.hist { list-style: none; display: grid; gap: 8px; border-left: 2px solid var(--line); padding-left: 14px; }
.hist li { font-size: 13px; color: #d3dde3; position: relative; }
.hist li::before { content: ""; position: absolute; left: -19px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }
.hist time { font: 600 11px var(--mono); color: var(--muted); margin-right: 8px; }

/* bottom */
.legend { position: fixed; z-index: 9; left: 14px; top: 82px; display: flex; flex-direction: column; gap: 6px; background: var(--glass); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 12px; color: #d3dde3; }
.legend span { display: flex; gap: 8px; align-items: center; }
#feed { position: fixed; z-index: 9; left: 14px; bottom: 16px; width: 330px; list-style: none; display: flex; flex-direction: column; gap: 5px; }
#feed li { background: var(--glass); border: 1px solid var(--line); border-left: 3px solid var(--muted); border-radius: 9px; padding: 7px 10px; font-size: 12.5px; animation: in .4s ease-out; }
#feed li.good { border-left-color: var(--green); } #feed li.bad { border-left-color: var(--red); } #feed li.info { border-left-color: var(--orange); }
#feed li:nth-child(n+4) { opacity: .6; }
@keyframes in { from { transform: translateX(-20px); opacity: 0; } }
#minimap { position: fixed; z-index: 9; left: 14px; bottom: 16px; width: 240px; height: 206px; border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.4); cursor: pointer; display: none; }
body:not([data-mode="overview"]) #minimap { display: block; }
body:not([data-mode="overview"]) #feed, body:not([data-mode="overview"]) .legend { display: none; }
.hint { position: fixed; z-index: 9; right: 14px; bottom: 22px; font: 500 11px var(--mono); color: rgba(255,255,255,.75); text-shadow: 0 1px 4px #000; max-width: 300px; text-align: right; }
body:not([data-mode="overview"]) .hint { display: none; }
#views { position: fixed; z-index: 11; left: calc(50% - 140px); bottom: 16px; transform: translateX(-50%); display: flex; gap: 4px; background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; padding: 5px; max-width: calc(100vw - 420px); overflow-x: auto; }
body[data-mode="overview"] #views { display: none; }
#views button { padding: 8px 12px; border-radius: 9px; font-weight: 700; font-size: 13px; white-space: nowrap; }
#views button:hover { background: rgba(255,255,255,.08); }
#views button.on { background: var(--orange); }
#views button[data-v="orbit"].on { background: #5ff3ff; color: #0b1a24; }
.loading { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--dark); font: 600 12px var(--mono); letter-spacing: .16em; transition: opacity .6s; }
.loading.done { opacity: 0; pointer-events: none; }

@media (max-width: 1100px) { .stats span:nth-child(n+3) { display: none; } .hint { display: none; } }
@media (max-width: 1300px) { .stats span:nth-child(n+4) { display: none; } }
@media (max-width: 760px) {
  #views { left: 10px; right: 10px; transform: none; top: 120px; bottom: auto; max-width: none; }
  #views button { padding: 7px 9px; font-size: 12px; }
  .top { flex-wrap: wrap; top: 10px; left: 10px; right: 10px; gap: 8px; }
  .brand small { display: none; }
  .stats { order: 3; flex-basis: 100%; } .stats span:nth-child(n+3) { display: none; }
  .ctrl button[data-speed="4"] { display: none; }
  .legend { display: none; }
  #feed { width: auto; right: 10px; left: 10px; bottom: 12px; } #feed li:nth-child(n+3) { display: none; }
  #panel { top: auto; left: 10px; right: 10px; bottom: 10px; width: auto; max-height: 52vh; transform: translateY(calc(100% + 90px)); }
  #minimap { width: 120px; height: 103px; bottom: auto; top: 170px; left: 10px; }
    .st-label { font-size: 12px; padding: 5px 9px 5px 5px; }
}

.toast { position: fixed; z-index: 30; left: 50%; top: 92px; transform: translate(-50%, -8px); background: var(--dark); color: #fff; border: 1px solid var(--orange); border-radius: 999px; padding: 8px 16px; font: 800 14px var(--display); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; box-shadow: 0 8px 22px rgba(0,0,0,.35); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#btn-pause.paused { background: var(--orange); }

/* feature agent cards */
.f-label { pointer-events: auto; display: flex; align-items: center; gap: 8px; background: rgba(11,26,36,.92); color: #fff; border: 1.5px solid rgba(255,255,255,.18); border-left: 4px solid #9aa3a8; border-radius: 12px; padding: 5px 10px 6px 6px; box-shadow: 0 8px 20px rgba(0,0,0,.3); cursor: pointer; transition: transform .15s; min-width: 150px; }
.f-label:hover { transform: translateY(-2px) scale(1.04); border-color: rgba(255,255,255,.5); }
.f-label[data-tone="red"] { border-left-color: #ff5a1f; } .f-label[data-tone="yellow"] { border-left-color: #e9b949; } .f-label[data-tone="green"] { border-left-color: #2bd47d; }
.f-label b { display: block; font: 800 12px var(--display); }
.f-label small { display: block; font: 600 10.5px var(--mono); color: #b9c6cd; margin-top: 1px; }
.f-label .bar { display: block; height: 4px; border-radius: 4px; background: rgba(255,255,255,.12); margin-top: 4px; overflow: hidden; }
.f-label .bar u { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #5ff3ff, #2bd47d); transition: width .3s; }
.f-label[data-tone="red"] .bar u { background: linear-gradient(90deg, #ff9f5a, #ff5a1f); }
.av { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: #0b1a24; font: 900 13px var(--display); box-shadow: 0 0 0 2px rgba(255,255,255,.85), 0 0 12px var(--c); flex: none; }
.av.big { width: 34px; height: 34px; font-size: 17px; vertical-align: middle; margin-right: 4px; }
body.mid .f-label small { display: none; }
body.mid .f-label { min-width: 0; padding: 3px 8px 4px 4px; gap: 6px; }
body.mid .f-label .av { width: 20px; height: 20px; font-size: 11px; }
body.mid .f-label b { font-size: 11px; }
.f-label:hover small { display: block !important; }
body:not(.show-feats) .f-label { display: none; }

/* game zone */
.arcade-label { pointer-events: auto; cursor: pointer; display: flex; flex-direction: column; align-items: center; background: linear-gradient(135deg, #7b5cff, #e86a92); color: #fff; border-radius: 12px; padding: 6px 12px; box-shadow: 0 0 18px rgba(162,89,255,.6); font-family: var(--display); white-space: nowrap; transition: transform .15s; }
.arcade-label:hover { transform: scale(1.07); }
.arcade-label b { font-size: 13px; font-weight: 900; letter-spacing: .04em; } .arcade-label small { font-size: 10.5px; opacity: .9; }
body.far .arcade-label small { display: none; }
.games { list-style: none; display: grid; gap: 8px; margin-top: 12px; }
.games button { width: 100%; display: flex; gap: 10px; align-items: center; text-align: left; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-left: 4px solid var(--gc); border-radius: 12px; padding: 10px 12px; }
.games button:hover { background: rgba(255,255,255,.12); }
.games .gi { font-size: 26px; } .games b { display: block; font-size: 14px; } .games small { display: block; font-size: 12px; color: var(--muted); line-height: 1.35; }
.games em { margin-left: auto; font-style: normal; font: 800 12px var(--mono); color: var(--gc); white-space: nowrap; }
#game { position: fixed; inset: 0; z-index: 40; background: rgba(4,10,16,.62); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; }
#game[hidden] { display: none; }
.gbox { width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; background: #0f1d27; border: 1px solid rgba(255,255,255,.14); border-top: 5px solid var(--gc); border-radius: 18px; padding: 16px 18px 18px; color: #fff; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.gbox header { display: flex; gap: 12px; align-items: center; } .gbox header .gi { font-size: 34px; }
.gbox header b { display: block; font-size: 20px; font-weight: 900; } .gbox header small { display: block; color: var(--muted); font-size: 12.5px; }
.gx { margin-left: auto; align-self: flex-start; font-size: 26px; line-height: 1; color: #fff; opacity: .7; } .gx:hover { opacity: 1; }
.ghud { display: flex; justify-content: space-between; margin: 12px 0 10px; font: 600 13px var(--mono); color: var(--muted); } .ghud b { color: #fff; }
.gstage { min-height: 300px; display: grid; place-items: center; }
.gend { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; } .gend b { width: 100%; font-size: 16px; } .gend em { width: 100%; font-style: normal; color: #ffd84d; font-weight: 800; }
.gend button { background: var(--gc); color: #0b1a24; font-weight: 800; border-radius: 10px; padding: 9px 14px; } .gend .gback { background: rgba(255,255,255,.1); color: #fff; }
.gbug { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.gbug .cell { aspect-ratio: 1.3; background: #f4f2ee; border-radius: 10px; position: relative; overflow: hidden; box-shadow: inset 0 -4px 0 #d8d4ca; }
.gbug .cell::before { content: ''; position: absolute; left: 10%; right: 10%; top: 14%; height: 12%; background: #d8e6ee; border-radius: 4px; }
.gbug .cell i { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 34px; transform: scale(0); transition: transform .12s; }
.gbug .cell.on i { transform: scale(1); } .gbug .cell.hit { background: #2bd47d; }
.gpix { position: relative; width: 100%; max-width: 420px; height: 220px; background: #f4f2ee; border-radius: 12px; overflow: hidden; cursor: pointer; }
.gpix .guide { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #ff3b8a; }
.gpix .guide::after { content: 'căn giữa'; position: absolute; top: 6px; left: 6px; font: 700 10px var(--mono); color: #ff3b8a; }
.gpix .frame { position: absolute; left: 0; top: 80px; width: 120px; height: 46px; border: 2px dashed #3fb5ff; border-radius: 10px; display: grid; place-items: center; background: rgba(63,181,255,.12); }
.gpix .frame span { background: #0b1a24; color: #fff; font-weight: 800; font-size: 13px; padding: 7px 14px; border-radius: 8px; }
.gpix .frame.good { border-color: #2bd47d; background: rgba(43,212,125,.2); }
.gpix .hint { position: absolute; bottom: 34px; width: 100%; text-align: center; color: #6b7a83; font-size: 12px; }
.gpix .res, .ghex .res { position: absolute; bottom: 10px; width: 100%; text-align: center; color: #0b1a24; font-weight: 800; }
.gmem { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.gmem .card { aspect-ratio: 1; border-radius: 12px; position: relative; font-size: 34px; background: #7b5cff; color: #fff; transition: transform .25s; }
.gmem .card .f { display: none; } .gmem .card.up { background: #f4f2ee; transform: rotateY(180deg) scaleX(-1); } .gmem .card.up .f { display: inline; } .gmem .card.up .b { display: none; }
.gmem .card.done { background: #2bd47d33; box-shadow: inset 0 0 0 2px #2bd47d; }
.gmem .card .b { font: 900 24px var(--display); opacity: .6; }
.ghex { position: relative; width: 100%; display: grid; gap: 12px; justify-items: center; padding-bottom: 30px; }
.ghex .sw { width: 100%; height: 150px; border-radius: 14px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.ghex .opts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: 100%; }
.ghex .opt { background: rgba(255,255,255,.08); border: 1px solid var(--line); border-radius: 10px; padding: 11px; font: 800 15px var(--mono); color: #fff; }
.ghex .opt:hover { background: rgba(255,255,255,.16); } .ghex .opt.ok { background: #2bd47d; color: #0b1a24; } .ghex .opt.no { background: #ff3b1f; }
.ghex .res { color: #fff; position: absolute; bottom: 0; }
/* bản đồ toàn cảnh: ẩn tag các khu cho gọn, chỉ hiện khi zoom vào gần / vào chi tiết (hoặc khi rê chuột vào khu đó) */
body[data-mode="overview"].far .st-label:not(.hover):not(.on), body[data-mode="overview"].far .arcade-label, body[data-mode="overview"].far .useralert { display: none; }
