/* ==========================================================================
   SportsGenX — Tournament Draw Manager
   Design system mirrored from sportsgenx.com (Oswald display + Inter body,
   red #B0121E on a chalk ground). Light theme only, print-faithful.
   ========================================================================== */

:root {
  /* Brand ---------------------------------------------------------------- */
  --red: #B0121E;
  --red-light: #D81E2C;
  --red-deep: #8C0E18;
  --rose: #FF8A8F;
  --red-wash: #FDEBEC;

  /* Surfaces ------------------------------------------------------------- */
  --chalk: #FFF8F8;
  --white: #FFFFFF;
  --line: #F0DEDF;
  --line-strong: #E0C4C6;

  /* Text ----------------------------------------------------------------- */
  --ink: #1A1A1A;
  --slate: #6B6B6B;
  --slate-soft: #8E8A8A;

  /* Semantic ------------------------------------------------------------- */
  --ok: #1E7A46;
  --warn: #B45309;

  /* Bracket -------------------------------------------------------------- */
  --bracket-line: #E0C4C6;
  --bracket-line-active: var(--red);
  --bracket-line-glow: rgba(176, 18, 30, 0.28);
  --highlight-bg: #FDEBEC;

  /* Type ----------------------------------------------------------------- */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Oswald', 'Arial Narrow', sans-serif;

  /* Shape & depth -------------------------------------------------------- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(176, 18, 30, 0.06);
  --shadow-md: 0 6px 16px rgba(176, 18, 30, 0.08);
  --shadow-lg: 0 18px 40px rgba(176, 18, 30, 0.10);
  --shadow-red: 0 12px 24px rgba(176, 18, 30, 0.26);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--chalk);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-weight: 700;
}

/* Icon primitives — identical contract to sportsgenx.com ------------------ */
.ui-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: currentColor;
}

.ui-icon svg {
  width: 100%;
  height: 100%;
}

.ui-icon--sm { width: 15px; height: 15px; }
.ui-icon--md { width: 22px; height: 22px; }

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

/* ==========================================================================
   Application Shell & Top Navigation
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--white);
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.brand-mark {
  display: block;
  height: 30px;
  width: auto;
}

.brand-divider {
  width: 1px;
  height: 30px;
  background: var(--line);
}

.brand-info h1 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.brand-info p {
  font-size: 0.72rem;
  color: var(--slate);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2px;
}

.brand-info .badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--red-wash);
  color: var(--red);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.63rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  min-width: 230px;
}

.search-box input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.3rem;
  font-family: var(--font-body);
  font-size: 0.825rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background-color: var(--chalk);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-box input::placeholder {
  color: var(--slate-soft);
}

.search-box input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(176, 18, 30, 0.12);
}

.search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate);
  pointer-events: none;
}

/* Category Navigation Pills ---------------------------------------------- */
.category-nav-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.category-nav-container::-webkit-scrollbar {
  height: 4px;
}

.category-nav-container::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--radius-full);
}

.category-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  background-color: var(--white);
  color: var(--slate);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.category-btn:hover {
  background-color: var(--red-wash);
  color: var(--red);
  border-color: var(--line-strong);
}

.category-btn.active {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
  box-shadow: 0 4px 12px rgba(176, 18, 30, 0.22);
}

.category-btn .cat-count {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  background: var(--chalk);
  color: var(--slate);
  border-radius: var(--radius-full);
}

.category-btn.active .cat-count {
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
}

/* Action Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.48rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background-color: var(--white);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}

.btn:hover {
  background-color: var(--red-wash);
  border-color: var(--line-strong);
  color: var(--red);
}

.btn-primary {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  box-shadow: var(--shadow-red);
}

.btn-primary:hover {
  background: var(--red-light);
  border-color: var(--red-light);
  color: var(--white);
  transform: translateY(-2px);
}

.btn-icon-only {
  padding: 0;
  width: 34px;
  height: 34px;
  justify-content: center;
}

.view-mode-group {
  display: inline-flex;
  background-color: var(--chalk);
  border-radius: var(--radius-md);
  padding: 3px;
  border: 1px solid var(--line);
  gap: 2px;
}

.view-mode-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  font-family: var(--font-body);
  font-size: 0.775rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--slate);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.view-mode-btn:hover {
  color: var(--red);
}

.view-mode-btn.active {
  background-color: var(--white);
  color: var(--red);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Main Canvas & Workspace Area
   ========================================================================== */
.main-viewport {
  position: relative;
  min-height: calc(100vh - 128px);
  padding: 1.75rem 1.5rem 3.5rem;
  overflow: auto;
  display: flex;
  justify-content: center;
}

/* Zoom / Pan Floating Bar ------------------------------------------------ */
.canvas-controls-floating {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
}

.zoom-level-text {
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 46px;
  text-align: center;
  color: var(--ink);
}

/* ==========================================================================
   Official Draw Sheet Container
   ========================================================================== */
