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

:root {
  --bg: #0a0a0c;
  --panel: #121216;
  --panel-2: #17171d;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f2f2f5;
  --text-dim: #8b8b96;
  --white: #ffffff;
  --ok: #3ddc84;
  --bad: #ff5c5c;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 0%, rgba(255, 255, 255, 0.05), transparent),
    radial-gradient(ellipse 50% 40% at 85% 100%, rgba(255, 255, 255, 0.04), transparent);
  pointer-events: none;
}

.shell {
  width: min(720px, 94vw);
  height: min(860px, 92vh);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

/* ── top bar ─────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-mark {
  font-size: 18px;
  color: var(--white);
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--white);
}

.brand-sub {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.status {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
}

.count {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.conn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 10px;
}

.conn .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.3s, box-shadow 0.3s;
}

.conn.on {
  color: var(--text);
  border-color: var(--line-strong);
}

.conn.on .dot {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}

.conn.off .dot {
  background: var(--bad);
  box-shadow: 0 0 8px var(--bad);
}

/* ── feed ────────────────────────────── */

.feed {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.feed::-webkit-scrollbar {
  width: 6px;
}

.feed::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}

.msg {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  animation: rise 0.18s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg .meta {
  display: block;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
  opacity: 0.55;
}

.msg.them {
  align-self: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.msg.me {
  align-self: flex-end;
  background: var(--white);
  color: #0a0a0c;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 24px rgba(255, 255, 255, 0.12);
}

.msg.sys {
  align-self: center;
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
}

/* ── control board ───────────────────── */

.board {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.board.dead {
  opacity: 0.35;
  pointer-events: none;
}

.b-hint {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
  padding: 2px 0 4px;
}

.hidden { display: none !important; }

.game-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 11px;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.game-strip.live {
  color: var(--ok);
  border-color: rgba(61, 220, 132, 0.25);
}

.game-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}

.game-strip.live .game-dot {
  background: #2ce08a;
  box-shadow: 0 0 6px #2ce08a;
}

.b-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.b-label {
  width: 62px;
  flex-shrink: 0;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.b-select {
  flex: 1;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.4px;
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.b-select:focus { outline: none; border-color: var(--line-strong); }
.b-select option { background: var(--panel); }

.b-btn {
  flex: 1;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.1s;
}

.b-btn:hover {
  border-color: var(--line-strong);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.1);
}

.b-btn:active {
  transform: scale(0.96);
}

.b-btn.accent {
  background: var(--white);
  color: #0a0a0c;
  border-color: var(--white);
}

.b-btn.danger {
  color: var(--bad);
}

.seg {
  flex: 1;
  display: flex;
  gap: 8px;
}

.seg .b-btn.active {
  background: var(--white);
  color: #0a0a0c;
  border-color: var(--white);
}

.g-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  color: var(--white);
  font-size: 13px;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  outline: none;
  text-align: center;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.g-input.mono {
  text-transform: lowercase;
  letter-spacing: 4px;
}

.g-input::placeholder {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.g-input:focus {
  border-color: var(--white);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

/* ── pin gate ─────────────────────────── */

.gate {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 12, 0.88);
  backdrop-filter: blur(6px);
  z-index: 10;
}

.gate.hidden {
  display: none;
}

.gate-card {
  width: min(320px, 86%);
  padding: 34px 28px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.gate-mark {
  font-size: 26px;
  color: var(--white);
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
  margin-bottom: 8px;
}

.gate-title {
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.gate-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#pin-input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  color: var(--white);
  font-size: 22px;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  letter-spacing: 10px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#pin-input:focus {
  border-color: var(--white);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.gate-card form button {
  background: var(--white);
  color: #0a0a0c;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.12s;
}

.gate-card form button:hover {
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.22);
}

.gate-card form button:active {
  transform: scale(0.97);
}

.pin-err {
  margin-top: 12px;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--bad);
  min-height: 14px;
}

/* ── sliders ─────────────────────────── */

.mb-row {
  gap: 10px;
}

.b-range {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--panel-2);
  outline: none;
  cursor: pointer;
  border: 1px solid var(--line);
}

.b-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--white);
  border: none;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
}

.b-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--white);
  border: none;
}

.b-val {
  width: 44px;
  flex-shrink: 0;
  font-size: 10px;
  font-family: ui-monospace, monospace;
  color: var(--text-dim);
  text-align: right;
}

/* ── esp view ────────────────────────── */

.esp-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #050507;
  overflow: hidden;
  line-height: 0;
  position: relative;
}

.esp-wrap.full {
  position: fixed;
  inset: 0;
  z-index: 30;
  border: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050507;
}

#esp-canvas {
  display: block;
  max-width: 100%;
}

.esp-exit {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 31;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(18, 18, 22, 0.8);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  display: none;
}

.esp-wrap.full .esp-exit {
  display: block;
}

.esp-exit:hover {
  color: var(--white);
  border-color: var(--white);
}
