:root {
  color-scheme: light;
  --navy: #0a3765;
  --navy-dark: #062846;
  --blue: #1769aa;
  --blue-soft: #e9f3fb;
  --red: #c8202f;
  --ink: #162536;
  --muted: #5f6f80;
  --line: #d8e0e8;
  --surface: #ffffff;
  --background: #f2f5f8;
  --success: #18763b;
  --success-soft: #e8f7ee;
  --danger: #a51d2d;
  --danger-soft: #fff0f2;
  --shadow: 0 8px 24px rgba(16, 39, 64, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.team-logo-backdrop {
  position: fixed;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 20%, rgba(23, 105, 170, 0.09), transparent 28%),
    radial-gradient(circle at 85% 75%, rgba(200, 32, 47, 0.07), transparent 30%),
    var(--background);
}

.team-logo-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(72px, 1fr));
  align-items: center;
  width: 116%;
  min-height: 116%;
  margin: -8%;
  gap: clamp(28px, 4vw, 62px);
  transform: rotate(-5deg) scale(1.04);
}

.team-logo-grid img {
  width: clamp(54px, 6.5vw, 88px);
  aspect-ratio: 1;
  justify-self: center;
  object-fit: contain;
  opacity: 0.11;
  filter: grayscale(0.4) saturate(0.7);
}

.site-header,
.page-shell,
.site-footer {
  position: relative;
  z-index: 1;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--navy);
}

.hidden {
  display: none !important;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 190px;
  padding: 40px 24px;
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
  color: white;
  text-align: left;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.site-header p {
  margin: 10px 0 0;
  color: #d7e7f5;
  font-size: 1.05rem;
}

.header-mark {
  display: grid;
  width: 68px;
  height: 68px;
  flex: 0 0 68px;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  background: var(--red);
  font-weight: 900;
  letter-spacing: -0.05em;
}

.compact-header {
  min-height: 160px;
}

.page-shell {
  width: min(960px, calc(100% - 32px));
  margin: -28px auto 60px;
  position: relative;
}

.narrow-shell {
  width: min(680px, calc(100% - 32px));
}

.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 150px;
  padding: 30px;
}

.status-panel h2,
.status-panel p {
  margin: 0;
}

.status-panel p {
  margin-top: 4px;
  color: var(--muted);
}

.spinner {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 4px solid #dbe6ef;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.status-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--navy);
  font-size: 1.4rem;
  font-weight: 900;
}

.error-panel {
  border-color: #f0c8ce;
}

.error-panel .status-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.access-panel {
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 32px;
}

.access-panel h2,
.access-panel > p {
  margin: 0;
}

.access-panel > p:not(.eyebrow) {
  margin-top: 5px;
  color: var(--muted);
}

.access-panel form {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.access-panel .form-message {
  width: 100%;
  margin: 4px 0 0;
}

.intro-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 30px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.intro-panel h2,
.section-heading h2,
.host-panel h2 {
  margin: 0;
  font-size: 1.65rem;
  letter-spacing: -0.025em;
}

.file-name {
  margin: 6px 0 0;
  color: var(--muted);
}

.progress-card {
  min-width: 145px;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--blue-soft);
  text-align: center;
}

.progress-card strong,
.progress-card span {
  display: block;
}

.progress-card strong {
  color: var(--navy);
  font-size: 1.3rem;
}

.progress-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.player-panel {
  margin-top: 18px;
  padding: 24px 30px;
}

label {
  display: block;
  margin-bottom: 7px;
  font-weight: 750;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"] {
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  border: 1px solid #aebdcc;
  border-radius: 10px;
  background: white;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(23, 105, 170, 0.25);
  outline-offset: 2px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin: 34px 4px 14px;
}

.section-heading > p {
  max-width: 320px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
}

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

.game-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 130px;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  box-shadow: 0 3px 12px rgba(16, 39, 64, 0.05);
}

.game-number {
  display: grid;
  place-items: center;
  padding: 18px 10px;
  background: var(--navy);
  color: white;
  text-align: center;
}

.game-number strong,
.game-number span {
  display: block;
}

.game-number strong {
  font-size: 1.25rem;
}

.game-number span {
  margin-top: 2px;
  color: #cfe0ef;
  font-size: 0.67rem;
  line-height: 1.2;
}

.team-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}

.team-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-height: 66px;
  padding: 10px 14px;
  border: 2px solid #c9d4df;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
  line-height: 1.25;
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease, transform 120ms ease;
}

.team-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  object-fit: contain;
}

.team-button:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.team-button.selected {
  border-color: var(--navy);
  background: var(--navy);
  color: white;
}

.rank-control {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 16px;
  border-left: 1px solid var(--line);
  background: #f8fafc;
}

.rank-control label {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.rank-select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #aebdcc;
  border-radius: 9px;
  background: white;
  color: var(--ink);
  text-align: center;
  font-weight: 800;
}

.tiebreaker-panel {
  display: grid;
  grid-template-columns: 1fr 130px;
  align-items: center;
  gap: 24px;
  margin-top: 20px;
  padding: 24px 30px;
}

