:root {
  --bg: #0b1020;
  --panel: rgba(14, 20, 38, 0.92);
  --panel-2: #141c33;
  --line: #2a3658;
  --text: #dfe6f5;
  --dim: #8a97b6;
  --teal: #4fd1c5;
  --ember: #ff9152;
  --lumen: #b892ff;
  --bad: #ff5d6c;
  --good: #67e39a;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); user-select: none; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: default; }
.hidden { display: none !important; }
button { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 14px; cursor: pointer; }
button:hover { border-color: var(--teal); }
button:disabled { opacity: .45; cursor: default; border-color: var(--line); }
input, select { font: inherit; color: var(--text); background: #0d1428; border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; }
input:focus, select:focus { outline: none; border-color: var(--teal); }
kbd { font: 12px/1 ui-monospace, Consolas, monospace; background: #1a2440; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; color: var(--text); }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px;
  background: radial-gradient(ellipse at 50% 30%, rgba(30, 44, 84, .55), rgba(6, 9, 18, .96)), var(--bg); overflow: auto; z-index: 20; }
.screen.dim { background: rgba(5, 8, 16, .72); }
#menu::before { content: ""; position: absolute; inset: 0; opacity: .16; pointer-events: none;
  background-image: linear-gradient(60deg, transparent 49.3%, #4fd1c5 49.3%, #4fd1c5 50.7%, transparent 50.7%),
    linear-gradient(-60deg, transparent 49.3%, #4fd1c5 49.3%, #4fd1c5 50.7%, transparent 50.7%),
    linear-gradient(0deg, transparent 49.3%, #4fd1c5 49.3%, #4fd1c5 50.7%, transparent 50.7%);
  background-size: 56px 97px; }
.title-wrap { text-align: center; position: relative; }
.logo { width: 84px; height: 74px; }
h1 { font-size: 54px; letter-spacing: 14px; margin: 6px 0 2px 14px; font-weight: 300; }
.tag { color: var(--dim); margin: 0; letter-spacing: 1px; }
.cards { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; position: relative; }
.card { width: 270px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; }
.card p { margin: 0; color: var(--dim); font-size: 14px; }
.big { background: linear-gradient(180deg, #1f6f6a, #17504d); border-color: #2f9c94; font-weight: 600; padding: 10px; }
.big:hover { border-color: #8af0e6; }
.link { background: none; border: none; color: var(--dim); text-decoration: underline; padding: 4px; position: relative; }
.link:hover { color: var(--text); }
.seg { display: flex; }
.seg button { flex: 1; border-radius: 0; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button.on { background: #22355e; border-color: var(--teal); }
.field { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 14px; }
.field input { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 3px; }
.row.center { justify-content: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; min-width: 220px; }
.msg { min-height: 18px; font-size: 13px; color: var(--dim); }
.msg.err { color: var(--bad); }
.foot { color: #56628a; font-size: 12px; position: relative; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px 26px; text-align: center; min-width: 320px; max-width: 92vw; }
.panel h2 { margin: 0 0 10px; letter-spacing: 3px; text-transform: uppercase; font-weight: 500; }
.panel.wide { max-width: min(980px, 94vw); text-align: left; }
.panel.wide h2 { text-align: center; }
.code { font: 600 46px/1.1 ui-monospace, Consolas, monospace; letter-spacing: 10px; color: var(--teal); margin: 8px 0; }
.cols { display: flex; gap: 28px; flex-wrap: wrap; }
.cols > div { flex: 1; min-width: 300px; }
h3 { margin: 10px 0 6px; color: var(--teal); font-weight: 600; font-size: 15px; letter-spacing: 1px; text-transform: uppercase; }
.keys { padding-left: 18px; margin: 0; line-height: 1.9; font-size: 14px; }
.small { font-size: 13px; color: var(--dim); }
.lumen { color: var(--lumen); }
#unitTable { border-collapse: collapse; font-size: 13px; width: 100%; }
#unitTable td { padding: 4px 6px; border-bottom: 1px solid #1d2744; vertical-align: top; }
#unitTable td:first-child { white-space: nowrap; font-weight: 600; }
.good { color: var(--good); } .bad { color: var(--bad); }
.stats { margin: 10px auto 16px; border-collapse: collapse; font-size: 14px; }
.stats td, .stats th { padding: 5px 14px; border-bottom: 1px solid #1d2744; }
.stats th { color: var(--dim); font-weight: 500; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
#topbar { position: absolute; top: 0; left: 0; right: 0; height: 38px; display: flex; align-items: center; gap: 18px; padding: 0 12px;
  background: linear-gradient(180deg, rgba(10, 15, 30, .95), rgba(10, 15, 30, .75)); border-bottom: 1px solid var(--line); font-size: 15px; }
#topbar .grow { flex: 1; }
.stat { display: flex; align-items: center; gap: 7px; }
.stat b { font-weight: 600; min-width: 40px; }
.stat b.warn { color: var(--bad); }
.ico-lumen, .ico-sup, .ico-mote { width: 14px; height: 14px; display: inline-block; }
.ico-lumen { background: var(--lumen); clip-path: polygon(50% 0, 100% 40%, 50% 100%, 0 40%); }
.ico-sup { background: var(--teal); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.ico-mote { background: var(--text); border-radius: 50%; width: 11px; height: 11px; }
.clock { font: 600 16px ui-monospace, Consolas, monospace; letter-spacing: 1px; color: var(--dim); }
.net { font-size: 13px; color: var(--dim); }
.net .ok { color: var(--good); } .net .warn { color: #ffd166; } .net .bad { color: var(--bad); }
.tbtn { padding: 3px 12px; font-size: 13px; }
#banner { position: absolute; top: 48px; left: 50%; transform: translateX(-50%); padding: 8px 16px; border-radius: 8px; font-size: 14px;
  background: rgba(20, 28, 52, .95); border: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
#banner.desync { background: rgba(80, 16, 28, .95); border-color: var(--bad); }
#toast { position: absolute; bottom: 196px; left: 50%; transform: translateX(-50%); pointer-events: none; text-align: center; }
#toast div { background: rgba(10, 14, 28, .85); padding: 5px 14px; border-radius: 6px; margin-top: 4px; font-size: 14px; color: #ffd6a0; animation: fade 2.4s forwards; }
@keyframes fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

#bottom { position: absolute; left: 0; right: 0; bottom: 0; height: 186px; display: flex; gap: 0; align-items: stretch;
  background: linear-gradient(0deg, rgba(10, 15, 30, .97), rgba(10, 15, 30, .9)); border-top: 1px solid var(--line); }
#mmWrap { padding: 8px; border-right: 1px solid var(--line); }
#minimap { width: 170px; height: 170px; display: block; background: #05080f; border: 1px solid var(--line); cursor: crosshair; image-rendering: auto; }
#selPanel { flex: 1; padding: 10px 14px; overflow: hidden; display: flex; gap: 14px; min-width: 0; }
#cmdCard { width: 316px; padding: 10px; border-left: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 56px); grid-auto-rows: 52px; gap: 5px; align-content: start; }
.cb { position: relative; padding: 12px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; line-height: 1.1; gap: 2px; overflow: hidden; }
.cb img { width: 24px; height: 24px; }
.cb > span:last-child:not(.cost), .cb > span:nth-child(3) { max-width: 54px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb .hk { position: absolute; top: 2px; left: 4px; font-size: 10px; color: var(--teal); font-weight: 700; }
.cb .cost { position: absolute; top: 2px; right: 4px; font-size: 10px; color: var(--lumen); }
.cb.on { border-color: var(--teal); background: #1d3a4f; }
.cb.locked { opacity: .4; }
.sel-main { display: flex; gap: 14px; min-width: 0; flex: 1; }
.sel-portrait { width: 84px; height: 84px; flex: none; background: #0d1428; border: 1px solid var(--line); border-radius: 8px; }
.sel-info { min-width: 0; flex: 1; font-size: 14px; }
.sel-info h4 { margin: 0 0 2px; font-size: 17px; font-weight: 600; }
.sel-info .role { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.sel-info .line { margin-top: 5px; color: var(--dim); font-size: 13px; }
.sel-info .line b { color: var(--text); font-weight: 600; }
.hpbar { height: 6px; background: #2a1a24; border-radius: 3px; overflow: hidden; margin-top: 6px; max-width: 240px; }
.hpbar i { display: block; height: 100%; background: var(--good); }
.queue { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.qi { width: 36px; height: 36px; background: #0d1428; border: 1px solid var(--line); border-radius: 6px; position: relative; overflow: hidden; cursor: pointer; }
.qi canvas { width: 34px; height: 34px; }
.qi .pr { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--teal); }
.grid-sel { display: flex; flex-wrap: wrap; gap: 4px; align-content: flex-start; overflow: hidden; }
.gs { width: 40px; height: 40px; background: #0d1428; border: 1px solid var(--line); border-radius: 6px; position: relative; cursor: pointer; }
.gs canvas { width: 38px; height: 38px; }
.gs i { position: absolute; left: 3px; right: 3px; bottom: 2px; height: 3px; background: var(--good); border-radius: 2px; }
.gs b { position: absolute; top: 1px; right: 3px; font-size: 10px; }
.vs { font-size: 12px; margin-top: 6px; }

#replayBar { position: absolute; top: 46px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
#rbSpeeds { display: flex; }
#rbSpeeds button { padding: 3px 8px; font-size: 12px; border-radius: 0; }
#rbSpeeds button.on { background: #22355e; border-color: var(--teal); }
#rbTrack { width: 260px; height: 8px; background: #0d1428; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; overflow: hidden; }
#rbFill { height: 100%; width: 0; background: var(--teal); }
#rbTime { white-space: nowrap; font-family: ui-monospace, Consolas, monospace; color: var(--dim); }
.badge { white-space: nowrap; padding: 3px 8px; border-radius: 10px; background: #1a2440; color: var(--dim); }
.badge.ok { background: #143a2a; color: var(--good); }
.badge.bad { background: #4a1420; color: var(--bad); }
#tip { position: absolute; z-index: 30; max-width: 260px; background: rgba(8, 12, 24, .97); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; pointer-events: none; }
#tip h5 { margin: 0 0 3px; font-size: 14px; }
#tip .c { color: var(--lumen); }
#tip p { margin: 4px 0 0; color: var(--dim); }

@media (max-width: 900px) {
  #cmdCard { width: 216px; grid-template-columns: repeat(3, 56px); }
  #minimap { width: 130px; height: 130px; }
  #bottom { height: 150px; }
  h1 { font-size: 36px; letter-spacing: 8px; }
}
