:root {
  --ink: #17211c;
  --muted: #66736b;
  --paper: #f6f7f2;
  --panel: #ffffff;
  --line: #dfe5dc;
  --green: #0b7a4b;
  --green-dark: #075135;
  --red: #c83f3a;
  --blue: #2778b8;
  --gold: #c89a2b;
  --shadow: 0 16px 42px rgba(20, 36, 29, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(7, 22, 16, .25), var(--paper) 360px),
    url("/assets/mundial-2026-banner.png") top center / 100% min(420px, 48vw) no-repeat,
    var(--paper);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app {
  width: min(1440px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  min-height: 175px;
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .38);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 64px);
  line-height: .95;
}

h2 {
  margin: 0 0 14px;
  font-size: 19px;
}

.subtitle {
  max-width: 680px;
  margin: 12px 0 0;
  color: rgba(255, 255, 255, .9);
}

.session {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(5, 25, 18, .44);
  backdrop-filter: blur(12px);
}

.auth-screen,
.admin-grid {
  display: grid;
  gap: 14px;
}

.auth-screen {
  min-height: 360px;
  place-items: start center;
}

.auth-card {
  width: min(480px, 100%);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 8px;
  background: rgba(255, 255, 255, .97);
  box-shadow: var(--shadow);
}

.auth-copy {
  margin-bottom: 16px;
}

.auth-copy h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.auth-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.eyebrow.dark {
  color: var(--green-dark);
  text-shadow: none;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f4ee;
}

.auth-tab {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.auth-tab.active {
  background: #fff;
  color: var(--green-dark);
  box-shadow: 0 4px 12px rgba(20, 36, 29, .08);
}

.auth-form {
  margin-top: 0;
}

.wide {
  width: 100%;
}

.admin-entry {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  text-decoration: underline;
}

.admin-login {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.admin-grid {
  display: grid;
  gap: 14px;
}

.admin-grid {
  grid-template-columns: minmax(280px, .8fr) minmax(280px, 1.2fr);
  margin-bottom: 14px;
}

.panel {
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input, textarea, select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  resize: vertical;
  text-transform: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(11, 122, 75, .14);
}

.btn {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: 8px;
  padding: 9px 13px;
  color: #fff;
  background: rgba(5, 25, 18, .62);
}

.btn.primary {
  background: var(--green);
  border-color: var(--green);
}

.btn.light {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.btn.ghost {
  background: rgba(255, 255, 255, .16);
}

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

.hint {
  color: var(--muted);
  font-size: 13px;
}

.phase-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.phase-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.phase-tab {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

.phase-tab.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

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

.status-strip > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.status-strip strong {
  display: block;
  color: var(--green-dark);
  font-size: 24px;
}

.status-strip span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.notice {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #cde6d8;
  border-radius: 8px;
  background: #edf8f1;
  color: var(--green-dark);
  font-weight: 700;
}

.notice.warn {
  border-color: #ecd6a4;
  background: #fff8e8;
  color: #7d5a08;
}

.match-list {
  display: grid;
  gap: 10px;
}

.match {
  display: grid;
  grid-template-columns: 86px minmax(170px, .8fr) minmax(260px, 1.15fr) 230px;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(20, 36, 29, .06);
}

.match.locked { border-left-color: var(--gold); }
.match.knockout { border-left-color: var(--blue); }

.num {
  display: grid;
  gap: 6px;
  font-weight: 900;
}

.pill {
  width: max-content;
  max-width: 100%;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eaf4ef;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
}

.meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.venue {
  color: var(--ink);
  font-weight: 800;
}

.teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  font-size: 17px;
  font-weight: 900;
}

.team {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.team.away {
  justify-content: flex-end;
  text-align: right;
}

.flag {
  width: 24px;
  height: 18px;
  border: 1px solid rgba(23, 33, 28, .18);
  border-radius: 3px;
  object-fit: cover;
}

.team-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vs {
  color: var(--muted);
  font-size: 13px;
}

.score {
  display: grid;
  grid-template-columns: 54px 18px 54px minmax(92px, 1fr);
  gap: 6px;
  align-items: center;
}

.score input {
  text-align: center;
  font-size: 17px;
  font-weight: 900;
  padding-inline: 5px;
}

.dash {
  text-align: center;
  color: var(--muted);
  font-weight: 900;
}

.advance-select {
  min-width: 92px;
}

.footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.ranking {
  display: grid;
  gap: 6px;
}

.rank-row,
.matrix-row {
  display: grid;
  grid-template-columns: 46px 1fr 84px 92px;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.rank-row strong,
.matrix-row strong {
  color: var(--ink);
}

.phase-admin {
  display: grid;
  gap: 8px;
}

.phase-admin-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.admin-results {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.admin-result-row {
  display: grid;
  grid-template-columns: 70px 1fr 54px 54px 130px;
  gap: 8px;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.admin-result-row input {
  text-align: center;
}

.matrix {
  overflow-x: auto;
}

.matrix-row {
  grid-template-columns: minmax(160px, 1fr) repeat(7, 94px);
  min-width: 840px;
}

.tag {
  display: inline-flex;
  justify-content: center;
  min-height: 24px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #f0f2ee;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.tag.done {
  background: #eaf4ef;
  color: var(--green-dark);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }

@media (max-width: 1080px) {
  .auth-screen,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .phase-bar,
  .status-strip {
    grid-template-columns: 1fr;
  }

  .match {
    grid-template-columns: 76px 1fr;
  }

  .teams,
  .score {
    grid-column: 1 / -1;
  }

  .score {
    grid-template-columns: 1fr 18px 1fr minmax(120px, 1fr);
  }
}

@media (max-width: 680px) {
  .app {
    width: min(100vw - 20px, 1440px);
    padding-top: 16px;
  }

  .hero {
    flex-direction: column;
  }

  .match {
    grid-template-columns: 1fr;
  }

  .teams {
    grid-template-columns: 1fr;
  }

  .team.away {
    justify-content: flex-start;
    text-align: left;
  }

  .vs {
    display: none;
  }

  .score {
    grid-template-columns: 1fr 18px 1fr;
  }

  .advance-select {
    grid-column: 1 / -1;
  }

  .footer-actions {
    flex-direction: column;
  }
}
