/* /assets/bracket.css */

:root {
  --bg: #f3f5f7;
  --paper: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-hover: #f6f7f8;
  --ink: #111111;
  --muted: #5d626b;
  --field-ink: #1f2933;
  --line: #111111;
  --king-line: #555555;
  --border: #d7dce2;
  --control-border: #b9c0ca;
  --active-bg: #e8edf3;
  --active-ink: #0f172a;
  --primary-bg: #0f172a;
  --primary-hover: #1f2937;
  --primary-ink: #ffffff;
  --card-border: #888888;
  --card-hover: #111111;
  --row-ink: #08110a;
  --row-divider: rgba(17, 17, 17, 0.28);
  --score-bg: rgba(255, 255, 255, 0.32);
  --score-ink: #111111;
  --winner-bg: #d8f8d8;
  --loser-bg: #ffd9d9;
  --male: #1687d9;
  --female: #c735a8;
  --status-current: #15803d;
  --status-upcoming: #2563eb;
  --warning-border: #d97706;
  --warning-bg: #fffbeb;
  --warning-ink: #92400e;
  --success-border: #16a34a;
  --success-bg: #ecfdf5;
  --success-ink: #166534;
  --error-border: #dc2626;
  --error-bg: #fef2f2;
  --error-ink: #991b1b;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.16);
  --dialog-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  --menu-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
  --backdrop: rgba(15, 23, 42, 0.42);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d1117;
  --paper: #111821;
  --surface: #161b22;
  --surface-soft: #202733;
  --surface-hover: #252d3a;
  --ink: #eef2f8;
  --muted: #a8b1bf;
  --field-ink: #dce3ec;
  --line: #d6dce5;
  --king-line: #7e8a9a;
  --border: #303946;
  --control-border: #4b5565;
  --active-bg: #29364a;
  --active-ink: #f8fbff;
  --primary-bg: #3b82f6;
  --primary-hover: #2563eb;
  --primary-ink: #ffffff;
  --card-border: #6b7788;
  --card-hover: #dbe5f2;
  --row-ink: #eef2f8;
  --row-divider: rgba(214, 220, 229, 0.34);
  --score-bg: rgba(255, 255, 255, 0.08);
  --score-ink: #eef2f8;
  --winner-bg: #103a25;
  --loser-bg: #461d23;
  --male: #68b7ff;
  --female: #ff7adf;
  --status-current: #86efac;
  --status-upcoming: #93c5fd;
  --warning-border: #f59e0b;
  --warning-bg: #422006;
  --warning-ink: #fde68a;
  --success-border: #22c55e;
  --success-bg: #052e1a;
  --success-ink: #bbf7d0;
  --error-border: #f87171;
  --error-bg: #451a1a;
  --error-ink: #fecaca;
  --shadow: 0 14px 42px rgba(0, 0, 0, 0.38);
  --dialog-shadow: 0 24px 70px rgba(0, 0, 0, 0.58);
  --menu-shadow: 0 16px 40px rgba(0, 0, 0, 0.46);
  --backdrop: rgba(0, 0, 0, 0.58);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

.is-hidden {
  display: none !important;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

body.has-mobile-menu {
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.has-mobile-menu .topbar {
  flex: 0 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar__left {
  flex: 0 0 auto;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
}

.brand-title {
  line-height: 1;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: 112px;
  height: 98px;
  max-width: min(112px, 38vw);
  object-fit: contain;
  object-position: center;
}

.brand-logo--light {
  display: none;
}

:root[data-theme="dark"] .brand-logo--dark {
  display: none;
}

:root[data-theme="dark"] .brand-logo--light {
  display: block;
}

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

.topbar__right {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  position: relative;
}

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

.topbar-tools {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.topbar-tools-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 260;
  display: none;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 12px;
  width: min(640px, calc(100vw - 28px));
  padding: 12px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--dialog-shadow);
}

body.tools-menu-open .topbar-tools-panel {
  display: grid;
}

.tools-section {
  display: grid;
  align-content: start;
  gap: 8px;
}

.tools-section[hidden],
.tools-section .btn[hidden],
.tools-section .select-control[hidden] {
  display: none !important;
}

.tools-section__title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.tools-section .btn,
.tools-section .select-control {
  width: 100%;
}

body.is-tournament-list-page [data-bracket-only] {
  display: none !important;
}

body.is-tournament-list-page .topbar-tools-panel {
  grid-template-columns: 1fr;
  width: min(260px, calc(100vw - 28px));
}

.mobile-menu-toggle,
.mobile-menu-head,
.mobile-menu-backdrop,
.mobile-tournament-info {
  display: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--control-border);
  background: var(--surface);
  color: var(--ink);
  min-height: 36px;
  padding: 0 13px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.btn.mobile-menu-toggle {
  display: none;
}

.is-pwa-standalone [data-pwa-install],
[data-pwa-install][hidden] {
  display: none !important;
}

.select-control {
  min-height: 36px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 30px 0 10px;
  font: inherit;
}

.btn:hover {
  background: var(--surface-hover);
}

.btn.is-active {
  border-color: var(--active-ink);
  background: var(--active-bg);
  color: var(--active-ink);
}

.btn[aria-pressed="true"] {
  border-color: var(--active-ink);
  background: var(--active-bg);
  color: var(--active-ink);
}

.btn-icon {
  width: 36px;
  padding: 0;
  font-size: 18px;
  font-weight: 800;
}

.zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.zoom-level {
  min-width: 48px;
  color: var(--field-ink);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.page {
  position: relative;
  padding: 18px 24px 36px;
}

body.has-mobile-menu .page {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: auto;
  overflow: hidden;
  padding-bottom: 18px;
}

.page--manager {
  max-width: 1228px;
}

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

.desktop-info-bar {
  position: relative;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
}

.desktop-info-toggle[hidden] {
  display: none;
}

.tournament-info {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  max-width: 1200px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--field-ink);
}

.tournament-info--popover {
  position: absolute;
  z-index: 90;
  top: 48px;
  left: 24px;
  right: 24px;
  max-width: 1200px;
  box-shadow: var(--dialog-shadow);
}

.tournament-info--popover:not(.is-open) {
  display: none;
}

.tournament-info.is-hidden {
  display: none;
}

.tournament-info__description {
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.tournament-info__flyer {
  display: block;
  width: min(420px, 100%);
  max-height: 280px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.tournament-info__facts,
.tournament-info__chips,
.tournament-info__payouts,
.tournament-info__ledger {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.tournament-info__chips span,
.tournament-info__payouts span,
.tournament-info__ledger span {
  display: inline-flex;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--field-ink);
}

.tournament-list {
  display: grid;
  gap: 24px;
  width: min(100%, 760px);
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
  background: transparent;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

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

.tournament-list__head {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.tournament-list__head h2 {
  margin: 0;
  font-size: 20px;
}

.tournament-list__hint {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.tournament-list__group h2 {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.tournament-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.tournament-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--ink);
  text-decoration: none;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.tournament-card:hover {
  border-color: var(--control-border);
  background: var(--surface-hover);
}

.tournament-card__media {
  order: 2;
  border-block: 1px solid var(--border);
  background: var(--surface);
}

.tournament-card__media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
}

.tournament-card__media--empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 24px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}

.tournament-card__body {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 14px;
}

.tournament-card__head {
  order: 1;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface-soft);
}

.tournament-card__identity {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.tournament-card__head strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tournament-card__top,
.tournament-card__chips,
.tournament-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
}

.tournament-list .tournament-card__meta {
  display: none;
}

.tournament-card__description {
  order: 3;
  margin: 0;
  padding: 14px 16px 0;
}

.tournament-card__chips {
  order: 4;
  padding: 12px 16px 16px;
}

.tournament-card__head span,
.tournament-card__meta,
.tournament-card__description,
.tournament-list__empty,
.tournament-list__loading {
  color: var(--muted);
  font-size: 13px;
}

.tournament-card__description {
  line-height: 1.45;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.tournament-card__status,
.tournament-card__team-count {
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.tournament-card__status {
  padding: 4px 7px;
}

.tournament-card__team-count {
  flex: 0 0 auto;
  padding: 6px 9px;
}

.tournament-card__status--current {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.12);
  color: var(--status-current);
}

.tournament-card__status--upcoming {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.1);
  color: var(--status-upcoming);
}

.tournament-card__subline {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tournament-card__chips span {
  display: inline-flex;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--field-ink);
  font-size: 12px;
  font-weight: 700;
}

.tournament-card__chips span:first-child {
  border-color: var(--control-border);
}

.pending-signup {
  width: min(980px, calc(100vw - 28px));
  margin: 28px auto;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 16px;
  align-items: start;
}

.pending-signup__card,
.pending-signup__list {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pending-signup__card {
  padding: 20px;
}

.pending-signup__card h2 {
  margin: 0;
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1;
}

.pending-signup__kicker {
  width: fit-content;
  margin-bottom: 8px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.pending-signup__schedule,
.pending-signup__description,
.pending-signup__hint,
.pending-signup__empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.pending-signup__card p {
  margin: 14px 0 0;
  color: var(--field-ink);
  font-size: 16px;
  font-weight: 800;
}

.pending-signup__description {
  margin-top: 12px;
  white-space: pre-wrap;
}

.pending-signup__facts,
.pending-signup__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
}

.pending-signup__facts span {
  display: inline-flex;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--field-ink);
  font-size: 12px;
  font-weight: 800;
}

.pending-signup__status {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pending-signup__status select {
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--field-ink);
}

.pending-signup__list {
  max-height: min(60dvh, 560px);
  overflow: auto;
  padding: 12px;
}

.pending-signup__list h3 {
  position: sticky;
  top: -12px;
  z-index: 1;
  margin: -12px -12px 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.pending-signup__row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  color: var(--field-ink);
  font-size: 13px;
}

.pending-signup__row:last-child {
  border-bottom: 0;
}

.pending-signup__row strong {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .admin-page {
    padding: 14px;
  }

  .admin-topbar .topbar__right,
  .admin-dashboard__actions {
    justify-content: flex-start;
  }

  .admin-dashboard__head,
  .admin-panel__head {
    display: grid;
  }

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

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

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .admin-tournament-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .admin-tournament-card__meta {
    text-align: left;
  }

  .admin-tournament-card__actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .admin-user-card {
    align-items: stretch;
    display: grid;
  }

  .admin-user-card__actions {
    justify-content: space-between;
  }

  .tournament-list {
    padding: 10px;
  }

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

  .tournament-card__head {
    align-items: flex-start;
  }

  .tournament-card__media img {
    max-height: none;
  }

  .pending-signup {
    width: auto;
    margin: 12px;
    grid-template-columns: 1fr;
  }

  .pending-signup__card {
    padding: 16px;
  }
}

.setup-panel {
  display: grid;
  gap: 14px;
  max-width: 1180px;
  margin: 0 0 18px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.setup-panel.is-collapsed {
  display: none;
}

.setup-panel.is-locked .entry-panel,
.setup-panel.is-locked .setup-options--bracket {
  opacity: 0.7;
}

.manager-lock-notice {
  padding: 11px 13px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--field-ink);
  font-size: 14px;
  line-height: 1.35;
}

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

.setup-grid--details,
.setup-grid--money {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.field--wide {
  grid-column: span 2;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--field-ink);
  font-size: 13px;
  font-weight: 700;
}

.field--pin-pair {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field--pin-pair label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 14px/1.35 Arial, Helvetica, sans-serif;
}

.field input,
.field select {
  height: 38px;
  padding: 0 10px;
}

.field input[readonly] {
  cursor: default;
  color: var(--field-ink);
}

.field textarea {
  min-height: 210px;
  padding: 10px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
}

.board-panel {
  max-width: 360px;
}

.field textarea.board-list {
  min-height: 132px;
}

.field textarea.small-list,
.field textarea.details-text {
  min-height: 96px;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.flyer-upload {
  align-content: start;
}

.flyer-preview {
  min-height: 118px;
  border: 1px dashed var(--control-border);
  border-radius: 8px;
  background: var(--surface-soft);
  overflow: hidden;
}

.flyer-preview img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
}

.flyer-preview__empty {
  display: grid;
  min-height: 118px;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.flyer-upload__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.flyer-upload__actions input[type="file"] {
  width: auto;
  max-width: 100%;
  height: auto;
  padding: 8px;
}

.setup-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  color: var(--field-ink);
  font-size: 14px;
}

.setup-options label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.setup-options input:disabled + span,
.setup-options label:has(input:disabled) {
  color: var(--muted);
}

.entry-panel.is-hidden {
  display: none;
}

.entry-panel__head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.entry-panel__title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

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

.history-panel {
  align-content: start;
}

.history-panel__head {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.history-panel__head h2 {
  margin: 0;
  font-size: 20px;
}

.history-panel__hint {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(120px, 170px) 1fr;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.history-item__time {
  color: var(--muted);
  font-size: 12px;
}

.history-item__title {
  color: var(--ink);
  font-weight: 800;
}

.history-item__body {
  margin-top: 3px;
  color: var(--field-ink);
  font-size: 13px;
  line-height: 1.35;
}

.setup-summary {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--field-ink);
  font-size: 14px;
}

.setup-summary--error {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--error-ink);
}

.setup-summary--warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-ink);
}

.btn-primary {
  border-color: var(--primary-bg);
  background: var(--primary-bg);
  color: var(--primary-ink);
}

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

.btn-danger {
  border-color: var(--error-border);
  color: var(--error-ink);
}

:root[data-theme="dark"] .btn-danger {
  color: #fecaca;
}

.btn-danger:hover {
  background: var(--error-bg);
}

.admin-page {
  min-height: calc(100dvh - 76px);
  padding: 24px;
}

.admin-shell {
  display: grid;
  place-items: start center;
}

.auth-shell {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 18px;
  align-items: start;
  max-width: 980px;
  margin: 0 auto;
}

.admin-login-card,
.admin-panel,
.admin-tournament-card,
.admin-user-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.admin-login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 16px;
  padding: 22px;
}

.auth-card {
  width: auto;
}

.auth-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn-link {
  border-color: transparent;
  background: transparent;
  color: var(--accent);
  box-shadow: none;
}

.btn-link:hover {
  border-color: var(--control-border);
  background: var(--surface-soft);
}

.admin-login-card h2,
.admin-dashboard__head h2,
.admin-panel h3 {
  margin: 0;
}

.admin-login-card p,
.admin-panel p,
.admin-muted,
.admin-empty {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-dashboard {
  max-width: 1500px;
  margin: 0 auto;
}

.auth-profile {
  max-width: 780px;
}

.auth-profile-card {
  display: grid;
  gap: 14px;
}

.auth-avatar-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.auth-verification-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border: 1px solid var(--warning-border);
  border-radius: 8px;
  background: var(--warning-bg);
  color: var(--warning-ink);
}

.auth-verification-panel p {
  margin: 4px 0 0;
  color: inherit;
}

.auth-verification-panel[hidden] {
  display: none;
}

.auth-avatar-preview {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  overflow: hidden;
  border: 1px solid var(--control-border);
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 26px;
  font-weight: 800;
}

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

.admin-dashboard__head,
.admin-dashboard__actions,
.admin-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-dashboard__actions {
  align-items: center;
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.admin-summary-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.admin-summary-card strong {
  font-size: 28px;
  line-height: 1;
}

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

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.admin-side-stack {
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
}

.admin-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px;
  min-width: 0;
}

.admin-tournament-list,
.admin-user-list {
  display: grid;
  gap: 10px;
}

.admin-tournament-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  box-shadow: none;
  min-width: 0;
}

.admin-tournament-card__main {
  min-width: 0;
}

.admin-tournament-card h4 {
  margin: 8px 0 3px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.admin-tournament-card p,
.admin-tournament-card__description,
.admin-tournament-card__meta span,
.admin-user-card strong,
.admin-user-card span,
.admin-user-card small {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.admin-user-card strong {
  color: var(--field-ink);
  font-size: 14px;
}

.admin-tournament-card__description {
  margin-top: 8px;
  max-width: 74ch;
}

.admin-tournament-card__meta {
  display: grid;
  gap: 4px;
  text-align: right;
  white-space: nowrap;
}

.admin-tournament-card__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-create-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.admin-create-form input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--field-ink);
  padding: 0 10px;
  font: inherit;
}

.admin-user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  box-shadow: none;
  min-width: 0;
}