.tournament-sheet-container {
  position: relative;
  width: 100%;
  max-width: 1200px;
  background-color: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  transform-origin: top center;
  transition: transform 0.15s ease-out;
  overflow: hidden;
}

/* Brand accent rail across the top of the sheet */
.tournament-sheet-container::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--red-deep), var(--red), var(--red-light));
}

/* Sheet Header ----------------------------------------------------------- */
.sheet-header {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.75rem;
}

.sheet-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
}

.sheet-title-area h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
}

.sheet-event-tag {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--red);
  margin-top: 0.35rem;
  padding: 2px 10px;
  background: var(--red-wash);
  border-radius: var(--radius-full);
}

.sheet-event-tag .event-fullname {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: none;
  color: var(--red-deep);
}

.sheet-logos-area {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
}

.sheet-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem 1.5rem;
  margin-top: 0.9rem;
  font-size: 0.8rem;
}

.meta-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.meta-item .ui-icon {
  color: var(--red);
  margin-top: 2px;
}

.meta-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.meta-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--slate);
}

.meta-value {
  font-weight: 600;
  color: var(--ink);
}

.print-timestamp-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--slate);
  border-top: 1px solid var(--line);
  padding-top: 0.45rem;
  margin-top: 0.6rem;
}

/* ==========================================================================
   Dynamic Bracket Tree Engine
   ========================================================================== */
.bracket-wrapper {
  position: relative;
  width: 100%;
  overflow-x: auto;
  padding: 1rem 0;
}

.bracket-rounds-header {
  display: grid;
  border-bottom: 2px solid var(--line-strong);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate);
}

.bracket-tree-canvas {
  position: relative;
  display: grid;
  width: 100%;
}

.round-column {
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Gutter on the right of each round so the connector elbow has room to draw
   its horizontal legs instead of collapsing into a bare vertical line. */
.round-column:not(.rank-column) {
  padding-right: 22px;
}

/* Rank column (left index) */
.rank-column {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  border-right: 1px solid var(--line);
  padding-right: 0.4rem;
}

.rank-cell {
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--slate-soft);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 4px 2px;
}

/* Bracket match cells ----------------------------------------------------- */
.match-node {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  background-color: transparent;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  cursor: pointer;
}

.match-node:hover {
  background-color: var(--highlight-bg);
}

.match-node.highlighted {
  background-color: var(--highlight-bg) !important;
  box-shadow: inset 0 0 0 1.5px var(--red);
}

.match-node.dimmed {
  opacity: 0.25;
}

.player-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.775rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-line.winner {
  font-weight: 700;
  color: var(--red);
}

.player-line.bye {
  font-style: italic;
  color: var(--slate-soft);
}

.player-names-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.seed-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--red-light);
  margin-left: 2px;
}

.score-badge {
  font-size: 0.7rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--slate);
  white-space: nowrap;
  margin-top: 2px;
}

.score-badge.wo,
.score-badge.ret {
  color: var(--warn);
  font-style: italic;
}

/* Bracket connectors (SVG overlay) --------------------------------------- */
.bracket-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.bracket-path {
  fill: none;
  stroke: var(--bracket-line);
  stroke-width: 1.5;
  stroke-linejoin: round;
  transition: stroke 0.15s ease, stroke-width 0.15s ease;
}

.bracket-path.active {
  stroke: var(--bracket-line-active);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 4px var(--bracket-line-glow));
}

/* Champion card ---------------------------------------------------------- */
.winner-node {
  align-items: flex-start;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: linear-gradient(150deg, var(--red) 0%, var(--red-light) 100%);
  border: none;
  box-shadow: var(--shadow-red);
  cursor: default;
}

.winner-node:hover {
  background: linear-gradient(150deg, var(--red) 0%, var(--red-light) 100%);
}

.winner-crown-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--rose);
}

.winner-player-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--white);
  margin-top: 0.2rem;
}

/* ==========================================================================
   Sheet Footer (seeds, alternates, verification)
   ========================================================================== */
.sheet-footer {
  border-top: 2px solid var(--ink);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.footer-tables-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: 0.75rem;
}

.footer-box {
  padding: 0.7rem 0.85rem;
  border-right: 1px solid var(--line-strong);
  min-height: 116px;
}

.footer-box:last-child {
  border-right: none;
}

.footer-box-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  font-size: 0.72rem;
  color: var(--ink);
}

.footer-box-title .ui-icon {
  color: var(--red);
}

.seeded-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.seeded-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.seed-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--red-wash);
  color: var(--red);
  font-weight: 700;
  font-size: 0.66rem;
}

.footer-form-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.footer-form-row span {
  color: var(--slate);
}

.footer-rule {
  min-height: 18px;
  border-bottom: 1px dotted var(--line-strong);
}

.verify-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--ink);
}

.verify-list strong {
  color: var(--slate);
  font-weight: 600;
}

.signature-line-area {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.2rem;
  border-top: 1px dashed var(--line-strong);
  padding-top: 0.45rem;
  font-size: 0.7rem;
  color: var(--slate);
}

