:root {
  --accent: #ffb347;
  --accent-2: #ffd27a;
  --accent-rgb: 255, 179, 71;
  --bg: #05080c;
  --panel: rgba(8, 13, 19, .88);
  --panel-2: rgba(14, 20, 28, .9);
  --line: #26333f;
  --line-soft: rgba(255, 255, 255, .07);
  --text: #cfd8e3;
  --muted: #7d8b9a;
  --red: #ff6b5a;
  --green: #6fdc8c;
  --blue: #72d8ff;
  --radius: 7px;
}
body.theme-realistic {
  --accent: #7fdcff;
  --accent-2: #c3f2ff;
  --accent-rgb: 127, 220, 255;
  --panel: rgba(7, 12, 17, .78);
  --panel-2: rgba(13, 20, 27, .86);
  --line: #243746;
  --line-soft: rgba(160, 220, 255, .09);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  -webkit-font-smoothing: antialiased;
}
#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}
#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
#fx::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%, transparent 38%, rgba(0, 0, 0, .58) 100%);
}
body.theme-realistic #fx::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .045;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, .55) 0,
    rgba(255, 255, 255, .55) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

#ui { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.hud { position: fixed; pointer-events: none; }
.panel {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .55);
  backdrop-filter: blur(7px);
}
body.theme-realistic .panel {
  box-shadow: 0 18px 60px rgba(0, 0, 0, .65), inset 0 0 0 1px rgba(160, 220, 255, .035);
}
.panel-title {
  font-size: 10px;
  letter-spacing: .16em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 8px;
  text-transform: uppercase;
}

#topbar {
  top: 16px;
  left: 16px;
  padding: 13px 16px;
  min-width: 300px;
}
#topbar .brand {
  font-size: 15px;
  letter-spacing: .16em;
  color: var(--accent);
  font-weight: 800;
}
#topbar .sub {
  color: var(--muted);
  font-size: 9px;
  margin-top: 4px;
  letter-spacing: .12em;
}
#topbar .sub b { color: var(--text); font-weight: 600; }
#turnLine { margin-top: 9px; font-size: 13px; }
#turnLine b { color: var(--accent-2); }
#conn { font-size: 10px; color: var(--muted); margin-top: 4px; letter-spacing: .05em; }
#conn.online { color: var(--green); }
#conn.offline { color: var(--red); }

#right {
  top: 16px;
  right: 16px;
  width: 370px;
  height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow: hidden;
}
#right > * { pointer-events: auto; flex: 0 0 auto; }

