/* ======================================================================
   Design tokens
   ====================================================================== */
:root {
  color-scheme: dark;
  --bg: #050505;
  --surface: #101010;
  --panel: #151515;
  --panel-2: #202020;
  --panel-3: #292929;
  --ink: #f4f4f4;
  --muted: #b9b9b9;
  --quiet: #7f7f7f;
  --line: #3b3b3b;
  --line-strong: #4a4a4a;
  --accent: #ff7a1a;
  --accent-hover: #ff8e32;
  --accent-dark: #9c3e08;
  --gold: #ffb14a;
  --good: #39c27f;
  --danger: #e04f42;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
  --overlay: rgba(0, 0, 0, 0.62);
  /* Ink printed on accent/gold fills. Deliberately dark in BOTH themes: the
     fills stay orange when the page goes light, so the text must stay dark. */
  --on-accent: #050505;
  /* Channels of --accent, for rgb(var(--accent-rgb) / <alpha>) tints. */
  --accent-rgb: 255 122 26;
  /* Inputs, selects, menus, popovers: the recessed field surface. */
  --surface-input: #0c0c0c;
  /* Recessed panels: table headers, code blocks, empty states. */
  --surface-well: #111111;
  --surface-well-soft: rgba(12, 12, 12, 0.42);
  /* The dark base inside decorative accent gradients (avatars, medallions,
     result banners). Stays dark in BOTH themes, like --on-accent: the gradient
     over it is orange either way. */
  --surface-medallion: #111111;
  /* One action-button size, based on Back. Variants change color, not density. */
  --button-height: 40px;
  --button-font-size: 16px;
  --button-font-weight: 900;
  --button-line-height: 1;
  --button-padding: 2px 14px 0;
  --button-radius: 7px;
  /* Right-hand room reserved for the fixed language/theme/notification controls. */
  --topbar-controls-gutter: calc(var(--button-height) * 3 + 34px);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f3f5;
  --surface: #ffffff;
  --panel: #ffffff;
  --panel-2: #f5f6f8;
  --panel-3: #e8eaed;
  --ink: #171717;
  --muted: #555b63;
  --quiet: #737983;
  --line: #d4d7dc;
  --line-strong: #b9bec6;
  --accent: #f36d0d;
  --accent-hover: #ff7a1a;
  --accent-dark: #b74708;
  --gold: #9b5700;
  --good: #178653;
  --danger: #c53d34;
  --shadow: 0 14px 32px rgba(28, 31, 35, 0.12);
  --accent-rgb: 243 109 13;
  --surface-input: var(--surface);
  --surface-well: var(--panel-2);
  --surface-well-soft: var(--panel-2);
}

/* ======================================================================
   Base elements
   ====================================================================== */
* {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgb(var(--accent-rgb) / 0.08), transparent 280px),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 16px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[hidden] {
  display: none !important;
}

button,
:where(a[data-app-link]),
input,
select,
textarea {
  font: inherit;
}

button,
:where(a[data-app-link]) {
  border: 0;
  text-decoration: none;
  cursor: pointer;
}

/* Also covers future native buttons and links styled as action buttons. */
button,
:where(a[data-app-link]),
.primary-button,
.ghost-button,
.danger-button,
.small-button,
input[type="file"]::file-selector-button {
  min-height: var(--button-height);
  padding: var(--button-padding);
  border-radius: var(--button-radius);
  font-family: inherit;
  font-size: var(--button-font-size);
  font-weight: var(--button-font-weight);
  line-height: var(--button-line-height);
  text-align: center;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* Clickable content cards keep their content typography and intrinsic height. */
.challenge-user-card,
.team-stat-card,
.notification-item {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.loading {
  padding: 48px;
  color: var(--muted);
}

/* ======================================================================
   Sign-in and registration
   ====================================================================== */
.auth-layout {
  display: grid;
  grid-template-columns: minmax(280px, 440px) minmax(360px, 1fr);
  gap: 18px;
  min-height: 100vh;
  padding: 14px 18px;
  align-items: stretch;
}

.brand-panel {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 34px 30px;
  color: var(--ink);
  background:
    linear-gradient(140deg, rgb(var(--accent-rgb) / 0.16), rgba(21, 21, 21, 0.98) 34%),
    linear-gradient(90deg, var(--accent) 0 5px, transparent 5px),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 560px;
}

.brand-panel h1 {
  margin: 0;
  font-size: 42px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-logo {
  width: 126px;
  height: 126px;
  margin-bottom: 20px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 34px rgb(var(--accent-rgb) / 0.36);
}

.brand-panel p {
  max-width: 440px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.auth-stack {
  width: min(460px, 100%);
  justify-self: center;
  align-self: center;
}

/* ======================================================================
   Cards, panels and section headings
   ====================================================================== */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 28px;
}

.section-title {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 24px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-subtitle {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.45;
}

/* ======================================================================
   Tabs
   ====================================================================== */
.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  margin-bottom: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.page-tabs {
  align-items: center;
  flex-wrap: wrap;
  height: 50px;
  margin-bottom: -10px;
  overflow: hidden;
}

.page-tabs .tab {
  height: var(--button-height);
}

.tab {
  flex: 1;
  color: var(--muted);
  background: transparent;
  white-space: normal;
}

.tab.active {
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 2px 0 var(--accent-dark);
}

/* ======================================================================
   Form fields
   ====================================================================== */
.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface-input);
}

.field textarea {
  min-height: 132px;
  padding-top: 12px;
  resize: vertical;
  line-height: 1.45;
}

.field input::placeholder {
  color: var(--quiet);
}

.field-help {
  color: var(--quiet);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid rgb(var(--accent-rgb) / 0.26);
  border-color: var(--accent);
}

/* ======================================================================
   Filters and type-ahead suggestions
   ====================================================================== */
.filter-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  margin: 12px 0 18px;
}

.compact-field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.compact-field input,
.compact-field select {
  min-height: 40px;
}

.filter-suggest-field {
  position: relative;
}

.filter-suggestions {
  position: absolute;
  z-index: 18;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: grid;
  gap: 3px;
  max-height: 260px;
  padding: 5px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-input);
  box-shadow: var(--shadow);
}

.filter-suggestions[hidden] {
  display: none;
}

.filter-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.filter-suggestion:hover {
  color: var(--on-accent);
  background: var(--accent);
}

.filter-suggestion small,
.filter-suggestion-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.filter-suggestion:hover small {
  color: var(--on-accent);
}

.filter-suggestion-empty {
  padding: 10px;
}

.filter-summary {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

/* ======================================================================
   Password input
   ====================================================================== */
.password-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--button-height);
}

.password-control input {
  border-radius: 7px 0 0 7px;
}

.password-toggle {
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--muted);
  background: var(--surface-input);
  border: 1px solid var(--line-strong);
  border-left: 0;
  border-radius: 0 7px 7px 0;
}

.password-toggle:hover,
.password-toggle[aria-pressed="true"] {
  color: var(--accent);
}

