:root {
  color-scheme: light;
  --paper: #f7ead0;
  --surface: #fff8eb;
  --ink: #122126;
  --muted: #6d6254;
  --line: #dec9a4;
  --accent: #f47a20;
  --accent-strong: #c65316;
  --danger: #a62929;
  --gold: #ffb23f;
  --road: #152227;
  --shadow: 0 18px 45px rgba(18, 33, 38, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(247, 122, 32, 0.18), rgba(247, 234, 208, 0.96) 28rem),
    var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--road);
  color: white;
  min-height: 44px;
  padding: 0.75rem 1rem;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: #000;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0.75rem 0.85rem;
}

input:focus,
button:focus-visible {
  outline: 3px solid rgba(244, 122, 32, 0.28);
  outline-offset: 2px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1080px;
  margin: 0 auto;
  padding: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 850;
  text-transform: uppercase;
}

.brand img {
  width: 3.1rem;
  height: 3.1rem;
  border: 2px solid var(--road);
  border-radius: 8px;
  object-fit: cover;
  object-position: center;
  background: white;
}

.text-button,
.secondary-button {
  background: transparent;
  color: var(--road);
  border: 1px solid var(--line);
}

.text-button:hover,
.secondary-button:hover {
  background: rgba(244, 122, 32, 0.12);
}

main {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.summary {
  display: grid;
  gap: 1.2rem;
  padding: clamp(1.4rem, 5vw, 3.5rem) 0 clamp(1.5rem, 4vw, 3rem);
}

.summary-copy {
  align-self: center;
}

.intro {
  max-width: 34rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.45;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1;
}

h1 {
  max-width: 11ch;
  font-size: clamp(2.9rem, 11vw, 6.4rem);
}

h2 {
  font-size: clamp(1.6rem, 5vw, 2.6rem);
}

.totals {
  display: grid;
  gap: 0.8rem;
}

.totals div {
  display: grid;
  gap: 0.3rem;
  padding: 1rem 1.05rem;
  border: 2px solid var(--road);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 8px 8px 0 var(--road);
}

.totals span,
.amount-label,
.section-heading p,
.status {
  color: var(--muted);
}

.totals strong {
  color: var(--accent-strong);
  font-size: clamp(2.45rem, 12vw, 5.6rem);
  line-height: 1;
}

.total-label {
  font-weight: 800;
}

.total-support {
  color: var(--muted);
  font-size: clamp(0.95rem, 3.6vw, 1.15rem);
}

.total-support b {
  color: var(--ink);
  white-space: nowrap;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1rem;
}

.section-heading p {
  margin: 0;
  text-align: right;
  font-size: 0.9rem;
}

.leaderboard-section,
.admin-panel {
  padding: 1.5rem 0;
}

.leaderboard {
  display: grid;
  gap: 0.65rem;
}

.leaderboard-row,
.admin-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: center;
  background: rgba(255, 248, 235, 0.92);
  border: 1px solid rgba(18, 33, 38, 0.18);
  border-radius: 8px;
  padding: 0.72rem;
  box-shadow: var(--shadow);
}

.rank {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--road);
  color: white;
  font-weight: 850;
}

.team-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  min-width: 0;
}

.team-copy {
  min-width: 0;
}

.team-title {
  margin: 0 0 0.24rem;
  overflow-wrap: anywhere;
  font-size: clamp(0.98rem, 4.2vw, 1.12rem);
  line-height: 1.08;
  font-weight: 850;
}

.raised-line {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.78rem, 3.2vw, 0.92rem);
  line-height: 1.15;
}

.raised-line strong {
  color: var(--ink);
  white-space: nowrap;
}

.gift-aid-total {
  display: grid;
  gap: 0.08rem;
  justify-items: end;
  text-align: right;
  min-width: 7.9rem;
}

.gift-aid-total span {
  color: var(--muted);
  font-size: clamp(0.72rem, 2.9vw, 0.82rem);
  line-height: 1.1;
}

.gift-aid-total strong {
  color: var(--accent-strong);
  font-size: clamp(1.18rem, 5.1vw, 1.55rem);
  line-height: 1;
  white-space: nowrap;
}

.team-amounts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.amount {
  display: grid;
  gap: 0.1rem;
}

.amount strong {
  font-size: 1.25rem;
}

.amount.primary strong {
  color: var(--accent-strong);
}

.quick-amount {
  display: grid;
  gap: 0.25rem;
}

.quick-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: center;
}

.quick-amount input {
  min-height: 42px;
  padding: 0.55rem 0.65rem;
  color: var(--ink);
  font-weight: 850;
  font-size: 1.1rem;
}

.quick-edit button {
  min-height: 42px;
  padding: 0.55rem 0.75rem;
}

.quick-status {
  min-height: 1rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.quick-status[data-state="saved"] {
  color: var(--accent-strong);
}

.quick-status[data-state="error"] {
  color: var(--danger);
}

.admin-panel {
  border-top: 1px solid var(--line);
}

.login-form,
.team-form {
  display: grid;
  gap: 0.9rem;
  max-width: 680px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
}

.team-form {
  grid-template-columns: 1fr;
  padding: 0.4rem 0 1.25rem;
}

.team-form label,
.login-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-weight: 700;
}

.admin-subhead {
  padding-top: 1rem;
}

.admin-subhead h3 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.1;
}

.existing-teams-heading {
  border-top: 1px solid var(--line);
  margin-top: 0.3rem;
}

.form-actions,
.row-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.admin-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

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

.admin-row .team-main {
  display: block;
}

.admin-row .team-title {
  margin-bottom: 0.55rem;
}

.row-actions button {
  flex: 1 1 8rem;
}

.delete-button {
  background: var(--danger);
}

.delete-button:hover {
  background: #7c1f1f;
}

.status {
  min-height: 1.5rem;
}

.empty {
  margin: 0;
  padding: 1.25rem 0;
  color: var(--muted);
}

@media (min-width: 700px) {
  .summary {
    grid-template-columns: minmax(0, 1fr) minmax(22rem, 0.85fr);
    align-items: center;
  }

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

  .leaderboard-row {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 0.95rem 1.05rem;
  }

  .team-main {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

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

  .team-form {
    grid-template-columns: minmax(12rem, 1.2fr) minmax(9rem, 0.8fr) minmax(9rem, 0.8fr) auto;
    align-items: end;
    max-width: none;
  }

  .form-actions {
    min-width: 10rem;
  }

  .admin-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}
