:root {
  --red: #8f1733;
  --red-dark: #651125;
  --red-bright: #bd2348;
  --khaki: #d9c9a6;
  --khaki-light: #f2ead9;
  --cream: #faf7f0;
  --ink: #1e2025;
  --muted: #676a70;
  --line: #ded9ce;
  --white: #ffffff;
  --green: #15803d;
  --green-soft: #dcfce7;
  --blue: #1d4ed8;
  --blue-soft: #dbeafe;
  --shadow: 0 18px 45px rgba(48, 34, 29, 0.09);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

button,
input,
select {
  font: inherit;
}

button,
label[for] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
label[for]:focus-visible,
a:focus-visible {
  outline: 3px solid #ffca48;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: var(--ink);
  color: var(--white);
}

.skip-link:focus {
  top: 1rem;
}

.site-header,
main,
footer {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding-block: 28px 22px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 14px 6px 14px 6px;
  background: var(--khaki);
  font-size: 1rem;
  font-weight: 950;
  letter-spacing: -0.04em;
  transform: rotate(-2deg);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--red);
  font-size: 0.73rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow-light {
  color: #f7dfe6;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-weight: 900;
  letter-spacing: -0.04em;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 0.82rem;
}

.private-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--white);
  color: var(--ink);
  font-weight: 750;
}

.private-pill span {
  color: var(--green);
  font-size: 0.65rem;
}

.signout-link {
  color: var(--red);
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration: none;
}

.signout-link:hover {
  text-decoration: underline;
}

.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: clamp(28px, 6vw, 82px);
  align-items: center;
  overflow: hidden;
  min-height: 350px;
  padding: clamp(34px, 5vw, 66px);
  border-radius: 30px;
  background: var(--red);
  color: var(--white);
  box-shadow: var(--shadow);
}

.hero::before,
.hero::after {
  position: absolute;
  z-index: -1;
  border-radius: 999px;
  content: "";
  opacity: 0.18;
}

.hero::before {
  width: 330px;
  height: 330px;
  right: -110px;
  top: -160px;
  border: 55px solid var(--khaki);
}

.hero::after {
  width: 220px;
  height: 220px;
  left: 33%;
  bottom: -185px;
  border: 46px solid var(--white);
}

.hero h2 {
  margin-bottom: 9px;
  font-size: clamp(2.3rem, 6vw, 4.9rem);
  line-height: 0.95;
  letter-spacing: -0.075em;
}

.total-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.total-row strong {
  font-size: clamp(2rem, 5vw, 4.2rem);
  font-weight: 950;
  letter-spacing: -0.06em;
}

.total-row span {
  color: #f7dfe6;
  font-weight: 700;
}

.goal-copy {
  margin: 4px 0 0;
  color: #f7dfe6;
  font-size: 1.02rem;
}

.goal-panel {
  padding: clamp(22px, 4vw, 36px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 22px;
  background: rgba(74, 8, 29, 0.34);
  backdrop-filter: blur(8px);
}

.progress-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 750;
}

.progress-summary strong {
  font-size: 1.45rem;
}

.progress-track {
  position: relative;
  height: 24px;
  overflow: visible;
  border: 4px solid rgba(255, 255, 255, 0.92);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.2);
}

.progress-fill {
  height: 100%;
  width: 46.2%;
  border-radius: 99px;
  background: var(--khaki);
  transition: width 300ms ease;
}

.toolbar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 22px;
  margin-top: 28px;
  padding: 28px 30px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--white);
}

.toolbar h2,
.rules-heading h2 {
  margin-bottom: 4px;
  font-size: clamp(1.65rem, 3vw, 2.2rem);
  letter-spacing: -0.045em;
}

.toolbar-copy p,
.rules-heading > p:last-child {
  margin: 0;
  color: var(--muted);
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

.search-box {
  display: flex;
  align-items: center;
  width: 190px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--cream);
}

.search-box:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(143, 23, 51, 0.12);
}

.search-box svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.search-box input {
  min-width: 0;
  width: 100%;
  padding: 10px 8px;
  border: 0;
  outline: 0;
  background: transparent;
}

.button,
.text-button {
  border: 0;
  cursor: pointer;
  font-weight: 800;
}

.button {
  padding: 11px 15px;
  border-radius: 12px;
}

.button-dark {
  background: var(--ink);
  color: var(--white);
}

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

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

.button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.button-dark:hover {
  background: #36383d;
}

.button-light {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
}

.button-light:hover {
  background: var(--khaki-light);
}