.password-control:focus-within input,
.password-control:focus-within .password-toggle {
  outline: 2px solid rgb(var(--accent-rgb) / 0.26);
  border-color: var(--accent);
}

/* ======================================================================
   Combo box
   ====================================================================== */
.combo-field {
  position: relative;
  min-width: 0;
}

.user-search-field {
  margin-bottom: 0;
}

.combo-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--button-height);
}

.password-control input,
.combo-control .combo-input {
  min-height: var(--button-height);
}

.combo-control .combo-input {
  border-radius: 7px 0 0 7px;
}

.combo-toggle {
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-left: 0;
  border-radius: 0 7px 7px 0;
  color: var(--ink);
  background: var(--surface-input);
}

.combo-toggle::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--ink);
}

.combo-field.open .combo-input,
.combo-field.open .combo-toggle,
.combo-control:focus-within .combo-input,
.combo-control:focus-within .combo-toggle {
  outline: 2px solid rgb(var(--accent-rgb) / 0.26);
  border-color: var(--accent);
}

.combo-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: grid;
  gap: 3px;
  max-height: 224px;
  padding: 5px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-input);
  box-shadow: var(--shadow);
}

.combo-menu[hidden] {
  display: none;
}

.combo-option {
  width: 100%;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.combo-option:hover,
.combo-option.active {
  color: var(--on-accent);
  background: var(--accent);
}

.combo-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

/* ======================================================================
   Buttons
   ====================================================================== */
.primary-button,
.ghost-button,
.danger-button,
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  border: 1px solid transparent;
  overflow-wrap: anywhere;
}

.primary-button {
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent-dark);
}

.primary-button:hover {
  background: var(--accent-hover);
}

.inline-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.icon-heading .inline-icon {
  color: var(--accent);
}

.ghost-button {
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
}

.ghost-button:hover,
.small-button:hover {
  border-color: var(--accent);
}

.danger-button {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line-strong);
}

.danger-button:hover:not(:disabled) {
  background: var(--panel-2);
  border-color: var(--muted);
}

.small-button {
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
}

.text-button {
  min-height: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 900;
  font-size: inherit;
  line-height: inherit;
}

.text-button:hover {
  color: var(--accent);
}

/* ======================================================================
   Leaderboard
   ====================================================================== */
.leaderboard-player-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.leaderboard-avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  overflow: hidden;
  border: 2px solid var(--accent);
  border-radius: 50%;
  color: #ffffff;
  background: radial-gradient(circle at 35% 30%, #ffb347, #5c2400 70%);
  font-size: 12px;
  font-weight: 950;
}

.leaderboard-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ======================================================================
   Pagination
   ====================================================================== */
.pagination-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  flex-wrap: wrap;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.pagination-summary {
  line-height: 1.4;
}

.pagination-current {
  color: var(--ink);
  font-weight: 900;
}

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

.text-link-button {
  min-height: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 900;
  text-align: left;
  font-size: inherit;
  line-height: inherit;
}

.text-link-button:hover {
  color: var(--accent);
}

.inline-profile-link {
  display: inline;
}

.message {
  min-height: 22px;
  margin-top: 14px;
  color: var(--muted);
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--good);
}

/* ======================================================================
   Top bar
   ====================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px var(--topbar-controls-gutter) 14px 18px;
  background: rgba(5, 5, 5, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.topbar-user-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 250px;
  padding-right: 14px;
  border-right: 1px solid var(--line);
}

.app-logo {
  width: 46px;
  height: 46px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 22px rgb(var(--accent-rgb) / 0.26);
}

.app-brand-name {
  color: var(--ink);
  font-size: 14px;
  font-weight: 950;
  line-height: 1.1;
  text-transform: uppercase;
}

.app-brand-subtitle {
  margin-top: 2px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 950;
  line-height: 1.1;
  text-transform: uppercase;
}

.mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgb(var(--accent-rgb) / 0.78), rgba(12, 12, 12, 0.8)),
    var(--surface-medallion);
  box-shadow: 0 0 24px rgb(var(--accent-rgb) / 0.22);
  font-weight: 950;
  overflow: hidden;
}

.mark img,
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-button {
  width: var(--button-height);
  height: var(--button-height);
}

.avatar-button:hover {
  box-shadow: 0 0 32px rgb(var(--accent-rgb) / 0.34);
}

.avatar-button span {
  display: block;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  text-transform: uppercase;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.topbar-player {
  min-width: 0;
}

.topbar-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.menu-toggle {
  display: none;
  place-items: center;
  width: var(--button-height);
  height: var(--button-height);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-2);
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 3px 0;
  border-radius: 999px;
  background: currentColor;
}

.sidebar-backdrop {
  display: none;
}

.rating-pill {
  padding: 8px 12px;
  border-radius: 7px;
  color: var(--on-accent);
  background: var(--accent);
  font-weight: 950;
}

.inline-rating {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  white-space: nowrap;
}

/* ======================================================================
   App shell: layout, sidebar, navigation
   ====================================================================== */
.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  width: min(1280px, calc(100% - 36px));
  margin: 14px auto 28px;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 86px;
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--panel);
  height: fit-content;
}

.sidebar::before {
  content: "TGTV Ranking";
  display: block;
  margin: 2px 0 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
  font-weight: 950;
  text-transform: uppercase;
}

.nav-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.nav-button + .nav-button {
  margin-top: 8px;
}

.sidebar-logout {
  margin-top: 16px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
}

.nav-button.active {
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent-dark);
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-content: start;
}

/* ======================================================================
   Public tournament pages
   ====================================================================== */
.public-tournament-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  width: min(1180px, calc(100% - 36px));
  margin: 18px auto 32px;
}

.public-tournament-layout.embedded-public-tournament {
  width: 100%;
  margin: 0;
}

.public-tournament-shell {
  background:
    linear-gradient(90deg, rgb(var(--accent-rgb) / 0.14), transparent 56%),
    var(--panel);
}

.public-tournament-header {
  align-items: flex-start;
}

.public-tournament-description {
  max-width: 820px;
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

:root[data-theme="light"] body {
  background:
    linear-gradient(90deg, rgba(243, 109, 13, 0.08), transparent 280px),
    repeating-linear-gradient(135deg, rgba(23, 23, 23, 0.025) 0 1px, transparent 1px 16px),
    var(--bg);
}

/* ======================================================================
   Floating language and theme controls
   ====================================================================== */
.floating-controls {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 60;
  display: flex;
  gap: 8px;
}

.theme-toggle,
.lang-toggle {
  display: grid;
  place-items: center;
  width: var(--button-height);
  height: var(--button-height);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  line-height: 1;
}

.theme-toggle {
  font-size: 22px;
}

.lang-toggle {
  letter-spacing: 0.04em;
}

.theme-toggle:hover,
.theme-toggle:focus-visible,
.lang-toggle:hover,
.lang-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

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

.tournament-stats,

/* ======================================================================
   Tournament tables
   ====================================================================== */
.tournament-table-admin {
  display: grid;
  gap: 14px;
}

.roster-profile-page {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.roster-profile-page .panel-header,
.roster-profile-page .row-actions {
  flex-wrap: wrap;
}

.roster-profile-page .panel-header > div,
.roster-profile-page .row-main {
  min-width: 0;
  overflow-wrap: anywhere;
}

.roster-summary-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr));
  gap: 12px;
}

