:root {
  --ink: #17212b;
  --muted: #637083;
  --line: #d8dee8;
  --panel: #ffffff;
  --field: #f5f7fa;
  --page: #edf1f5;
  --green: #116149;
  --red: #b42342;
  --yellow: #f0b429;
  --blue: #246b8f;
  --shadow: 0 18px 45px rgba(23, 33, 43, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior-y: contain;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 48px) 22px;
  background: #14332c;
  color: white;
}

.eyebrow {
  margin: 0 0 6px;
  color: #9dd9c5;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.header-actions,
.section-heading,
.controls,
.match-meta,
.team-row,
.match-top,
.badges {
  display: flex;
  align-items: center;
}

.header-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.danger-button,
.small-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  background: #f7c948;
  color: #1d252c;
}

.ghost-button {
  background: transparent;
  color: white;
  border-color: rgba(255, 255, 255, 0.32);
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  padding: 0 14px;
  color: white;
  font-weight: 800;
  text-decoration: none;
}

.danger-button {
  background: var(--red);
  color: white;
}

.small-button {
  min-height: 34px;
  background: var(--ink);
  color: white;
}

.app-shell {
  padding: 18px clamp(14px, 3vw, 36px) 34px;
}

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

.summary-tile {
  width: 100%;
  border: 0;
  padding: 16px;
  border-radius: 8px;
  background: var(--panel);
  color: inherit;
  font: inherit;
  text-align: left;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.summary-tile[open] {
  grid-row: span 2;
}

.summary-toggle {
  display: block;
  list-style: none;
}

.summary-toggle::-webkit-details-marker {
  display: none;
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 28px;
}

.summary-name {
  color: var(--muted);
  font-size: 0.88rem;
}

.expand-indicator {
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
}

.hide-label,
.summary-tile[open] .show-label {
  display: none;
}

.summary-tile[open] .hide-label {
  display: inline;
}

.summary-count {
  display: block;
  margin: 4px 0 8px;
  font-size: 1.3rem;
  font-weight: 900;
}

.next-match {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
}

.next-match > span:not(.muted) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.next-team {
  min-width: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.next-owner {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.summary-countries {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.country-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--field);
  font-size: 0.82rem;
  font-weight: 800;
}

.country-pill span {
  display: inline-flex;
}

.country-pill > span:nth-child(2) {
  color: var(--muted);
  font-size: 0.72rem;
}

.standing-pill {
  color: var(--green);
  font-size: 0.72rem;
}

.country-pill.rank-3 {
  background: #fff6d6;
  border: 1px solid #f0b429;
}

.country-pill.rank-4 {
  background: #ffe5e9;
  border: 1px solid #b42342;
}

.country-pill.rank-4 .standing-pill {
  color: var(--red);
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.pull-refresh-indicator {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 10;
  transform: translate(-50%, calc(-120% + var(--pull-offset, 0px)));
  min-width: 150px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 9px 14px;
  background: #14332c;
  color: white;
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: transform 160ms ease, opacity 160ms ease;
}

.pull-refresh-indicator[data-visible="true"] {
  opacity: 1;
}

.controls {
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.push-panel {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.push-panel label {
  min-width: 220px;
}

.push-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.push-panel .muted {
  flex: 1 1 240px;
  margin: 0 0 9px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 180px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.search-box {
  flex: 1 1 260px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--field);
  color: var(--ink);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(310px, 390px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.public-workspace {
  grid-template-columns: 1fr;
}

.admin-shell {
  display: grid;
  grid-template-columns: minmax(310px, 390px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.login-panel {
  max-width: 460px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-form,
.admin-actions {
  display: grid;
  gap: 12px;
}

.admin-country-grid {
  max-height: none;
}

.side-panel,
.schedule-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.side-panel {
  position: sticky;
  top: 14px;
  overflow: hidden;
}

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

.panel-section:last-child {
  border-bottom: 0;
}

.section-heading {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.players {
  display: grid;
  gap: 10px;
}

.player-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 10px;
  align-items: center;
}

.player-color {
  width: 14px;
  height: 42px;
  border-radius: 8px;
}

.player-row input {
  min-width: 0;
}

.country-grid {
  display: grid;
  gap: 8px;
  max-height: 52vh;
  overflow: auto;
  padding-right: 4px;
}

.country-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 142px;
  gap: 8px;
  align-items: center;
}

.country-name {
  min-width: 0;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.country-code {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.schedule-panel {
  padding: 16px;
}

.schedule-list {
  display: grid;
  gap: 12px;
}

.match-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.match-section-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  list-style: none;
  cursor: pointer;
  font-weight: 900;
}

.match-section-summary::-webkit-details-marker {
  display: none;
}

.match-section-summary::after {
  content: "+";
  flex: 0 0 auto;
  color: var(--blue);
  font-size: 1.1rem;
  font-weight: 900;
}

.match-section[open] .match-section-summary::after {
  content: "-";
}

.match-section-body {
  display: grid;
  gap: 16px;
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
}

.day-group {
  display: grid;
  gap: 10px;
}

.day-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 0;
  background: var(--panel);
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 900;
}

.match-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: white;
}

.match-card.unowned {
  border-left-color: var(--line);
}

.match-top {
  justify-content: space-between;
  gap: 12px;
}

.match-number {
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--muted);
  text-transform: uppercase;
}

.match-time {
  font-weight: 900;
}

.teams {
  display: grid;
  gap: 8px;
}

.team-row {
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
}

.team-side {
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-score {
  min-width: 28px;
  border-radius: 6px;
  padding: 4px 7px;
  background: var(--ink);
  color: white;
  font-weight: 900;
  text-align: center;
}

.team-name {
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.placeholder {
  color: var(--muted);
}

.owner-badge {
  flex: 0 0 auto;
  max-width: 140px;
  border-radius: 999px;
  padding: 5px 9px;
  color: white;
  font-size: 0.78rem;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badges {
  gap: 6px;
  flex-wrap: wrap;
}

.match-meta {
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.empty-state {
  padding: 44px 14px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.empty-state.compact {
  padding: 18px 14px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 clamp(14px, 3vw, 36px) 24px;
  color: var(--muted);
  font-size: 0.86rem;
}

footer a {
  color: var(--blue);
  font-weight: 800;
  margin-left: 14px;
}

@media (max-width: 920px) {
  .app-header {
    align-items: start;
    flex-direction: column;
  }

  .summary-strip,
  .workspace,
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }

  .country-grid {
    max-height: none;
  }
}

@media (max-width: 560px) {
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .controls label {
    min-width: 100%;
  }

  .push-panel {
    align-items: stretch;
  }

  .push-panel label,
  .push-actions,
  .push-actions button,
  .push-panel .muted {
    width: 100%;
  }

  .country-row {
    grid-template-columns: 1fr;
  }

  .match-top,
  .match-meta,
  .team-row,
  footer {
    align-items: start;
    flex-direction: column;
  }
}