.more-actions {
  position: absolute;
  z-index: 5;
  top: calc(100% - 18px);
  right: 30px;
  display: flex;
  min-width: 210px;
  flex-direction: column;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.more-actions[hidden] {
  display: none;
}

.text-button {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.text-button:hover {
  background: var(--khaki-light);
}

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

.leaderboard {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.table-head,
.team-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 132px 150px;
  gap: 18px;
  align-items: center;
}

.table-head {
  padding: 13px 30px;
  background: var(--khaki-light);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.table-head span:nth-child(3) {
  text-align: center;
}

.table-head span:last-child {
  text-align: right;
}

.team-row {
  padding: 17px 30px;
  border-top: 1px solid #ece8df;
  transition: background 150ms ease;
}

.team-row:first-child {
  border-top: 0;
}

.team-row:hover,
.team-row:focus-within {
  background: #fffdfa;
}

.team-row.top-three {
  background: linear-gradient(90deg, rgba(217, 201, 166, 0.36), transparent 42%);
}

.loading-row {
  margin: 0;
  padding: 48px 24px;
  color: var(--muted);
  text-align: center;
}

.rank {
  color: var(--red);
  font-size: 1.55rem;
  font-weight: 950;
  letter-spacing: -0.05em;
}

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

.team-name strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.98rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.movement {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  justify-self: center;
  min-width: 82px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 850;
}

.movement-up {
  background: var(--green-soft);
  color: var(--green);
}

.movement-down {
  background: #fee2e2;
  color: #b91c1c;
}

.movement-same {
  background: #f1f1ef;
  color: #5f6268;
}

.movement-new {
  background: var(--blue-soft);
  color: var(--blue);
}

.amount-field {
  position: relative;
  justify-self: end;
  width: 132px;
}

.amount-field span {
  position: absolute;
  left: 13px;
  top: 50%;
  color: var(--muted);
  font-weight: 800;
  transform: translateY(-50%);
  pointer-events: none;
}

.amount-field input {
  width: 100%;
  padding: 9px 12px 9px 27px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  text-align: right;
}

.amount-field input:focus {
  border-color: var(--red);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(143, 23, 51, 0.12);
}

.amount-display {
  justify-self: end;
  color: var(--ink);
  font-size: 1.02rem;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.save-status {
  display: inline-block;
  margin-top: 7px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
}

.save-status.saving {
  color: var(--muted);
}

.save-status.unsaved,
.save-status.error {
  color: var(--red);
}

.empty-state {
  margin: 0;
  padding: 48px 24px;
  color: var(--muted);
  text-align: center;
}

.rules-section {
  margin-block: 84px 64px;
}

.rules-heading {
  max-width: 650px;
  margin-bottom: 26px;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.rule-card {
  position: relative;
  min-height: 210px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: 0 8px 24px rgba(48, 34, 29, 0.05);
}

.rule-card-featured {
  background: var(--ink);
  color: var(--white);
}

.rule-card h3 {
  margin-bottom: 12px;
  font-size: 1.24rem;
  letter-spacing: -0.025em;
}

.rule-card p,
.rule-card li {
  color: var(--muted);
}

.rule-card-featured li {
  color: #dedee0;
}

.rule-card ul {
  margin: 0;
  padding-left: 1.15rem;
}

.rule-card li + li {
  margin-top: 7px;
}

.rule-number {
  display: block;
  margin-bottom: 25px;
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.rule-card-featured .rule-number {
  color: var(--khaki);
}

.rule-card-wide {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 52px 0.75fr 2.25fr;
  gap: 22px;
  align-items: start;
  min-height: 0;
}

.challenge-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.challenge-list div {
  display: flex;
  min-height: 112px;
  flex-direction: column;
  padding: 13px;
  border-radius: 13px;
  background: var(--khaki-light);
}

.challenge-list strong {
  color: var(--red);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.challenge-list span {
  margin-top: 4px;
  font-size: 0.87rem;
  font-weight: 850;
}

.challenge-list small {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.25;
}

.award-card {
  grid-template-columns: 52px 1fr;
  background: var(--khaki);
}

.award-card p {
  max-width: 900px;
  margin-bottom: 0;
  color: #4f493e;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-block: 28px 44px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84rem;
}

footer strong {
  color: var(--ink);
}

dialog {
  width: min(490px, calc(100% - 32px));
  padding: 30px;
  border: 0;
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(17, 18, 21, 0.58);
  backdrop-filter: blur(3px);
}

dialog h2 {
  margin-bottom: 8px;
  letter-spacing: -0.04em;
}

dialog p:not(.eyebrow) {
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 24px;
}

.csv-dialog {
  width: min(920px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.csv-dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 24px;
}

.csv-dialog-heading p:last-child {
  max-width: 680px;
  margin-bottom: 0;
}

.dialog-close {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.csv-dropzone {
  display: grid;
  gap: 5px;
  margin-top: 24px;
  padding: 22px;
  border: 2px dashed #cbbfaa;
  border-radius: 16px;
  background: var(--khaki-light);
  cursor: pointer;
}

.csv-dropzone strong {
  color: var(--red);
  font-size: 1.05rem;
}

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

.csv-dropzone input {
  margin-top: 10px;
}

.csv-workspace {
  margin-top: 22px;
}

.csv-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.csv-fields label {
  display: grid;
  gap: 6px;
}

.csv-fields label > span {
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 850;
}

.csv-fields select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
}

.csv-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.csv-summary div {
  display: grid;
  gap: 2px;
  padding: 14px;
  border-radius: 12px;
  background: #f4f3ef;
}

.csv-summary strong {
  font-size: 1.08rem;
}

.csv-summary span {
  color: var(--muted);
  font-size: 0.76rem;
}

.csv-summary .summary-warning {
  background: #fff0e5;
}

.csv-preview-wrap {
  max-height: 330px;
  margin-top: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.csv-preview {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.csv-preview th,
.csv-preview td {
  padding: 10px 12px;
  border-bottom: 1px solid #ece8df;
  text-align: right;
  white-space: nowrap;
}

.csv-preview th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--khaki-light);
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.csv-preview th:first-child,
.csv-preview td:first-child {
  width: 100%;
  text-align: left;
}

.csv-preview td:first-child span,
.csv-delta {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
}

.csv-preview tr.csv-changed td {
  background: #fffdfa;
}

.csv-issues {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid #f0c7a8;
  border-radius: 12px;
  background: #fff7ed;
  color: #7c2d12;
  font-size: 0.8rem;
}

.csv-issues p,
.csv-issues ul {
  margin: 7px 0 0;
}

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 24px;
  padding: 11px 16px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--white);
  font-size: 0.86rem;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .toolbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .more-actions {
    left: 30px;
    right: auto;
  }

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

  .rule-card-featured {
    grid-row: span 2;
  }

  .rule-card-wide {
    grid-column: 1 / -1;
    grid-template-columns: 42px 1fr;
  }

  .rule-card-wide .challenge-list {
    grid-column: 2;
  }

  .challenge-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .award-card {
    grid-template-columns: 42px 1fr;
  }
}

@media (max-width: 680px) {
  .site-header,
  main,
  footer {
    width: min(100% - 24px, 1180px);
  }

  .site-header {
    align-items: flex-start;
    padding-block: 18px;
  }

  .header-meta {
    align-items: flex-end;
    flex-direction: column;
    gap: 6px;
    text-align: right;
  }

  .header-meta > span:last-child {
    display: none;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .hero {
    min-height: 0;
    padding: 30px 22px;
    border-radius: 22px;
  }

  .toolbar {
    padding: 22px 18px;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .csv-dialog {
    width: calc(100% - 16px);
    padding: 22px 16px;
  }

  .csv-fields,
  .csv-summary {
    grid-template-columns: 1fr;
  }

  .csv-preview th,
  .csv-preview td {
    padding: 9px 8px;
  }

  .search-box {
    grid-column: 1 / -1;
    width: 100%;
  }

  .more-actions {
    left: 18px;
    right: 18px;
  }

  .table-head {
    display: none;
  }

  .team-row {
    grid-template-columns: 42px minmax(0, 1fr) 108px;
    gap: 10px;
    padding: 17px 16px;
  }

  .rank {
    grid-row: span 2;
    align-self: start;
    padding-top: 5px;
  }

  .movement {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
  }

  .amount-field {
    grid-column: 3;
    grid-row: 1 / span 2;
    width: 108px;
  }

  .amount-display {
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .team-name strong {
    white-space: normal;
  }

  .rules-section {
    margin-top: 60px;
  }

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

  .rule-card-featured {
    grid-row: auto;
  }

  .rule-card-wide,
  .award-card {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .rule-card-wide .challenge-list {
    grid-column: auto;
  }

  .rule-card-wide .rule-number {
    margin-bottom: 0;
  }

  .challenge-list {
    grid-template-columns: 1fr;
  }

  .challenge-list div {
    min-height: 0;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