.roster-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.roster-heading > div {
  min-width: 0;
}

.roster-team-logo {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.roster-team-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 24px;
  font-weight: 900;
}

.roster-heading-compact {
  margin-bottom: 10px;
}

.roster-heading-compact .roster-team-logo {
  width: 48px;
  height: 48px;
  flex-basis: 48px;
  font-size: 18px;
}

.roster-summary-metrics .metric-card {
  min-width: 0;
}

.tournament-stats-grid {
  align-items: start;
}

.tournament-stat-table h4 {
  margin: 0;
  color: var(--accent);
  font-size: 14px;
  text-transform: uppercase;
}

.admin-table-form,
.table-admin-controls {
  display: grid;
  gap: 10px;
}

.table-admin-controls {
  grid-template-columns: minmax(0, 1fr) minmax(120px, 180px);
  max-width: 680px;
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 40px 18px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.72);
}

.round-setup-dialog {
  width: min(1080px, 100%);
}

.round-setup-form,
.round-setup-list {
  display: grid;
  gap: 12px;
}

.round-setup-match-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.round-setup-match-grid.has-table {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ======================================================================
   Rendered markdown
   ====================================================================== */
.markdown-content {
  overflow-wrap: anywhere;
}

.markdown-content > * {
  margin: 0 0 10px;
}

.markdown-content > :last-child {
  margin-bottom: 0;
}

.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  color: var(--ink);
  line-height: 1.25;
}

.markdown-content ul,
.markdown-content ol {
  padding-left: 22px;
}

.markdown-content li + li {
  margin-top: 4px;
}

.markdown-content a {
  color: var(--accent);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.markdown-content code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-well);
  color: var(--ink);
}

.markdown-content pre {
  overflow-x: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-well);
}

.markdown-content pre code {
  padding: 0;
  border: 0;
  background: transparent;
}

.markdown-content blockquote {
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: rgb(var(--accent-rgb) / 0.08);
}

/* ======================================================================
   Markdown editor
   ====================================================================== */
.markdown-field {
  gap: 0;
}

.markdown-field-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.markdown-view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.markdown-view-tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  text-transform: uppercase;
  cursor: pointer;
}

.markdown-view-tab.is-active {
  border-color: var(--accent);
  background: rgb(var(--accent-rgb) / 0.12);
  color: var(--ink);
}

.markdown-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  background: var(--surface-well);
}

.markdown-tool {
  min-width: var(--button-height);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.markdown-tool:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--ink);
}

.markdown-tool:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.markdown-field textarea[data-markdown-input] {
  border-radius: 0 0 7px 7px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
}

.markdown-preview {
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-input);
  color: var(--ink);
  overflow-y: auto;
}

.markdown-field .field-help {
  margin-top: 7px;
}

.tournament-registration-shell {
  width: min(620px, 100%);
  margin: 0 auto;
}

