/* ================================================================
   CUEDUP — Catapult Sports-inspired design system
   ================================================================ */

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --orange:        #ee4d24;
  --orange-hover:  #be3e1d;
  --orange-dim:    rgba(238, 77, 36, 0.15);
  --dark:          #000000;
  --dark-2:        #0d0d0d;
  --dark-3:        #1a1a1a;
  --dark-4:        #252525;
  --gray:          #3a3a3a;
  --gray-mid:      #666;
  --gray-light:    #aaa;
  --white:         #ffffff;
  --white-dim:     rgba(255,255,255,0.07);
  --white-border:  rgba(255,255,255,0.12);
  --green:         #2ecc71;
  --red:           #e74c3c;

  --navbar-h:      64px;
  --radius:        0px;
  --transition:    0.2s ease;

  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--dark);
  color: var(--white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ───────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-transform: uppercase;
}

/* ── Container ────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Utilities ────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ================================================================
   NAVBAR
   ================================================================ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--navbar-h);
  background: var(--dark);
  border-bottom: 2px solid var(--orange);
}

.navbar__inner {
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.navbar__brand {
  text-decoration: none;
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  line-height: 1;
  flex-shrink: 0;
}

.brand-cued { color: var(--orange); }
.brand-up   { color: var(--white); }

.navbar__nav {
  display: flex;
  align-items: center;
  gap: 0;
}

.navbar__link {
  display: inline-block;
  padding: 0 18px;
  height: var(--navbar-h);
  line-height: var(--navbar-h);
  text-decoration: none;
  color: var(--gray-light);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 3px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  position: relative;
  top: 2px; /* offset for bottom border */
}

.navbar__link:hover,
.navbar__link--active {
  color: var(--white);
  border-bottom-color: var(--orange);
}

/* Hamburger */
.navbar__hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  width: 36px;
  height: 36px;
}

.navbar__hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--white);
  transition: transform var(--transition), opacity var(--transition);
}

.navbar__hamburger.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.navbar__hamburger.is-open span:nth-child(2) {
  opacity: 0;
}
.navbar__hamburger.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ================================================================
   MAIN
   ================================================================ */
.main {
  flex: 1;
  padding-top: var(--navbar-h);
}

.phase {
  padding: 48px 0 80px;
}

/* ── Page Header ──────────────────────────────────────────────── */
.page-header {
  margin-bottom: 40px;
}

.page-header__eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 8px;
}

.page-header__title {
  font-size: clamp(2.4rem, 6vw, 4rem);
  color: var(--white);
  margin-bottom: 12px;
}

.page-header__subtitle {
  font-size: 1rem;
  color: var(--gray-light);
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), opacity var(--transition);
  white-space: nowrap;
  user-select: none;
  border-radius: var(--radius);
  line-height: 1;
}

.btn--primary {
  background: var(--orange);
  color: var(--white);
  border-color: var(--orange);
}
.btn--primary:hover:not(:disabled) {
  background: var(--orange-hover);
  border-color: var(--orange-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--white);
  border-color: var(--white-border);
}
.btn--ghost:hover:not(:disabled) {
  border-color: var(--white);
  background: var(--white-dim);
}

.btn--danger {
  background: transparent;
  color: var(--red);
  border-color: rgba(231,76,60,0.3);
}
.btn--danger:hover:not(:disabled) {
  background: rgba(231,76,60,0.1);
  border-color: var(--red);
}

.btn--large {
  padding: 16px 36px;
  font-size: 0.9rem;
}

.btn--sm {
  padding: 8px 16px;
  font-size: 0.7rem;
}

