/*
 * Console styles.
 *
 *   Tokens / Qonzer theme      :root
 *   Login page                 Connect
 *   Buttons / shell / tables   later in this file (search the ---------- headings)
 *   Scoreboard / cash          Scores / status, Cash
 */

.hidden,
[hidden] {
  display: none !important;
}

:root {
  --bg: #0b0f19;
  --surface: #12182a;
  --surface-2: #182238;
  --primary: #3b82f6;
  --primary-ink: #061018;
  --secondary: #6b7c99;
  --accent: #2563eb;
  --fg: #e8eef8;
  --muted: #8b9bb4;
  --line: color-mix(in srgb, var(--secondary) 30%, transparent);
  --valkyra: #e05a5a;
  --lonestar: #5b9bd5;
  --manticore: #5cb87a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
  --radius: 10px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Mono", ui-monospace, monospace;
}

[data-brand="qonzer"] {
  --bg: #0b0f19;
  --surface: #12182a;
  --surface-2: #182238;
  --primary: #3b82f6;
  --primary-ink: #061018;
  --secondary: #6b7c99;
  --accent: #2563eb;
  --fg: #e8eef8;
  --muted: #8b9bb4;
  --line: color-mix(in srgb, var(--secondary) 30%, transparent);
}

[data-brand="qonzer"].plus-grid::before,
[data-brand="qonzer"] .plus-grid::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='12' cy='12' r='1.2' fill='%233b82f6' fill-opacity='0.22'/%3E%3C/svg%3E");
}

[data-brand="qonzer"] .mark {
  display: none;
}

[data-brand="qonzer"] .brand-icon {
  display: block;
}

[data-brand="qonzer"] .brand {
  align-items: flex-start;
  gap: 8px;
}

[data-brand="qonzer"] .brand h1 {
  font-size: 30px;
  letter-spacing: -0.03em;
  text-transform: none;
  font-weight: 700;
  line-height: 1;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  scroll-padding-top: 72px;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--primary);
}

.plus-grid {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
}

.plus-grid::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='12' cy='12' r='1.2' fill='%233b82f6' fill-opacity='0.22'/%3E%3C/svg%3E");
}

/* ---------- Connect ---------- */

.connect-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 32px 16px 40px;
}

.connect-card {
  width: min(440px, 100%);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 26px 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.mark {
  width: 40px;
  height: 40px;
  border: 1px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-icon {
  display: none;
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.03em;
  text-transform: none;
  font-weight: 700;
  line-height: 1;
}

.brand-sub {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.gold-pill {
  display: inline-block;
  margin: 10px 0 22px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 8px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.field label,
.lbl {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input:not([type="checkbox"]):not([type="range"]),
.field select,
.field textarea,
.ctrl {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

.field input:not([type="checkbox"]):not([type="range"]):focus,
.field select:focus,
.field textarea:focus,
.ctrl:focus {
  border-color: var(--primary);
}

.row-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.login-mode {
  margin: 0 0 18px;
}

.pass-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.pass-row .ctrl {
  flex: 1;
  min-width: 0;
}

.pass-row .btn {
  flex-shrink: 0;
}

.server-grant {
  display: grid;
  gap: 6px;
  margin-top: 6px;
  justify-items: stretch;
}

.table-wrap .server-grant {
  margin-top: 0;
}

.server-grant .row-check {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  margin: 0;
  width: 100%;
  color: var(--fg);
  font-size: 13px;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}

.server-grant .row-check .tick,
.server-grant .row-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  max-width: 16px;
  min-width: 16px;
  justify-self: center;
  border-radius: 3px;
}

.server-grant .row-check span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

#user-create .server-grant {
  max-width: 360px;
}

#users-body td:nth-child(4) {
  white-space: normal;
  vertical-align: top;
  min-width: 180px;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--fg);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  border-color: color-mix(in srgb, var(--primary) 50%, var(--line));
}

.btn-gold {
  width: 100%;
  border-color: var(--primary);
  background: transparent;
  color: var(--primary);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 12px;
}

.btn-gold:hover {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
  font-weight: 700;
}

.btn-danger {
  border-color: var(--accent);
  color: #f3c0bb;
}

.btn-ghost {
  background: transparent;
}

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

.icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 6px;
}

/* ---------- App shell ---------- */

.app {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  z-index: 20;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.topbar .brand {
  margin: 0;
}

.topbar .brand h1 {
  font-size: 18px;
}

.topbar .brand-icon {
  width: 30px;
  height: 30px;
}

[data-brand="qonzer"] .topbar .brand h1 {
  font-size: 18px;
}

.server-tabs {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow: auto;
  align-items: center;
}

.server-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  max-width: 7.5rem;
}

.server-tab > span:not(.status-dot) {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.server-tab .status-dot {
  width: 8px;
  height: 8px;
  box-shadow: none;
  background: #6b7280;
}

.server-tab .status-dot.up {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.server-tab .status-dot.down {
  background: #ef4444;
  box-shadow: 0 0 6px #ef4444;
}

.server-tab .icon-btn {
  width: 16px;
  height: 16px;
  font-size: 12px;
  line-height: 1;
}

.server-tab.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
}

.top-users,
#add-server {
  margin-left: 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  flex-shrink: 0;
}

.perm-acc {
  border-bottom: 1px solid var(--line);
}

.perm-acc:last-child {
  border-bottom: 0;
}

.perm-acc-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.perm-acc-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: none;
  border: 0;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  padding: 9px 0;
  cursor: pointer;
  text-align: left;
}

