:root {
  --paper: #fff3e0;
  --paper-2: #ffe7c7;
  --ink: #4a3b2a;
  --ink-soft: #8a7456;
  --line: #3a2e22;
  --coral: #ff8a5c;
  --mint: #6fd3b6;
  --sky: #7cc4ff;
  --sun: #ffd45c;
  --grape: #c9a7f5;
  --white: #fffaf2;
  --shadow: 5px 6px 0 var(--line);
  --shadow-lg: 8px 9px 0 var(--line);
  --radius: 26px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(74, 59, 42, 0.09) 1.5px, transparent 0),
    radial-gradient(120% 90% at 50% -10%, var(--paper-2), var(--paper) 60%);
  background-size: 22px 22px, 100% 100%;
  overflow-x: hidden;
}

/* ---- floating stickers ---- */
.stickers { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.stickers span {
  position: absolute;
  top: -8vh;
  left: var(--x);
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  opacity: 0.5;
  transform: rotate(var(--r));
  animation: drift 16s linear var(--d) infinite;
}
@keyframes drift {
  0% { transform: translateY(-10vh) rotate(var(--r)); }
  100% { transform: translateY(115vh) rotate(calc(var(--r) * -1)); }
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(1.2rem, 4vw, 2.8rem) clamp(1rem, 4vw, 1.6rem) 3rem;
}

/* ---- hero ---- */
.hero { text-align: center; margin-bottom: 2.2rem; }
.kicker {
  font-family: "Fredoka", sans-serif;
  text-transform: lowercase;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  font-weight: 600;
  margin: 0 0 0.3rem;
  font-size: 0.85rem;
}
.title {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: clamp(2.6rem, 9vw, 4.4rem);
  line-height: 0.95;
  margin: 0;
  color: var(--coral);
  text-shadow: 3px 3px 0 var(--line);
  animation: wobble 5s ease-in-out infinite;
}
@keyframes wobble {
  0%, 100% { transform: rotate(-1.5deg); }
  50% { transform: rotate(1.5deg); }
}
.date-pill {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.45rem 1.1rem;
  background: var(--white);
  border: 3px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 0.95rem;
}

/* share-as-image button */
.share-row { margin-top: 1.1rem; }
.share-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 1rem;
  padding: 0.6rem 1.2rem; cursor: pointer;
  color: var(--white); background: var(--coral);
  border: 3px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.share-btn:hover:not(:disabled) { transform: translate(-1px, -2px); box-shadow: var(--shadow-lg); }
.share-btn:active:not(:disabled) { transform: translate(3px, 4px); box-shadow: none; }
.share-btn:disabled { opacity: 0.7; cursor: default; }
.share-ico { font-size: 1.05rem; }

.countdown {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1.3rem;
  flex-wrap: wrap;
}
.cd {
  background: var(--sun);
  border: 3px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  width: 72px;
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.cd:nth-child(2) { background: var(--mint); }
.cd:nth-child(3) { background: var(--sky); }
.cd:nth-child(4) { background: var(--grape); }
.cd-num {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 1.7rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.cd-lbl { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.ended-banner {
  margin-top: 1.2rem;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--mint);
  text-shadow: 2px 2px 0 var(--line);
}

/* ---- podium ---- */
.podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 0.7rem;
  margin-bottom: 2rem;
}
.pod {
  background: var(--white);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 0.5rem 1.1rem;
  text-align: center;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.pod:hover { transform: translate(-2px, -4px) rotate(-1deg); box-shadow: var(--shadow-lg); }
.pod--1 { padding-top: 1.6rem; background: #fff8e6; }
.pod--1 { animation-delay: 0.05s; }
.pod--2 { animation-delay: 0.15s; }
.pod--3 { animation-delay: 0.25s; }
.pod .medal { font-size: clamp(1.8rem, 6vw, 2.6rem); }
.pod--1 .medal { filter: drop-shadow(0 3px 0 rgba(0,0,0,0.15)); }
.avatar {
  width: 56px; height: 56px; margin: 0.4rem auto 0.5rem;
  border-radius: 50%;
  border: 3px solid var(--line);
  display: grid; place-items: center;
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 1.5rem;
  color: var(--line);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.08);
}
.pod--1 .avatar { width: 68px; height: 68px; font-size: 1.9rem; }
.pod .name { font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 1.05rem; margin: 0; }
.pod .steps { font-weight: 800; color: var(--coral); margin-top: 0.15rem; }
.pod .steps small { color: var(--ink-soft); font-weight: 700; }
.pod .days { font-size: 0.75rem; color: var(--ink-soft); }

@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(0.92); } }

/* ---- board rows ---- */
.board { display: flex; flex-direction: column; gap: 0.7rem; }
.row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 0.8rem;
  background: var(--white);
  border: 3px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  animation: slidein 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.row:hover { transform: translate(-2px, -3px) rotate(-0.6deg); box-shadow: var(--shadow-lg); }
.rank {
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 1.1rem;
  width: 34px; height: 34px; border-radius: 12px;
  border: 3px solid var(--line); display: grid; place-items: center;
  background: var(--paper-2);
}
.row .avatar { width: 42px; height: 42px; font-size: 1.15rem; margin: 0; }
.row .who { min-width: 0; }
.row .name { font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 8px; border-radius: 999px; background: var(--paper-2); border: 2px solid var(--line); overflow: hidden; margin-top: 0.3rem; }
.bar > i { display: block; height: 100%; background: var(--coral); }
.row .total { text-align: right; }
.row .total b { font-family: "Fredoka", sans-serif; font-size: 1.15rem; color: var(--coral); }
.row .total span { display: block; font-size: 0.72rem; color: var(--ink-soft); font-weight: 700; }
.row--zero { opacity: 0.5; }
.row--zero .total b { color: var(--ink-soft); }

@keyframes slidein { from { opacity: 0; transform: translateX(-16px); } }

.empty { text-align: center; font-size: 1.1rem; padding: 2rem 1rem; }
.foot { text-align: center; margin-top: 2.4rem; color: var(--ink-soft); font-weight: 700; font-size: 0.9rem; }

/* ---- bottom sheet (daily log) ---- */
.sheet { position: fixed; inset: 0; z-index: 20; display: grid; place-items: end center; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(58, 46, 34, 0.4); animation: fade 0.2s ease; }
.sheet-card {
  position: relative;
  width: min(560px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--paper);
  border: 4px solid var(--line);
  border-bottom: none;
  border-radius: 30px 30px 0 0;
  box-shadow: 0 -10px 0 rgba(58,46,34,0.12);
  padding: 1.4rem clamp(1rem, 4vw, 1.6rem) 2rem;
  animation: slideup 0.32s cubic-bezier(0.34, 1.4, 0.64, 1);
}
@media (min-width: 640px) {
  .sheet { place-items: center; }
  .sheet-card { border-bottom: 4px solid var(--line); border-radius: 30px; }
}
.sheet-close {
  position: absolute; top: 1rem; right: 1rem;
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--line); background: var(--white);
  font-weight: 800; font-size: 1rem; cursor: pointer; box-shadow: 3px 3px 0 var(--line);
}
.sheet-close:active { transform: translate(2px, 2px); box-shadow: none; }
.sheet-head { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1.2rem; padding-right: 2.5rem; }
.sheet-avatar {
  width: 62px; height: 62px; border-radius: 50%; border: 3px solid var(--line);
  display: grid; place-items: center; font-family: "Fredoka", sans-serif; font-weight: 700;
  font-size: 1.7rem; color: var(--line); box-shadow: inset 0 -4px 0 rgba(0,0,0,0.08);
}
.sheet-name { font-family: "Fredoka", sans-serif; font-weight: 700; margin: 0; font-size: 1.5rem; }
.sheet-sub { margin: 0.1rem 0 0; color: var(--ink-soft); font-weight: 700; }

