* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #16181d;
  --panel: #1e2229;
  --panel-2: #262b34;
  --line: #333a45;
  --text: #d8dde5;
  --muted: #8b95a3;
  --accent: #c99a4a;
  --accent-dim: #7a6636;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- sidebar ---------- */
#sidebar {
  width: 20rem;
  min-width: 16rem;
  max-width: 24rem;
  height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

#brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #232833, var(--panel));
}
.brand-mark {
  font-size: 1.8rem;
  color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(201,154,74,0.35));
}
#brand h1 {
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: #f0e6d2;
}
#brand p {
  font-size: 0.72rem;
  color: var(--muted);
}

#catalog {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.9rem 2rem;
}
#catalog::-webkit-scrollbar { width: 9px; }
#catalog::-webkit-scrollbar-thumb { background: #333a45; border-radius: 5px; }

.cat { margin-bottom: 1.1rem; }
.cat h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent);
  margin-bottom: 0.45rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--line);
}
.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.gear-btn {
  font-size: 0.78rem;
  padding: 0.5rem 0.4rem;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  text-align: center;
  line-height: 1.15;
}
.gear-btn:hover { background: #303743; border-color: #454e5b; }
.gear-btn:active { transform: translateY(1px); }
.gear-btn.active {
  background: linear-gradient(180deg, var(--accent), var(--accent-dim));
  border-color: var(--accent);
  color: #1a140a;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(201,154,74,0.3);
}

/* ---------- stage ---------- */
#stage {
  flex: 1;
  position: relative;
  height: 100vh;
  overflow: hidden;
}
#viewport {
  position: absolute;
  inset: 0;
  cursor: grab;
}
#viewport:active { cursor: grabbing; }
#viewport canvas { display: block; width: 100%; height: 100%; }

#loadout {
  position: absolute;
  top: 1rem;
  left: 1rem;
  width: 12.5rem;
  padding: 0.7rem 0.85rem 0.8rem;
  background: rgba(24,27,33,0.82);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  backdrop-filter: blur(6px);
}
#loadout h4 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}
.lo-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 0.32rem;
}
.lo-row strong { color: var(--text); font-size: 0.9rem; }
#lo-weight { color: #f0e6d2; }
.lo-tag {
  padding: 0.05rem 0.4rem;
  border-radius: 0.35rem;
  font-size: 0.72rem !important;
  font-weight: 600;
}
.lo-tag.light  { background: #244a30; color: #a8e0b6; }
.lo-tag.medium { background: #4a4322; color: #e6d69a; }
.lo-tag.heavy  { background: #4a2a22; color: #e6a99a; }
.lo-bar {
  margin-top: 0.5rem;
  height: 0.45rem;
  background: var(--panel-2);
  border-radius: 0.3rem;
  overflow: hidden;
}
#lo-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width 0.25s ease;
}

#controls {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  background: rgba(24,27,33,0.82);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  backdrop-filter: blur(6px);
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100% - 2rem);
}
.ctl {
  font-size: 0.8rem;
  padding: 0.4rem 0.7rem;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ctl:hover { background: #303743; }
.ctl.on {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #f0e6d2;
}
.hint {
  font-size: 0.72rem;
  color: var(--muted);
  padding-left: 0.3rem;
}

@media (max-width: 620px) {
  body { flex-direction: column; }
  #sidebar {
    width: 100%;
    max-width: none;
    height: 42vh;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  #stage { height: 58vh; }
  .hint { display: none; }
}