#unitPanel { padding: 12px 14px; }
#unitPanel { flex: 0 0 auto; }
.unit-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.unit-head b { font-size: 14px; color: #eef4fa; letter-spacing: .03em; }
.unit-head .muted { font-size: 10px; color: var(--muted); margin-top: 2px; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  font-size: 9px;
  letter-spacing: .08em;
  color: var(--accent-2);
  border: 1px solid rgba(var(--accent-rgb), .32);
  background: rgba(var(--accent-rgb), .08);
  padding: 3px 6px;
  border-radius: 3px;
  white-space: nowrap;
}
.statrow {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  color: var(--muted);
  margin-top: 8px;
  letter-spacing: .04em;
}
.statrow span:last-child { color: #e8eef6; }
.bar {
  height: 5px;
  background: #151d26;
  border-radius: 3px;
  overflow: hidden;
  margin: 3px 0 2px;
}
.bar > i { display: block; height: 100%; border-radius: 3px; }
.bar.hp > i { background: linear-gradient(90deg, #2f8a53, #7fe29b); }
.bar.tu > i { background: linear-gradient(90deg, #2d5f9a, #7fc4ff); }
.bar.wt > i { background: linear-gradient(90deg, #8a6b2f, #ffcf7a); }
.slots { display: grid; gap: 6px; margin-top: 9px; }
.slot {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .018);
  border-radius: 5px;
  padding: 5px 7px;
  min-height: 48px;
}
.slot .slot-label { font-size: 8px; color: var(--muted); letter-spacing: .14em; }
.slot b { display: block; font-size: 11px; color: #e9f0f8; font-weight: 600; }
.slot small { display: block; font-size: 9px; color: var(--muted); margin-top: 2px; }
.slot img { width: 38px; height: 38px; object-fit: contain; }

#invPanel { padding: 12px 12px 10px; min-height: 110px; flex: 1 1 auto; display: flex; flex-direction: column; overflow: hidden; }
.inv-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.inv-head .panel-title { margin: 0; }
#giveTarget {
  font: inherit;
  font-size: 9px;
  color: var(--text);
  background: #0e151d;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 3px 5px;
  max-width: 120px;
}
.inventory { margin-top: 9px; display: flex; flex-direction: column; gap: 5px; flex: 1 1 auto; min-height: 0; overflow: auto; padding-right: 2px; }
.inventory::-webkit-scrollbar { width: 5px; }
.inventory::-webkit-scrollbar-thumb { background: #2b3946; border-radius: 3px; }
.item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 5px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: rgba(255, 255, 255, .014);
}
.item.is-equipped { border-color: rgba(var(--accent-rgb), .35); background: rgba(var(--accent-rgb), .055); }
.item img { width: 36px; height: 36px; object-fit: contain; opacity: .95; }
.item b { display: block; font-size: 10.5px; color: #e9f0f8; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item small { display: block; font-size: 8.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-actions { display: flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; max-width: 132px; }

button {
  pointer-events: auto;
  font: inherit;
  font-size: 9.5px;
  letter-spacing: .08em;
  font-weight: 700;
  color: #070b10;
  background: var(--accent);
  border: 0;
  border-radius: 3px;
  padding: 5px 8px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: var(--accent-2); }
button:disabled { opacity: .34; cursor: default; }
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
button.ghost:hover { border-color: var(--accent); color: var(--accent); background: transparent; }
button.active { background: var(--accent); color: #070b10; }
button.tiny { font-size: 8.5px; padding: 4px 6px; }

#logPanel { padding: 10px 12px; flex: 0 1 18vh; min-height: 90px; display: flex; flex-direction: column; overflow: hidden; }
#log { overflow: auto; font-size: 10px; line-height: 1.45; flex: 1; }
#log .m { color: var(--muted); border-bottom: 1px solid rgba(255, 255, 255, .035); padding: 3px 0; }
#log .m:last-child { border-bottom: 0; }
#log .hit { color: var(--accent-2); }
#log .bad { color: var(--red); }
#log .good { color: var(--green); }
#log .sys { color: var(--blue); }

#bottom {
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 9px;
}
#bottom button { padding: 9px 13px; }
#bottom button span { opacity: .55; font-weight: 400; }

#hint {
  position: fixed;
  bottom: 17px;
  left: 16px;
  font-size: 9px;
  line-height: 1.9;
  color: #5c6a79;
  pointer-events: none;
  letter-spacing: .04em;
  max-width: 360px;
}
#hint b { color: #8997a6; font-weight: 600; }

#toast {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%) scale(.96);
  opacity: 0;
  font-size: 25px;
  letter-spacing: .3em;
  color: var(--accent);
  text-shadow: 0 0 32px rgba(var(--accent-rgb), .4);
  transition: opacity .22s, transform .22s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 4;
}
#toast.show { opacity: 1; transform: translateX(-50%) scale(1); }

#banner {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  background: rgba(3, 6, 9, .66);
  pointer-events: auto;
  z-index: 5;
  backdrop-filter: blur(2px);
}
#banner.show { display: flex; }
#banner h2 { margin: 0; font-size: 44px; letter-spacing: .2em; color: var(--accent); text-shadow: 0 0 50px rgba(var(--accent-rgb), .35); }
#banner p { margin: 0; color: var(--muted); font-size: 12px; letter-spacing: .08em; }
#banner button { margin-top: 8px; padding: 11px 18px; }

#cursorTip {
  position: fixed;
  z-index: 6;
  pointer-events: none;
  padding: 4px 7px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: rgba(5, 9, 13, .9);
  color: #dce7f2;
  font-size: 9px;
  letter-spacing: .04em;
  opacity: 0;
  transform: translate(12px, 12px);
  white-space: nowrap;
  max-width: 260px;
}
#cursorTip.show { opacity: 1; }
#cursorTip b { color: var(--accent-2); font-weight: 600; }

.hidden { display: none !important; }

@media (max-width: 980px) {
  #right { width: 310px; }
  #hint { display: none; }
}
@media (max-width: 720px) {
  #right { width: calc(100vw - 24px); right: 12px; top: 12px; height: 52vh; }
  #topbar { top: 12px; left: 12px; min-width: 0; }
  #bottom { bottom: 12px; }
}