/* Sponsor / powered-by strip --------------------------------------------- */
.sheet-bottom-sponsors {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.powered-by {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
}

.powered-by img {
  height: 18px;
  width: auto;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(26, 26, 26, 0.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  background-color: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(26, 26, 26, 0.28);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.modal-header h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.modal-header h3 .ui-icon {
  color: var(--red);
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--slate);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
  background: var(--red-wash);
  color: var(--red);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--slate);
}

.form-input, .form-select {
  padding: 0.6rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background-color: var(--chalk);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus, .form-select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(176, 18, 30, 0.12);
}

.form-hint {
  font-size: 0.7rem;
  color: var(--slate);
  margin-top: 2px;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ==========================================================================
   Sheet View — a calm, print-faithful preview of the same draw
   ========================================================================== */
body.mode-official .match-node {
  cursor: default;
}

body.mode-official .match-node:hover {
  background-color: transparent;
}

body.mode-official .tournament-sheet-container {
  box-shadow: var(--shadow-md);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .app-header { padding: 0.7rem 1rem; }
  .header-actions { width: 100%; }
  .search-box { flex: 1 1 180px; min-width: 0; }
  .main-viewport { padding: 1rem 0.75rem 3.5rem; }
  .tournament-sheet-container { padding: 1.25rem; }
  .sheet-header-top { flex-direction: column; }
  .sheet-logos-area { flex-wrap: wrap; gap: 0.9rem; }
  .footer-tables-grid { grid-template-columns: 1fr; }
  .footer-box { border-right: none; border-bottom: 1px solid var(--line-strong); min-height: 0; }
  .footer-box:last-child { border-bottom: none; }
}

@media (max-width: 600px) {
  .brand-divider, .brand-info p { display: none; }
  .brand-info h1 { font-size: 0.95rem; }
  .sheet-title-area h2 { font-size: 1.2rem; }
  .btn span.btn-label { display: none; }
  .btn { padding: 0.48rem 0.6rem; }
  .btn-primary { padding: 0.48rem 0.9rem; }
  .btn-primary span.btn-label { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Print Optimization (A4 official draw sheet)
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 6mm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 8pt;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .app-header,
  .canvas-controls-floating,
  .modal-overlay,
  .no-print,
  button,
  .search-box {
    display: none !important;
  }

  .main-viewport {
    padding: 0 !important;
    min-height: auto !important;
    overflow: visible !important;
    display: block !important;
  }

  .tournament-sheet-container {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    background: #ffffff !important;
    transform: none !important;
    page-break-inside: avoid;
  }

  .tournament-sheet-container::before { display: none !important; }

  .sheet-header { border-bottom: 2px solid #000000 !important; }
  .sheet-title-area h2 { color: #000000 !important; font-size: 14pt !important; }

  .sheet-event-tag {
    color: #000000 !important;
    background: transparent !important;
    padding: 0 !important;
    font-size: 11pt !important;
  }
  .sheet-event-tag .event-fullname { color: #000000 !important; }

  .meta-item .ui-icon,
  .footer-box-title .ui-icon,
  .print-timestamp-bar .ui-icon,
  .signature-line-area .ui-icon { color: #000000 !important; }

  .meta-value, .meta-label, .print-timestamp-bar,
  .verify-list, .verify-list strong, .signature-line-area { color: #000000 !important; }

  .bracket-rounds-header {
    border-bottom: 1.5px solid #000000 !important;
    color: #000000 !important;
  }

  .rank-column { border-right: 1px solid #000000 !important; }
  .rank-cell { color: #000000 !important; font-size: 7.5pt !important; }

  .player-line { color: #000000 !important; font-size: 7.5pt !important; }
  .player-line.winner { color: #000000 !important; font-weight: bold !important; }
  .player-line.bye { color: #000000 !important; }

  .seed-badge { color: #000000 !important; font-weight: bold !important; }
  .score-badge { color: #000000 !important; font-size: 7pt !important; }

  .bracket-path { stroke: #000000 !important; stroke-width: 1px !important; }

  .match-node.highlighted,
  .match-node:hover { background: transparent !important; box-shadow: none !important; }
  .match-node.dimmed { opacity: 1 !important; }

  .winner-node {
    background: transparent !important;
    box-shadow: none !important;
    border: 1px solid #000000 !important;
    padding: 0.35rem 0.5rem !important;
  }
  .winner-crown-label, .winner-player-name { color: #000000 !important; }

  .sheet-footer { border-top: 2px solid #000000 !important; }

  .footer-tables-grid {
    border: 1px solid #000000 !important;
    border-radius: 0 !important;
  }
  .footer-box { border-right: 1px solid #000000 !important; }
  .footer-box-title { color: #000000 !important; }

  .seed-num {
    background: transparent !important;
    color: #000000 !important;
    font-weight: bold !important;
  }

  .sheet-bottom-sponsors { border-top: 1px solid #000000 !important; }
  .powered-by { color: #000000 !important; }
  .sheet-bottom-sponsors svg,
  .sheet-bottom-sponsors img { filter: grayscale(100%); }
}
