:root {
  --accent: #ff4d55;
  --bg: #120f0f;
  --card: #161414;
  --line: #221e1e;
  --line2: #2a2525;
  --text: #efeceb;
  --text2: #c9c2c2;
  --muted: #8a8282;
  --good: #50ff78;
  --accent-bg: #2a1517;
  --accent-line: #5a2328;
  --accent-text: #ffd9db;
  --field: #120f0f;
  --r: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: "League Spartan", system-ui, sans-serif; font-size: 15px; line-height: 1.25;
  display: flex; flex-direction: column; min-height: 100%;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
  background: rgba(18, 15, 15, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .14em; display: flex; align-items: center; gap: 9px; font-size: 16px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.top-right { display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 13px; }
.pill {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: #1f1b1b; color: var(--muted); border: 1px solid var(--line2);
}
.pill.live { color: var(--good); border-color: #1f4a2a; background: #121f15; }
.pill.wait { color: #ffcc66; border-color: #4a3d1f; background: #1f1a12; }
.ghost { background: none; border: 1px solid var(--line2); border-radius: 8px; padding: 4px 10px; color: var(--muted); cursor: pointer; font-size: 12px; }
.ghost:hover { color: var(--text); }

.screen { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.panel {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 26px;
}
.panel.center { text-align: center; }
.panel h1 { margin: 0 0 6px; font-size: 22px; font-weight: 600; }
.muted { color: var(--muted); margin: 0 0 18px; }
.error { color: var(--accent); min-height: 1.3em; margin: 14px 0 0; font-size: 14px; }
#pair-form { display: flex; gap: 10px; }
#pair-code {
  flex: 1; min-width: 0; background: var(--field); border: 1px solid var(--line2); border-radius: 10px;
  padding: 12px 14px; font-size: 22px; letter-spacing: .35em; text-align: center; font-weight: 600; outline: none;
}
#pair-code:focus { border-color: var(--accent); }
.spinner {
  width: 34px; height: 34px; margin: 4px auto 18px; border-radius: 50%;
  border: 3px solid var(--line2); border-top-color: var(--accent); animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- menu ---- */
.menu { flex: 1; display: flex; min-height: 0; }
.tabs {
  width: 200px; flex-shrink: 0; padding: 18px 12px; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; position: sticky; top: 53px; align-self: flex-start;
}
.tab {
  text-align: left; background: none; border: 1px solid transparent; border-radius: 10px;
  padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 15px;
  display: flex; align-items: center; gap: 10px;
}
.tab::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #3a3333; }
.tab:hover { color: var(--text); }
.tab.on { background: var(--accent-bg); border-color: var(--accent-line); color: #fff; }
.tab.on::before { background: var(--accent); }
.page-wrap { flex: 1; min-width: 0; padding: 18px 20px 40px; }
.subs, .weapons { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.subs:empty, .weapons:empty { display: none; }

.seg { display: flex; gap: 6px; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 4px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto; background: none; border: 1px solid transparent; border-radius: 9px; padding: 8px 14px;
  color: var(--muted); font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
}
.seg button::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #3a3333; }
.seg button:hover { color: #fff; }
.seg button.on { background: var(--accent-bg); border-color: var(--accent-line); color: #fff; }
.seg button.on::before { background: var(--accent); }
.subs .seg, .weapons .seg { width: 100%; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 20px 16px; min-width: 0; }
.card.full { grid-column: 1 / -1; }
.card h3 { margin: 4px 0 10px; font-size: 15px; font-weight: 600; }
.card h4 { margin: 14px 0 6px; font-size: 14px; font-weight: 600; color: var(--text2); }
.card p.text { margin: 6px 0; color: var(--muted); font-size: 13px; word-break: break-word; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; padding: 3px 0; }
.row .label { flex: 1; min-width: 0; font-size: 14px; }

.switch { width: 38px; height: 22px; border-radius: 999px; background: #2a2525; border: none; position: relative; cursor: pointer; flex-shrink: 0; padding: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(16px); }

.slider { padding: 4px 0 6px; }
.slider .head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 14px; }
.slider .val { font-weight: 700; font-size: 12px; background: var(--field); border-radius: 6px; padding: 4px 8px; min-width: 44px; text-align: center; }
input[type=range] { width: 100%; -webkit-appearance: none; appearance: none; background: transparent; height: 22px; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p, 0%), #262222 var(--p, 0%)); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: #262222; }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: var(--accent); border: 3px solid #0e0d0d; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid #0e0d0d; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 0; }
.chip {
  border-radius: 999px; border: 1px solid var(--line2); background: none; padding: 7px 14px 7px 12px;
  color: var(--muted); font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 8px;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3a3333; }
.chip.on { background: var(--accent-bg); border-color: var(--accent-line); color: var(--accent-text); }
.chip.on::before { background: var(--accent); }

.key { display: flex; gap: 6px; align-items: center; }
.key .badge {
  min-width: 70px; padding: 6px 10px; border-radius: 7px; background: #1f1b1b; border: 1px solid #332d2d;
  font-weight: 700; font-size: 11px; letter-spacing: .04em; cursor: pointer; color: var(--text);
}
.key .badge.none { color: #6f6868; }
.key .badge.cap { border-color: var(--accent); color: var(--accent); }
.key .clear { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 2px 4px; }

.btns { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.btn {
  flex: 1 1 120px; padding: 10px 14px; border-radius: 10px; border: 1px solid #241f1f; background: var(--card);
  color: var(--text2); font-weight: 600; cursor: pointer;
}
.btn:hover { background: #1c1919; }
.btn.primary, button.primary { background: var(--accent-bg); border: 1px solid var(--accent-line); color: var(--accent-text); border-radius: 10px; padding: 10px 18px; font-weight: 600; cursor: pointer; }
.btn.primary:hover, button.primary:hover { background: #3a1b1e; }

.field input[type=text] {
  width: 55%; max-width: 280px; background: var(--field); border: 1px solid #241f1f; border-radius: 10px;
  padding: 9px 12px; font-size: 13px; outline: none;
}
.field input[type=text]:focus { border-color: var(--accent); }
input[type=color] { width: 40px; height: 26px; border: 1px solid var(--line2); border-radius: 7px; background: none; padding: 0; cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 5px; }

.loading { grid-column: 1 / -1; color: var(--muted); text-align: center; padding: 60px 0; }

@media (max-width: 860px) {
  .menu { flex-direction: column; }
  .tabs {
    width: auto; flex-direction: row; overflow-x: auto; padding: 10px 12px; border-right: none;
    border-bottom: 1px solid var(--line); position: sticky; top: 49px; z-index: 9; background: var(--bg); scrollbar-width: none;
    align-self: stretch; min-width: 0;
  }
  .menu, .page-wrap { min-width: 0; max-width: 100vw; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; padding: 8px 12px; }
  .page-wrap { padding: 14px 12px 40px; }
  .grid { grid-template-columns: 1fr; }
  .subs .seg, .weapons .seg { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .who { display: none; }
  .card { padding: 12px 16px 14px; }
  .field input[type=text] { width: 60%; }
}
