:root {
  --bg: #F7F0F0;
  --bg-elevated: #fff8f8;
  --panel: rgba(255, 250, 250, 0.96);
  --panel-strong: #fffdfd;
  --line: rgba(141, 31, 45, 0.12);
  --line-strong: rgba(141, 31, 45, 0.24);
  --text: #2f1d21;
  --muted: #7a5f66;
  --accent: #8d1f2d;
  --accent-2: #c9a96a;
  --accent-3: #5a1320;
  --success: #3b8f68;
  --warning: #b88429;
  --danger: #b64b4b;
  --shadow: 0 12px 28px rgba(79, 33, 43, 0.08);
  --radius: 18px;
  --sticky-offset: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', sans-serif;
}

body {
  padding: 8px;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  letter-spacing: 0.02em;
}

p {
  margin: 0;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-shell {
  max-width: none;
  width: 100%;
  margin: 0;
}

.admin-shell {
  max-width: 1320px;
}

.site-header {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.compact-header {
  align-items: center;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
}

.lede {
  margin-top: 10px;
  max-width: 820px;
  color: var(--muted);
  line-height: 1.55;
}

.lede.compact {
  max-width: none;
  margin-top: 6px;
}

.header-actions,
.inline-controls,
.actions-inline,
.space-between-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.space-between-row {
  justify-content: space-between;
}

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

.page-stack {
  display: grid;
  gap: 20px;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 252, 252, 0.98), rgba(253, 246, 246, 0.98));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.panel-wide {
  padding: 8px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.wrap-row {
  flex-wrap: wrap;
}

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

.hero-meta > div {
  background: rgba(141, 31, 45, 0.03);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.hero-meta > div > div {
  font-weight: 700;
  margin-top: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(201, 169, 106, 0.12);
  color: var(--accent);
  font-size: 0.9rem;
  white-space: nowrap;
}

.small-pill {
  min-height: 28px;
  font-size: 0.8rem;
}

.button {
  appearance: none;
  border: 1px solid rgba(141, 31, 45, 0.22);
  border-radius: 999px;
  padding: 11px 16px;
  background: linear-gradient(180deg, #a12737, #7d1724);
  color: #fff8f6;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
  box-shadow: 0 8px 18px rgba(141, 31, 45, 0.16);
}

.button:hover {
  transform: translateY(-1px);
  border-color: rgba(141, 31, 45, 0.38);
}

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

.button-ghost {
  background: #fffdfd;
  color: var(--accent);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.button-danger {
  background: linear-gradient(180deg, #8f2b2b, #6d1a1a);
}

.small-button {
  padding: 8px 12px;
  font-size: 0.86rem;
}

.text-input,
.select-input,
.text-area,
.helper-box {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

.text-input:focus,
.select-input:focus,
.text-area:focus {
  outline: 2px solid rgba(141, 31, 45, 0.14);
  border-color: rgba(141, 31, 45, 0.35);
}

.helper-box {
  color: var(--muted);
  min-height: 48px;
  display: flex;
  align-items: center;
}

.text-area {
  resize: vertical;
}

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

.field-span-full {
  grid-column: 1 / -1;
}

.helper-text {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.stack {
  display: grid;
  gap: 12px;
}

.card-row,
.admin-game-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  padding: 14px;
}

.top-gap,
.top-gap-small {
  margin-top: 10px;
}

/* Major bracket usability fix */
.bracket-scroll {
  overflow: auto;
  max-width: 100%;
  max-height: calc(100vh - 220px);
  padding: 6px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.45);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  scrollbar-gutter: stable both-edges;
}

/* Optional nicer scrollbars */
.bracket-scroll::-webkit-scrollbar {
  height: 12px;
  width: 12px;
}

.bracket-scroll::-webkit-scrollbar-track {
  background: rgba(141, 31, 45, 0.06);
  border-radius: 999px;
}

.bracket-scroll::-webkit-scrollbar-thumb {
  background: rgba(141, 31, 45, 0.28);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.bracket {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 260px);
  gap: 14px;
  align-items: start;
  min-width: max-content;
  padding-bottom: 2px;
}

.bracket-round {
  display: grid;
  gap: 12px;
  align-content: start;
}

.round-title {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--accent);
  margin-bottom: 2px;
  padding: 8px 10px;
  background: rgba(247, 240, 240, 0.92);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(6px);
}

.game-card,
.admin-game-card {
  overflow: hidden;
}

.game-card-admin {
  margin-bottom: 14px;
}

.game-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(141, 31, 45, 0.05);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}

.competitor-option,
.competitor-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 0;
  border-top: 1px solid rgba(141, 31, 45, 0.08);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.competitor-display {
  cursor: default;
}

.competitor-option:hover {
  background: rgba(141, 31, 45, 0.05);
}

.competitor-option.selected,
.competitor-display.winner {
  background: linear-gradient(90deg, rgba(141, 31, 45, 0.12), rgba(201, 169, 106, 0.10));
}

.competitor-core {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

/* Critical for text wrapping instead of getting crushed */
.competitor-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.competitor-name {
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.competitor-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: rgba(141, 31, 45, 0.04);
  flex: 0 0 auto;
}

.competitor-avatar-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.action-tag {
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  padding: 6px 10px;
  color: var(--accent);
  font-size: 0.76rem;
  white-space: nowrap;
  flex: 0 0 auto;
}

.seed-badge {
  min-width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(201, 169, 106, 0.14);
  border: 1px solid var(--line);
  color: var(--accent);
  font-weight: 700;
  flex: 0 0 auto;
}

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

.meta-text {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.3;
  margin-top: 2px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.action-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.empty-state {
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
}

.admin-games-grid,
.matchup-grid {
  display: grid;
  gap: 14px;
}

.admin-action-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 0 14px 14px;
}

.min-280 {
  min-width: 280px;
}

.compact-input {
  max-width: 86px;
}

/* Bigger screens get a little more breathing room */
@media (min-width: 1200px) {
  .bracket {
    grid-auto-columns: minmax(245px, 275px);
    gap: 16px;
  }
}

/* Tablet */
@media (max-width: 980px) {
  body {
    padding: 14px;
  }

  .page-grid,
  .form-grid,
  .hero-meta {
    grid-template-columns: 1fr;
  }

  .site-header,
  .action-panel,
  .panel-title-row {
    flex-direction: column;
    align-items: stretch;
  }

  .site-shell {
    max-width: 100%;
  }

  .panel {
    padding: 14px;
  }

  .panel-wide {
    padding: 12px;
  }

  .bracket-scroll {
    max-height: calc(100vh - 180px);
    padding: 2px 2px 8px;
  }

  .bracket {
    grid-auto-columns: minmax(220px, 240px);
    gap: 12px;
  }

  .competitor-option,
  .competitor-display {
    padding: 10px;
  }

  .competitor-avatar {
    width: 38px;
    height: 38px;
  }

  .competitor-name {
    font-size: 0.95rem;
  }

  .meta-text {
    font-size: 0.8rem;
  }
}

/* Small phones */
@media (max-width: 640px) {
  body {
    padding: 10px;
  }

  .panel {
    border-radius: 14px;
    padding: 12px;
  }

  .button,
  .button-ghost,
  .button-danger {
    width: 100%;
    justify-content: center;
  }

  .header-actions {
    width: 100%;
  }

  .bracket-scroll {
    max-height: calc(100vh - 160px);
  }

  .bracket {
    grid-auto-columns: minmax(240px, 260px);
    gap: 10px;
  }

  .seed-badge {
    min-width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }

  @media (max-width: 640px) {
  .bracket {
    grid-auto-columns: minmax(250px, 270px);
  }
}

  .action-tag {
    padding: 5px 8px;
    font-size: 0.72rem;
  }
}