.perm-acc-btn::before {
  content: "▸";
  color: var(--muted);
  font-size: 11px;
  margin-right: 6px;
}

.perm-acc.open .perm-acc-btn::before {
  content: "▾";
  color: var(--primary);
}

.perm-count {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.perm-acc-head > label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}

.perm-list {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 16px;
  padding: 0 0 10px 18px;
}

.perm-acc.open .perm-list {
  display: grid;
}

.perm-list label {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
  cursor: pointer;
}

.role-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  margin-top: 10px;
}

.role-card-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 12px 14px;
  cursor: pointer;
}

.role-card-head b {
  display: inline;
}

.role-card-body {
  display: none;
  padding: 0 14px 10px;
  border-top: 1px solid var(--line);
}

.role-card.open .role-card-body {
  display: block;
}

@media (max-width: 640px) {
  .perm-list {
    grid-template-columns: 1fr;
  }
}

.tick,
.switch input[type="checkbox"],
.row-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
}

.tick:checked,
.switch input[type="checkbox"]:checked,
.row-check input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.tick:checked::after,
.switch input[type="checkbox"]:checked::after,
.row-check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid var(--primary-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.tick:disabled,
.switch input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: default;
}

.tick:focus-visible,
.switch input[type="checkbox"]:focus-visible,
.row-check input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.rot-edit {
  min-width: 118px;
  width: auto;
}

.rot-order {
  display: flex;
  align-items: center;
  gap: 4px;
}

.rot-handle {
  cursor: grab;
  border: 1px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  color: var(--primary);
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rot-handle:active {
  cursor: grabbing;
}

.rot-arrow {
  min-width: 28px;
  padding-left: 6px;
  padding-right: 6px;
}

.rot-row-ghost {
  opacity: 0.3;
}

body.rot-dragging,
body.rot-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

.rot-float {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  padding: 10px 14px 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--primary);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow);
  transform: translate(-10px, -72%) rotate(-2deg);
}

.rot-float b {
  display: block;
}

.rot-float span {
  color: var(--muted);
  font-size: 12px;
}

.map-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.map-thumb {
  width: 52px;
  height: 66px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  flex-shrink: 0;
}

.rot-add {
  display: grid;
  grid-template-columns: minmax(200px, 280px) 1fr;
  gap: 16px;
  align-items: start;
  margin-top: 8px;
}

.map-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

@media (max-width: 800px) {
  .rot-add {
    grid-template-columns: 1fr;
  }
}

.settings-block {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 280px);
  gap: 16px;
  align-items: start;
}

.settings-row .hint {
  margin-top: 6px;
}

.steam-key-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

@media (max-width: 980px) {
  .settings-row {
    grid-template-columns: 1fr;
  }
}

.probe-table td:last-child {
  white-space: normal;
  min-width: 220px;
  max-width: 460px;
}

.probe-code {
  font-family: var(--mono);
  font-weight: 700;
}

.probe-fail {
  color: var(--accent);
  font-weight: 700;
}

.probe-wait {
  color: var(--muted);
}

.probe-table pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow: auto;
}

.probe-table details summary {
  cursor: pointer;
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--manticore);
  box-shadow: 0 0 8px var(--manticore);
}

.live-chip {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.live-chip.down {
  color: var(--accent);
}

.nav-toggle {
  display: none;
}

.shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 0;
  overflow: hidden;
}

