:root {
  color-scheme: dark;
  --bg: #090c10;
  --panel: #121922;
  --panel-2: #1a2430;
  --line: #2d3947;
  --text: #f5f8fb;
  --muted: #9aa8b6;
  --green: #35d07f;
  --red: #ff6969;
  --gold: #f0c94a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  color: inherit;
  touch-action: manipulation;
}

button:active {
  transform: scale(0.98);
}

.hidden {
  display: none !important;
}

.shell {
  width: 100%;
  max-width: 500px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 14px;
}

.join-view {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  gap: 28px;
}

.brand-lockup {
  text-align: center;
}

.cup-mark {
  font-size: 58px;
}

h1,
h2,
p {
  margin: 0;
}

.brand-lockup h1,
.topbar h1 {
  font-size: 26px;
  line-height: 1.1;
}

.brand-lockup p,
.eyebrow,
.view-head span {
  color: var(--muted);
}

.brand-lockup h1 {
  font-size: 36px;
}

.join-form {
  display: grid;
  gap: 10px;
}

.join-form input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--text);
}

.join-help {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.join-error {
  min-height: 22px;
  color: var(--red);
  font-size: 14px;
}

.join-form button,
.small-btn {
  border-radius: 8px;
  background: var(--text);
  color: #071016;
  font-weight: 800;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  margin: -14px -14px 0;
  padding: 12px 14px 8px;
  background: rgba(9, 12, 16, 0.96);
  border-bottom: 1px solid var(--line);
}

.title-block {
  min-width: 0;
}

.app-brand {
  display: block;
  margin-top: 2px;
  color: var(--gold);
  font-size: 14px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.menu-btn,
.icon-btn {
  width: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 22px;
}

.tabs {
  position: absolute;
  top: calc(100% + 6px);
  left: 14px;
  right: 14px;
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090c10;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}

.tabs:not(.menu-open) {
  display: none;
}

.tab,
.round-tab {
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
}

.tab.active,
.round-tab.active {
  background: var(--panel-2);
  color: var(--text);
  outline: 1px solid var(--gold);
}

.deadline-banner {
  position: sticky;
  top: 61px;
  z-index: 8;
  margin: 0 -14px 10px;
  padding: 8px 14px;
  background: rgba(240, 201, 74, 0.16);
  border-bottom: 1px solid rgba(240, 201, 74, 0.28);
  color: #ffe08a;
  text-align: center;
  font-size: 14px;
  font-weight: 900;
}

.deadline-banner.locked {
  background: rgba(255, 105, 105, 0.14);
  border-color: rgba(255, 105, 105, 0.28);
  color: #ffaaaa;
}

.status-bar {
  min-height: 24px;
  color: var(--muted);
  font-size: 14px;
}

.status-bar.ok {
  color: var(--green);
}

.status-bar.error {
  color: var(--red);
}

.completion-chip {
  display: grid;
  gap: 4px;
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.completion-chip span {
  color: var(--muted);
  font-size: 14px;
}

.completion-chip.complete {
  border-color: rgba(53, 208, 127, 0.7);
}

.completion-chip.locked {
  border-color: rgba(255, 105, 105, 0.55);
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0;
}

.review-head {
  align-items: stretch;
}

.round-tabs {
  position: sticky;
  top: 94px;
  z-index: 7;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  margin: 0 -14px 12px;
  padding: 8px 14px;
  overflow-x: auto;
  background: rgba(9, 12, 16, 0.96);
}

.round-tab {
  min-width: 62px;
}

.round-column,
.bracket-list,
.match-grid {
  display: grid;
  gap: 10px;
}

.slot-card,
.person-card,
.match-card,
.table,
.readonly-round {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.slot-card.correct {
  border-color: rgba(53, 208, 127, 0.7);
}

.live-now {
  margin-bottom: 18px;
}

.live-now h2,
.match-day h2 {
  margin: 12px 0 8px;
  font-size: 15px;
}

.match-card {
  padding: 12px;
}

.match-card.live {
  border-color: rgba(255, 105, 105, 0.75);
  box-shadow: inset 3px 0 0 var(--red);
}

.match-card.live-top {
  background: rgba(255, 105, 105, 0.1);
}

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

.match-card-head {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.live-label {
  color: var(--red);
}

.match-score {
  min-height: 28px;
  margin: 8px 0;
  font-size: 24px;
  font-weight: 900;
}

.match-team {
  grid-template-columns: 32px minmax(0, 1fr) auto;
  min-height: 34px;
}

.pulse-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.slot-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
}

.score-chip {
  color: var(--green);
  font-weight: 900;
}

.candidate-list {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.candidate {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: var(--panel);
  text-align: left;
}

.candidate.picked {
  background: rgba(240, 201, 74, 0.16);
  color: var(--gold);
  font-weight: 900;
}

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

.flag {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
}

.flag.placeholder {
  display: grid;
  place-items: center;
  background: var(--panel-2);
  color: var(--muted);
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 56px 56px 62px;
  gap: 8px;
  align-items: center;
  padding: 10px;
}

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

.table-row {
  border-top: 1px solid var(--line);
}

.person-card {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  text-align: left;
}

.person-card span,
.empty span {
  color: var(--muted);
}

.readonly-round {
  margin-bottom: 12px;
  padding: 12px;
}

.readonly-round h2 {
  margin-bottom: 8px;
  font-size: 16px;
}

.readonly-slot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.readonly-slot.champion {
  color: var(--gold);
  font-weight: 900;
}

.review-tree {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 10px;
}

.review-tree-inner {
  display: grid;
  grid-template-columns: repeat(5, 160px);
  gap: 10px;
  min-width: 840px;
  min-height: 980px;
  align-items: stretch;
}

.review-round {
  display: grid;
  grid-template-rows: auto 1fr;
  margin-bottom: 0;
}

.review-stack {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 10px;
  min-height: 0;
}

.review-slot {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.review-slot.correct {
  border-color: rgba(53, 208, 127, 0.7);
  background: rgba(53, 208, 127, 0.1);
}

.review-slot.empty-pick {
  color: var(--muted);
}

.review-slot-head,
.review-advances {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.review-slot-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.review-matchup {
  display: grid;
  gap: 4px;
}

.review-team {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 5px 6px;
  border-radius: 6px;
  color: var(--muted);
}

.review-team.picked {
  color: var(--text);
  background: rgba(53, 208, 127, 0.12);
  font-weight: 900;
}

.review-team.empty {
  opacity: 0.7;
}

.review-advances {
  padding-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.review-advances strong {
  min-width: 0;
  color: var(--text);
}

.empty {
  display: grid;
  gap: 8px;
  padding: 28px 10px;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 768px) {
  .shell {
    max-width: 1100px;
    padding: 20px;
  }

  .topbar {
    grid-template-columns: minmax(220px, auto) 1fr 48px;
    margin: -20px -20px 0;
    padding-left: 20px;
    padding-right: 20px;
  }

  .menu-btn {
    display: none;
  }

  .tabs,
  .tabs:not(.menu-open) {
    position: static;
    display: flex;
    justify-self: center;
    width: auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .tab {
    min-width: 128px;
    padding: 0 14px;
  }

  .deadline-banner,
  .round-tabs {
    margin-left: -20px;
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
  }

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

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

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

  .review-tree-inner {
    grid-template-columns: repeat(5, 200px);
    gap: 18px;
    min-width: 1080px;
    min-height: 1320px;
  }

  .review-stack {
    gap: 14px;
  }

  .review-slot {
    min-height: 142px;
    padding: 10px;
  }
}
