:host {
  --nc-neon: #ff45c8;
  --nc-bg: #06060d;
  --nc-surface: rgba(20, 17, 42, 0.6);
  --nc-text: #fff;
  --nc-text-muted: rgba(255, 255, 255, 0.65);
  --nc-text-dim: rgba(255, 255, 255, 0.45);
  --nc-border: rgba(255, 255, 255, 0.08);
  --nc-border-strong: rgba(255, 255, 255, 0.15);
  --nc-success: #5ee5a1;
  --nc-danger: #ff7a7a;
  --nc-warn: #ffd166;
  --nc-sans: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  display: block;
  min-height: 100vh;
  background: var(--nc-bg);
  font-family: var(--nc-sans);
  color: var(--nc-text);
}

:host-context(html:not([data-theme='dark'])) {
  --nc-neon: #c026d3;
  --nc-bg: #f5f0fc;
  --nc-surface: rgba(255, 255, 255, 0.88);
  --nc-text: #0f0022;
  --nc-text-muted: rgba(15, 0, 34, 0.65);
  --nc-text-dim: rgba(15, 0, 34, 0.4);
  --nc-border: rgba(15, 0, 34, 0.1);
  --nc-border-strong: rgba(15, 0, 34, 0.2);
  --nc-success: #16a34a;
  --nc-danger: #dc2626;
  --nc-warn: #b45309;
}

.t-shell { padding-top: 72px; min-height: 100vh; }

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

/* Breadcrumb */
.crumb {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 28px; font-size: 11px;
  color: var(--nc-text-dim); letter-spacing: 0.06em;
}
.crumb-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--nc-text-dim); text-decoration: none;
  transition: color 0.15s;
}
.crumb-link:hover { color: var(--nc-neon); }
.crumb-sep { opacity: 0.35; }
.crumb-current { color: var(--nc-text-muted); }

/* Header */
.page-header { margin-bottom: 28px; }
.page-title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.page-title { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }

.page-actions { display: flex; align-items: center; gap: 8px; }

.btn-servers {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--nc-border-strong);
  background: transparent; color: var(--nc-text-muted);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-servers:hover { color: var(--nc-text); border-color: var(--nc-text-muted); }

.btn-new {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: none;
  background: var(--nc-neon); color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s;
}
.btn-new:hover { opacity: 0.85; }

/* Create dialog */
.dialog-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.dialog-card {
  background: var(--nc-bg); border: 1px solid var(--nc-border-strong);
  border-radius: 16px; padding: 24px; width: 100%; max-width: 420px;
}
.dialog-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.dialog-brand { font-size: 14px; font-weight: 700; color: var(--nc-neon); }
.dialog-close {
  background: none; border: none; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--nc-text-muted);
  padding: 0 4px;
}
.dialog-close:hover { color: var(--nc-text); }
.dialog-field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.dialog-label { font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--nc-text-muted); }
.dialog-input {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--nc-border-strong);
  background: rgba(255,255,255,0.04); color: var(--nc-text);
  font-size: 14px; box-sizing: border-box;
}
.dialog-input:focus { outline: 2px solid var(--nc-neon); outline-offset: 1px; border-color: transparent; }
.dialog-row { display: flex; gap: 12px; margin-bottom: 16px; }
.dialog-field:not(.dialog-row .dialog-field) { margin-bottom: 16px; }
.dialog-toggle {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  margin-bottom: 20px; user-select: none;
}
.dialog-toggle input[type=checkbox] { display: none; }
.toggle-track {
  width: 36px; height: 20px; border-radius: 10px;
  background: var(--nc-border-strong); flex-shrink: 0;
  transition: background 0.2s; position: relative;
}
.toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--nc-text-muted); transition: transform 0.2s, background 0.2s;
}
.dialog-toggle input:checked ~ .toggle-track { background: var(--nc-neon); }
.dialog-toggle input:checked ~ .toggle-track::after { transform: translateX(16px); background: #fff; }
.toggle-label { font-size: 14px; color: var(--nc-text); }
.dialog-error {
  font-size: 13px; color: var(--nc-danger);
  background: rgba(255,122,122,0.1); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 16px;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-ghost {
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--nc-border-strong);
  background: transparent; color: var(--nc-text-muted); font-size: 13px; cursor: pointer;
}
.btn-ghost:hover { color: var(--nc-text); border-color: var(--nc-text-muted); }
.btn-primary {
  padding: 8px 18px; border-radius: 8px; border: none;
  background: var(--nc-neon); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tabs */
.tabs { display: flex; gap: 4px; }
.tab-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 8px; border: none;
  background: transparent; color: var(--nc-text-muted);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { background: var(--nc-border); color: var(--nc-text); }
.tab-btn.active { background: var(--nc-surface); color: var(--nc-text); border: 1px solid var(--nc-border-strong); }
.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--nc-border-strong);
  font-size: 10px; font-weight: 700; color: var(--nc-text-muted);
}
.live-badge { background: rgba(94, 229, 161, 0.2); color: var(--nc-success); }