.nav {
  border-right: 1px solid var(--line);
  padding: 14px 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  overflow: auto;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

.nav a:hover,
.nav a.active {
  color: var(--primary-ink);
  background: var(--primary);
}

.nav-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.nav-theme {
  display: grid;
  gap: 6px;
}

.nav-theme span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-theme .ctrl {
  width: 100%;
}

.main {
  padding: 20px 22px 40px;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.view-head h2 {
  margin: 0 0 4px;
  font-size: 26px;
}

.view-head p {
  margin: 0;
  color: var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.stack {
  display: grid;
  gap: 14px;
}

.card {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.card h3 {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

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

.card-head h3 {
  margin: 0;
}

.board-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.board-tools .ctrl {
  width: 220px;
}

/* ---------- Scores / status ---------- */

.scores {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.score {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
}

.score .name {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.score .n {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.1;
}

.score.valkyra .n { color: var(--valkyra); }
.score.lonestar .n { color: var(--lonestar); }
.score.manticore .n { color: var(--manticore); }

.limit {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

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

.chip {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--fg);
}

.chip b {
  color: var(--muted);
  font-weight: 600;
  margin-right: 6px;
}

.timer {
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.match-maps,
.next-map {
  color: var(--muted);
  margin-top: 4px;
}

.match-maps {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.start-players {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.start-players label {
  font-size: 13px;
  color: var(--muted);
}

.start-players input {
  width: 72px;
}

#queue-map {
  width: auto;
  min-width: 9.5rem;
}

#start-players-hint {
  margin: 8px 0 0;
}

.listing-preview {
  display: block;
  width: 100%;
  max-width: 512px;
  aspect-ratio: 4 / 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  margin-top: 4px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}

.settings-grid .field {
  margin-bottom: 0;
}

@media (max-width: 860px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.settings-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.settings-label label {
  margin: 0;
}

.apply-badge {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
}

.apply-badge.live {
  color: #7dcea0;
  border: 1px solid color-mix(in srgb, #7dcea0 55%, transparent);
}

.apply-badge.next {
  color: #f4d03f;
  border: 1px solid color-mix(in srgb, #f4d03f 55%, transparent);
}

.apply-badge.restart {
  color: #e67e22;
  border: 1px solid color-mix(in srgb, #e67e22 55%, transparent);
}

.apply-badge.pending {
  color: #58d3f7;
  border: 1px solid color-mix(in srgb, #58d3f7 55%, transparent);
}

.settings-span {
  grid-column: 1 / -1;
}

.tick-row {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 10px;
  align-items: center;
}

.tick-row input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

.settings-result {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
  line-height: 1.45;
}

.settings-result h4 {
  margin: 12px 0 6px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.settings-result h4:first-child {
  margin-top: 0;
}

.settings-result ul {
  margin: 0;
  padding-left: 18px;
}

.field.gs-dirty {
  border-left: 2px solid var(--primary);
  padding-left: 10px;
}

.gs-stage {
  position: fixed;
  left: calc(230px + 22px);
  right: 22px;
  bottom: 16px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 50%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 92%, var(--primary) 8%);
  box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.35);
}

body.has-gs-stage .main {
  padding-bottom: 96px;
}

.gs-stage-copy {
  min-width: 0;
  font-size: 13px;
  line-height: 1.4;
}

.gs-stage-copy strong {
  display: block;
}

#gs-stage-list {
  color: var(--muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-stage-actions {
  display: flex;
  flex: none;
  gap: 8px;
}

#hpk-card {
  margin-top: 14px;
}

.hpk-actions {
  margin-top: 12px;
}

.composer {
  display: grid;
  gap: 10px;
}

.composer-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rot-raw {
  width: 100%;
  min-height: 220px;
  max-height: 420px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
  white-space: pre-wrap;
}

.rot-row .actions-row {
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.audit-target {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.25;
}

.audit-target b {
  font-weight: 600;
}

.audit-target span {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
}

/* ---------- Command bar ---------- */

.cmd {
  display: grid;
  gap: 10px;
}

.cmd-row {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 8px;
}

.cmd-extra {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ---------- Tables ---------- */

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
}

.pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}

.pill.valkyra.active { background: var(--valkyra); border-color: var(--valkyra); color: #fff; }
.pill.lonestar.active { background: var(--lonestar); border-color: var(--lonestar); color: #0b0f12; }
.pill.manticore.active { background: var(--manticore); border-color: var(--manticore); color: #0b0f12; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

#users-body .user-role-pick {
  min-width: 10rem;
  width: auto;
  max-width: 14rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.player-table {
  table-layout: fixed;
}

.player-table th.time-col,
.player-table td.time-col {
  width: 5.4rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12px;
}

.player-table th.player-name-col,
.player-table td.player-col {
  width: 20%;
}

.player-table th.acts-head,
.player-table td.acts-col {
  width: 36%;
}

.player-table th.stat-head,
.player-table td.stat-col {
  width: 11%;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.player-table th[data-sort] {
  cursor: pointer;
  user-select: none;
}

.player-table th[data-sort]:hover {
  color: var(--fg);
}

.player-table th[aria-sort] {
  color: var(--primary);
}

.player-table th[data-sort] .s-dir {
  margin-left: 4px;
  font-size: 10px;
  letter-spacing: 0;
}

td.player-col {
  white-space: nowrap;
}

td.acts-col {
  white-space: normal;
}

tr.faction-valkyra td:first-child {
  box-shadow: inset 3px 0 0 var(--valkyra);
}

tr.faction-lonestar td:first-child {
  box-shadow: inset 3px 0 0 var(--lonestar);
}

tr.faction-manticore td:first-child {
  box-shadow: inset 3px 0 0 var(--manticore);
}

.player-who .name-valkyra,
.player-who .name-lonestar,
.player-who .name-manticore {
  font-weight: 600;
}

.player-acts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.player-acts .btn {
  flex: 1 1 4.5rem;
  padding: 5px 8px;
  font-size: 11px;
}

th {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--bg) 70%, var(--surface));
}

tr:last-child td {
  border-bottom: 0;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.dot.valkyra { background: var(--valkyra); }
.dot.lonestar { background: var(--lonestar); }
.dot.manticore { background: var(--manticore); }
.dot.total { background: var(--primary); }

.name-valkyra { color: var(--valkyra); }
.name-lonestar { color: var(--lonestar); }
.name-manticore { color: var(--manticore); }

.sid {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

/* ---------- Cash ---------- */

.cash-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-btn {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  min-width: 140px;
}

.legend-btn.off {
  opacity: 0.4;
}

.legend-btn .k {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.legend-btn .v {
  font-weight: 700;
}

.legend-btn .d {
  font-size: 11px;
}

.up { color: var(--manticore); }
.down { color: var(--valkyra); }

.cash-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#cash-canvas {
  width: 100%;
  height: 280px;
  display: block;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cash-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  display: none;
  z-index: 5;
  box-shadow: var(--shadow);
}

.cash-box {
  position: relative;
}

/* ---------- Accordion / tabs ---------- */

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.acc {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
  background: var(--bg);
}

.acc-btn {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
}

.acc-body {
  padding: 12px;
  display: none;
}

.acc.open .acc-body {
  display: block;
}

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

.sticky-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.faq details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bg);
}

.faq summary {
  cursor: pointer;
  font-weight: 600;
}

.host-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* ---------- Overlay ---------- */

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 16px;
}

.modal {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin: 0 0 8px;
  color: var(--fg);
  letter-spacing: 0;
  text-transform: none;
  font-size: 18px;
}

.menu {
  position: fixed;
  z-index: 45;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  box-shadow: var(--shadow);
}

.menu button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.menu button:hover {
  background: var(--surface-2);
}

.help-tip {
  color: var(--muted);
  cursor: help;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  font-size: 10px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .gs-stage {
    left: 12px;
    right: 12px;
  }

  .app {
    height: auto;
    overflow: visible;
  }

  .shell {
    overflow: visible;
  }

  .nav {
    display: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav.open {
    display: flex;
  }

  .main {
    overflow: visible;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .grid-2,
  .composer-row,
  .cmd-row,
  .cmd-extra,
  .pair,
  .scores,
  .host-grid {
    grid-template-columns: 1fr;
  }

  .live-chip {
    display: none;
  }
}

.site-faq {
  margin-top: 28px;
  padding: 18px 18px 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.connect-faq {
  width: min(640px, 100%);
  margin-top: 0;
}

.faq-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.faq-head h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.faq-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.faq-brand img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.faq-brand:hover {
  color: var(--primary);
}

.site-faq > .btn {
  margin: 8px 0 10px;
}

#tour-root {
  position: fixed;
  inset: 0;
  z-index: 70;
}

#tour-root[hidden] {
  display: none !important;
}

.tour-back {
  position: absolute;
  inset: 0;
}

.tour-spot {
  position: fixed;
  border: 2px solid var(--primary);
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(5, 8, 16, 0.68);
  pointer-events: none;
}

.tour-card {
  position: fixed;
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.tour-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.tour-card p {
  margin: 0 0 14px;
  color: var(--muted);
}

.tour-step {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 8px !important;
}

.tour-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