.admin-user-card > div:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

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

.admin-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-pill--active {
  background: rgba(34, 197, 94, 0.16);
  color: var(--status-current);
}

.admin-pill--disabled {
  background: rgba(148, 163, 184, 0.18);
  color: var(--muted);
}

.admin-confirm-dialog {
  max-width: 520px;
}

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

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

.bracket {
  overflow: auto;
  height: calc(100vh - 132px);
  padding-bottom: 12px;
  cursor: grab;
  user-select: none;
  overscroll-behavior: contain;
  touch-action: none;
}

.bracket.is-list-mode {
  cursor: default;
  user-select: auto;
  overscroll-behavior: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

body.has-mobile-menu .bracket {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.bracket.is-panning {
  cursor: grabbing;
}

.bracket-floating-title {
  position: fixed;
  z-index: 40;
  max-width: min(760px, 82vw);
  padding: 8px 16px;
  transform: translateX(-50%);
  border: 1px solid var(--control-border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 18px;
  line-height: 1.15;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.bracket-zoom-stage {
  position: relative;
}

.bracket-zoom-content {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: top left;
}

.print-sheet {
  position: relative;
  width: 1800px;
  min-height: 1410px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.sheet-title {
  position: absolute;
  left: 0;
  right: 0;
  top: 22px;
  margin: 0;
  text-align: center;
  font-size: 64px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

.section-title {
  position: absolute;
  left: 12px;
  font-size: 26px;
  line-height: 1;
  font-weight: 500;
  white-space: nowrap;
}

.section-title--winners {
  top: 22px;
}

.section-title--losers {
  top: 792px;
}

.bracket-canvas {
  position: absolute;
  inset: 0;
  height: 1410px;
}

.br-line {
  position: absolute;
  display: block;
  border-color: var(--line);
  pointer-events: none;
}

.br-line--h {
  height: 2px;
  border: 0;
  background: var(--line);
}

.br-line--v {
  width: 2px;
  border: 0;
  background: var(--line);
}

.br-line--dash {
  height: 0;
  background: transparent;
  border-style: dashed;
  border-width: 2px 0 0;
}

.br-line--v.br-line--dash {
  width: 0;
  background: transparent;
  border-width: 0 0 0 2px;
}

.slot-text,
.slot-label,
.loss-label,
.first-loss-note {
  position: absolute;
  z-index: 2;
  display: block;
  background: var(--paper);
  color: var(--ink);
  font-family: "Times New Roman", Times, serif;
}

.slot-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
  line-height: 22px;
  min-height: 22px;
}

.slot-label,
.loss-label {
  font-size: 18px;
  line-height: 20px;
}

.slot-label {
  text-align: right;
}

.match-no {
  position: absolute;
  z-index: 2;
  display: block;
  color: var(--ink);
  font-family: "Times New Roman", Times, serif;
  padding: 0 3px;
  font-size: 16px;
  line-height: 18px;
}

.loss-label {
  padding-right: 6px;
  text-align: right;
  background: transparent;
}

.first-loss-note {
  left: 1292px;
  top: 1250px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 22px;
  line-height: 24px;
}

.triple-note {
  position: absolute;
  left: 980px;
  top: 1180px;
  width: 420px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  background: var(--paper);
  font-size: 18px;
  line-height: 1.3;
}

.bracket-note {
  position: absolute;
  left: 42px;
  bottom: 42px;
  width: 620px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  background: var(--paper);
  font-size: 18px;
  line-height: 1.3;
}

.king-sheet {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.king-title {
  position: absolute;
  left: 0;
  right: 0;
  top: 30px;
  margin: 0;
  text-align: center;
  font-size: 42px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0;
}

.king-section-label {
  position: absolute;
  z-index: 2;
  height: 22px;
  border-bottom: 1px solid var(--control-border);
  color: var(--muted);
  font: 800 12px/20px Arial, Helvetica, sans-serif;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

.king-card {
  position: absolute;
  z-index: 3;
  height: 42px;
  border: 1px solid var(--card-border);
  background: var(--surface);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.king-sheet--triple .king-card {
  font-size: 10px;
}

.king-sheet--triple .king-note {
  font-size: 10px;
}

.king-card:hover {
  border-color: var(--card-hover);
  box-shadow: 0 0 0 1px var(--card-hover);
}

.king-card--status-waiting {
  box-shadow: 0 0 0 2px #f59e0b;
}

.king-card--status-started {
  box-shadow: 0 0 0 2px #2563eb;
}

.king-card--status-finished {
  box-shadow: 0 0 0 2px #16a34a;
}

.king-card--mine {
  border-color: #facc15;
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.75);
}

.king-card--my-next {
  box-shadow: 0 0 0 2px #facc15, 0 0 0 7px rgba(250, 204, 21, 0.22);
}

.king-row {
  position: relative;
  display: block;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  color: var(--row-ink);
}

.king-row-text {
  display: block;
  width: 100%;
  padding-right: var(--king-row-meta-space, 0);
  font-size: var(--team-font-size, 11px);
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.king-row-meta {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--king-row-meta-space, 24px);
  border-left: 1px solid var(--row-divider);
  background: var(--score-bg);
  line-height: 20px;
  text-align: center;
  white-space: nowrap;
}

.king-row-meta--ref {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.king-row-meta--score {
  color: var(--score-ink);
  font-size: 11px;
  font-weight: 700;
}

.king-row--top,
.king-row--bottom {
  background: var(--surface);
}

.king-row--bottom {
  border-top: 1px solid var(--row-divider);
}

.king-row--winner {
  background: var(--winner-bg);
}

.king-row--loser {
  background: var(--loser-bg);
}

.king-row--mine {
  background: rgba(250, 204, 21, 0.18);
}

.player-name--male {
  color: var(--male);
}

.player-name--female {
  color: var(--female);
}

.player-name--mine {
  color: #facc15;
  font-weight: 900;
  text-shadow: 0 0 10px rgba(250, 204, 21, 0.25);
}

.king-label {
  position: absolute;
  left: 50%;
  top: 42px;
  transform: translateX(-50%);
  color: var(--ink);
  font-size: 13px;
  line-height: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.king-board {
  position: absolute;
  left: 0;
  right: 0;
  top: -16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 13px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

.king-note {
  position: absolute;
  left: 0;
  right: 0;
  top: 56px;
  color: var(--muted);
  font-size: 11px;
  line-height: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.king-caption {
  position: absolute;
  z-index: 4;
  color: var(--muted);
  font-size: 16px;
  line-height: 20px;
  font-weight: 700;
}

.king-line {
  background: var(--king-line);
  border-color: var(--king-line);
}

.match-context-menu {
  position: fixed;
  z-index: 1100;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--menu-shadow);
}

.match-context-menu__title {
  padding: 6px 8px 7px;
  color: var(--field-ink);
  font-size: 12px;
  font-weight: 800;
}

.match-context-menu__sep {
  height: 1px;
  margin: 6px 0;
  background: var(--border);
}

.match-context-menu button {
  display: block;
  width: 100%;
  min-height: 30px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font: 13px/1.2 Arial, Helvetica, sans-serif;
  text-align: left;
  cursor: pointer;
}

.match-context-menu button:hover:not(:disabled) {
  background: var(--surface-hover);
}

.match-context-menu button:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

@media (pointer: coarse) {
  .match-context-menu {
    min-width: 220px;
    padding: 8px;
  }

  .match-context-menu button {
    min-height: 42px;
    font-size: 14px;
  }
}

.match-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}

.match-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
}

.match-dialog__panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  width: min(760px, 100%);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--dialog-shadow);
}

.match-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.match-dialog__head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
}

.match-dialog__timer {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.match-dialog__x {
  width: 32px;
  height: 32px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.matchup-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background:
    linear-gradient(90deg, var(--surface-soft), transparent 48%, transparent 52%, var(--surface-soft)),
    var(--surface);
}

.matchup-side {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 0;
  text-align: center;
}

.matchup-side strong {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matchup-vs {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--control-border);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
}

.matchup-avatars {
  display: flex;
  justify-content: center;
  min-height: 76px;
  width: 100%;
}

.match-avatar {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  overflow: hidden;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 23px;
  font-weight: 900;
  box-shadow: 0 0 0 1px var(--control-border);
}

.match-avatar + .match-avatar {
  margin-left: -18px;
}

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

.match-avatar--fallback {
  background: linear-gradient(135deg, var(--surface-soft), var(--paper));
}

.match-avatar--empty {
  color: var(--muted);
}

.match-avatar--more {
  background: var(--control-bg);
  font-size: 18px;
}

.match-dialog__teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 92px;
  gap: 10px;
  align-items: end;
}

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

.match-dialog__score input {
  text-align: center;
}

.match-dialog__real-name {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.match-dialog__winner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  font-size: 13px;
  font-weight: 700;
}

.match-dialog__notice {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--field-ink);
  font-size: 13px;
}

.match-dialog__notice--error {
  border-color: var(--error-border);
  background: var(--error-bg);
  color: var(--error-ink);
}

.match-dialog__notice--success {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success-ink);
}

.match-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.board-dialog__panel {
  width: min(460px, 100%);
}

.manager-pin-dialog {
  width: min(420px, 100%);
}

.board-dialog__in-play {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.tournament-details-dialog {
  width: min(720px, 100%);
}

.signup-sheet-dialog {
  width: min(940px, 100%);
}

.signup-sheet-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.signup-sheet-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.signup-sheet-share {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.signup-sheet-share img {
  width: 88px;
  height: 88px;
  border-radius: 4px;
  background: #fff;
}

.signup-sheet-share strong,
.signup-sheet-share span,
.signup-sheet-share__empty {
  display: block;
}

.signup-sheet-share span,
.signup-sheet-share__empty {
  margin: 3px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.signup-sheet-list {
  max-height: min(54dvh, 560px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.signup-sheet-header,
.signup-row {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) 116px 132px 72px 96px 36px;
  gap: 8px;
  align-items: center;
}

.signup-sheet-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 9px 7px;
  border-bottom: 1px solid var(--border);
  background: var(--active-bg);
  color: var(--active-ink);
  font-size: 12px;
  font-weight: 900;
}

.signup-sheet-rows {
  display: grid;
  gap: 4px;
  padding: 6px;
}

.signup-row {
  min-height: 42px;
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  transition: background 120ms ease, border-color 120ms ease;
}

.signup-row.is-paid {
  border-color: #22c55e;
  background: var(--winner-bg);
}

.signup-row input[type="text"],
.signup-row select {
  width: 100%;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--field-ink);
  font: inherit;
}

.signup-paid {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  color: var(--field-ink);
  font-size: 13px;
  font-weight: 800;
  justify-content: center;
}

.signup-source {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.signup-remove {
  align-self: center;
}

.tournament-details-dialog__grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mystery-quick {
  display: grid;
  grid-template-columns: minmax(170px, 1.2fr) minmax(130px, 0.8fr) 120px 110px auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.join-dialog {
  width: min(700px, 100%);
}

.join-dialog__share {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.join-dialog__qr {
  width: 112px;
  height: 112px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
}

.join-dialog__link {
  align-self: stretch;
}

.player-view-dialog {
  width: min(520px, 100%);
}

.player-view-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.player-view-card > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.player-view-card span,
.nickname-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.player-view-card strong {
  overflow: hidden;
  color: var(--field-ink);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nickname-dialog {
  width: min(820px, 100%);
}

.nickname-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nickname-tabs .is-active {
  border-color: var(--card-hover);
  background: var(--surface-hover);
  color: var(--ink);
}

.nickname-list {
  display: grid;
  gap: 10px;
  max-height: min(60vh, 580px);
  overflow: auto;
}

.nickname-item {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.nickname-item > div:first-child {
  display: grid;
  gap: 3px;
}

.nickname-item__actions {
  display: inline-flex;
  gap: 8px;
}

.nickname-item__approved {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.nickname-request-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(440px, calc(100vw - 28px));
  padding: 12px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--dialog-shadow);
  color: var(--ink);
}

.nickname-request-toast > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.nickname-request-toast strong {
  font-size: 14px;
}

.nickname-request-toast span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.director-dashboard-dialog {
  width: min(1120px, 100%);
}

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

.dashboard-stats > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.dashboard-stats span,
.dashboard-match small,
.dashboard-empty,
.dashboard-announcement__list,
.undo-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-stats strong {
  overflow: hidden;
  color: var(--field-ink);
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.dashboard-actions > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.dashboard-actions strong {
  color: var(--field-ink);
  font-size: 14px;
  text-transform: capitalize;
}

.dashboard-actions span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.dashboard-grid--compact {
  align-items: start;
}

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

.dashboard-grid h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 14px;
}

.dashboard-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.dashboard-match {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.dashboard-match > div:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.dashboard-match strong,
.dashboard-match span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-match__actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: end;
}

.dashboard-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.dashboard-pill-list span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--field-ink);
  font-size: 12px;
  font-weight: 800;
}

.dashboard-pill-list span.is-busy {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.14);
}

.dashboard-announcement {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.dashboard-announcement__list {
  grid-column: 1 / -1;
  display: grid;
  gap: 4px;
}

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

.dashboard-qr-grid > div,
.export-qr-section > div {
  display: grid;
  gap: 6px;
  justify-items: center;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
}

.dashboard-qr-grid img,
.export-qr-section img {
  width: 120px;
  height: 120px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
}

.dashboard-qr-grid span,
.export-qr-section span {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dashboard-tool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.dashboard-audit {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.dashboard-audit__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-audit__head h3 {
  margin: 0;
}

.dashboard-audit__head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dashboard-audit__list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.audit-item {
  display: grid;
  gap: 3px;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.audit-item strong {
  color: var(--field-ink);
  font-size: 13px;
}

.audit-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.audit-item time {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.export-dialog,
.undo-dialog {
  width: min(620px, 100%);
}

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

.export-qr-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.undo-list {
  display: grid;
  gap: 8px;
  max-height: min(58vh, 520px);
  overflow: auto;
}

.undo-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.undo-item > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.undo-confirm-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.notice-dialog {
  width: min(460px, 100%);
}

.mystery-draw-dialog {
  width: min(760px, 100%);
}

.mystery-draw-stage {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
}

.mystery-draw-pot {
  color: var(--muted);
  font-size: 15px;
  font-weight: 900;
}

.mystery-draw-number {
  min-width: 150px;
  padding: 10px 18px;
  border: 2px solid var(--control-border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 56px;
  line-height: 1;
  font-weight: 900;
}

.mystery-draw-winner {
  color: var(--field-ink);
  font-size: 22px;
  font-weight: 900;
}

.mystery-draw-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mystery-draw-note.is-error {
  color: #f87171;
}

.triple-foundation-note {
  position: absolute;
  left: 18px;
  top: 18px;
  z-index: 5;
  width: min(520px, 80vw);
  padding: 10px 12px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--field-ink);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.big-screen-qr {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.big-screen-qr img {
  width: 104px;
  height: 104px;
  background: #ffffff;
}

.big-screen-qr span {
  font-size: 12px;
  font-weight: 900;
}

.big-screen-announcement {
  position: fixed;
  left: 18px;
  right: 150px;
  bottom: 18px;
  z-index: 80;
  overflow: hidden;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 18px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

body.big-screen-mode {
  background: var(--paper);
}

body.big-screen-mode .topbar,
body.big-screen-mode .desktop-info-bar,
body.big-screen-mode .tournament-info {
  display: none !important;
}

body.big-screen-mode .page {
  height: 100dvh;
  padding: 0;
}

body.big-screen-mode .bracket {
  height: 100dvh;
  padding: 0;
  cursor: default;
}

body.big-screen-mode .bracket-floating-title {
  display: none !important;
}

body.big-screen-mode .king-sheet,
body.big-screen-mode .print-sheet {
  box-shadow: none;
}

body.big-screen-mode .king-card {
  cursor: default;
}

body.big-screen-mode .king-card:hover {
  border-color: var(--card-border);
  box-shadow: none;
}

@media (max-width: 900px) {
  .match-dialog {
    place-items: start center;
    padding: 8px;
  }

  .match-dialog__panel {
    width: 100%;
    max-height: calc(100dvh - 16px);
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 120;
    align-items: center;
    flex-direction: row;
    padding: 10px 12px;
  }

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

  .brand-logo {
    width: 76px;
    height: 66px;
    max-width: min(76px, 36vw);
  }

  .subtitle {
    display: none;
  }

  .has-mobile-menu .mobile-menu-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .has-mobile-menu .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 180;
    display: block;
    background: var(--backdrop);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }

  body.has-mobile-menu.mobile-menu-open {
    overflow: hidden;
  }

  body.has-mobile-menu.mobile-menu-open .topbar {
    z-index: 220;
  }

  body.has-mobile-menu.mobile-menu-open .mobile-menu-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .has-mobile-menu .topbar__right {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 230;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 10px;
    width: min(86vw, 380px);
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    box-sizing: border-box;
    padding: 14px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    border-left: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--dialog-shadow);
    transform: translateX(104%);
    transition: transform 180ms ease;
  }

  .has-mobile-menu .topbar-primary {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
  }

  body.has-mobile-menu.mobile-menu-open .topbar__right {
    transform: translateX(0);
  }

  .has-mobile-menu .mobile-menu-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
  }

  .has-mobile-menu .mobile-menu-status {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
  }

  .has-mobile-menu .mobile-tournament-info {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--field-ink);
  }

  .has-mobile-menu .topbar-primary > .btn,
  .has-mobile-menu .topbar-primary > .select-control {
    width: 100%;
  }

  .has-mobile-menu .topbar-tools {
    display: block;
    width: 100%;
  }

  .has-mobile-menu .topbar-tools-toggle {
    display: none;
  }

  .has-mobile-menu .topbar-tools-panel {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .has-mobile-menu .tools-section {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
  }

  .has-mobile-menu .topbar__right .zoom-controls {
    width: 100%;
    justify-content: space-between;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
  }

  .dashboard-stats,
  .dashboard-actions,
  .dashboard-grid,
  .dashboard-grid--queues,
  .dashboard-qr-grid,
  .export-qr-section,
  .dashboard-announcement,
  .export-grid,
  .undo-item {
    grid-template-columns: 1fr;
  }

  .dashboard-match {
    grid-template-columns: 1fr;
  }

  .dashboard-match__actions {
    justify-content: start;
  }

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

  .big-screen-qr {
    right: 10px;
    bottom: 10px;
  }

  .big-screen-qr img {
    width: 86px;
    height: 86px;
  }

  .big-screen-announcement {
    right: 120px;
    font-size: 14px;
  }

  .page {
    padding: 8px;
  }

  body.has-mobile-menu .page {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    padding: 8px;
  }

  .desktop-info-bar,
  .desktop-info-toggle {
    display: none;
  }

  .tournament-info--popover {
    position: static;
    box-shadow: none;
  }

  .status,
  .page > .tournament-info {
    display: none !important;
  }

  body.has-mobile-menu .bracket {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
  }

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

  .field--pin-pair {
    grid-template-columns: 1fr;
  }

  .admin-grid,
  .admin-side-stack {
    grid-template-columns: 1fr;
  }

  .admin-tournament-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .admin-tournament-card__meta {
    text-align: left;
    white-space: normal;
  }

  .admin-tournament-card__actions,
  .admin-user-card__actions {
    justify-content: flex-start;
  }

  .admin-user-card {
    align-items: stretch;
    display: grid;
  }

  .entry-panel__head,
  .signup-sheet-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .signup-sheet-header,
  .signup-row {
    min-width: 780px;
  }

  .signup-remove {
    width: 100%;
  }

  .match-dialog__teams {
    grid-template-columns: 1fr;
  }

  .matchup-card {
    grid-template-columns: 1fr;
  }

  .matchup-vs {
    width: 42px;
    height: 42px;
    justify-self: center;
  }

  .match-avatar {
    width: 64px;
    height: 64px;
    font-size: 19px;
  }

  .matchup-avatars {
    min-height: 64px;
  }

  .match-dialog__extras {
    grid-template-columns: 1fr;
  }

  .mystery-quick,
  .player-view-card,
  .nickname-item {
    grid-template-columns: 1fr;
  }

  .nickname-item__actions {
    justify-content: flex-end;
  }

  .join-dialog__share {
    grid-template-columns: 1fr;
  }

  .join-dialog__qr {
    width: 160px;
    height: 160px;
  }
}

@media print {
  @page {
    size: landscape;
    margin: 0.2in;
  }

  :root,
  :root[data-theme="dark"] {
    --bg: #ffffff;
    --paper: #ffffff;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-hover: #f6f7f8;
    --ink: #111111;
    --muted: #5d626b;
    --field-ink: #1f2933;
    --line: #111111;
    --king-line: #555555;
    --border: #d7dce2;
    --control-border: #b9c0ca;
    --card-border: #888888;
    --card-hover: #111111;
    --row-ink: #08110a;
    --row-divider: rgba(17, 17, 17, 0.28);
    --score-bg: rgba(255, 255, 255, 0.32);
    --score-ink: #111111;
    --winner-bg: #d8f8d8;
    --loser-bg: #ffd9d9;
    --male: #1687d9;
    --female: #c735a8;
  }

  body {
    background: #ffffff;
  }

  .topbar,
  .setup-panel,
  .status,
  .bracket-floating-title,
  .big-screen-qr,
  .big-screen-announcement,
  .match-dialog {
    display: none;
  }

  .page,
  .bracket {
    height: auto;
    padding: 0;
    overflow: visible;
  }

  .bracket-zoom-content {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    transform: scale(var(--print-zoom, 1)) !important;
    transform-origin: top left;
  }

  .print-sheet,
  .king-sheet {
    box-shadow: none;
    transform-origin: top left;
  }
}
