@font-face {
  font-family: "KuaiLe";
  src: url("./fonts/ZCOOLKuaiLe-Regular.ttf") format("truetype");
  font-display: swap;
}

* { box-sizing: border-box; }

html { touch-action: manipulation; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "KuaiLe", "WenQuanYi Micro Hei", "PingFang SC", sans-serif;
  overflow-x: hidden;
}

body[data-screen="home"] {
  color: #243056;
  background:
    radial-gradient(circle at 108% -8%, #ffd98a 0 150px, transparent 151px),
    radial-gradient(circle at -12% -6%, #c5e4ff 0 130px, transparent 131px),
    #fff3df;
}

body[data-screen="night"] {
  color: #fff6e4;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.55) 0 1.5px, transparent 1.7px),
    radial-gradient(circle at 78% 12%, rgba(255, 255, 255, 0.4) 0 1.2px, transparent 1.4px),
    radial-gradient(circle at 64% 28%, rgba(255, 255, 255, 0.35) 0 1px, transparent 1.2px),
    radial-gradient(circle at 30% 42%, rgba(255, 255, 255, 0.3) 0 1px, transparent 1.2px),
    radial-gradient(circle at 88% 48%, rgba(255, 255, 255, 0.4) 0 1.4px, transparent 1.6px),
    #071433;
}

button,
input { font-family: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 4px solid #ffd43b;
  outline-offset: 3px;
}

.page {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 36px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.hello {
  margin: 4px 0 0;
  font-size: 48px;
  line-height: 1;
  font-weight: 400;
}

.bi { display: flex; flex-direction: column; min-width: 0; }

.en {
  display: block;
  font-family: "Trebuchet MS", "Segoe UI", "Noto Sans", sans-serif;
  font-weight: 700;
  line-height: 1.15;
}

.hello .en { margin-top: 4px; font-size: 20px; color: #66708c; }

button .bi { align-items: center; }

.when {
  margin: 8px 0 0;
  font-size: 18px;
  color: #66708c;
}

.when .en,
.hint .en,
.star-count .en,
.part .en,
.pack-title .en { margin-top: 2px; font-size: 14px; color: #7d879e; }

.hint .en { font-size: 16px; }

.sample {
  display: inline-block;
  margin: 0;
  padding: 2px 10px;
  border-radius: 999px;
  background: #ffd43b;
  color: #3d3000;
  font-size: 14px;
}

.sound {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 18px;
  background: white;
  font-size: 26px;
  box-shadow: 0 6px 0 rgba(36, 48, 86, 0.08);
}

body[data-screen="night"] .sound {
  background: rgba(255, 246, 228, 0.92);
  box-shadow: none;
}

.progress-panel {
  margin-top: 18px;
  padding: 16px 16px 14px;
  border-radius: 28px;
  background: white;
  box-shadow: 0 10px 0 rgba(36, 48, 86, 0.06);
}

.hint {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.25;
}

.star-count {
  margin: 8px 0 0;
  text-align: center;
  font-size: 16px;
  color: #66708c;
}

.star-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  width: 100%;
  gap: 3px;
}

.star-shape {
  width: clamp(16px, 6vw, 34px);
  height: clamp(16px, 6vw, 34px);
  flex: 0 0 auto;
  overflow: visible;
}

.star-shape polygon {
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.star-shape.is-lit polygon { fill: #ffd43b; stroke: #e0a800; }

.star-shape.is-wait.tone-cream polygon { fill: transparent; stroke: #e4c48a; }
.star-shape.is-current.tone-cream polygon { fill: transparent; stroke: #243056; }
.star-shape.is-wait.tone-night polygon { fill: transparent; stroke: rgba(255, 246, 228, 0.45); }
.star-shape.is-current.tone-night polygon { fill: transparent; stroke: #fff; }

.star-shape.is-current {
  transform-origin: center;
  animation: pulse 1.1s ease-in-out infinite;
}

.part {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 4px 10px;
  font-size: 26px;
}

.part .en { color: #8a93ab; }

.part-icon { font-size: 28px; }

.tasks {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 28px;
  background: #fff4d6;
}

.pack-title {
  margin: 0 6px;
  font-size: 22px;
  color: #8a5a12;
}

.task {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 10px;
  border: 4px solid var(--accent);
  border-radius: 24px;
  background: white;
  color: #243056;
  text-align: left;
  box-shadow: 0 8px 0 rgba(36, 48, 86, 0.06);
}

.task.is-now {
  box-shadow: 0 0 0 4px #ffd43b, 0 8px 0 rgba(36, 48, 86, 0.06);
}

.task:active { transform: translateY(2px); }

.task-titleline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-titleline .bi { flex: 1; }

.task-copy .en { margin-top: 1px; font-size: 14px; color: #7d879e; }

.task-title { font-size: 30px; line-height: 1.1; }

.task-time {
  margin-top: 2px;
  font-size: 16px;
  color: #66708c;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: #ffd43b;
  color: #3d3000;
  font-size: 16px;
  line-height: 1.05;
}

.badge .en { font-size: 11px; color: inherit; }

.badge.next { background: #d7ecff; color: #1c3f66; }

.picture {
  position: relative;
  display: grid;
  place-items: center;
  width: 220px;
  height: 220px;
  border: 7px solid var(--accent, #4da3ff);
  border-radius: 36px;
  background: #fff8ec;
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.18);
}

.picture.mini {
  width: 84px;
  height: 84px;
  border-width: 4px;
  border-radius: 22px;
  box-shadow: none;
}

.emoji,
.part-icon,
.sound {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

.emoji { font-size: 112px; line-height: 1; }

.task-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.picture.mini .emoji { font-size: 46px; }

.check-badge {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 0 0 4px white);
}

.picture.mini .check-badge { width: 28px; height: 28px; right: -4px; bottom: -4px; }

.page.step {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: min(560px, 100%);
}

.step-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 0 12px;
}

.step-copy { text-align: center; }

.step-title {
  margin: 6px 0 0;
  color: var(--accent);
  font-size: clamp(56px, 16vw, 84px);
  font-weight: 400;
  line-height: 0.95;
}

.step-title.long { font-size: clamp(36px, 9vw, 56px); }

.step-time,
.step-detail,
.step-copy .en {
  margin: 6px 0 0;
  font-size: 22px;
  color: rgba(255, 246, 228, 0.78);
}

.badge .en { font-size: 11px; color: inherit; }

.cheer-en {
  margin: -6px 0 0;
  font-size: 28px;
  color: rgba(255, 246, 228, 0.82);
  text-align: center;
}

.task-detail {
  display: block;
  margin-top: 2px;
  font-size: 15px;
  color: #66708c;
}

.countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 10px;
  min-width: 196px;
  padding: 14px 22px 16px;
  border-radius: 28px;
  color: #fff6e4;
  background: rgba(255, 246, 228, 0.12);
}

button.countdown {
  border: 0;
  background: #ffd43b;
  color: #14224a;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.28);
}

button.countdown:active {
  transform: translateY(3px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.28);
}

.countdown-time {
  font-variant-numeric: tabular-nums;
  font-size: 64px;
  line-height: 0.95;
  letter-spacing: 1px;
}

.countdown.is-done .countdown-time { font-size: 42px; }

.countdown .en,
.countdown-go.en {
  font-size: 16px;
}

.countdown-stop {
  margin-top: 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 18px;
}

.countdown-stop .en { font-size: 13px; color: rgba(255, 246, 228, 0.75); }

.timer-prompt {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 16px;
  background: #071433;
  text-align: center;
}

.timer-title {
  margin: 0;
  color: #ffd43b;
  font-size: clamp(40px, 12vw, 64px);
  line-height: 1;
}

.timer-en { margin: 0; font-size: 22px; color: rgba(255, 246, 228, 0.82); }

.timer-ok {
  min-height: 56px;
  border: 3px solid rgba(255, 246, 228, 0.4);
  border-radius: 999px;
  background: transparent;
  color: #fff6e4;
  font-size: 22px;
  padding: 8px 22px;
}

.timer-ok .en { font-size: 14px; color: rgba(255, 246, 228, 0.75); }

.step-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.back,
.undo-button,
.dismiss {
  border-radius: 999px;
  background: transparent;
  color: #fff6e4;
  font-size: 22px;
}

.back,
.undo-button {
  border: 3px solid rgba(255, 246, 228, 0.4);
  padding: 8px 18px;
  height: auto;
}

.back .en,
.undo-button .en { font-size: 14px; color: rgba(255, 246, 228, 0.75); }

.do-button,
.dismiss {
  width: min(100%, 420px);
  min-height: 88px;
  height: auto;
  padding: 10px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--accent, #ffd43b);
  color: #14224a;
  font-size: 36px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.28);
}

.do-button .en,
.dismiss .en { font-size: 16px; color: #243056; }

.dismiss {
  background: #ffd43b;
  width: min(100%, 280px);
  min-height: 76px;
}

.do-button:active,
.dismiss:active {
  transform: translateY(3px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.28);
}

.undo-button { width: min(100%, 420px); min-height: 72px; }

.next-day-button {
  width: min(100%, 420px);
  min-height: 64px;
  height: auto;
  padding: 8px 18px;
  border-radius: 999px;
  border: 3px solid rgba(255, 246, 228, 0.45);
  background: transparent;
  color: #fff6e4;
  font-size: 24px;
}

.next-day-button .en { font-size: 14px; color: rgba(255, 246, 228, 0.75); }

.log-sum { margin: 8px 0; font-size: 18px; }
.log-sum .en { font-size: 14px; color: #7d879e; }

.log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 8px 0;
  border-top: 1px solid rgba(36, 48, 86, 0.08);
}

.log-row .zh { font-size: 18px; }
.log-row .en { font-size: 13px; color: #7d879e; }
.log-row.is-done .zh { color: #2f8f4e; }
.log-name { min-width: 0; }

.bob { animation: bob 1.6s ease-in-out infinite; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: #071433;
}

.overlay-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: min(560px, 100%);
}

.yay,
.all-done-title {
  margin: 0;
  color: #ffd43b;
  font-size: clamp(64px, 16vw, 96px);
  font-weight: 400;
  line-height: 1;
  text-align: center;
}

.stage {
  position: relative;
  display: grid;
  width: 260px;
  height: 260px;
  place-items: center;
}

.hop { animation: hop 1.2s ease-out both; }

.tick {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 78px;
  height: 78px;
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.tick .check-badge {
  position: static;
  width: 78px;
  height: 78px;
  filter: drop-shadow(0 0 0 6px white);
}

.burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.star-shape.fly {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  animation: fly 0.95s ease-out forwards;
}

.star-shape.fly polygon { fill: currentColor; stroke: none; }

.fireworks {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.burst-origin { position: absolute; width: 10px; height: 10px; }

.burst-origin i {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  animation: boom 1.1s ease-out infinite;
}

.problem {
  margin: 48px 16px;
  font-size: 24px;
  text-align: center;
}

.home-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.link-button,
.text-button,
.save-button {
  border: 0;
  border-radius: 18px;
  color: #243056;
  font-size: 18px;
}

.link-button {
  flex: 1 1 30%;
  min-width: 0;
  padding: 12px 8px;
  background: white;
  box-shadow: 0 8px 0 rgba(36, 48, 86, 0.06);
}

.link-button .en,
.text-button .en { font-size: 13px; color: #7d879e; }

.text-button {
  background: white;
  padding: 8px 12px;
  box-shadow: 0 4px 0 rgba(36, 48, 86, 0.06);
}

.save-button {
  background: #4da3ff;
  color: white;
  padding: 8px 14px;
}

.save-button .en { font-size: 12px; color: rgba(255, 255, 255, 0.9); }

.edit-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -8px -4px 8px;
  padding: 8px 4px 10px;
  background: #fff3df;
}

.edit-title { flex: 1; min-width: 0; text-align: center; font-size: 22px; }
.edit-title .en,
.edit-date .zh,
.edit-date .en { font-size: 13px; color: #7d879e; }
.edit-spacer { width: 72px; flex: 0 0 auto; }

.form-actions { display: flex; gap: 8px; }
.form-actions .add-go,
.form-actions .text-button { flex: 1; }

.tune-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.tune-row.is-editing { background: #e7f3ff; border-radius: 12px; padding-left: 8px; padding-right: 8px; }

.week-day {
  margin-top: 12px;
  padding: 12px;
  border-radius: 24px;
  background: white;
  box-shadow: 0 8px 0 rgba(36, 48, 86, 0.06);
}

.week-day.is-today { box-shadow: 0 0 0 4px #ffd43b, 0 8px 0 rgba(36, 48, 86, 0.06); }

.week-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.week-head .zh { font-size: 20px; }
.week-head .en { font-size: 13px; color: #7d879e; }
.today-flag {
  display: inline-flex;
  margin: 6px 0 0;
  padding: 2px 10px;
  border-radius: 999px;
  background: #ffd43b;
  color: #3d3000;
  font-size: 14px;
}
.today-flag .bi { align-items: center; }
.today-flag .en { font-size: 11px; color: #3d3000; }
.week-part { margin: 10px 0 0; font-size: 14px; color: #8a93ab; }
.week-part .en { font-size: 12px; }
.week-task { margin: 3px 0; font-size: 16px; }
.week-task .en { font-size: 13px; color: #7d879e; }

.adjust {
  margin-top: 28px;
  padding: 8px 8px 12px;
  border-radius: 28px;
  background: white;
  box-shadow: 0 10px 0 rgba(36, 48, 86, 0.06);
}

.adjust-toggle {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: #243056;
  font-size: 26px;
  text-align: left;
}

.adjust-toggle .en { font-size: 14px; color: #7d879e; }

.adjust-body { display: flex; flex-direction: column; gap: 10px; padding: 0 8px 8px; }

.adjust-note,
.adjust-label { margin: 4px 0 0; }

.adjust-note { font-size: 16px; color: #66708c; }
.adjust-note .en,
.adjust-label .en { font-size: 13px; color: #7d879e; }

.adjust-label { font-size: 20px; }

.add-form { display: flex; flex-direction: column; gap: 8px; }

.add-input {
  width: 100%;
  padding: 10px 12px;
  border: 3px solid #ead9b5;
  border-radius: 14px;
  background: #fffaf1;
  color: #243056;
  font-size: 18px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 3px solid #ead9b5;
  border-radius: 999px;
  background: white;
  color: #243056;
  padding: 6px 10px;
  font-size: 18px;
}

.chip.is-on { border-color: #4da3ff; background: #e7f3ff; }

.emoji-pick { font-size: 26px; line-height: 1; padding: 4px 6px; }

.add-error { margin: 0; color: #b4234a; font-size: 16px; }

.add-go {
  border: 0;
  border-radius: 999px;
  background: #4da3ff;
  color: white;
  padding: 10px 16px;
  font-size: 22px;
}

.add-go .en { font-size: 14px; color: rgba(255, 255, 255, 0.88); }

.tune-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-top: 2px solid #f3e6cf;
}

.tune-name { min-width: 0; font-size: 18px; }
.tune-name .en { font-size: 13px; color: #7d879e; }

.tune-pause,
.tune-resume {
  flex: 0 0 auto;
  border: 3px solid #e0a800;
  border-radius: 999px;
  background: #fff8dc;
  color: #3d3000;
  padding: 6px 12px;
  font-size: 16px;
}

.tune-pause .en,
.tune-resume .en { font-size: 12px; color: #7a6230; }

@media (min-width: 840px) {
  .page.step { width: min(920px, 100%); }
  .step-layout {
    flex-direction: row;
    justify-content: center;
    gap: 48px;
  }
  .step-copy { text-align: left; }
  .step-title { font-size: 84px; }
}

@keyframes pulse {
  50% { transform: scale(1.28); }
}

@keyframes bob {
  50% { transform: translateY(-8px); }
}

@keyframes hop {
  0% { transform: translateY(0); }
  18% { transform: translateY(-26px); }
  36% { transform: translateY(0); }
  52% { transform: translateY(-12px); }
  68%, 100% { transform: translateY(0); }
}

@keyframes pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

@keyframes fly {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(0.75); opacity: 0; }
}

@keyframes boom {
  0% { transform: translate(0, 0) scale(0.4); opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) scale(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bob,
  .hop,
  .star-shape.is-current,
  .tick,
  .star-shape.fly,
  .burst-origin i { animation: none; }
  .burst { display: none; }
  .tick { transform: none; }
}