.tournament-registration-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.public-rounds {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

/* ======================================================================
   Rounds
   ====================================================================== */
.tournament-round-switcher {
  min-width: 0;
}

.tournament-round-tabs {
  margin-bottom: 14px;
  overflow-x: auto;
}

.tournament-round-tabs .tab {
  flex: 0 0 auto;
  min-width: 112px;
  white-space: nowrap;
}

.public-round {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.public-round-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
}

.public-round-title strong {
  color: var(--accent);
  text-transform: uppercase;
}

.tournament-sections {
  display: grid;
  gap: 22px;
}

/* ======================================================================
   Tournament list and cards
   ====================================================================== */
.tournament-list-section {
  display: grid;
  gap: 10px;
}

.tournament-list-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.tournament-list-heading h3 {
  margin: 0;
  color: var(--accent);
  font-size: 15px;
  text-transform: uppercase;
}

.tournament-list-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.row-card.tournament-card {
  align-items: flex-start;
  flex-wrap: wrap;
}

.tournament-card > .row-main {
  flex: 1 1 360px;
  overflow-wrap: anywhere;
}

.tournament-card-main {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.tournament-card-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 0;
}

.tournament-card-facts div {
  min-width: 0;
}

.tournament-card-facts dt {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.tournament-card-facts dd {
  margin: 0;
  color: var(--ink);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.tournament-card-actions {
  display: grid;
  flex: 0 0 auto;
  justify-items: end;
  gap: 8px;
  margin-left: auto;
}

.tournament-card-buttons {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: 8px;
}

.tournament-card-buttons > button {
  width: 100%;
  white-space: nowrap;
}

@media (max-width: 1000px) {
  .tournament-card-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

.compact-row-card {
  min-height: 54px;
  padding: 11px 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

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

/* ======================================================================
   Player profile
   ====================================================================== */
.profile-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  background:
    linear-gradient(90deg, rgb(var(--accent-rgb) / 0.16), transparent 48%),
    var(--panel);
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 30%, rgba(255, 177, 74, 0.95), rgb(var(--accent-rgb) / 0.62) 36%, rgba(12, 12, 12, 0.94) 72%),
    var(--surface-medallion);
  box-shadow: 0 0 28px rgb(var(--accent-rgb) / 0.22);
  color: var(--ink);
  font-size: 24px;
  font-weight: 950;
  overflow: hidden;
}

.compact-avatar {
  width: 64px;
  height: 64px;
  font-size: 18px;
  flex: 0 0 auto;
}

.profile-main h2 {
  margin: 0;
  font-size: 34px;
}

.profile-label {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.profile-info-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.profile-info-item {
  display: grid;
  gap: 2px;
  min-width: 138px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-well-soft);
}

.profile-info-item small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.profile-info-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.contact-list {
  display: grid;
  gap: 10px;
}

.contact-row {
  display: grid;
  grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.contact-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.contact-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.profile-rating {
  display: grid;
  justify-items: end;
  gap: 2px;
  min-width: 120px;
}

.profile-rating span {
  color: var(--accent);
  font-size: 42px;
  line-height: 1;
  font-weight: 950;
}

.profile-rating small {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

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

.challenge-user-card {
  display: grid;
  gap: 5px;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-2);
  text-align: left;
}

.challenge-user-card:hover,
.challenge-user-card.active {
  border-color: var(--accent);
}

.challenge-user-card span {
  font-weight: 950;
}

.challenge-user-card strong {
  color: var(--accent);
  font-size: 24px;
  line-height: 1;
}

.challenge-user-card small,
.challenge-team-card small {
  color: var(--muted);
  font-size: 12px;
}

/* ======================================================================
   Challenges
   ====================================================================== */
.challenge-track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 10px;
}

.challenge-subheader {
  margin-top: 18px;
}

.challenge-team-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  align-items: start;
  gap: 12px;
  min-width: 0;
  min-height: 140px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.challenge-team-card.completed {
  border-color: rgba(57, 194, 127, 0.62);
}

.challenge-team-card.current,
.challenge-team-card.available {
  border-color: rgb(var(--accent-rgb) / 0.7);
  background:
    linear-gradient(90deg, rgb(var(--accent-rgb) / 0.12), transparent 58%),
    var(--panel-2);
}

.challenge-team-card.locked {
  opacity: 0.58;
}

.challenge-team-main {
  display: grid;
  grid-template-columns: clamp(56px, 24%, 80px) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.challenge-team-main > div {
  min-width: 0;
}

.challenge-team-logo {
  width: 100%;
  max-width: 80px;
  height: auto;
  aspect-ratio: 1;
  justify-self: center;
  object-fit: contain;
  filter: drop-shadow(0 0 14px rgb(var(--accent-rgb) / 0.32));
}

.challenge-team-main span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.challenge-team-card strong {
  display: block;
  margin: 3px 0;
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.25;
}

.challenge-team-card .row-actions {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.challenge-team-card .status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 132px;
  max-width: 100%;
  height: 28px;
  min-height: 0;
  padding: 0 10px;
  text-align: center;
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 92px;
  padding: 16px;
  background: var(--panel-2);
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-card strong {
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.stats-tabs {
  max-width: 760px;
}

.stats-season-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 18px;
}

.stats-season-row label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.stats-season-row select {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-2);
  font-weight: 900;
}

.stat-rate {
  display: inline-grid;
  place-items: center;
  min-width: 58px;
  min-height: 28px;
  padding: 2px 9px 0;
}

/* ======================================================================
   Team cards and team detail
   ====================================================================== */
.team-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.team-stat-card {
  display: grid;
  grid-template-areas:
    "meta rate"
    "logo logo"
    "name name";
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  justify-items: center;
  gap: 12px;
  min-height: 190px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-2);
  text-align: left;
  cursor: pointer;
}

.team-stat-card:hover {
  border-color: rgb(var(--accent-rgb) / 0.72);
  background:
    linear-gradient(90deg, rgb(var(--accent-rgb) / 0.12), transparent 64%),
    var(--panel-2);
}

.team-stat-logo {
  grid-area: logo;
  width: 112px;
  height: 112px;
  object-fit: contain;
  filter: drop-shadow(0 0 14px rgb(var(--accent-rgb) / 0.28));
}

.team-stat-card span {
  grid-area: meta;
  justify-self: start;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.team-stat-card strong {
  grid-area: name;
  max-width: 100%;
  overflow-wrap: normal;
  font-size: 17px;
  line-height: 1.08;
  text-align: center;
}

.team-stat-rate {
  grid-area: rate;
  justify-self: end;
  display: grid;
  place-items: center;
  min-width: 62px;
  min-height: 38px;
  padding: 4px 10px 2px;
  border-radius: 7px;
  color: var(--on-accent);
  background: var(--accent);
  font-size: 18px;
  font-weight: 950;
}

.team-detail {
  display: grid;
  gap: 14px;
}

.team-detail-hero {
  display: grid;
  grid-template-columns: auto 116px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgb(var(--accent-rgb) / 0.12), transparent 60%),
    var(--panel-2);
}

.team-detail-logo {
  width: 116px;
  height: 116px;
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgb(var(--accent-rgb) / 0.34));
}

.team-detail-main {
  min-width: 0;
}

.team-detail-main h3 {
  margin: 0;
  font-size: 30px;
}

.team-classification {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin: 8px 0;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.team-classification.classified {
  color: var(--on-accent);
  background: var(--accent);
}

.team-classification.non-classified {
  color: var(--ink);
  background: var(--panel-3);
  border: 1px solid var(--line-strong);
}

.team-detail-rate {
  min-width: 110px;
}

.team-detail-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.team-detail-grid {
  align-items: start;
}

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

.settings-block {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.settings-block h3 {
  margin: 0 0 12px;
}

.avatar-settings-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.file-input {
  width: 100%;
  color: var(--muted);
}

.file-input::file-selector-button {
  margin-right: 10px;
  border: 1px solid var(--line-strong);
  color: var(--on-accent);
  background: var(--accent);
  cursor: pointer;
}

.small-note {
  margin: 8px 0 10px;
  font-size: 12px;
}

.panel {
  padding: 18px;
  background: var(--panel);
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header > div:first-child {
  min-width: 0;
}

.panel-header > .row-actions {
  flex: 0 0 auto;
  max-width: 100%;
}

.panel h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel h2 {
  color: var(--ink);
  font-size: 28px;
}

.panel h3 {
  color: var(--accent);
  font-size: 16px;
}

.panel h2 + .muted,
.panel h3 + .muted {
  margin-top: 6px;
}

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

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

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

.search-results {
  gap: 8px;
}

.suggestion-card {
  border-color: var(--line-strong);
  background:
    linear-gradient(90deg, rgb(var(--accent-rgb) / 0.12), transparent 42%),
    var(--panel-2);
}

.suggestion-card:hover {
  border-color: var(--accent);
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-well);
}

.row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.profile-challenge-next-card {
  margin-top: 12px;
  min-height: 116px;
}

.profile-challenge-next-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.profile-challenge-logo {
  flex: 0 0 86px;
  width: 86px;
  height: 86px;
  object-fit: contain;
  filter: drop-shadow(0 0 14px rgb(var(--accent-rgb) / 0.34));
}

.profile-challenge-actions {
  margin-top: 12px;
}

.game-challenge-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 150px;
  margin-top: 8px;
}

.game-challenge-logo {
  flex: 0 0 168px;
  width: 168px;
  height: 168px;
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgb(var(--accent-rgb) / 0.28));
}

.game-challenge-actions {
  margin-left: auto;
}

.row-main {
  min-width: 0;
}

.row-title {
  color: var(--ink);
  font-weight: 900;
}

.row-title.text-button {
  display: inline;
  text-align: left;
  font-size: inherit;
  line-height: 1.25;
}

.row-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.feedback-description {
  margin: 8px 0 0;
  color: var(--ink);
  line-height: 1.45;
  white-space: pre-wrap;
}

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

/* ======================================================================
   Status pills
   ====================================================================== */
.status {
  display: inline-grid;
  place-items: center;
  height: 28px;
  min-height: 0;
  padding: 2px 9px 0;
  border-radius: 7px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.status.open {
  color: var(--on-accent);
  background: var(--gold);
}

.status.pending {
  color: var(--on-accent);
  background: var(--accent);
}

.status.completed {
  color: #04120b;
  background: var(--good);
}

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

/* ======================================================================
   Tables
   ====================================================================== */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel-2);
}

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

th {
  color: var(--accent);
  background: var(--surface-well);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sort-button {
  min-height: 0;
  padding: 0;
  color: var(--accent);
  background: transparent;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
}

.sort-button:hover {
  color: var(--accent-hover);
}

td {
  color: var(--ink);
}

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

.rank {
  width: 54px;
  color: var(--gold);
  font-weight: 950;
}

/* ======================================================================
   Match scoring
   ====================================================================== */
.result-form {
  display: grid;
  gap: 14px;
}

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

.score-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.score-card h4 {
  margin: 0 0 12px;
  color: var(--accent);
  text-transform: uppercase;
}

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

.score-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.killzone-panel,
.tiebreaker-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.killzone-panel h3 {
  margin: 0 0 12px;
}

.killzone-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(120px, 180px);
  gap: 10px;
}

.killzone-review {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-2);
  font-weight: 900;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 900;
}