/* States */
.state-msg {
  display: flex; align-items: center; gap: 10px;
  padding: 24px 0; color: var(--nc-text-muted); font-size: 13px;
}
.state-msg.small { padding: 12px 0; }
.pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--nc-neon); flex-shrink: 0;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 64px 0; text-align: center;
}
.empty-icon { color: var(--nc-text-dim); margin-bottom: 4px; }
.empty-title { font-size: 15px; font-weight: 600; margin: 0; }
.empty-sub { font-size: 13px; color: var(--nc-text-muted); margin: 0; }

/* Tournament list */
.t-list { display: flex; flex-direction: column; gap: 8px; }

.t-card {
  border: 1px solid var(--nc-border);
  border-radius: 12px;
  background: var(--nc-surface);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.t-card:hover, .t-card.expanded {
  border-color: var(--nc-border-strong);
  background: rgba(255, 255, 255, 0.04);
}
.t-card:focus-visible { outline: 2px solid var(--nc-neon); outline-offset: 2px; }

.t-action-btn {
  padding: 5px 12px; border-radius: 7px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: none; transition: opacity 0.15s; white-space: nowrap;
}
.t-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.t-btn-start { background: var(--nc-success); color: #0f0022; }
.t-btn-start:hover:not(:disabled) { opacity: 0.85; }
.t-btn-join { background: var(--nc-neon); color: #fff; }
.t-btn-join:hover:not(:disabled) { opacity: 0.85; }

/* Join dialog extras */
.join-hint { font-size: 13px; color: var(--nc-text-muted); margin: 0 0 16px; line-height: 1.5; }
.join-empty { font-size: 13px; color: var(--nc-text-muted); margin: 0 0 8px; }
.dialog-loading { display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--nc-text-muted); padding: 12px 0; }
.bot-pick-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.bot-pick-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--nc-border); background: var(--nc-surface);
  cursor: pointer; text-align: left; width: 100%;
  transition: border-color 0.15s, background 0.15s;
}
.bot-pick-row:hover:not(:disabled) { border-color: var(--nc-neon); background: rgba(255,69,200,0.06); }
.bot-pick-row:disabled { opacity: 0.5; cursor: not-allowed; }
.bot-pick-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--nc-neon);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.bot-pick-name { flex: 1; font-size: 14px; font-weight: 600; color: var(--nc-text); }
.bot-pick-rating { font-size: 12px; color: var(--nc-text-muted); }
.bot-pick-spinner { font-size: 13px; color: var(--nc-neon); }

.t-card-main {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; gap: 12px;
}
.t-card-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.t-card-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.t-status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.dot-started { background: var(--nc-success); box-shadow: 0 0 6px var(--nc-success); }
.dot-created { background: var(--nc-warn); }
.dot-finished { background: var(--nc-text-dim); }

.t-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.t-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-meta { font-size: 11px; color: var(--nc-text-muted); }

.winner-badge {
  font-size: 11px; font-weight: 600; color: var(--nc-warn);
  padding: 3px 8px; border-radius: 6px;
  background: rgba(255, 209, 102, 0.12);
}

.chevron { color: var(--nc-text-dim); transition: transform 0.2s; }
.chevron.open { transform: rotate(180deg); }

/* Detail panel */
.t-detail {
  border-top: 1px solid var(--nc-border);
  padding: 16px;
  display: flex; flex-direction: column; gap: 20px;
}

.detail-section { display: flex; flex-direction: column; gap: 10px; }
.detail-heading {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--nc-text-muted); margin: 0;
}