.btn--icon {
  padding: 8px;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  font-weight: 900;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ================================================================
   INPUT
   ================================================================ */
.input {
  width: 100%;
  background: var(--dark-3);
  border: 2px solid var(--gray);
  color: var(--white);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 11px 14px;
  outline: none;
  transition: border-color var(--transition);
  border-radius: var(--radius);
}

.input::placeholder { color: var(--gray-mid); }
.input:focus { border-color: var(--orange); }

/* ================================================================
   CARDS (setup)
   ================================================================ */
.card {
  background: var(--dark-3);
  border: 1px solid var(--white-border);
  padding: 28px;
}

.card__title {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--orange);
  margin-bottom: 20px;
  border-bottom: 1px solid var(--white-border);
  padding-bottom: 12px;
}

/* ================================================================
   SETUP SCREEN
   ================================================================ */
.setup-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

.add-player-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.add-player-row .input { flex: 1; }

.hint {
  font-size: 0.78rem;
  color: var(--gray-mid);
  margin-bottom: 20px;
}

/* Setup player list */
.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 40px;
  margin-bottom: 20px;
}

.player-list__item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--dark-4);
  border: 1px solid var(--white-border);
  padding: 10px 12px;
  cursor: grab;
  transition: background var(--transition), border-color var(--transition);
  user-select: none;
}

.player-list__item:active { cursor: grabbing; }
.player-list__item.drag-over { border-color: var(--orange); background: var(--orange-dim); }
.player-list__item.dragging { opacity: 0.4; }

.player-list__drag {
  color: var(--gray-mid);
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1;
  cursor: grab;
}

.player-list__order {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--orange);
  width: 18px;
  flex-shrink: 0;
  letter-spacing: 0.05em;
}

.player-list__name {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
}

.player-list__delete {
  background: none;
  border: none;
  color: var(--gray-mid);
  cursor: pointer;
  padding: 4px;
  font-size: 1rem;
  line-height: 1;
  transition: color var(--transition);
  display: flex;
  align-items: center;
}
.player-list__delete:hover { color: var(--red); }

.setup-actions {
  display: flex;
  gap: 10px;
}

/* Settings card */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.setting-row__label {
  font-size: 0.9rem;
  font-weight: 600;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 2px solid var(--gray);
}

.stepper__btn {
  background: var(--dark-4);
  border: none;
  color: var(--white);
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.stepper__btn:hover { background: var(--orange); }

.stepper__value {
  width: 44px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
  border-left: 2px solid var(--gray);
  border-right: 2px solid var(--gray);
  line-height: 36px;
  background: var(--dark-3);
}

.start-row {
  margin-top: 32px;
  display: flex;
  justify-content: flex-start;
}

/* ================================================================
   GAME SCREEN
   ================================================================ */
.game-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.game-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

/* Turn Banner */
.turn-banner {
  background: var(--orange-dim);
  border: 1px solid var(--orange);
  border-left: 4px solid var(--orange);
  padding: 12px 20px;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.turn-banner__label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--orange);
}

