:root {
  color-scheme: dark;
  --bg: #0b0f19;
  --panel: rgba(19, 24, 39, 0.86);
  --panel-strong: #171d2d;
  --panel-soft: #111625;
  --text: #f7f9ff;
  --muted: #9aa5bb;
  --line: rgba(255,255,255,.09);
  --accent: #8b7cff;
  --accent-2: #45d6b5;
  --danger: #ff6b7c;
  --warning: #ffc857;
  --shadow: 0 18px 50px rgba(0,0,0,.32);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 10% 0%, rgba(139,124,255,.16), transparent 30%),
    radial-gradient(circle at 100% 20%, rgba(69,214,181,.12), transparent 28%),
    var(--bg);
  color: var(--text);
}

body { min-height: 100vh; }

a {
  color: var(--accent-2);
  text-decoration: none;
}

a:hover { color: var(--text); }

.topbar {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: rgba(11,15,25,.84);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  font-weight: 800;
  color: var(--text);
}

nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px 18px;
}

.hero-row,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1,
h2,
h3 {
  margin-top: 0;
  letter-spacing: 0;
}

h1 { margin-bottom: 6px; }
h2 { font-size: 1.08rem; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted,
dt {
  color: var(--muted);
}

.small { font-size: 13px; }

.grid,
.game-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.grid.two,
.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.panel,
.metric,
.tenant-card,
.game-card,
.auth-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel,
.metric,
.tenant-card {
  padding: 18px;
  margin-bottom: 14px;
}

.game-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  color: var(--text);
}

.game-card strong { font-size: 1rem; }
.game-card span { color: var(--muted); }

.lobby-command-panel {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
}

.lobby-action {
  min-height: 96px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.12)),
    var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  text-align: left;
}

.lobby-action.primary {
  background:
    linear-gradient(135deg, rgba(139,124,255,.38), rgba(69,214,181,.18)),
    var(--panel-strong);
}

.lobby-action strong,
.lobby-action small {
  display: block;
}

.lobby-action small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 600;
}

.action-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(255,255,255,.09);
  color: var(--text);
  font-size: 25px;
  font-weight: 900;
}

.lobby-section {
  margin-bottom: 22px;
}

.how-to-card {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
  padding: 12px;
}

.how-to-toggle {
  min-height: 42px;
  display: grid;
  place-items: center;
  cursor: pointer;
  list-style: none;
  text-align: center;
}

.how-to-toggle::-webkit-details-marker {
  display: none;
}

.how-to-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 4px;
}

.how-to-content h3 {
  margin: 0 0 6px;
  font-size: .92rem;
}

.how-to-content p,
.how-to-content ul {
  margin: 0;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.45;
}

.how-to-content ul {
  padding-left: 18px;
}

.scoring-rules ul {
  columns: 2;
  column-gap: 26px;
}

.scoring-rules li {
  break-inside: avoid;
  margin-bottom: 4px;
}

.how-to-wide {
  grid-column: 1 / -1;
}

.lobby-chat {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
  padding: 12px;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 22px;
}

.chat-log {
  height: 168px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-gutter: stable;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(0,0,0,.16);
}

.chat-msg {
  display: flex;
  justify-content: flex-start;
  font-size: 13px;
}

.chat-msg.mine {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: min(76%, 520px);
  display: grid;
  gap: 3px;
  padding: 7px 9px;
  border-radius: 12px 12px 12px 4px;
  background: rgba(255,255,255,.07);
}

.chat-msg.mine .chat-bubble {
  border-radius: 12px 12px 4px 12px;
  background: rgba(139,124,255,.2);
}

.chat-bubble b {
  color: var(--accent-2);
}

.chat-msg.mine .chat-bubble b {
  color: var(--accent);
}

.chat-bubble small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-bubble span { overflow-wrap: anywhere; }

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.chat-form input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  background: rgba(255,255,255,.06);
  color: var(--text);
  font: inherit;
}

.rule-options {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.035);
}

.rule-options summary {
  cursor: pointer;
  font-weight: 800;
}

.empty-state {
  min-height: 104px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 18px;
  border: 1px dashed rgba(255,255,255,.16);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
}

.lobby-overlay[hidden] {
  display: none;
}

.lobby-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3,6,14,.72);
  backdrop-filter: blur(10px);
}

.lobby-sheet {
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255,255,255,.055), rgba(0,0,0,.14)),
    var(--panel-strong);
  box-shadow: 0 24px 80px rgba(0,0,0,.46);
}

.lobby-sheet.compact {
  width: min(420px, 100%);
}

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

.icon-close {
  width: 42px;
  min-height: 42px;
  padding: 0;
  font-size: 22px;
}

.code-input {
  height: 54px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.lobby-footer-link {
  margin: 28px 0 8px;
  display: flex;
  justify-content: center;
}

.lobby-footer-link a {
  width: min(460px, 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.04);
  color: var(--text);
}

.lobby-footer-link strong,
.lobby-footer-link small {
  display: block;
}

.lobby-footer-link small {
  color: var(--muted);
}

.narrow {
  max-width: 440px;
  margin: 40px auto;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 32px;
  align-items: center;
  min-height: calc(100vh - 160px);
}

.auth-copy h1 {
  font-size: 42px;
  line-height: 1.05;
}

.auth-copy p {
  max-width: 620px;
  font-size: 18px;
  line-height: 1.5;
}

.auth-form {
  margin: 0;
  padding: 20px;
}

form {
  display: grid;
  gap: 14px;
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.check-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.04);
  color: var(--text);
}

.check-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-2);
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0 12px;
  font: inherit;
  background: rgba(255,255,255,.045);
  color: var(--text);
  outline: none;
}

select option {
  background: var(--panel-strong);
  color: var(--text);
}

input:focus,
select:focus {
  border-color: rgba(139,124,255,.7);
  box-shadow: 0 0 0 4px rgba(139,124,255,.12);
}

button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), #6e5ff1);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  padding: 0 14px;
  cursor: pointer;
}

button:hover { filter: brightness(1.08); }
button:disabled { opacity: .42; cursor: not-allowed; }

button.secondary {
  background: rgba(255,255,255,.075);
  border: 1px solid var(--line);
  color: var(--text);
}

code {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  background: rgba(255,255,255,.075);
  color: var(--text);
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

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

th { color: var(--muted); }

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

.product.compact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border-top: 0;
  padding: 10px 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric strong {
  display: block;
  font-size: 30px;
}

.metric span {
  color: var(--muted);
}

.tenant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.tenant-title,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tenant-title h3,
.panel-head h2 {
  margin-bottom: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.075);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.pill.ok {
  background: rgba(69,214,181,.16);
  color: var(--accent-2);
}

.pill.warn {
  background: rgba(255,200,87,.16);
  color: var(--warning);
}

dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

dt { font-size: 12px; }

dd {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}

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

.result {
  margin-top: 12px;
  max-height: 280px;
  overflow: auto;
  background: var(--panel-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 12px;
}

.empty,
.alert {
  border-radius: var(--radius-md);
  padding: 14px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
}

.alert.error {
  background: rgba(255,107,124,.13);
  color: #ffd9df;
  border-color: rgba(255,107,124,.28);
}

@media (max-width: 760px) {
  .auth-shell,
  .split,
  .grid.two,
  .how-to-content,
  .lobby-command-panel {
    grid-template-columns: 1fr;
  }

  .scoring-rules ul {
    columns: 1;
  }

  .hero-row,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-copy h1 {
    font-size: 32px;
  }

  .topbar {
    padding: 10px 16px;
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    flex-wrap: wrap;
  }

  .page {
    padding: 20px 14px;
  }
}
