:root {
  color-scheme: light;
  --brand: #d9464d;
  --gold: #e8d678;
  --ink: #4a4a4a;
  --paper: #f5f5f5;
  --blue: #6d8aae;
  --line: #cfcfcf;
  --clay: #a98274;
  --steel: #92a1a6;
  --coral: #dc8b6c;
  --paper-2: #ffffff;
  --panel: #ffffff;
  --muted: #6f6f6f;
  --green: var(--brand);
  --green-dark: #b9363d;
  --red: var(--brand);
  --shadow: 0 14px 28px rgba(74, 74, 74, 0.12);
  font-family:
    ui-serif, "New York", "Iowan Old Style", "Georgia", serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(74, 74, 74, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(74, 74, 74, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

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

button {
  min-height: 38px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  padding: 0 14px;
  color: #fff;
  background: var(--ink);
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: #2f2f2f;
}

button.secondary,
.segmented button {
  color: var(--ink);
  background: var(--paper-2);
}

button.secondary:hover,
.segmented button:hover {
  background: #eeeeee;
}

button.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
}

textarea {
  min-height: 188px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 0.88rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

.topbar,
.toolbar,
.panel-header,
.game-header,
.results-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  border-bottom: 2px solid var(--ink);
  margin-bottom: 18px;
  padding-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 54px;
  height: 54px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  object-fit: cover;
}

.mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper-2);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-weight: 900;
}

.brand h1,
.game-header h2,
.hero h2,
.results-hero h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.04;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 18px;
  align-items: stretch;
  border: 2px solid var(--ink);
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(217, 70, 77, 0.12), transparent 42%),
    var(--panel);
  box-shadow: var(--shadow);
}

.hero-score {
  display: grid;
  place-items: center;
  border-left: 1px solid var(--line);
  text-align: center;
}

.hero-score img {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  object-fit: cover;
}

.hero-score span {
  display: block;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 3rem;
  font-weight: 900;
}

.hero-score small,
.muted,
.sync-card span {
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.panel,
.game-header,
.results-hero,
.sync-card,
.stat,
.group-card,
.draw-card,
.manual-entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.panel.slim {
  box-shadow: none;
}

.panel-header {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.panel-header h2,
.section-title,
.group-card h3,
.bracket-round h3 {
  margin: 0;
  font-size: 1rem;
}

.panel-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 12px;
}

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

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

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

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

.participant-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 128px 110px 36px;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.setup-note {
  display: grid;
  align-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(232, 214, 120, 0.28);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.setup-note span {
  color: var(--muted);
  font-size: 0.84rem;
}

.upload-label input[type="file"] {
  max-width: 110px;
  padding: 7px;
  font-size: 0.72rem;
}

.compact-label {
  min-width: 180px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  overflow-x: auto;
}

.tab {
  min-height: 42px;
  color: var(--ink);
  background: var(--paper-2);
  border-color: var(--ink);
  box-shadow: 0 2px 0 var(--ink);
}

.tab.active {
  color: #fff;
  background: var(--brand);
}

.game-header,
.results-hero {
  margin-bottom: 14px;
  padding: 16px;
}

.sync-card {
  display: grid;
  min-width: 245px;
  gap: 4px;
  padding: 12px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

.stat {
  padding: 12px;
}

.stat strong {
  display: block;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 1.6rem;
  line-height: 1;
}

.stat span,
.pill,
.last-pick,
.pick-card small {
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 0.8rem;
}

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

.draw-card {
  display: grid;
  position: relative;
  min-height: 310px;
  place-items: center;
  padding: 28px;
  overflow: hidden;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(232, 214, 120, 0.42), transparent 42%),
    linear-gradient(225deg, rgba(217, 70, 77, 0.08), transparent 35%),
    var(--panel);
}

.draw-card::before {
  content: "";
  position: absolute;
  inset: 16px;
  background: url("/assets/sweepslogo.png") center / contain no-repeat;
  opacity: 0.045;
}

.draw-card > * {
  position: relative;
}

.draw-card h2 {
  margin: 0;
  font-size: 2.2rem;
  line-height: 1.02;
}

.avatar,
.mini-avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--paper-2);
  background: var(--blue);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-weight: 900;
  overflow: hidden;
}

.avatar {
  width: 54px;
  height: 54px;
  font-size: 1.55rem;
}

.avatar.large {
  width: 74px;
  height: 74px;
  font-size: 2rem;
}

.mini-avatar {
  width: 28px;
  height: 28px;
  margin-right: 7px;
  font-size: 0.9rem;
}

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

.preview {
  margin-bottom: 2px;
}

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

.allocation {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.allocation-player,
.table-name,
.team-inline,
.team-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.team-badge {
  font-weight: 800;
}

.allocation > strong {
  min-width: 0;
  text-align: right;
}

.allocation-player,
.team-badge span:last-child,
.team-inline span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flag-emoji {
  display: inline-grid;
  width: 24px;
  min-width: 24px;
  height: 20px;
  place-items: center;
  line-height: 1;
  text-align: center;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 1.05rem;
}

.flag-svg svg {
  display: block;
  width: 22px;
  height: 15px;
  border: 1px solid rgba(74, 74, 74, 0.2);
  border-radius: 2px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: #fff;
  font-weight: 800;
}

.winner,
.is-winner {
  border-color: var(--gold);
  background: rgba(232, 214, 120, 0.42);
}

.message {
  border: 1px solid var(--gold);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(232, 214, 120, 0.38);
}

.message.error {
  border-color: var(--brand);
  color: #7d1f27;
  background: rgba(217, 70, 77, 0.1);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.pick-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.pick-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.player-summary {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(232, 214, 120, 0.2);
}

.player-summary h2 {
  margin: 0 0 10px;
  font-size: 1.65rem;
}

.player-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.player-stats span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff;
}

.team-avatar {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
}

.segmented {
  display: flex;
  gap: 4px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  padding: 3px;
  background: var(--paper-2);
}

.segmented button {
  min-height: 32px;
  border: 0;
  box-shadow: none;
}

.segmented button.active {
  color: #fff;
  background: var(--ink);
}

.table-wrap {
  overflow-x: auto;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.group-card header {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.group-card table th,
.group-card table td {
  padding: 8px 9px;
}

.bracket {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 1fr);
  gap: 12px;
  overflow-x: auto;
}

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

.bracket-match,
.empty-bracket {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.bracket-match strong {
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 1.15rem;
}

.empty-bracket {
  grid-column: 1 / -1;
  min-height: 120px;
  place-items: center;
  text-align: center;
}

.manual-entry {
  margin-top: 18px;
  padding: 12px;
}

.manual-entry summary {
  cursor: pointer;
  font-weight: 850;
}

.manual-entry[open] summary {
  margin-bottom: 12px;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .layout,
  .draw-stage,
  .grid-2,
  .grid-3,
  .stat-strip,
  .hero {
    grid-template-columns: 1fr;
  }

  .topbar,
  .toolbar,
  .panel-header,
  .game-header,
  .results-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-score {
    border-top: 1px solid var(--line);
    border-left: 0;
    padding-top: 14px;
  }

  .participant-row {
    grid-template-columns: 46px minmax(0, 1fr) 36px;
  }

  .participant-row label {
    grid-column: 1 / -1;
  }

  .participant-row .preview,
  .participant-row .icon-button {
    grid-column: auto;
  }
}
