:root {
  --bg: #0d0f12;
  --panel: rgba(18, 21, 27, 0.92);
  --panel2: rgba(28, 32, 40, 0.95);
  --line: #2c323d;
  --line2: #3d4553;
  --text: #e6e2d8;
  --muted: #9aa3b2;
  --dim: #6b7382;
  --accent: #e0a458;
  --accent2: #7fc7ff;
  --good: #6fd17a;
  --bad: #ff6b6b;
  --warn: #ffd166;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; }
button { font-family: inherit; }
input, select { font-family: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #3a4150; border-radius: 4px; }

#game { position: fixed; inset: 0; display: block; background: #05070a; cursor: default; }
#fx { position: fixed; inset: 0; pointer-events: none; }

.hidden { display: none !important; }

/* ------------------------------------------------------------- screens */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 30% 20%, #1c2230 0%, #0b0d11 60%, #050608 100%);
  z-index: 50;
}
.screen::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .35;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(224,164,88,.18), transparent 35%),
    radial-gradient(circle at 80% 30%, rgba(127,199,255,.12), transparent 40%);
}
.card {
  position: relative; background: var(--panel); border: 1px solid var(--line2); border-radius: 12px;
  padding: 22px 26px; width: min(1080px, 94vw); max-height: 92vh; overflow: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.brand { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; }
.brand h1 { margin: 0; font-size: 34px; letter-spacing: 2px; color: var(--accent); font-weight: 800; text-transform: uppercase; }
.brand small { color: var(--muted); font-size: 13px; letter-spacing: 1px; }
.row { display: flex; gap: 14px; align-items: flex-start; }
.col { flex: 1; min-width: 0; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin: 10px 0 5px; }
.field { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.field label { width: 120px; color: var(--muted); font-size: 13px; }
.field input, .field select {
  flex: 1; background: #0e1117; border: 1px solid var(--line2); color: var(--text); padding: 7px 9px; border-radius: 6px; font-size: 13px;
}
.btn {
  background: linear-gradient(#3a4150, #2a3040); color: var(--text); border: 1px solid var(--line2); border-radius: 7px;
  padding: 8px 14px; cursor: pointer; font-size: 13px; transition: filter .12s, transform .05s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(#e6b26a, #c98d3f); color: #1a1409; border-color: #f0c583; font-weight: 700; }
.btn.danger { background: linear-gradient(#a24040, #7a2b2b); border-color: #c05656; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

/* class picker */
.classes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.cls {
  border: 1px solid var(--line2); border-radius: 10px; padding: 12px; cursor: pointer; background: var(--panel2);
  transition: border-color .15s, transform .12s; position: relative; overflow: hidden; min-height: 240px;
}
.cls::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, var(--c, #fff) 0, transparent 50%); opacity: .08; pointer-events: none; }
.cls:hover { transform: translateY(-2px); }
.cls.sel { border-color: var(--c, var(--accent)); box-shadow: 0 0 0 1px var(--c, var(--accent)), 0 0 24px rgba(224,164,88,.15) inset; }
.cls h3 { margin: 0 0 2px; font-size: 16px; color: var(--c, var(--accent)); }
.cls .title { font-size: 11px; color: var(--muted); font-style: italic; margin-bottom: 8px; }
.cls .desc { font-size: 12px; color: var(--text); margin-bottom: 8px; line-height: 1.35; }
.cls ul { margin: 4px 0 0; padding-left: 16px; font-size: 11.5px; line-height: 1.4; }
.cls ul.good li { color: var(--good); }
.cls ul.bad li { color: var(--bad); }
.cls .stats { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.cls .stat { font-size: 10.5px; background: rgba(0,0,0,.35); border: 1px solid var(--line); padding: 2px 6px; border-radius: 4px; color: var(--muted); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--c, #888); margin-bottom: 8px; position: relative; box-shadow: 0 0 0 3px rgba(0,0,0,.4), 0 0 18px var(--c, #888); }

/* room list */
.rooms { border: 1px solid var(--line); border-radius: 8px; background: #0e1117; min-height: 120px; max-height: 240px; overflow: auto; }
.room { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.room:last-child { border-bottom: none; }
.room .n { flex: 1; font-weight: 600; }
.room .m { color: var(--muted); font-size: 12px; }
.room.empty { color: var(--dim); justify-content: center; padding: 26px; font-style: italic; }

/* lobby */
.players { border: 1px solid var(--line); border-radius: 8px; background: #0e1117; }
.pl { display: grid; grid-template-columns: 1.3fr 1fr .7fr .7fr; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; align-items: center; }
.pl:last-child { border-bottom: none; }
.pl .ready { color: var(--good); }
.pl .notready { color: var(--dim); }
.pl select { background: #0e1117; border: 1px solid var(--line2); color: var(--text); padding: 3px 6px; border-radius: 5px; font-size: 12px; }
.chatbox { background: #0e1117; border: 1px solid var(--line); border-radius: 8px; height: 150px; overflow: auto; padding: 8px; font-size: 12.5px; }
.chatbox .msg b { color: var(--accent2); }
.help { font-size: 12px; color: var(--muted); line-height: 1.5; }
.help kbd { background: #1c212b; border: 1px solid var(--line2); border-radius: 4px; padding: 0 5px; font-family: var(--mono); font-size: 11px; color: var(--text); }

/* ----------------------------------------------------------------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 20; font-size: 13px; }
#hud > * { pointer-events: auto; }

#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 44px; display: flex; align-items: center; gap: 6px; padding: 0 10px;
  background: linear-gradient(180deg, rgba(10,12,16,.96), rgba(10,12,16,.75)); border-bottom: 1px solid var(--line);
}
.res { display: flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.35); border: 1px solid var(--line); min-width: 66px; cursor: default; }
.res .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.res .v { font-family: var(--mono); font-size: 12.5px; }
.res.low .v { color: var(--bad); }
.res.rare { border-color: #5a4a7a; }
#resMore { padding: 3px 8px; }
.spacer { flex: 1; }
.pill { padding: 3px 9px; border-radius: 12px; background: rgba(0,0,0,.35); border: 1px solid var(--line); color: var(--muted); font-size: 12px; white-space: nowrap; }
.pill b { color: var(--text); }
.pill.warn { border-color: var(--warn); color: var(--warn); }

#buildBar {
  position: absolute; left: 0; top: 44px; bottom: 0; width: 240px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; transition: transform .18s;
}
#buildBar.collapsed { transform: translateX(-232px); }
#buildBar .tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
#buildBar .tab { flex: 1 0 33%; text-align: center; padding: 7px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
#buildBar .tab.on { color: var(--accent); border-bottom-color: var(--accent); }
#buildList { flex: 1; overflow: auto; padding: 6px; }
.bitem { display: flex; gap: 8px; align-items: center; padding: 6px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; margin-bottom: 3px; }
.bitem:hover { background: rgba(255,255,255,.05); border-color: var(--line); }
.bitem.locked { opacity: .45; }
.bitem.poor .cost { color: var(--bad); }
.bitem .ic { width: 30px; height: 30px; border-radius: 6px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 15px; background: #1a1f28; border: 1px solid var(--line2); }
.bitem .t { flex: 1; min-width: 0; }
.bitem .n { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bitem .cost { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bitem .tier { font-size: 10px; color: var(--dim); }
#buildToggle { position: absolute; right: -1px; top: 0; transform: translateX(100%); background: var(--panel); border: 1px solid var(--line); border-left: none; padding: 6px 7px; cursor: pointer; border-radius: 0 6px 6px 0; color: var(--muted); }

#rightBar { position: absolute; right: 0; top: 44px; width: 232px; display: flex; flex-direction: column; gap: 6px; padding: 6px; }
#minimapWrap { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
#minimap { display: block; width: 100%; aspect-ratio: 1; border-radius: 4px; cursor: crosshair; image-rendering: pixelated; }
.side { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.side h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.mission { display: flex; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 12px; margin-bottom: 3px; background: rgba(0,0,0,.25); border: 1px solid var(--line); }
.mission:hover { border-color: var(--accent); }
.mission .k { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.mission .bar { height: 3px; background: #1a1f28; border-radius: 2px; margin-top: 3px; overflow: hidden; }
.mission .bar i { display: block; height: 100%; background: var(--accent); }
.pline { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 0; }
.pline .sw { width: 10px; height: 10px; border-radius: 50%; }
.pline.dead { opacity: .4; text-decoration: line-through; }
.pline .tm { margin-left: auto; color: var(--dim); font-size: 10.5px; }

#bottom {
  position: absolute; left: 248px; right: 240px; bottom: 0; height: 176px; background: var(--panel); border-top: 1px solid var(--line);
  display: flex; gap: 8px; padding: 8px;
}
#selPanel { flex: 1.2; min-width: 0; overflow: auto; }
#actPanel { flex: 1.6; min-width: 0; overflow: auto; }
#selPanel h3 { margin: 0 0 4px; font-size: 15px; }
#selPanel .sub { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.hpbar { height: 6px; background: #1a1f28; border-radius: 3px; overflow: hidden; margin: 4px 0; }
.hpbar i { display: block; height: 100%; background: var(--good); }
.hpbar.en i { background: var(--accent2); }
.hpbar.xp i { background: var(--accent); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; font-size: 11.5px; color: var(--muted); }
.stats b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.multi { display: flex; flex-wrap: wrap; gap: 4px; }
.multi .u { width: 34px; height: 34px; border-radius: 6px; background: #1a1f28; border: 1px solid var(--line2); display: flex; align-items: center; justify-content: center; font-size: 11px; cursor: pointer; position: relative; }
.multi .u i { position: absolute; bottom: 0; left: 0; height: 2px; background: var(--good); }
.acts { display: flex; flex-wrap: wrap; gap: 5px; }
.act {
  width: 62px; height: 62px; border-radius: 8px; background: #161b23; border: 1px solid var(--line2); cursor: pointer; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10.5px; text-align: center; padding: 3px; line-height: 1.1;
}
.act:hover { border-color: var(--accent); }
.act.locked { opacity: .4; }
.act.poor { border-color: #6a2e2e; }
.act .ico { font-size: 18px; }
.act .k { position: absolute; top: 2px; left: 4px; font-size: 9px; color: var(--dim); font-family: var(--mono); }
.act .cd { position: absolute; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 14px; border-radius: 8px; }
.act.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.queue { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.job { width: 52px; height: 42px; background: #161b23; border: 1px solid var(--line2); border-radius: 6px; font-size: 10px; text-align: center; position: relative; overflow: hidden; cursor: pointer; padding-top: 4px; }
.job i { position: absolute; bottom: 0; left: 0; height: 3px; background: var(--accent2); }
.job.rep::after { content: "↻"; position: absolute; top: 1px; right: 3px; font-size: 10px; color: var(--accent); }
.stances { display: flex; gap: 4px; margin-top: 6px; }
.stances .btn.on { border-color: var(--accent); color: var(--accent); }
.hint { font-size: 11px; color: var(--dim); margin-top: 6px; }

#abilBar { position: absolute; left: 50%; bottom: 184px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 5px; }
#abilBar .abils { display: flex; gap: 6px; }
#abilBar .act { width: 56px; height: 56px; }
.vitals { width: 250px; background: rgba(10,12,16,.85); border: 1px solid var(--line2); border-radius: 8px; padding: 6px 10px; }
.vitals .nm { font-weight: 700; font-size: 13px; }
.vitals .lv { float: right; font-size: 11px; color: var(--muted); }
.vitals .hpbar { margin: 3px 0 0; height: 7px; }
.vitals .hpbar.en, .vitals .hpbar.xp { height: 4px; }
.vitals.dead { border-color: var(--bad); text-align: center; }
.vitals.dead .lv { float: none; display: block; }
#topbar .btn { white-space: nowrap; }
body.softlock #game, body.softlock #overlay { cursor: none; }

/* ---- first-person overlays */
#overlay { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
#crosshair { position: fixed; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; pointer-events: none; z-index: 3; }
#crosshair::before, #crosshair::after { content: ''; position: absolute; background: rgba(255,255,255,.9); box-shadow: 0 0 2px rgba(0,0,0,.8); }
#crosshair::before { left: 8px; top: 0; width: 2px; height: 18px; }
#crosshair::after { top: 8px; left: 0; width: 18px; height: 2px; }
#prompt { position: fixed; left: 50%; top: calc(50% + 30px); transform: translateX(-50%); background: rgba(10,12,16,.85); border: 1px solid var(--line2); border-radius: 6px; padding: 5px 11px; font-size: 13px; color: #f0ead8; pointer-events: none; z-index: 3; white-space: nowrap; }
#clickHint { position: fixed; left: 50%; top: 60px; transform: translateX(-50%); background: rgba(10,12,16,.85); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 14px; font-size: 14px; z-index: 3; pointer-events: none; }
body.locked #clickHint { display: none; }
body.locked #game { cursor: none; }
#minimapWrap { transition: transform .15s; transform-origin: top right; }
#minimapWrap.big { transform: scale(2.6); z-index: 5; position: relative; }
#topbar .btn.on { border-color: var(--accent); color: var(--accent); }

#notes { position: absolute; left: 50%; top: 54px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 4px; align-items: center; pointer-events: none; }
.note { background: rgba(10,12,16,.9); border: 1px solid var(--line2); border-radius: 6px; padding: 5px 12px; font-size: 12.5px; animation: fade 5s forwards; box-shadow: 0 6px 20px rgba(0,0,0,.5); }
.note.warn { border-color: var(--warn); color: var(--warn); }
.note.good { border-color: var(--good); color: var(--good); }
.note.bad { border-color: var(--bad); color: var(--bad); }
.note.mission { border-color: var(--accent); color: var(--accent); }
@keyframes fade { 0% { opacity: 0; transform: translateY(-6px); } 8% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }

#chat { position: absolute; left: 248px; bottom: 184px; width: 380px; }
#chatLog { max-height: 130px; overflow: auto; font-size: 12px; text-shadow: 0 1px 2px #000; padding: 4px; }
#chatLog .msg { opacity: .9; }
#chatLog .msg b { color: var(--accent2); }
#chatInput { width: 100%; background: rgba(10,12,16,.9); border: 1px solid var(--line2); color: var(--text); padding: 6px 8px; border-radius: 6px; font-size: 12.5px; }

#tooltip { position: fixed; z-index: 60; background: var(--panel2); border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; font-size: 12px; max-width: 280px; pointer-events: none; box-shadow: 0 10px 30px rgba(0,0,0,.5); line-height: 1.4; }
#tooltip b { color: var(--accent); }
#tooltip .c { color: var(--muted); font-family: var(--mono); font-size: 11px; }
#tooltip .d { color: var(--text); margin-top: 3px; }
#tooltip .r { color: var(--warn); font-size: 11px; margin-top: 3px; }

/* modals */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; }
.modal .card { width: min(980px, 92vw); max-height: 86vh; }
.modal h2 { margin: 0 0 8px; font-size: 20px; color: var(--accent); display: flex; align-items: center; gap: 12px; }
.modal h2 small { color: var(--muted); font-size: 12px; font-weight: 400; }
.close { margin-left: auto; }
.techs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.tech { border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; background: var(--panel2); cursor: pointer; font-size: 12px; }
.tech:hover { border-color: var(--accent); }
.tech.done { border-color: var(--good); opacity: .8; }
.tech.busy { border-color: var(--accent2); }
.tech.locked { opacity: .5; cursor: default; }
.tech .n { font-weight: 600; font-size: 13px; }
.tech .b { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--dim); float: right; }
.tech .d { color: var(--muted); margin: 3px 0; }
.tech .c { font-family: var(--mono); font-size: 11px; color: var(--text); }
.tech .req { color: var(--warn); font-size: 11px; }
.branch { margin: 12px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 3px; }

.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.track { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.track .n { width: 90px; font-weight: 600; }
.track .pips { display: flex; gap: 3px; }
.track .pip { width: 16px; height: 8px; border-radius: 2px; background: #1a1f28; border: 1px solid var(--line2); }
.track .pip.on { background: var(--accent); border-color: var(--accent); }
.track .d { color: var(--muted); font-size: 11.5px; flex: 1; }
.abil { border: 1px solid var(--line2); border-radius: 8px; padding: 8px; margin-bottom: 6px; background: var(--panel2); display: flex; gap: 10px; align-items: center; }
.abil .ico { font-size: 22px; width: 36px; text-align: center; }
.abil .t { flex: 1; }
.abil .n { font-weight: 600; }
.abil .d { color: var(--muted); font-size: 11.5px; }
.abil .r { font-family: var(--mono); font-size: 11px; color: var(--accent2); }
.inv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.item { border: 1px solid var(--line2); border-radius: 8px; padding: 7px 9px; background: var(--panel2); cursor: pointer; font-size: 12px; }
.item:hover { border-color: var(--accent); }
.item.eq { border-color: var(--good); box-shadow: 0 0 0 1px var(--good) inset; }
.item .n { font-weight: 600; }
.item .d { color: var(--muted); font-size: 11px; }
.rar-common .n { color: #ddd; } .rar-uncommon .n { color: #6fd17a; } .rar-rare .n { color: #7fc7ff; } .rar-legendary .n { color: #e0a458; }
.slots { display: flex; gap: 8px; margin-bottom: 10px; }
.slot { flex: 1; border: 1px dashed var(--line2); border-radius: 8px; padding: 6px 8px; font-size: 12px; min-height: 48px; }
.slot .l { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); }

#endCard table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
#endCard th, #endCard td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
#endCard th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
.winner { font-size: 26px; color: var(--accent); font-weight: 800; margin: 4px 0; }
.loser { color: var(--bad); }

#loading { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: #0d0f12; color: var(--muted); font-size: 14px; letter-spacing: 1px; }
#loading.hidden { display: none; }

.kbd { display: inline-block; background: #1c212b; border: 1px solid var(--line2); border-radius: 4px; padding: 0 5px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); }

#logPanel { position: absolute; right: 244px; bottom: 262px; width: 300px; max-height: 110px; overflow: hidden; font-size: 11.5px; pointer-events: none; text-align: right; }
#logPanel div { color: var(--muted); text-shadow: 0 1px 2px #000; opacity: .85; }
#logPanel div.hi { color: var(--warn); }