.tiebreaker-panel label {
  margin: 0;
  font-size: 1.08rem;
}

.tiebreaker-panel p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.tiebreaker-panel input {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
}

.submit-section {
  padding: 28px 0 0;
  text-align: center;
}

.primary-button {
  min-height: 50px;
  padding: 12px 22px;
  border: 0;
  border-radius: 10px;
  background: var(--navy);
  color: white;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(10, 55, 101, 0.18);
}

.primary-button:hover {
  background: var(--navy-dark);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.secondary-button {
  min-height: 50px;
  padding: 12px 22px;
  border: 2px solid var(--navy);
  border-radius: 10px;
  background: white;
  color: var(--navy);
  cursor: pointer;
  font-weight: 800;
}

.secondary-button:hover {
  background: var(--blue-soft);
}

.submit-button {
  width: min(100%, 430px);
}

.privacy-note,
.field-help {
  color: var(--muted);
  font-size: 0.82rem;
}

.form-message {
  margin: 0 auto 14px;
  padding: 11px 14px;
  border-radius: 9px;
  font-weight: 650;
}

.error-message {
  max-width: 650px;
  background: var(--danger-soft);
  color: var(--danger);
}

.success-message {
  background: var(--success-soft);
  color: var(--success);
}

.success-panel {
  padding: 52px 30px;
  text-align: center;
}

.review-header {
  padding: 28px 30px;
}

.review-header h2,
.review-header > p {
  margin: 0;
}

.review-header > p:not(.eyebrow) {
  margin-top: 5px;
  color: var(--muted);
}

.review-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 22px 0 0;
}

.review-details > div {
  padding: 13px 15px;
  border-radius: 10px;
  background: var(--blue-soft);
}

.review-details dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.review-details dd {
  margin: 2px 0 0;
  color: var(--navy);
  font-weight: 800;
}

.review-games {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}

.review-game {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 130px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: 0 3px 12px rgba(16, 39, 64, 0.05);
}

.review-game-number {
  align-self: stretch;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: white;
  font-weight: 900;
}

.review-team {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  font-weight: 800;
}

.review-team .team-logo {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
}

.review-rank {
  padding: 16px 18px;
  border-left: 1px solid var(--line);
  background: #f8fafc;
  text-align: center;
}

.review-rank span,
.review-rank strong {
  display: block;
}

.review-rank span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.review-rank strong {
  color: var(--navy);
  font-size: 1.15rem;
}

.review-actions {
  padding-top: 24px;
  text-align: center;
}

.review-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.success-check {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  place-items: center;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  font-size: 2rem;
  font-weight: 900;
}

.success-panel h2,
.success-panel p {
  margin: 0;
}

.download-button {
  display: inline-block;
  margin-top: 24px;
  text-decoration: none;
}

.success-panel p {
  margin-top: 6px;
  color: var(--muted);
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 0 24px 40px;
  color: var(--muted);
  font-size: 0.84rem;
}

.host-panel {
  padding: 32px;
}

.host-panel > p:not(.eyebrow) {
  margin: 8px 0 26px;
  color: var(--muted);
}

.host-panel form {
  display: grid;
  gap: 10px;
}

.host-panel label:not(:first-child) {
  margin-top: 10px;
}

.host-panel .field-help {
  margin: -4px 0 8px;
}

.host-panel .primary-button {
  margin-top: 8px;
}

.back-link {
  text-align: center;
}

@media (max-width: 720px) {
  .team-logo-grid {
    grid-template-columns: repeat(4, minmax(58px, 1fr));
    min-height: 140%;
    gap: 30px 22px;
  }

  .team-logo-grid img {
    width: clamp(48px, 16vw, 72px);
    opacity: 0.09;
  }

  .site-header {
    align-items: flex-start;
    min-height: 175px;
    padding-top: 30px;
  }

  .header-mark {
    width: 54px;
    height: 54px;
    flex-basis: 54px;
    font-size: 0.85rem;
  }

  .intro-panel,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-heading > p {
    text-align: left;
  }

  .progress-card {
    width: 100%;
  }

  .game-card {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .game-number {
    grid-row: 1 / span 2;
  }

  .team-choices {
    grid-template-columns: 1fr;
  }

  .team-button {
    justify-content: flex-start;
  }

  .rank-control {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .tiebreaker-panel {
    grid-template-columns: 1fr;
  }

  .review-game {
    grid-template-columns: 52px minmax(0, 1fr) 100px;
  }

  .review-details {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .site-header h1 {
    font-size: 1.8rem;
  }

  .page-shell {
    width: min(100% - 20px, 960px);
  }

  .intro-panel,
  .player-panel,
  .tiebreaker-panel,
  .host-panel {
    padding: 22px 18px;
  }

  .game-card {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .game-number {
    padding-inline: 4px;
  }

  .site-footer {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .review-header {
    padding: 22px 18px;
  }

  .review-buttons {
    flex-direction: column;
  }
}
