:root {
  --bg: #080d18;
  --surface: #11192b;
  --surface-2: #17223a;
  --border: rgba(148, 163, 184, 0.18);
  --gold: #eab308;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --green: #22c55e;
  --red: #ef4444;
}

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

body {
  background: radial-gradient(circle at top right, #16223d 0%, var(--bg) 52%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
}

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 20px 44px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 15px;
  font-weight: 700;
  color: #fde68a;
}

.subtitle {
  font-size: 13px;
  color: var(--muted);
}

.status-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.pill-muted {
  background: var(--surface);
  color: var(--muted);
}

.pill-online {
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.45);
  color: #4ade80;
}

.pill-warn {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fcd34d;
}

.banner-alert {
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.48);
  color: #fde68a;
}

.readonly-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.readonly-wrap input[type="text"] {
  max-width: 340px;
}

.room-bar {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.room-bar-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 360px;
}

.room-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  filter: none;
}

.banner-info {
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #e0f2fe;
}

.switch-notice {
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.42);
  color: #e0f2fe;
  font-size: 12.5px;
  line-height: 1.4;
}

.banner-steps {
  margin-top: 8px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #cbd5e1;
}

.hidden {
  display: none !important;
}

.grid-main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
}

.card-wide {
  grid-column: 1 / -1;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.compact-top {
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: #0b1120;
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
}

.select-sm {
  width: auto;
  padding: 5px 8px;
  font-size: 12px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #cbd5e1;
  cursor: pointer;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(15, 23, 42, 0.9);
  padding: 2px 6px;
  border-radius: 5px;
  color: #fde68a;
  font-size: 12px;
}

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

.wrap {
  flex-wrap: wrap;
}

.align-end {
  align-self: end;
}

.btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.15s ease, background 0.15s ease;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-primary {
  background: linear-gradient(135deg, #eab308, #ca8a04);
  color: #0b101b;
  border-color: rgba(253, 224, 71, 0.5);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}

.btn-win {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.5);
  color: #86efac;
}

.btn-loss {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.btn-danger-outline {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.status-text {
  font-size: 12px;
  color: #4ade80;
}

.daily-summary-grid,
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  background: #0b1120;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 10px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.metric-val {
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.metric-val.small {
  font-size: 13px;
  font-weight: 600;
}

.accent-gold {
  color: #fde047;
}

.hash-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.pending-tag {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.sim-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.sim-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.obs-controls {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.slider-field {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 10px;
  padding: 8px 11px;
}

.slider-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.slider-readout {
  font-size: 12px;
  font-weight: 800;
  color: #fde047;
  font-variant-numeric: tabular-nums;
}

.slider-field input[type="range"] {
  width: 100%;
  accent-color: #eab308;
  cursor: pointer;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: transparent;
}

.reset-field {
  align-self: end;
}

.url-copy-bar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.preview-bg-switch {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.preview-bg-switch .btn.is-active,
.preview-stage-switch .btn.is-active {
  background: rgba(234, 179, 8, 0.22);
  border-color: rgba(250, 204, 21, 0.65);
  color: #fef08a;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.preview-stage-switch {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.toolbar-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-right: 2px;
}

.preview-meta-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.inline-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.inline-select select {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.preview-mode-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(74, 222, 128, 0.4);
  color: #86efac;
}

.preview-mode-tag.is-preview {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.45);
  color: #bae6fd;
}

/* 16:9 Scaled In-Game Preview Stage (Virtual 1920x1080 OBS Canvas) */
.preview-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 360px;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.preview-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
}

.game-hud-backdrop {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse 65% 50% at 22% 28%, rgba(56, 189, 248, 0.24), transparent 65%),
    radial-gradient(ellipse 60% 50% at 78% 28%, rgba(244, 63, 94, 0.22), transparent 65%),
    radial-gradient(ellipse 90% 60% at 50% 85%, rgba(22, 78, 56, 0.35), transparent 70%),
    linear-gradient(180deg, #0b1629 0%, #152538 42%, #1d2d2a 72%, #131c24 100%);
}

.bg-game .game-hud-backdrop {
  display: block;
}

.game-lane-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: linear-gradient(180deg, transparent 20%, rgba(0, 0, 0, 0.7) 100%);
}

.game-hud-top {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 26px;
  border-radius: 0 0 14px 14px;
  background: rgba(7, 11, 20, 0.72);
  border: 1px solid rgba(234, 179, 8, 0.28);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.hud-order {
  color: #7dd3fc;
}

.hud-clock {
  color: #fde68a;
  font-variant-numeric: tabular-nums;
}

.hud-chaos {
  color: #fda4af;
}

.game-hud-bottom {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-radius: 14px;
  background: rgba(7, 11, 20, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.hud-bars {
  width: 440px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-hp,
.hud-mp {
  height: 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  overflow: hidden;
}

.hud-hp span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #16a34a, #4ade80);
}

.hud-mp span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #0284c7, #38bdf8);
}

.hud-abilities {
  display: flex;
  gap: 10px;
}

.hud-abilities span {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: #94a3b8;
  background: rgba(30, 41, 59, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.hud-abilities .hud-relic {
  border-color: rgba(234, 179, 8, 0.45);
  color: #fde68a;
}

.game-hud-minimap {
  position: absolute;
  right: 28px;
  bottom: 24px;
  width: 240px;
  height: 240px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 25% 75%, rgba(56, 189, 248, 0.25), transparent 45%),
    radial-gradient(circle at 75% 25%, rgba(244, 63, 94, 0.25), transparent 45%),
    rgba(7, 11, 20, 0.72);
  border: 2px solid rgba(234, 179, 8, 0.32);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10px;
}

.minimap-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: rgba(148, 163, 184, 0.7);
}

.preview-overlay-slot {
  position: absolute;
  inset: 0;
  display: flex;
  padding: 20px;
}

.preview-overlay-slot.pos-top-left {
  align-items: flex-start;
  justify-content: flex-start;
}

.preview-overlay-slot.pos-top-center {
  align-items: flex-start;
  justify-content: center;
  padding-top: 76px;
}

.preview-overlay-slot.pos-bottom-left {
  align-items: flex-end;
  justify-content: flex-start;
}

.preview-overlay-slot iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}

.bg-dark {
  background: #070b14;
}

.bg-checker {
  background-color: #141b2d;
  background-image:
    linear-gradient(45deg, #1b243b 25%, transparent 25%),
    linear-gradient(-45deg, #1b243b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1b243b 75%),
    linear-gradient(-45deg, transparent 75%, #1b243b 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.bg-game {
  background: #0b1629;
}

.details-summary {
  cursor: pointer;
  font-weight: 700;
  color: #fde68a;
  font-size: 14px;
}

.calibrator-body {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.selectors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.calibrator-test {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.code-output {
  background: #070b14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  color: #cbd5e1;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
}

@media (max-width: 980px) {
  .obs-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .form-row,
  .obs-controls,
  .url-copy-bar,
  .compact-top {
    grid-template-columns: 1fr;
  }
}
