/* DESIGN 4: ORGANIC / STADIUM ATMOSPHERE */
/* Warm stadium lighting. Soft gradients. Flowing shapes. */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&display=swap');

:root {
  --green: #2b9348;
  --amber: #e09f3e;
  --red: #d62828;
  --blue: #0077b6;
  --pitch: #1b4332;
  --warm: #fdf6ec;
  --cream: #fff8f0;
  --wheat: #f5e6cc;
  --terracotta: #c17849;
  --text: #2b2b2b;
  --muted: #7a7a6e;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--warm);
  color: var(--text);
  line-height: 1.6;
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(224, 159, 62, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 0% 100%, rgba(43, 147, 72, 0.04) 0%, transparent 40%);
}

.top-nav {
  background: linear-gradient(135deg, var(--pitch) 0%, #2d6a4f 100%);
  color: white;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 60px;
  box-shadow: 0 2px 20px rgba(27, 67, 50, 0.3);
}

.top-nav .brand {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-nav .brand svg { filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2)); }

.top-nav a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.top-nav a.active, .top-nav a:hover {
  color: white;
  border-bottom-color: var(--amber);
}

.container { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }

h1 { font-family: 'Fraunces', serif; font-size: 30px; font-weight: 700; margin-bottom: 4px; color: var(--pitch); }
h2 { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600; margin-bottom: 8px; color: var(--pitch); }
p { color: var(--muted); margin-bottom: 16px; font-size: 15px; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

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

.card {
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

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

.participant-card {
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  padding: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.participant-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.draw-participants .participant-card {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.draw-participants .participant-card h3 { margin-bottom: 0; margin-right: 4px; }

.participant-card h3 {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--pitch);
}

.team-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, var(--wheat) 0%, #f0dfc4 100%);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  margin: 3px;
  color: var(--pitch);
}

.team-chip.eliminated { opacity: 0.35; text-decoration: line-through; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }

.badge.alive { background: #d8f3dc; color: var(--green); }
.badge.eliminated { background: #fde2e4; color: var(--red); }
.badge.bonus { background: #fef3cd; color: #8a6d1b; }
.badge.pot { background: #d1ecf1; color: var(--blue); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
.standings-table { table-layout: fixed; }

th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid rgba(0, 0, 0, 0.06); }
th { font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 24px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.2s;
}

.btn.primary { background: linear-gradient(135deg, var(--pitch), #2d6a4f); color: white; box-shadow: 0 4px 12px rgba(27, 67, 50, 0.3); }
.btn.primary:hover { box-shadow: 0 6px 20px rgba(27, 67, 50, 0.4); transform: translateY(-1px); }
.btn.primary:active { transform: translateY(0); }
.btn.danger { background: linear-gradient(135deg, var(--red), #e63946); color: white; }
.btn.danger:hover { box-shadow: 0 4px 12px rgba(214, 40, 40, 0.3); }
.btn.outline { background: white; border: 2px solid var(--wheat); color: var(--text); border-radius: 24px; }
.btn.outline:hover { background: var(--wheat); }
.btn.outline:active { background: #e8d5b7; }
.btn:disabled { opacity: 0.35; cursor: default; }

svg.icon { vertical-align: middle; display: inline; }

input, select {
  padding: 10px 16px;
  border: 2px solid var(--wheat);
  border-radius: 12px;
  font-size: 14px;
  min-height: 44px;
  box-sizing: border-box;
  background: white;
  color: var(--text);
}

input:focus, select:focus { border-color: var(--terracotta); }

.form-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.form-row input { flex: 1; }

.alert { padding: 14px; border-radius: 12px; margin-bottom: 12px; font-size: 14px; }
.alert.error { background: #fde2e4; color: var(--red); }
.alert.success { background: #d8f3dc; color: var(--green); }
.alert.info { background: #d1ecf1; color: var(--blue); }

.match-card { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(0,0,0,0.04); }
.match-card .teams { flex: 1; display: flex; align-items: center; gap: 8px; }
.match-card .score { display: flex; align-items: center; gap: 4px; }
.match-card .score input { width: 48px; text-align: center; font-size: 15px; }
.match-card .vs { color: var(--wheat); font-weight: 600; }

.standings-table .col-num { text-align: center; white-space: nowrap; }
.standings-table .pos { width: 30px; color: var(--muted); }
.standings-table .col-pts { font-weight: 700; }

.group-section { margin-bottom: 32px; }

.group-section h3 {
  font-family: 'Fraunces', serif;
  margin-bottom: 10px;
  font-size: 18px;
  font-weight: 600;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--wheat);
  color: var(--pitch);
}

.group-layout { display: flex; gap: 28px; align-items: flex-start; }
.group-layout .standings-table { flex: 1; min-width: 0; }
.group-fixtures { flex: 1; min-width: 260px; font-size: 13px; }

.fixture-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.fixture-row:has(+ .fixture-teams) { border-bottom: 0; padding-bottom: 0; }

.fixture-time { min-width: 104px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.fixture-home { flex: 1; text-align: right; }
.fixture-away { flex: 1; }
.fixture-score { min-width: 28px; text-align: center; font-weight: 600; color: var(--pitch); }

.summary-strip {
  display: flex;
  gap: 36px;
  flex-wrap: wrap;
  padding: 24px;
  background: linear-gradient(135deg, white 0%, var(--cream) 100%);
  border-radius: 20px;
  border: 1px solid rgba(0,0,0,0.04);
  margin-bottom: 28px;
}

.summary-stat { text-align: center; }

.summary-stat .value {
  font-family: 'Fraunces', serif;
  font-size: 36px;
  font-weight: 700;
  color: var(--pitch);
  line-height: 1;
}

.summary-stat .label { font-size: 12px; color: var(--muted); margin-top: 4px; }

.zero-hero-stat .value { color: var(--amber); }
.zero-hero-stat .label { color: var(--amber); }

tr.zero-hero { background: #fef9ef; }

.badge.zero-hero-badge { background: #fef3cd; color: #8a6d1b; font-size: 12px; padding: 0 8px; border-radius: 20px; }
.badge.third { background: #fef3cd; color: #8a6d1b; }

tr.status-qualified { background: #edf7ed; }
tr.status-eliminated { background: #fdf0f0; }
tr.status-third { background: #fef9ef; }

.empty-state { text-align: center; padding: 64px 24px; color: var(--muted); }
.empty-state h2 { color: var(--pitch); margin-bottom: 8px; }

.draw-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
  font-size: 13px;
  align-items: start;
}

.draw-layout h1 { font-size: 22px; margin-bottom: 0; }
.draw-layout h2 { font-size: 16px; margin-bottom: 6px; }
.draw-layout h3 { font-size: 13px; margin-bottom: 0; }
.draw-layout .draw-participants h2, .draw-layout .draw-pool h2 { margin-bottom: 12px; }
.draw-layout .btn { font-size: 12px; padding: 8px 14px; min-height: 32px; }
.draw-layout .team-chip { font-size: 11px; padding: 5px 10px; margin: 2px; }
.draw-layout .badge { font-size: 10px; padding: 3px 7px; }

.team-pool .team-chip.selected {
  border: 2px solid var(--amber);
  box-shadow: 0 0 20px rgba(224, 159, 62, 0.4);
  animation: stadium-glow 1.2s ease-in-out infinite;
  transform: scale(1.05);
}

.team-pool .team-chip.assigned { opacity: 0.2; text-decoration: line-through; }

.draw-participants .assigned-teams { display: contents; }
.draw-participants h2, .draw-pool h2 { margin-bottom: 12px; }

.team-pool { display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; }
.team-pool .team-chip { transition: all 0.3s; }

.participant-card.revealed {
  border-color: var(--green) !important;
  box-shadow: 0 0 20px rgba(43, 147, 72, 0.15);
  transition: all 0.4s;
}

.draw-status { text-align: center; font-size: 14px; padding: 12px; font-weight: 600; color: var(--pitch); }

.pot-section { margin-bottom: 10px; }

.pot-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--wheat);
}

@keyframes stadium-glow {
  0%, 100% { box-shadow: 0 0 12px rgba(224, 159, 62, 0.3); }
  50% { box-shadow: 0 0 28px rgba(224, 159, 62, 0.6); }
}

.ko-match {
  display: flex;
  flex-direction: column;
  background: white;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  margin-bottom: 6px;
  overflow: hidden;
}

.ko-team { padding: 8px 12px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.ko-team.winner { background: #edf7ed; font-weight: 600; }
.ko-score { padding: 2px 12px; font-size: 12px; color: var(--muted); text-align: center; background: var(--cream); border-top: 1px solid rgba(0,0,0,0.04); border-bottom: 1px solid rgba(0,0,0,0.04); }
.ko-score-input { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 4px 8px; background: var(--cream); border-top: 1px solid rgba(0,0,0,0.04); border-bottom: 1px solid rgba(0,0,0,0.04); }
.ko-select { padding: 4px; font-size: 12px; border: 1px solid var(--wheat); border-radius: 8px; margin: 2px 4px; }

.ko-bracket-grid { display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: auto repeat(16, 1fr); gap: 4px; height: 750px; }
.ko-round-label { font-size: 10px; font-weight: 600; color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: 1px; padding: 2px 0; align-self: start; }
.ko-bracket-grid .ko-match { margin: 0; border-radius: 10px; justify-content: space-between; }
.ko-bracket-grid .ko-team { padding: 3px 6px; font-size: 10px; gap: 3px; }
.ko-bracket-grid .ko-score { padding: 1px 6px; font-size: 10px; }

.h2h-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: flex-start; margin-bottom: 20px; }
.h2h-table { min-width: 0; }
.h2h-table th, .h2h-table td { padding: 6px 5px; }
.h2h-table th:nth-child(2), .h2h-table td:nth-child(2) { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 768px) { .h2h-table th, .h2h-table td { padding: 4px 3px; font-size: 12px; } }
.h2h-fixtures { min-width: 0; }
.h2h-section { margin-bottom: 16px; }
.h2h-section h3 { font-family: 'Fraunces', serif; margin-bottom: 8px; font-size: 16px; font-weight: 600; color: var(--pitch); }
.h2h-section p { font-size: 13px; color: var(--muted); }

.fixture-teams { font-size: 11px; color: var(--muted); padding-top: 0; margin-bottom: 4px; }

@media (max-width: 1024px) {
  .h2h-layout { grid-template-columns: 1fr; }
  .h2h-table, .h2h-fixtures { width: 100%; min-width: 0; }
}

@media (max-width: 768px) {
  .container { padding: 24px 16px; }
  .grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .draw-layout { grid-template-columns: 1fr; }
  .ko-layout { flex-wrap: wrap; }
  .ko-bracket-grid { height: auto; grid-template-columns: 1fr 1fr; grid-template-rows: none; }
  .ko-bracket-grid .ko-round-label { display: none; }
  .ko-bracket-grid .ko-match { grid-column: auto !important; grid-row: auto !important; }
  .group-layout { flex-direction: column; }
  .group-fixtures { width: 100%; min-width: 0; }
  .h2h-layout { grid-template-columns: 1fr; }
  .h2h-table, .h2h-fixtures { width: 100%; min-width: 0; }
}

#auth-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(27, 67, 50, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-box {
  background: white;
  border-radius: 24px;
  padding: 40px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.auth-box h2 { font-family: 'Fraunces', serif; font-size: 22px; margin-bottom: 4px; }
.auth-box p { color: var(--muted); margin-bottom: 24px; }
.auth-box .form-row { flex-direction: row; }
.auth-box input { flex: 1; }

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