:root {
  color-scheme: dark;
  --bg: #0a0c10;
  --panel: #12161f;
  --panel2: #0e1219;
  --line: #243044;
  --text: #e8eef8;
  --muted: #8b9bb4;
  --accent: #6ea8ff;
  --gold: #d4af37;
  --good: #5ddea0;
  --warn: #ffb454;
  --danger: #ff6b7a;
  --radius: 10px;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
#app { display: flex; flex-direction: column; height: 100%; }
.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #141a26, #0f131b);
}
.brand { display: flex; gap: 10px; align-items: center; min-width: 220px; }
.brand .logo { font-size: 22px; }
.brand h1 { margin: 0; font-size: 15px; letter-spacing: 0.04em; }
.brand p { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tabs button, .top-actions button, .btn, button.chip, .side button.item {
  border: 1px solid var(--line); background: #151b28; color: var(--text);
  border-radius: 8px; padding: 8px 12px; cursor: pointer; font-size: 12px;
}
.tabs button.active { background: #1e3358; border-color: #3d6db5; color: #cfe0ff; }
.tabs button:hover, .btn:hover, .top-actions button:hover { filter: brightness(1.08); }
.top-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.auth-bar .auth-status { font-size: 11px; color: var(--muted); max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-bar .char-select {
  max-width: 180px; background: #0c1018; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 11px;
}
.auth-bar .btn-link {
  display: inline-flex; align-items: center; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--line); color: var(--gold); text-decoration: none; font-size: 12px;
  background: #151b28;
}
.auth-bar .btn-link:hover { filter: brightness(1.08); }
button.primary { background: linear-gradient(180deg, #2f4f8a, #1d3258); border-color: #4a74c0; font-weight: 600; }
button.ghost { background: transparent; }
button.danger { border-color: #6a3040; color: #ffb0ba; }
.body { display: grid; grid-template-columns: 300px 1fr 320px; flex: 1; min-height: 0; }
.side, .inspector {
  background: var(--panel); border-right: 1px solid var(--line);
  overflow: auto; padding: 10px; min-height: 0;
}
.inspector { border-right: 0; border-left: 1px solid var(--line); }
.stage-wrap { position: relative; min-width: 0; background: #080a0e; }
#stage, #stage canvas { width: 100%; height: 100%; display: block; }
.stage-hud {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--muted);
  pointer-events: none;
}
.stage-hud b { color: var(--good); }
.toast {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: #1a2436; border: 1px solid var(--accent); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-size: 12px; z-index: 5;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.section-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--gold); margin: 12px 0 8px; font-weight: 700;
}
.section-title:first-child { margin-top: 0; }
input, select, textarea {
  width: 100%; background: #0c1018; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px;
}
textarea { min-height: 90px; font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 11px; }
label.field { display: grid; gap: 4px; margin-bottom: 8px; font-size: 11px; color: var(--muted); }
label.field span.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
label.field input[type="range"] { padding: 0; }
label.field input[type="color"] { height: 32px; padding: 2px; }
.item {
  display: block; width: 100%; text-align: left; margin-bottom: 4px;
  padding: 8px 10px !important;
}
.item.active { border-color: #3d6db5; background: #182840; }
.item small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.tag {
  display: inline-block; font-size: 9px; padding: 1px 6px; border-radius: 999px;
  background: #1a2436; color: var(--accent); margin-right: 4px;
}
.tag.fire { color: #ff9a5c; }
.tag.hit { color: #ff6b7a; }
.tag.magic { color: #b388ff; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.actions .btn, .actions button { flex: 1 1 auto; min-width: 90px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.muted { color: var(--muted); font-size: 11px; line-height: 1.4; }
.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; background: var(--panel2); margin-bottom: 8px;
}
.card h3 { margin: 0 0 4px; font-size: 13px; }
.card .meta { font-size: 10px; color: var(--muted); }
.skill-row {
  display: grid; grid-template-columns: 40px 1fr; gap: 8px; align-items: start;
  padding: 8px; border: 1px solid transparent; border-radius: 8px; cursor: pointer;
}
.skill-row:hover { background: #182033; }
.skill-row.active { border-color: #3d6db5; background: #182840; }
.skill-row img { width: 36px; height: 36px; object-fit: contain; image-rendering: pixelated; background: #0c1018; border-radius: 6px; }
.prefab-slot {
  border: 1px dashed #3a4a66; border-radius: 8px; padding: 8px; margin-bottom: 6px;
  background: #0c1018;
}
.prefab-slot.filled { border-style: solid; border-color: #3d6db5; }
.prefab-slot label { font-size: 10px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.06em; display: block; margin-bottom: 4px; }
.prefab-slot .val { font-size: 12px; word-break: break-all; }
.prefab-slot .empty { color: var(--muted); font-size: 11px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 999px; font-size: 10px; background: #1a2436; color: var(--muted);
}
.pill.ok { color: var(--good); }
code, .mono { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 11px; }
.filters { display: grid; gap: 6px; margin-bottom: 8px; }
@media (max-width: 1100px) {
  .body { grid-template-columns: 260px 1fr; }
  .inspector { display: none; }
  .inspector.force-show { display: block; position: absolute; right: 0; top: 0; bottom: 0; width: min(320px, 90vw); z-index: 4; }
}
@media (max-width: 760px) {
  .body { grid-template-columns: 1fr; }
  .side { max-height: 35vh; border-right: 0; border-bottom: 1px solid var(--line); }
}
