:root {
  --bg: #f3f0e8;
  --panel: #fffdf9;
  --panel-strong: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #e7dfd2;
  --brand: #b3472f;
  --brand-dark: #8f3824;
  --accent: #1f6f78;
  --success: #1f8f58;
  --danger: #b42318;
  --warning: #b7791f;
  --shadow: 0 18px 45px rgba(77, 47, 24, 0.08);
  --radius: 22px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(179, 71, 47, 0.09), transparent 32%),
    radial-gradient(circle at bottom right, rgba(31, 111, 120, 0.08), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
}

a { color: inherit; text-decoration: none; }
.app-shell { max-width: 1180px; margin: 0 auto; padding: 24px; }
.topbar {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  margin-bottom: 24px; padding: 24px 28px; border-radius: 30px;
  background: rgba(255,255,255,0.72); backdrop-filter: blur(16px); box-shadow: var(--shadow);
}
.brand { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-family: system-ui, sans-serif; }
.topbar-actions { display: flex; gap: 12px; align-items: center; }
.admin-pill {
  background: #f7eee7; color: var(--brand-dark); border-radius: 999px;
  padding: 10px 14px; font-family: system-ui, sans-serif; font-size: 0.92rem; font-weight: 700;
}
.page { display: grid; gap: 20px; }
.card {
  background: rgba(255,255,255,0.92); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card-header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px;
}
.card-title { margin: 0; font-size: 1.45rem; }
.muted { color: var(--muted); font-family: system-ui, sans-serif; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 14px; }
.button, button {
  border: 0; cursor: pointer; border-radius: 16px; padding: 12px 16px; font-weight: 700;
  font-family: system-ui, sans-serif; transition: transform .15s ease, background .15s ease, opacity .15s ease;
}
.button:hover, button:hover { transform: translateY(-1px); }
.button-primary, button.button-primary { background: var(--brand); color: #fff; }
.button-primary:hover, button.button-primary:hover { background: var(--brand-dark); }
.button-secondary, button.button-secondary { background: #efe7dc; color: var(--text); }
.button-danger, button.button-danger { background: #fee4e2; color: var(--danger); }
.button-success, button.button-success { background: #dcfae6; color: var(--success); }
.button-inline { display: inline-flex; align-items: center; justify-content: center; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat {
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,241,233,.95));
  border: 1px solid var(--line); border-radius: 20px; padding: 18px;
}
.stat-label { color: var(--muted); font-family: system-ui, sans-serif; font-size: .88rem; }
.stat-value { font-size: 2rem; font-weight: 700; margin-top: 8px; }
form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-family: system-ui, sans-serif; font-weight: 600; }
input, select {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  background: #fff; font: inherit; color: var(--text);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { font-family: system-ui, sans-serif; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; }
.badge {
  display: inline-flex; border-radius: 999px; padding: 7px 12px; font-size: .78rem;
  font-weight: 700; font-family: system-ui, sans-serif; background: #eee7dd; color: #6b4f34;
}
.badge-draft { background: #eceff3; color: #344054; }
.badge-registration { background: #fff3cd; color: #8a6116; }
.badge-scheduled { background: #dbeafe; color: #1d4ed8; }
.badge-in_progress { background: #dcfae6; color: #166534; }
.badge-finished { background: #f3e8ff; color: #7e22ce; }
.tabs { display: flex; gap: 10px; flex-wrap: wrap; }
.tab {
  background: rgba(255,255,255,.72); padding: 10px 14px; border-radius: 999px;
  border: 1px solid var(--line); font-family: system-ui, sans-serif; font-weight: 700;
}
.tab.is-active { background: var(--brand); color: white; border-color: var(--brand); }
.flash {
  border-radius: 18px; padding: 14px 16px; font-family: system-ui, sans-serif;
  border: 1px solid transparent; margin-bottom: 4px;
}
.flash-success { background: #ecfdf3; color: #027a48; border-color: #abefc6; }
.flash-error { background: #fef3f2; color: #b42318; border-color: #fecdca; }
.flash-warning { background: #fffaeb; color: #b54708; border-color: #fedf89; }
.match-card {
  display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line);
  border-radius: 18px; background: #fff;
}
.round-form { display: block; }
.round-layout {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.round-meta {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 12px 4px 12px 0;
}
.round-meta .muted { margin: 0; }
.round-body { min-width: 0; }
.round-toolbar { justify-content: flex-end; }
.match-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.team-block { display: grid; gap: 6px; min-width: 0; }
.score-form { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.score-fields { display: flex; gap: 8px; align-items: center; justify-content: center; flex: 0 0 auto; }
.score-input { width: 74px; text-align: center; }
.small { font-size: .92rem; font-family: system-ui, sans-serif; color: var(--muted); }
.player-library {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 8px;
  background: rgba(255,255,255,0.82);
}
.player-library .player-library-item {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 12px;
  border-radius: 14px;
  font-family: system-ui, sans-serif;
  font-weight: 600;
}
.player-library-item:hover {
  background: #f8f2ea;
}
.player-library .player-library-item input {
  display: inline-block;
  width: auto;
  margin: 0;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 4px;
}
.player-library .player-library-item span {
  display: inline-block;
  flex: 1 1 auto;
}
.empty-state {
  border: 2px dashed var(--line); border-radius: 22px; padding: 28px; text-align: center;
  color: var(--muted); font-family: system-ui, sans-serif; background: rgba(255,255,255,.55);
}
.login-shell { max-width: 460px; margin: 10vh auto; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.space-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dashboard-hero { padding: 18px 22px; }
.dashboard-hero-row { min-height: auto; }
.stats-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 41, 55, 0.42);
  backdrop-filter: blur(8px);
  padding: 24px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  z-index: 40;
}
.modal-card {
  width: min(720px, 100%);
  background: rgba(255,255,255,0.97);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 30px 70px rgba(31, 41, 55, 0.16);
  padding: 22px;
  margin: 24px 0;
}
.modal-grid { align-items: end; }
.share-card {
  margin-top: 18px;
  padding: 18px;
}
.share-link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.public-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.public-standings-list {
  display: grid;
  gap: 12px;
}
.public-standings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(247,242,234,0.92));
}
.public-standings-player {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.public-rank {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f7eee7;
  color: var(--brand-dark);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  flex: 0 0 auto;
}
.public-points {
  font-size: 1.55rem;
}
.public-matches {
  display: grid;
  gap: 16px;
}
.public-round {
  display: grid;
  gap: 12px;
}
.public-round-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.public-round-head h3 {
  margin: 0;
  font-size: 1.2rem;
}
.public-match-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255,255,255,0.9);
  display: grid;
  gap: 10px;
  transition: opacity .2s ease, transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.public-match-completed {
  opacity: 0.5;
  background: rgba(245, 240, 232, 0.78);
}
.public-match-upcoming {
  opacity: 0.92;
}
.public-match-next {
  border-color: rgba(179, 71, 47, 0.5);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,245,238,0.98));
  box-shadow: 0 16px 36px rgba(179, 71, 47, 0.14);
  transform: translateY(-1px);
}
.public-match-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.public-match-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}
.public-team-names {
  display: grid;
  gap: 4px;
  font-size: 1.05rem;
}
.public-team-right {
  text-align: right;
}
.public-match-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 82px;
  padding: 10px 12px;
  border-radius: 16px;
  background: #f8f2ea;
  font-weight: 700;
  text-transform: uppercase;
}
.public-match-next .public-match-score {
  background: #b3472f;
  color: #fff;
}
.public-match-completed .public-match-score {
  background: #ece4d8;
}

@media (max-width: 900px) {
  .app-shell { padding: 16px; }
  .topbar, .card { padding: 20px; }
  .grid-2, .grid-3, .round-layout, .modal-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .topbar, .space-between { flex-direction: column; align-items: stretch; }
  .round-meta { padding: 0; }
  .round-toolbar { justify-content: flex-start; }
  .match-card { padding: 16px; }
  .match-head { flex-direction: column; align-items: flex-start; }
  .score-form {
    gap: 10px;
    align-items: center;
    justify-content: space-between;
  }
  .team-block { gap: 4px; flex: 1 1 0; }
  .team-block:last-child { text-align: right; }
  .score-fields { gap: 6px; }
  .score-input { width: 54px; padding: 10px 8px; }
  .stats-compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }
  .stats-compact .stat {
    padding: 14px 12px;
    min-width: 0;
  }
  .stats-compact .stat-label {
    font-size: 0.8rem;
    line-height: 1.15;
  }
  .stats-compact .stat-value {
    font-size: 1.65rem;
    margin-top: 6px;
  }
  .modal-backdrop { padding: 12px; }
  .modal-card { padding: 18px; margin: 12px 0; }
  .share-link-row { grid-template-columns: 1fr; }
  .public-board { grid-template-columns: 1fr; gap: 18px; }
  .public-round-head, .public-match-top { flex-direction: column; align-items: flex-start; }
  .public-match-line {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .public-team-right { text-align: left; }
  .public-match-score { justify-self: start; }
}