.log { display: flex; flex-direction: column; gap: 0.55rem; }
.log-item {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  background: var(--white); border: 3px solid var(--line); border-radius: 16px;
  box-shadow: 3px 3px 0 var(--line); padding: 0.6rem 0.9rem;
}
.log-date { font-weight: 800; }
.log-steps { font-family: "Fredoka", sans-serif; font-weight: 700; color: var(--coral); font-size: 1.1rem; }
.tag-edit {
  font-size: 0.68rem; font-weight: 800; color: var(--grape);
  border: 2px solid var(--grape); border-radius: 999px; padding: 0.05rem 0.45rem; margin-left: 0.4rem;
}
.log-empty { text-align: center; color: var(--ink-soft); font-weight: 700; padding: 1.5rem 0; }

@keyframes slideup { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation: none !important; }
}

/* week navigation (browse past leaderboards) */
.week-nav {
  display: inline-flex; align-items: center; gap: 0.6rem; margin: 0.5rem 0 0.2rem;
}
.week-btn {
  width: 2.2rem; height: 2.2rem; border-radius: 999px; cursor: pointer;
  background: var(--white); border: 3px solid var(--line); box-shadow: 3px 3px 0 var(--line);
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 1.3rem; line-height: 1;
  color: var(--line); transition: transform 0.06s ease;
}
.week-btn:hover:not(:disabled) { transform: translateY(-1px); }
.week-btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: none; }
.week-btn:disabled { opacity: 0.35; cursor: default; box-shadow: 1px 1px 0 var(--line); }
.week-label {
  font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 1.05rem;
  min-width: 5.5rem; text-align: center; color: var(--line);
}