.turn-banner__name {
  font-size: 1.1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.turn-banner__next {
  margin-left: auto;
  flex-shrink: 0;
}

/* Section titles */
.section-title {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--gray-light);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.section-title__dot--live { background: var(--green); box-shadow: 0 0 6px var(--green); }
.section-title__dot--elim { background: var(--gray-mid); }

.section-title__count {
  margin-left: auto;
  background: var(--dark-4);
  border: 1px solid var(--white-border);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  letter-spacing: 0.06em;
}

/* Player cards (game) */
.player-cards {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-card {
  background: var(--dark-3);
  border: 1px solid var(--white-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color var(--transition), background var(--transition), opacity 0.3s ease, transform 0.3s ease, max-height 0.35s ease;
  animation: cardIn 0.25s ease;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.player-card--current {
  border-color: var(--orange);
  background: var(--orange-dim);
}

.player-card--low {
  border-color: rgba(231, 76, 60, 0.5);
}

.player-card__name {
  flex: 1;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-card--elim .player-card__name {
  color: var(--gray-mid);
  text-decoration: line-through;
  font-weight: 600;
  font-size: 0.9rem;
}

.player-card__lives {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lives-display {
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1;
  min-width: 28px;
  text-align: center;
  color: var(--white);
}

.lives-display--low   { color: var(--red); }
.lives-display--zero  { color: var(--gray-mid); }

.lives-pips {
  display: flex;
  gap: 4px;
  align-items: center;
}

.lives-pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--gray);
  background: transparent;
  transition: background var(--transition), border-color var(--transition);
}

.lives-pip--filled {
  background: var(--orange);
  border-color: var(--orange);
}

.lives-pip--filled-low {
  background: var(--red);
  border-color: var(--red);
}

.player-card__controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ctrl-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid;
  background: transparent;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  line-height: 1;
  flex-shrink: 0;
}

.ctrl-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.ctrl-btn--minus {
  border-color: rgba(231, 76, 60, 0.5);
  color: var(--red);
}
.ctrl-btn--minus:hover:not(:disabled) {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}
.ctrl-btn--plus {
  border-color: rgba(46, 204, 113, 0.5);
  color: var(--green);
}
.ctrl-btn--plus:hover:not(:disabled) {
  background: var(--green);
  color: var(--white);
  border-color: var(--green);
}

/* Eliminated section */
.player-cards--elim .player-card {
  opacity: 0.7;
  background: var(--dark-2);
}

.elim-order {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--gray-mid);
  letter-spacing: 0.06em;
  flex-shrink: 0;
  min-width: 24px;
  text-align: center;
}

.elim-hint {
  font-size: 0.8rem;
  color: var(--gray-mid);
  text-align: center;
  padding: 20px 0;
  border: 1px dashed var(--gray);
}

/* Winner Banner */
.winner-banner {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.winner-banner__inner {
  background: var(--dark-3);
  border: 2px solid var(--orange);
  padding: 48px 56px;
  text-align: center;
  max-width: 480px;
  width: calc(100% - 40px);
  animation: slideUp 0.35s ease;
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.winner-banner__eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 12px;
}

.winner-banner__name {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  color: var(--white);
  margin-bottom: 32px;
  line-height: 1;
}

/* ================================================================
   TOURNAMENT BRACKET
   ================================================================ */
.bracket-round {
  margin-bottom: 40px;
}

.match-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.match-card {
  background: var(--dark-3);
  border: 1px solid var(--white-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  animation: cardIn 0.25s ease;
}

.match-card--active {
  border-color: var(--orange);
  background: var(--orange-dim);
}

.match-card--complete {
  opacity: 0.75;
  background: var(--dark-2);
}

.match-card--pending {
  opacity: 0.45;
  border-style: dashed;
}

.match-player {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-player--winner { color: var(--white); }
.match-player--loser  { color: var(--gray-mid); text-decoration: line-through; }
.match-player--unknown { color: var(--gray-mid); font-style: italic; font-weight: 400; text-transform: none; }

.match-vs {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gray-mid);
  flex-shrink: 0;
}

.match-btn {
  flex: 1;
  text-align: center;
  min-width: 80px;
}

.match-btn:hover:not(:disabled) {
  border-color: var(--orange);
  color: var(--orange);
  background: var(--orange-dim);
}

.match-bye {
  font-size: 0.9rem;
  color: var(--gray-light);
  font-weight: 600;
}

.match-bye em {
  color: var(--gray-mid);
  font-style: italic;
  font-weight: 400;
}

/* ================================================================
   FOOTER
   ================================================================ */
.footer {
  background: var(--dark-2);
  border-top: 3px solid var(--orange);
  padding: 40px 0 28px;
  margin-top: auto;
}

.footer__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

.footer__brand .navbar__brand {
  font-size: 1.3rem;
  margin-bottom: 6px;
  display: inline-block;
}

.footer__tagline {
  font-size: 0.75rem;
  color: var(--gray-mid);
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.footer__social {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
}

.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--white-border);
  color: var(--gray-light);
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.social-link:hover {
  color: var(--white);
  border-color: var(--orange);
  background: var(--orange-dim);
}

.footer__copy {
  font-size: 0.7rem;
  color: var(--gray-mid);
  letter-spacing: 0.04em;
  text-align: right;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 860px) {
  .setup-grid {
    grid-template-columns: 1fr;
  }

  .game-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }
}

@media (max-width: 640px) {
  .navbar__nav {
    display: none;
    position: absolute;
    top: var(--navbar-h);
    left: 0;
    right: 0;
    background: var(--dark-2);
    border-bottom: 2px solid var(--orange);
    flex-direction: column;
    padding: 8px 0;
  }

  .navbar__nav.is-open { display: flex; }

  .navbar__link {
    height: auto;
    line-height: 1;
    padding: 16px 24px;
    width: 100%;
    border-bottom: none;
    border-left: 3px solid transparent;
  }
  .navbar__link:hover,
  .navbar__link--active {
    border-bottom: none;
    border-left-color: var(--orange);
    background: var(--white-dim);
  }

  .navbar__hamburger { display: flex; }

  .phase { padding: 32px 0 60px; }

  .page-header__title { font-size: 2.2rem; }

  .card { padding: 20px; }

  .footer__inner {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 20px;
  }
  .footer__copy { text-align: center; }
  .footer__social { justify-content: center; }

  .player-card__name { font-size: 0.9rem; }

  .winner-banner__inner { padding: 36px 28px; }

  .match-card {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .match-vs { text-align: center; }

  .match-btn { width: 100%; }
}

@media (max-width: 420px) {
  .add-player-row { flex-direction: column; }
  .add-player-row .btn { width: 100%; }
}

/* ── Ladder ──────────────────────────────────────────────────────── */
.ladder-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.ladder-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-light);
  border-bottom: 1px solid var(--gray);
}

.ladder-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--dark-4);
  color: var(--white);
}