.checkbox-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.tiebreaker-menu {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.tiebreaker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.tiebreaker-list li {
  padding-right: 8px;
}

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

.tiebreaker-live {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.preview-summary,
.result-headline {
  padding: 12px 14px;
  border: 1px solid rgb(var(--accent-rgb) / 0.46);
  border-radius: 7px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgb(var(--accent-rgb) / 0.16), transparent 58%),
    var(--surface-medallion);
  font-size: 18px;
  font-weight: 950;
}

/* Match details: names and tournament text are content, not numeric metrics. */
.game-detail-header {
  align-items: flex-start;
  margin-bottom: 18px;
}

.game-detail-header > div:first-child {
  flex: 1 1 240px;
}

.game-detail-eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.game-detail-header h2 {
  font-size: 24px;
  line-height: 1.3;
  text-transform: none;
  overflow-wrap: anywhere;
}

.game-detail-header .game-detail-date {
  margin: 6px 0 0;
  font-size: 13px;
}

.game-detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.game-detail-navigation {
  justify-content: flex-start;
}

.game-detail-actions {
  margin-left: auto;
}

.game-detail-context {
  display: grid;
  grid-template-columns: minmax(0, 3fr) repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.game-detail-context > div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.game-detail-context dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.game-detail-context dd {
  margin: 8px 0 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.game-detail > [data-message]:empty {
  display: none;
}

.result-headline {
  margin-bottom: 14px;
}

.result-headline + .muted {
  margin: -6px 0 14px;
}

.score-grid + .tiebreaker-panel,
.score-grid + .elo-detail-card,
.tiebreaker-panel + .elo-detail-card {
  margin-top: 14px;
}

.elo-detail-card {
  box-shadow: none;
}

.preview-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.preview-step {
  display: grid;
  gap: 6px;
  min-height: 70px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-well);
}

.preview-step span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.preview-step strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.preview-step.winner {
  border-color: rgba(57, 194, 127, 0.7);
}

.preview-step.winner strong {
  color: var(--good);
}

.preview-step.skipped {
  opacity: 0.62;
}

.preview-step.pending {
  border-color: rgba(255, 177, 74, 0.62);
}

.review-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.review-lines {
  display: grid;
  gap: 8px;
}

.review-score-card .row-card {
  min-height: 42px;
  padding: 9px 10px;
}

.total-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-weight: 950;
}

.admin-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ======================================================================
   Admin
   ====================================================================== */
.admin-tournament-form {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.admin-save-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.autosave-status {
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.autosave-status[data-status="saving"],
.autosave-status[data-status="pending"] {
  color: var(--accent);
}

.autosave-status[data-status="saved"] {
  color: var(--success);
}

.autosave-status[data-status="error"] {
  color: var(--danger);
}

.compact-admin-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.tournament-settings-form {
  margin: 0;
  padding-top: 0;
  border-top: 0;
}

.admin-tournament-list {
  margin-top: 14px;
}

.admin-tournament-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.admin-tournament-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-subpanel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.admin-subpanel .table-wrap,
.admin-subpanel .row-card {
  background: var(--surface-well);
}

.admin-participant-form {
  display: grid;
  gap: 8px;
}

.admin-participant-form textarea {
  min-height: 96px;
}

.tournament-info-tabs {
  margin-bottom: 4px;
  min-width: 0;
  overflow-x: auto;
}

.tournament-participant-admin {
  display: grid;
  gap: 12px;
}

.participant-admin-note {
  margin-top: -4px;
}

.participant-admin-row {
  align-items: flex-start;
}

.participant-admin-row .row-main {
  min-width: 0;
}

.participant-admin-controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(240px, 0.9fr);
  gap: 12px;
  margin-top: 12px;
}

.participant-faction-control,
.participant-replace-control {
  display: grid;
  gap: 8px;
}

.participant-faction-control .field {
  margin: 0;
}

.participant-faction-control .small-button {
  justify-self: start;
}

.participant-replace-control label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.participant-replace-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.participant-replace-row select {
  flex: 1 1 230px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface-input);
}

.participant-replace-row .combo-field {
  flex: 1 1 230px;
  margin: 0;
}

.participant-replace-row .combo-control {
  min-width: 0;
}

.tournament-tiebreakers {
  display: grid;
  gap: 10px;
  padding: 10px 0;
}

.tiebreaker-rank-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tiebreaker-rank-field {
  display: grid;
  gap: 6px;
}

.tiebreaker-rank-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.tiebreaker-rank-field select {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface-input);
}

.rules-file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.rules-file-row input[type="file"] {
  min-height: auto;
  padding: 9px 10px;
  color: var(--muted);
}

.tournament-rules-link {
  margin: 8px 0 16px;
  font-size: 13px;
  font-weight: 900;
}

.tournament-rules-link a {
  color: var(--accent);
}

.seed-input {
  width: 72px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface-input);
}

.admin-contact-cell {
  display: grid;
  gap: 4px;
  min-width: 180px;
  color: var(--muted);
  font-size: 13px;
}

.admin-contact-cell span {
  overflow-wrap: anywhere;
}

.admin-password-card {
  margin-top: 14px;
}

.admin-password-value {
  max-width: 220px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-input);
  color: var(--gold);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.rating-input {
  width: 92px;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--surface-input);
}

/* ======================================================================
   Venues and rating pills
   ====================================================================== */
.venue-tabs {
  width: 100%;
  max-width: none;
  margin-bottom: 12px;
}

.venue-tabs .tab {
  flex: 1 1 0;
}

.profile-ratings {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 22px;
}

.tournament-tiebreaker-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-icon-button,
.dialog-close-button {
  display: grid;
  place-items: center;
  width: var(--button-height);
  height: var(--button-height);
  flex: 0 0 var(--button-height);
  padding: 0;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--panel-2);
}

.info-icon-button:hover,
.info-icon-button:focus-visible,
.dialog-close-button:hover,
.dialog-close-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

/* ======================================================================
   Dialogs
   ====================================================================== */
.tiebreaker-help-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tiebreaker-help-dialog::backdrop {
  background: var(--overlay);
}

