:root {
  --ink: #1a2740;
  --ink-soft: #3d4f6f;
  --paper: #f7f3ea;
  --paper-2: #fffaf1;
  --sky-top: #6eb6d9;
  --sky-mid: #9ed0e8;
  --sky-bottom: #f3e0c2;
  --gold: #e8a317;
  --gold-deep: #c4840c;
  --line: rgba(26, 39, 64, 0.12);
  --shadow: 0 18px 40px rgba(26, 39, 64, 0.12);
  --radius: 22px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background: var(--sky-bottom);
  line-height: 1.4;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.55), transparent 28%),
    radial-gradient(circle at 78% 12%, rgba(255, 255, 255, 0.35), transparent 24%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 42%, var(--sky-bottom) 78%, #efe2c8 100%);
  animation: sky-shift 18s ease-in-out infinite alternate;
}

@keyframes sky-shift {
  from {
    filter: saturate(1);
  }
  to {
    filter: saturate(1.08) brightness(1.03);
  }
}

.hero {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.4rem 0 1.2rem;
  text-align: center;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 8vw, 4.8rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 0.95;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.35);
  animation: rise 700ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.hero h1 {
  margin: 0.55rem 0 0;
  font-family: var(--font-body);
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  font-weight: 800;
  color: var(--ink-soft);
  animation: rise 800ms 80ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.lede {
  margin: 0.55rem auto 0;
  max-width: 34rem;
  color: var(--ink-soft);
  font-weight: 500;
  animation: rise 850ms 140ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.hero-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.85rem;
  margin-top: 1.1rem;
  flex-wrap: wrap;
  animation: rise 900ms 180ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.refresh {
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.refresh:hover {
  transform: translateY(-1px);
  background: #243556;
}

.refresh:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.stamp {
  font-size: 0.92rem;
  color: var(--ink-soft);
  font-weight: 700;
}

main {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto 3.5rem;
  display: grid;
  gap: 1.35rem;
}

.leaderboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
}

.star-chip {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 1rem 1rem 0.9rem;
  background: color-mix(in srgb, var(--person, #f7d9a0) 34%, var(--paper-2));
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.55);
  animation: rise 700ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.star-chip::after {
  content: "★";
  position: absolute;
  right: 0.7rem;
  top: 0.45rem;
  font-size: 1.5rem;
  color: var(--gold);
  opacity: 0.85;
  animation: twinkle 2.8s ease-in-out infinite;
}

.star-chip .name {
  margin: 0;
  font-weight: 800;
  font-size: 1rem;
}

.star-chip .balance {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.7rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.star-chip .lifetime {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.people {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.person {
  border-radius: calc(var(--radius) + 4px);
  background: var(--paper-2);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.7);
  overflow: hidden;
  animation: rise 750ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.person-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: end;
  padding: 1.1rem 1.15rem 0.9rem;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--person, #f7d9a0) 55%, white),
    color-mix(in srgb, var(--person, #f7d9a0) 18%, var(--paper-2))
  );
  border-bottom: 1px solid var(--line);
}

.person-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.person-head .points {
  font-weight: 800;
  color: var(--gold-deep);
  white-space: nowrap;
}

.person-body {
  padding: 0.95rem 1.15rem 1.15rem;
  display: grid;
  gap: 0.95rem;
}

.block h4 {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--line);
  font-weight: 700;
}

.item:last-child {
  border-bottom: 0;
}

.item .meta {
  color: var(--ink-soft);
  font-size: 0.88rem;
  white-space: nowrap;
}

.muted {
  color: var(--ink-soft);
  font-weight: 600;
  margin: 0;
}

.panel {
  border-radius: calc(var(--radius) + 6px);
  background: rgba(255, 250, 241, 0.86);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.65);
  padding: 1.25rem 1.25rem 1.35rem;
  animation: rise 800ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.panel-head {
  margin-bottom: 0.95rem;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.panel-head p {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
  font-weight: 700;
}

.reward-grid,
.bank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.reward,
.bank-item {
  border-radius: 18px;
  padding: 0.9rem 1rem;
  background: white;
  border: 1px solid var(--line);
  transition: transform 180ms ease;
}

.reward:hover,
.bank-item:hover {
  transform: translateY(-2px);
}

.reward .title,
.bank-item .title {
  margin: 0;
  font-weight: 800;
}

.reward .cost,
.bank-item .cost {
  margin: 0.35rem 0 0;
  color: var(--gold-deep);
  font-weight: 800;
}

.reward .who {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.45rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-weight: 700;
}

.reward .swatch {
  flex: 0 0 auto;
}

.chore-list {
  display: grid;
  gap: 0.45rem;
}

.chore-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0.9rem;
  border-radius: 16px;
  background: white;
  border: 1px solid var(--line);
}

.swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--person, #ccc);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.chore-row .summary {
  font-weight: 800;
}

.chore-row .detail {
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 700;
}

.chore-row .stars {
  font-weight: 800;
  color: var(--gold-deep);
  white-space: nowrap;
}

.reward {
  display: grid;
  gap: 0.35rem;
}

.reward .actions {
  margin-top: 0.45rem;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

.btn-redeem {
  background: var(--ink);
  color: var(--paper);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.btn-undo {
  background: #fff7e8;
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line));
  padding: 0.5rem 0.9rem;
}

.item-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.item-row .btn {
  flex: 0 0 auto;
}

.history-list {
  display: grid;
  gap: 0.5rem;
}

.history-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 0.85rem;
  align-items: center;
  padding: 0.8rem 0.95rem;
  border-radius: 16px;
  background: white;
  border: 1px solid var(--line);
}

.history-row.undone {
  opacity: 0.55;
}

.history-row .title {
  font-weight: 800;
}

.history-row .detail {
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 700;
}

.token-bar {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.token-bar input {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  min-width: min(260px, 80vw);
  font: inherit;
  background: rgba(255, 250, 241, 0.85);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: var(--shadow);
  z-index: 10;
}

.loading .leaderboard,
.loading .people,
.loading .panel {
  opacity: 0.55;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes twinkle {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.75;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .chore-row {
    grid-template-columns: auto 1fr;
  }

  .chore-row .stars {
    grid-column: 2;
  }
}
