:root {
  --slate-950: #020617;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --yellow-13unis: #fbce07;
  --blue: #2563eb;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --line: #dbe3ee;
  --text: #0f172a;
  --muted: #64748b;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.07);
}

* {
  box-sizing: border-box;
}

body.tournament-engine-page {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: var(--slate-100);
  color: var(--text);
}

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

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

h1 {
  margin-bottom: 10px;
  font-size: 2rem;
  line-height: 1.1;
}

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

.wrap {
  width: min(100%, 1360px);
  margin: 0 auto;
  padding: 24px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  line-height: 1.5;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--slate-500);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.login-panel,
.card,
.step-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.login-panel {
  max-width: 540px;
  margin: 86px auto;
  padding: 28px;
  border-top: 6px solid var(--yellow-13unis);
}

.login-panel .eyebrow {
  color: var(--amber);
}

.login-panel button {
  width: 100%;
}

.engine-shell {
  display: grid;
  gap: 16px;
}

.engine-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 20px;
  align-items: stretch;
  padding: 24px;
  border: 1px solid var(--slate-800);
  border-bottom: 6px solid var(--yellow-13unis);
  border-radius: 8px;
  background: var(--slate-900);
  color: #ffffff;
  box-shadow: var(--shadow);
}

.engine-hero .eyebrow {
  color: var(--yellow-13unis);
}

.hero-copy {
  display: grid;
  align-content: center;
}

.hero-text {
  max-width: 680px;
  margin-bottom: 18px;
  color: var(--slate-300);
  line-height: 1.55;
}

.hero-badges,
.toolbar,
.actions,
.inline-row,
.section-head,
.row-head,
.advanced-head {
  display: flex;
  gap: 12px;
}

.hero-badges,
.toolbar {
  flex-wrap: wrap;
}

.section-head,
.row-head,
.advanced-head {
  align-items: flex-start;
  justify-content: space-between;
}

.session-panel {
  display: grid;
  align-content: space-between;
  gap: 16px;
  min-height: 180px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.session-label {
  display: block;
  margin-bottom: 4px;
  color: var(--slate-300);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.card {
  padding: 20px;
}

.panel-section {
  display: grid;
  gap: 16px;
}

.setup-steps {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.step-card {
  min-height: 118px;
  padding: 14px;
  border-width: 2px;
}

.step-card.selected {
  border-color: var(--yellow-13unis);
  background: #fffbeb;
}

.step-card.muted-step {
  border-style: dashed;
  background: var(--slate-50);
}

.step-card span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 28px;
  margin-bottom: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--slate-900);
  color: var(--yellow-13unis);
  font-size: 0.72rem;
  font-weight: 900;
}

.step-card strong {
  display: block;
  margin-bottom: 5px;
  font-size: 0.92rem;
}

.step-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.grid,
.form-grid,
.stack {
  display: grid;
  gap: 14px;
}

.grid {
  margin-bottom: 16px;
}

.two-col {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.full-row {
  grid-column: 1 / -1;
}

.inline-row {
  align-items: stretch;
}

.inline-row input {
  min-width: 0;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--slate-700);
  font-weight: 800;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  border: 2px solid var(--slate-200);
  border-radius: 8px;
  background: var(--slate-50);
  color: var(--text);
}

textarea {
  min-height: 104px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

input[type="checkbox"] {
  width: auto;
  min-height: 0;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
.button-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(251, 206, 7, 0.22);
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  width: auto;
  padding: 10px 16px;
  border: 1px solid var(--slate-900);
  border-radius: 999px;
  background: var(--slate-900);
  color: var(--yellow-13unis);
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, color 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}

button:not(:disabled):hover,
.button-link:hover {
  transform: translateY(-1px);
}

button.secondary,
.button-link.secondary {
  border-color: var(--line);
  background: #ffffff;
  color: var(--slate-700);
}

button.secondary.danger,
button.danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--red);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--slate-50);
  color: var(--slate-700);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.engine-hero .badge {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.badge.success,
.pill.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #047857;
}

.badge.warn,
.pill.warn {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.badge.info,
.pill.info {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.badge.danger,
.pill.danger {
  border-color: #fecaca;
  background: #fff1f2;
  color: #be123c;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  border: 2px solid var(--slate-200);
  border-radius: 8px;
  background: var(--slate-50);
}

.checkbox-row span {
  color: var(--slate-700);
  font-weight: 800;
}

.checkbox-row--stacked {
  align-items: flex-start;
}

.checkbox-row--stacked span {
  display: grid;
  gap: 2px;
}

.checkbox-row--stacked strong {
  color: var(--slate-700);
  font-weight: 900;
}

.checkbox-row--stacked small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
}

.advanced-zone {
  padding: 14px;
  border: 1px dashed var(--slate-300);
  border-radius: 8px;
  background: var(--slate-50);
}

.advanced-zone summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  color: var(--slate-700);
  font-weight: 900;
  list-style: none;
}

.advanced-zone summary::-webkit-details-marker {
  display: none;
}

.advanced-zone summary::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--slate-900);
  color: var(--yellow-13unis);
  font-weight: 900;
}

.advanced-zone[open] summary::before {
  content: "-";
}

.advanced-zone label {
  margin-top: 12px;
}

.field-hint {
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.notice-line {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.4;
}

.row-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--slate-50);
}

.row-title {
  margin-bottom: 4px;
  font-weight: 900;
}

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

.metric-box {
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--slate-50);
}

.metric-box span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric-box strong {
  color: var(--slate-900);
  font-size: 1.8rem;
  line-height: 1;
}

.import-team-card {
  display: grid;
  gap: 12px;
}

.team-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.member-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.member-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.member-list span {
  font-weight: 800;
}

.member-list small {
  color: var(--muted);
  font-weight: 700;
}

.status-line {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.error {
  color: var(--red);
}

.empty-state {
  padding: 16px;
  border: 1px dashed var(--slate-300);
  border-radius: 8px;
  background: var(--slate-50);
  color: var(--muted);
  line-height: 1.5;
}

.empty-state.compact {
  padding: 12px;
}

@media (max-width: 1060px) {
  .engine-hero,
  .two-col,
  .three-col,
  .preview-summary {
    grid-template-columns: 1fr;
  }

  .setup-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .wrap {
    padding: 14px;
  }

  .engine-hero,
  .card,
  .login-panel {
    padding: 16px;
  }

  .setup-steps {
    grid-template-columns: 1fr;
  }

  .section-head,
  .row-head,
  .advanced-head,
  .inline-row {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar button,
  .toolbar .button-link,
  .inline-row button {
    width: 100%;
  }
}