.tiebreaker-help-content {
  padding: 20px;
}

.tiebreaker-help-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.tiebreaker-help-header h3,
.tiebreaker-help-header p {
  margin: 0;
}

.tiebreaker-help-header p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.tiebreaker-help-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.tiebreaker-help-list > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.tiebreaker-help-list dt {
  color: var(--accent);
  font-weight: 950;
}

.tiebreaker-help-list dd {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

/* Confirmation modal shared by every destructive action. */
.confirm-dialog {
  width: min(460px, calc(100vw - 32px));
}

.confirm-dialog-message {
  margin: 0;
  line-height: 1.5;
}

.confirm-dialog-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: 7px;
  color: var(--danger);
  background: var(--panel-2);
  font-weight: 900;
  line-height: 1.45;
}

.confirm-dialog-actions {
  margin-top: 18px;
}

/* ======================================================================
   Light theme: what the tokens cannot express
   ====================================================================== */
:root[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.92);
}

:root[data-theme="light"] .brand-panel {
  background:
    linear-gradient(140deg, rgba(243, 109, 13, 0.12), rgba(255, 255, 255, 0.98) 34%),
    linear-gradient(90deg, var(--accent) 0 5px, transparent 5px),
    var(--surface);
}

/* What is left of the old light-theme patch block. Everything else it used to
   repaint now comes from --surface-input / --surface-well, which the light
   palette overrides directly.

   These four cannot: .combo-input and .rules-file-row carry no background of
   their own, and .password-toggle / .admin-password-value deliberately use
   --muted and --gold, which need overriding on a pale surface. */
:root[data-theme="light"] .combo-input,
:root[data-theme="light"] .rules-file-row {
  background: var(--surface);
}

:root[data-theme="light"] .password-toggle,
:root[data-theme="light"] .admin-password-value {
  color: var(--ink);
}

/* ======================================================================
   Tournament summary metrics
   ====================================================================== */
/* Tournament summary needs unequal tracks: labels like Season carry names, not counters. */
.profile-grid.tournament-metrics {
  grid-template-columns:
    minmax(0, 1.05fr)
    minmax(0, 0.9fr)
    minmax(0, 0.75fr)
    minmax(0, 1.15fr)
    minmax(220px, 1.75fr);
}

.tournament-metrics .metric-card {
  min-width: 0;
}

.tournament-metrics .metric-card strong {
  overflow-wrap: anywhere;
  font-size: clamp(22px, 2.4vw, 28px);
}

.admin-tournament-detail .admin-subpanel {
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
}

/* ======================================================================
   Responsive: 900px and below
   ====================================================================== */