.ladder-table tbody tr:hover td {
  background: var(--dark-3);
}

.ladder-table__pos {
  color: var(--gray-light);
  font-variant-numeric: tabular-nums;
  width: 2.5rem;
}

.ladder-table__name {
  font-weight: 500;
}

.ladder-winpct {
  color: var(--gray-light);
}

/* Top 3 rank accent */
.ladder-table__rank--1 td:first-child { color: #ffd700; }
.ladder-table__rank--2 td:first-child { color: #c0c0c0; }
.ladder-table__rank--3 td:first-child { color: #cd7f32; }

.ladder-table__rank--1 .ladder-table__name { color: #ffd700; }
.ladder-table__rank--2 .ladder-table__name { color: #c0c0c0; }
.ladder-table__rank--3 .ladder-table__name { color: #cd7f32; }

/* Loading / error states */
.ladder-loading,
.ladder-error {
  padding: 2rem 0;
  text-align: center;
  color: var(--gray-light);
}

.ladder-error p {
  margin-bottom: 1rem;
}

/* Ladder → Competition ID setup */
.ladder-setup {
  padding: 2rem 0;
}

.ladder-setup__hint {
  margin-bottom: 1rem;
  color: var(--gray-light);
  font-size: 0.875rem;
}

.ladder-setup__form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ladder-setup__input {
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--gray-mid);
  border-radius: 0.375rem;
  background: var(--bg-card);
  color: inherit;
  font-size: 0.875rem;
  width: 10rem;
}

.ladder-change-competition {
  margin-top: 1rem;
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--gray-light);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--text-primary, #fff);
}

/* Ladder → Bracket bar */
.ladder-bracket-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.ladder-bracket-bar__label {
  font-size: 0.875rem;
  color: var(--gray-light);
}

.ladder-bracket-bar__input {
  width: 4.5rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--gray-mid);
  border-radius: 0.375rem;
  background: var(--bg-card);
  color: inherit;
  font-size: 0.875rem;
  text-align: center;
}