.no-standings { font-size: 12px; color: var(--nc-text-dim); margin: 0; }

/* Standings table */
.standings-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.standings-table th {
  text-align: left; padding: 6px 8px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--nc-text-dim);
  border-bottom: 1px solid var(--nc-border);
}
.standings-table td { padding: 8px 8px; border-bottom: 1px solid var(--nc-border); }
.standings-table tr:last-child td { border-bottom: none; }
.top-row td { color: var(--nc-text); }
.standings-table tr:not(.top-row) td { color: var(--nc-text-muted); }

.col-rank { width: 40px; font-size: 14px; }
.col-pts { width: 48px; font-weight: 700; color: var(--nc-neon) !important; }
.col-tb { width: 52px; color: var(--nc-text-dim) !important; font-size: 12px; }
.col-games { width: 64px; }

.wdl { font-size: 12px; font-variant-numeric: tabular-nums; }
.w { color: var(--nc-success); }
.d { color: var(--nc-text-muted); }
.l { color: var(--nc-danger); }

/* Pairings */
.pairings-list { display: flex; flex-direction: column; gap: 6px; }
.pairing-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  background: rgba(255,255,255,0.025);
  font-size: 13px; transition: background 0.15s;
}
.pairing-row.is-watchable { cursor: pointer; }
.pairing-row.is-watchable:hover { background: rgba(255,255,255,0.06); }
.pairing-white { font-weight: 600; flex: 1; }
.pairing-vs { color: var(--nc-text-dim); font-size: 11px; flex-shrink: 0; }
.pairing-black { flex: 1; }
.pairing-result { font-weight: 700; font-size: 12px; margin-left: auto; }
.result-white { color: var(--nc-success); }
.result-black { color: var(--nc-danger); }
.result-draw { color: var(--nc-text-muted); }
.pairing-ongoing {
  display: inline-flex; align-items: center; gap: 5px;
  margin-left: auto; font-size: 10px; font-weight: 700;
  color: var(--nc-success); letter-spacing: 0.06em; text-transform: uppercase;
}
.pairing-ongoing svg { animation: pulse 1.4s ease-in-out infinite; }

/* Official bot join section */
.join-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 20px 0 14px;
}
.join-divider::before, .join-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--nc-border);
}
.join-divider-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--nc-text-dim); white-space: nowrap;
}

.official-bot-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-bottom: 4px;
}

.official-bot-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 4px; border-radius: 8px; border: 1px solid var(--nc-border);
  background: var(--nc-surface); font-size: 12px; font-weight: 700;
  cursor: pointer; transition: border-color 0.15s, background 0.15s, color 0.15s;
  color: var(--nc-text-muted); text-transform: capitalize;
}
.official-bot-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.official-btn-easy:hover:not(:disabled)   { border-color: var(--nc-success); color: var(--nc-success); background: rgba(94,229,161,0.07); }
.official-btn-medium:hover:not(:disabled) { border-color: var(--nc-warn); color: var(--nc-warn); background: rgba(255,209,102,0.07); }
.official-btn-hard:hover:not(:disabled)   { border-color: var(--nc-neon); color: var(--nc-neon); background: rgba(255,69,200,0.07); }
.official-btn-expert:hover:not(:disabled) { border-color: var(--nc-danger); color: var(--nc-danger); background: rgba(255,122,122,0.07); }

/* Servers dialog */
.servers-dialog { max-width: 480px; }

.servers-list {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 20px;
}
.server-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--nc-border); background: var(--nc-surface);
}
.server-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.server-label { font-size: 13px; font-weight: 600; color: var(--nc-text); }
.server-url {
  font-size: 11px; color: var(--nc-text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: monospace;
}
.server-remove-btn {
  background: none; border: none; cursor: pointer;
  color: var(--nc-text-dim); padding: 4px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: color 0.15s, background 0.15s;
  font-size: 13px;
}
.server-remove-btn:hover:not(:disabled) { color: var(--nc-danger); background: rgba(255,122,122,0.1); }
.server-remove-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.server-add-form {
  border-top: 1px solid var(--nc-border);
  padding-top: 16px;
  display: flex; flex-direction: column; gap: 0;
}
.server-add-heading {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--nc-text-muted);
  margin: 0 0 14px;
}