@media (max-width: 900px) {
  .auth-layout,
  .layout,
  .grid-2,
  .profile-hero,
  .settings-grid,
  .score-grid {
    grid-template-columns: 1fr;
  }

  .profile-rating {
    justify-items: start;
  }

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

  .auth-layout {
    padding: 12px;
  }

  .brand-panel {
    min-height: 320px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-title {
    width: 100%;
    flex-wrap: nowrap;
    gap: 12px;
  }

  .topbar-user-controls {
    order: 1;
  }

  .topbar-player,
  .topbar-user-controls .avatar-button {
    display: none;
  }

  .menu-toggle {
    display: inline-grid;
    flex: 0 0 auto;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 24;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    background: var(--overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 25;
    width: min(320px, 86vw);
    height: 100dvh;
    min-height: 0;
    padding: 18px;
    overflow-y: auto;
    border-radius: 0 8px 8px 0;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .sidebar-logout {
    margin-top: auto;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .app-brand {
    flex: 1 1 auto;
    order: 2;
    min-width: 0;
    padding: 0;
    border-radius: 0;
    border-right: 0;
  }

  .app-brand > div {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .app-logo {
    flex: 0 0 auto;
  }

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

  .participant-admin-controls {
    grid-template-columns: 1fr;
  }

  .team-detail-hero {
    grid-template-columns: auto 96px minmax(0, 1fr);
  }

  .team-detail-logo {
    width: 96px;
    height: 96px;
  }

  .team-detail-rate,
  .team-detail-hero > a {
    justify-self: start;
  }

  .profile-grid.tournament-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tournament-metrics .metric-card:last-child {
    grid-column: 1 / -1;
  }
}

/* ======================================================================
   Team tournaments and pairing
   ====================================================================== */
.teams-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.teams-layout > .message {
  grid-column: 1 / -1;
}

.teams-page-actions {
  display: flex;
  justify-content: flex-end;
}

.teams-search,
.team-roster-member-grid,
.team-roster-members,
.team-match-games {
  display: grid;
  gap: 10px;
}

.teams-search {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  margin-bottom: 16px;
}

.team-profile-panel:not([hidden]) {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.team-profile-tabs {
  height: auto;
  min-height: 50px;
}

.team-members-panel > h3 {
  margin-bottom: 14px;
}

.team-members-panel > .list + h3 {
  margin-top: 28px;
}

.team-management-panel > form + form,
.team-management-panel > .row-actions {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.team-management-panel [data-team-invite-message] {
  padding: 10px 12px;
  border: 1px solid currentColor;
  border-radius: 7px;
  overflow-wrap: anywhere;
}

.team-description {
  margin-block: 28px;
}

.team-hero {
  display: flex;
  align-items: center;
  gap: 14px;
}

.team-logo {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

.team-roster-player-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.team-roster-members span,
.team-match-game {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.team-match-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.team-pairing-page {
  display: grid;
  gap: 18px;
}

.team-pairing-workspace > .team-match-card {
  margin: 0;
  border: 0;
  padding: 0;
  background: transparent;
}

.team-pairing-workspace > .team-match-card > .row-main > .row-title {
  font-size: 26px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.team-pairing-workspace .team-match-score {
  font-size: 21px;
  line-height: 1.4;
}

.team-match-result {
  margin-top: 10px;
  color: #f4f4f4;
  font-size: 21px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.team-match-result .team-match-score,
.team-match-result-note {
  margin-top: 4px;
  color: #b9b9b9;
  font-weight: 600;
}

.team-match-result-note {
  font-size: 13px;
}

.team-pairing-details {
  margin-top: 14px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.team-match-preview-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

[data-team-match-previews] .list,
.team-match-preview .team-match-games {
  grid-template-columns: minmax(0, 1fr);
}

.team-match-preview-header > .row-main {
  flex: 1 1 320px;
}

.team-match-preview-header > button {
  flex: 0 0 auto;
}

.team-pairing-details[open] {
  padding-bottom: 12px;
}

.team-pairing-details > summary {
  min-height: var(--button-height);
  padding: 10px 0;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.team-pairing-details > summary:hover,
.team-pairing-details > summary:focus-visible {
  color: var(--ink);
}

.team-pairing-details > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.team-pairing-selections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.team-pairing-side {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.team-pairing-side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.team-pairing-side .status-pill {
  padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.team-pairing-choices,
.team-pairing-choices div {
  margin: 0;
}

.team-pairing-choices {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.team-pairing-choices div {
  display: grid;
  grid-template-columns: minmax(80px, auto) minmax(0, 1fr);
  gap: 10px;
}

.team-pairing-choices dt {
  color: var(--muted);
}

.team-pairing-choices dd {
  font-weight: 700;
  text-align: right;
}

.team-match-progress {
  margin: 6px 0 8px;
  color: var(--muted);
  font-size: 0.875em;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.captain-pairing-progress {
  margin-top: 6px;
  font-weight: 700;
}

.team-match-games,
.team-captain-control {
  margin-top: 10px;
}

.team-match-game,
.team-pairing-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.team-match-game > .row-main {
  flex: 1;
  overflow-wrap: anywhere;
}

.team-match-game > button,
.team-game-actions {
  flex: 0 0 auto;
  white-space: nowrap;
}

.team-game-actions {
  display: grid;
}

.team-roll-controls {
  display: grid;
  gap: 12px;
}

.team-roll-controls input {
  min-width: 0;
  width: 100%;
}

.team-pairing-undo {
  margin-top: 14px;
  justify-content: flex-start;
}

.team-pairing-control label {
  display: grid;
  flex: 1;
  gap: 6px;
  color: var(--muted);
}

.team-pairing-control[data-team-pairing-form="environment"] {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.team-pairing-control[data-team-pairing-form="environment"] label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.team-pairing-control[data-team-pairing-form="environment"] select {
  width: 100%;
  min-width: 0;
}

.team-pairing-control[data-team-pairing-form="environment"] button {
  justify-self: start;
}

.team-admin-pairing h4 {
  margin: 0 0 10px;
}

.team-admin-pairing .team-pairing-control {
  flex-wrap: wrap;
  align-items: flex-end;
}

.team-admin-pairing .team-pairing-control label,
.team-admin-pairing select {
  min-width: 0;
  max-width: 100%;
}

.team-pairing-override {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.team-pairing-override-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.team-match-admin-actions {
  align-items: end;
}

.team-match-admin-actions label {
  display: grid;
  gap: 6px;
}

.team-roster-editor-dialog {
  width: min(680px, calc(100% - 24px));
}

.team-roster-admin-row.is-muted {
  opacity: 0.65;
}

/* ======================================================================
   Responsive: 760px and below
   ====================================================================== */
@media (max-width: 760px) {
  .game-detail-context {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .game-detail-tournament {
    grid-column: 1 / -1;
  }

  .profile-ratings {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .profile-rating {
    min-width: 96px;
    justify-items: start;
  }

  .profile-rating span {
    font-size: 34px;
  }

  .layout > .content {
    width: 100%;
    min-width: 0;
  }

  .admin-tournament-detail,
  .page-tabs .tab {
    min-width: 0;
  }

  .admin-tournament-detail .tournament-info-tabs {
    width: 100%;
    min-width: 0;
    overflow-x: auto;
  }

  .admin-tournament-detail .tournament-info-tabs .tab {
    flex: 0 0 auto;
    min-width: 108px;
  }

  .admin-tournament-detail > .admin-tournament-header {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
    min-width: 0;
  }

  .admin-tournament-header > .admin-tournament-header-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    width: 100%;
  }

  .admin-tournament-detail .admin-tournament-header-actions > button {
    width: 100%;
    min-width: 0;
    white-space: normal;
  }

  .grid-3,
  .table-admin-controls,
  .round-setup-match-grid,
  .round-setup-match-grid.has-table {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .team-roster-player-row,
  .teams-search,
  .team-pairing-selections {
    grid-template-columns: 1fr;
  }

  .team-match-game,
  .team-pairing-control,
  .team-pairing-override-row {
    align-items: stretch;
  }

  .team-match-game,
  .team-pairing-control {
    flex-direction: column;
  }

  .team-pairing-override-row {
    grid-template-columns: 1fr;
  }

  .team-pairing-side-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .team-pairing-choices dd {
    text-align: left;
  }
}

/* Notifications inbox */

/* ======================================================================
   Notification inbox
   ====================================================================== */
.notification-control {
  position: relative;
}

.notification-control[hidden],
.notification-panel[hidden],
.notification-badge[hidden] {
  display: none !important;
}

.team-start-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 24px;
}

.team-start-dialog::backdrop { background: var(--overlay); }
.team-table-setup { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 20px 0; }
.team-table-setup select { width: 100%; min-width: 0; }
.team-table-setup-card { padding: 14px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.team-table-image-field { margin-top: 12px; align-items: start; }
.team-table-image-field input[type="file"] {
  max-width: 100%;
  min-height: calc(var(--button-height) + 14px);
  padding: 6px 12px;
}
.team-table-image { max-width: 100%; max-height: 300px; width: auto; height: auto; border-radius: 6px; margin: 8px 0; }
.team-table-image:not([hidden]) { display: block; }
.team-table-choice-images { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.team-table-choice-images figure { margin: 0; max-width: 100%; }
.team-table-choice-images figcaption { color: var(--muted); font-size: 0.85rem; }

.team-mission-pool { margin: 16px 0; }
.team-mission-options { display: flex; flex-wrap: wrap; gap: 8px; }
.team-mission-option { display: flex; flex-direction: column; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 6px; }
.team-mission-option small { color: var(--muted); margin-top: 4px; }
.team-mission-option.is-banned { color: var(--muted); background: color-mix(in srgb, var(--danger) 12%, var(--panel-2)); border-color: var(--danger); }
.team-mission-option.is-assigned { background: color-mix(in srgb, var(--good) 12%, var(--panel-2)); border-color: var(--good); }
.team-pairing-turn { color: var(--accent); font-weight: 600; }
.team-roll-history { overflow-wrap: anywhere; }

.notification-toggle {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--button-height);
  height: var(--button-height);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  line-height: 1;
}

.notification-toggle:hover,
.notification-toggle:focus-visible,
.notification-toggle[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.notification-toggle svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border: 2px solid var(--bg);
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.notification-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(390px, calc(100vw - 24px));
  max-height: min(620px, calc(100vh - 86px));
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.48);
}

.notification-panel-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 15px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.notification-panel-header h2 {
  margin: 0;
  font-size: 17px;
}

.notification-list {
  display: grid;
}

.notification-item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 11px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.notification-item:last-child {
  border-bottom: 0;
}

.notification-item:hover,
.notification-item:focus-visible {
  color: var(--ink);
  background: var(--panel-2);
}

.notification-item.is-unread::after {
  content: "";
  position: absolute;
  top: 18px;
  right: 13px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.notification-item-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--accent);
  background: rgb(var(--accent-rgb) / 0.12);
  font-size: 17px;
  font-weight: 800;
}

.notification-item-copy {
  min-width: 0;
  padding-right: 10px;
}

.notification-item-title,
.notification-item-meta,
.notification-item-time {
  display: block;
}

.notification-item-title {
  font-size: 14px;
  font-weight: 750;
  line-height: 1.35;
}

.notification-item-meta,
.notification-item-time {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.notification-empty,
.notification-error,
.notification-loading {
  padding: 24px 18px;
  color: var(--muted);
  text-align: center;
}

.notification-retry {
  margin-top: 12px;
}

.notification-target-highlight {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  animation: notification-target-pulse 1.8s ease-out;
}

@keyframes notification-target-pulse {
  0%, 35% { box-shadow: 0 0 0 7px rgb(var(--accent-rgb) / 0.22); }
  100% { box-shadow: 0 0 0 0 rgb(var(--accent-rgb) / 0); }
}

/* ======================================================================
   Responsive: 560px and below
   ====================================================================== */
@media (max-width: 560px) {
  .game-detail-context > div:not(.game-detail-tournament) {
    padding: 12px 10px;
  }

  .game-detail-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .search-row,
  .profile-grid,
  .score-meta-grid,
  .killzone-grid,
  .tiebreaker-grid,
  .tiebreaker-rank-list,
  .preview-steps,
  .rules-file-row,
  .score-fields {
    grid-template-columns: 1fr;
  }

  .row-card {
    align-items: stretch;
    flex-direction: column;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .tournament-card > .row-main {
    flex-basis: auto;
  }

  .tournament-card-actions {
    justify-items: start;
    margin-left: 0;
  }

  .admin-tournaments-panel > .panel-header {
    align-items: flex-start;
    flex-direction: column;
    overflow-wrap: anywhere;
  }

  .game-challenge-card-body {
    align-items: flex-start;
    flex-direction: column;
  }

  .game-challenge-actions {
    margin-left: 0;
  }

  .layout {
    width: min(100% - 24px, 1240px);
  }

  .team-card-grid,
  .team-detail-hero {
    grid-template-columns: 1fr;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .team-stat-card {
    grid-template-areas:
      "meta rate"
      "logo logo"
      "name name";
  }

  .floating-controls {
    top: 10px;
    right: 10px;
    gap: 6px;
  }

  .topbar {
    padding: 10px var(--topbar-controls-gutter) 10px 12px;
  }

  .topbar-title,
  .app-brand {
    gap: 8px;
  }

  .app-logo {
    width: 32px;
    height: 32px;
  }

  .app-brand-name {
    font-size: 12px;
  }

  .app-brand-subtitle {
    font-size: 9px;
  }

  .theme-toggle {
    font-size: 19px;
  }

  .profile-grid.tournament-metrics {
    grid-template-columns: 1fr;
  }

  .tournament-metrics .metric-card:last-child {
    grid-column: auto;
  }

  .notification-panel {
    position: fixed;
    top: 58px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: calc(100vh - 70px);
  }

  :root {
    --topbar-controls-gutter: calc(var(--button-height) * 3 + 22px);
  }
}

@media (max-width: 360px) {
  .app-brand-subtitle {
    display: none;
  }
}

.tournament-heading,
.tournament-card-heading,
.tournament-logo-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.team-pairing-control > .field {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.tournament-heading > div,
.tournament-card-heading > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tournament-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  flex: 0 0 auto;
  border-radius: 10px;
}

.tournament-card .tournament-logo {
  width: 56px;
  height: 56px;
}

.tournament-logo-controls {
  flex-wrap: wrap;
}

.tournament-logo-controls input[type="file"] {
  flex: 1 1 220px;
  min-width: 0;
  max-width: 100%;
}

.tournament-logo[hidden] {
  display: none;
}

.admin-tournament-detail > .admin-tournament-header,
.public-tournament-header {
  flex-wrap: wrap;
}

.panel-header > .tournament-heading {
  min-width: min(100%, 260px);
  max-width: 100%;
}

.admin-tournament-header > .row-actions,
.public-tournament-header > .row-actions {
  max-width: 100%;
  flex-wrap: wrap;
}
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
  gap: 16px;
  margin-block: 20px;
}
.achievement-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: inherit;
  text-decoration: none;
  text-align: center;
  overflow-wrap: anywhere;
}
.achievement-card:hover, .achievement-card:focus-visible {
  border-color: var(--accent);
  background: var(--panel);
}
.achievement-picture { width: 96px; height: 96px; object-fit: contain; border-radius: 12px; }
.achievement-emoji { display: grid; place-items: center; width: 96px; height: 96px; font-size: 64px; }
.achievement-detail { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px; overflow-wrap: anywhere; }
.achievement-detail p, .achievement-card .muted { white-space: pre-wrap; }
.achievement-create form { display: grid; gap: 16px; }
.achievement-create [hidden] { display: none !important; }
.achievement-create .field, .achievement-create .tiebreaker-help-header { margin: 0; }
.achievement-create [data-achievement-message]:empty { display: none; }
.achievement-create label, [data-achievement-award] label { display: grid; gap: 8px; }
.profile-achievements { margin-block: 16px; }
.profile-progress-panels { align-items: start; }
.profile-progress-panels .profile-achievements { margin: 0; }
.profile-achievement-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.profile-achievement-item {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); text-decoration: none; overflow-wrap: anywhere;
}
.profile-achievement-item:hover, .profile-achievement-item:focus-visible { border-color: var(--accent); }
.profile-achievement-item .achievement-picture, .profile-achievement-item .achievement-emoji {
  width: 28px; height: 28px; flex: 0 0 28px; font-size: 24px; border-radius: 4px;
}
.profile-achievement-item strong { font-size: 14px; min-width: 0; }
.profile-achievement-item .achievement-emoji { line-height: 1; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }
[data-achievement-award] > .primary-button { margin-top: 20px; }
.achievement-delete-actions { margin-top: 24px; }
.achievement-edit-actions { margin-bottom: 20px; }
[data-achievement-roster] { margin-block: 16px; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
[data-achievement-award] .achievement-member { display: flex; align-items: center; gap: 10px; padding-block: 6px; }
.achievement-member input { width: auto; }
.registration-payment {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.registration-payment label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  cursor: pointer;
}

.registration-payment input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.registration-payment [data-payment-status]:empty {
  display: none;
}

.team-pairing-log { min-width: 0; }
.team-pairing-log > h3 { margin-bottom: 10px; }
.team-pairing-log > .muted { margin-bottom: 18px; }
.team-pairing-log-list { list-style: none; padding: 0 10px 0 0; margin: 0; max-height: 520px; overflow: auto; }
.team-pairing-log-list > li { display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 16px; padding: 16px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.team-pairing-log-list > li:first-child { border-top: 0; padding-top: 0; }
.team-pairing-log-list p { margin: 0; line-height: 1.5; }
.team-pairing-log-list time { font-size: 13px; line-height: 1.6; }
.team-pairing-log-details { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; line-height: 1.5; }
@media (max-width: 640px) {
  .team-pairing-log-list > li { grid-template-columns: minmax(0, 1fr); gap: 6px; }
}
