/* ============================================================
   My Champ Checklist — tablet-first, built for a 6-year-old
   Big targets, bright colors, zero tiny text.
   ============================================================ */

:root {
  --bg1: #667eea;
  --bg2: #764ba2;
  --card: #ffffff;
  --ink: #2d3436;
  --ink-soft: #636e72;
  --yellow: #fdcb6e;
  --orange: #e17055;
  --green: #00b894;
  --blue: #0984e3;
  --purple: #6c5ce7;
  --pink: #fd79a8;
  --radius: 24px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: "Baloo 2", "Comic Sans MS", cursive, sans-serif;
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  padding: 20px clamp(16px, 4vw, 48px) 60px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ============ HEADER ============ */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.hello { display: flex; align-items: center; gap: 14px; color: #fff; }
.hello-emoji { font-size: 3rem; animation: wave 2.4s ease-in-out infinite; transform-origin: 70% 70%; }
@keyframes wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  65%, 75%, 85% { transform: rotate(18deg); }
  70%, 80% { transform: rotate(-8deg); }
}
.hello h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; line-height: 1.1; }
.hello p { font-size: clamp(0.95rem, 2.2vw, 1.15rem); opacity: 0.9; font-weight: 600; }

.scoreboard { display: flex; align-items: center; gap: 12px; }

.score-chip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  padding: 8px 18px;
  box-shadow: var(--shadow);
  font-weight: 800;
}
.chip-icon { font-size: 1.5rem; }
.chip-num { font-size: 1.5rem; }
.stars-chip .chip-num { color: #e6a700; }
.streak-chip .chip-num { color: var(--orange); }
.score-chip.pop { animation: chipPop 0.45s ease; }
@keyframes chipPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35) rotate(-4deg); }
  100% { transform: scale(1); }
}

.gear-btn {
  background: rgba(255, 255, 255, 0.25);
  border: none;
  border-radius: 50%;
  width: 52px; height: 52px;
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.2s;
}
.gear-btn:active { transform: rotate(45deg) scale(0.92); }

/* ============ WEEK STRIP ============ */
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: clamp(6px, 1.5vw, 14px);
  margin-bottom: 18px;
}

.week-day {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  padding: 10px 4px 12px;
  text-align: center;
  color: #fff;
  border: 2px solid transparent;
}
.week-day.today { background: rgba(255, 255, 255, 0.95); color: var(--ink); border-color: var(--yellow); box-shadow: var(--shadow); }
.week-day .wd-name { font-size: clamp(0.75rem, 1.8vw, 1rem); font-weight: 700; opacity: 0.85; }
.week-day .wd-mark { font-size: clamp(1.3rem, 3.2vw, 1.9rem); line-height: 1.4; }

/* ============ DAY BANNER ============ */
.day-banner {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius);
  padding: 18px 26px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.banner-text h2 { font-size: clamp(1.3rem, 3.2vw, 1.8rem); font-weight: 800; }
.banner-text p { color: var(--ink-soft); font-weight: 600; font-size: clamp(0.9rem, 2.2vw, 1.1rem); }
.banner-trophy { font-size: clamp(2.4rem, 6vw, 3.6rem); filter: grayscale(1) opacity(0.35); transition: filter 0.4s, transform 0.4s; }
.day-banner.perfect .banner-trophy { filter: none; animation: trophyBounce 1s ease infinite alternate; }
@keyframes trophyBounce { from { transform: scale(1) rotate(-4deg); } to { transform: scale(1.15) rotate(6deg); } }

/* ============ ROUTINE CARDS ============ */
.routines {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: clamp(14px, 2.5vw, 24px);
}

.routine-card {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: none;
  text-align: left;
  font-family: inherit;
  transition: transform 0.15s ease;
  overflow: hidden;
}
.routine-card:active { transform: scale(0.97); }
.routine-card::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 8px;
  background: var(--accent, var(--purple));
}
.routine-card.done { background: #eafff5; }
.routine-card.done::after {
  content: "✓ DONE!";
  position: absolute; top: 16px; right: -34px;
  background: var(--green); color: #fff;
  font-weight: 800; font-size: 0.85rem;
  padding: 4px 40px;
  transform: rotate(38deg);
}

.rc-top { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.rc-emoji { font-size: clamp(2.4rem, 5vw, 3.2rem); }
.rc-name { font-size: clamp(1.25rem, 3vw, 1.6rem); font-weight: 800; line-height: 1.15; }
.rc-sub { color: var(--ink-soft); font-weight: 600; font-size: clamp(0.85rem, 2vw, 1rem); }

.rc-bar-track { background: #eee; border-radius: 999px; height: 14px; overflow: hidden; margin-bottom: 8px; }
.rc-bar-fill { height: 100%; border-radius: 999px; background: var(--accent, var(--purple)); width: 0%; transition: width 0.4s ease; }
.rc-count { font-weight: 700; color: var(--ink-soft); font-size: 1rem; }

/* ============ CHECKLIST VIEW ============ */
.checklist-view {
  position: fixed; inset: 0;
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  z-index: 40;
  padding: 20px clamp(16px, 4vw, 48px) 40px;
  overflow-y: auto;
}

.checklist-head {
  display: flex; align-items: center; gap: 16px;
  color: #fff;
  margin-bottom: 14px;
}
.back-btn {
  background: rgba(255, 255, 255, 0.25);
  border: none; border-radius: 50%;
  width: 56px; height: 56px;
  font-size: 1.8rem; color: #fff;
  cursor: pointer; flex-shrink: 0;
}
.back-btn:active { transform: scale(0.92); }
.checklist-title { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.checklist-emoji { font-size: 2.6rem; }
.checklist-title h2 { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 800; }
.checklist-progress { font-size: 1.4rem; font-weight: 800; background: rgba(255,255,255,0.25); border-radius: 999px; padding: 6px 18px; }

.progress-track { background: rgba(255,255,255,0.25); border-radius: 999px; height: 16px; overflow: hidden; margin-bottom: 20px; }
.progress-fill { height: 100%; background: var(--yellow); border-radius: 999px; width: 0%; transition: width 0.4s ease; }

.section-label {
  color: #fff; font-weight: 800;
  font-size: clamp(1.05rem, 2.6vw, 1.3rem);
  margin: 18px 4px 10px;
  opacity: 0.95;
}

.task-list { display: flex; flex-direction: column; gap: 12px; max-width: 760px; margin: 0 auto; }

.task {
  display: flex; align-items: center; gap: 16px;
  background: var(--card);
  border-radius: 20px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: none;
  font-family: inherit;
  text-align: left;
  width: 100%;
  min-height: 76px;
  transition: transform 0.12s ease, background 0.3s;
}
.task:active { transform: scale(0.98); }

.task-check {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 4px solid #dfe6e9;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
  transition: background 0.25s, border-color 0.25s;
  color: transparent;
}
.task-emoji { font-size: 2rem; flex-shrink: 0; }
.task-text { font-size: clamp(1.1rem, 2.8vw, 1.4rem); font-weight: 700; flex: 1; }

.task.checked { background: #eafff5; }
.task.checked .task-check { background: var(--green); border-color: var(--green); color: #fff; }
.task.checked .task-text { text-decoration: line-through; text-decoration-thickness: 3px; text-decoration-color: var(--green); opacity: 0.6; }
.task.just-checked { animation: taskPop 0.4s ease; }
@keyframes taskPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Tasks bounce in one-by-one when a checklist opens */
.task.enter {
  animation: taskIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes taskIn {
  from { opacity: 0; transform: translateY(34px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.routine-card.enter { animation: cardEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(26px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* The tapped task: checkmark pops, emoji jumps */
.task.just-checked .task-check { animation: checkPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes checkPop {
  0% { transform: scale(0.2) rotate(-30deg); }
  60% { transform: scale(1.35) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}
.task.just-checked .task-emoji { animation: emojiJump 0.6s ease; }
@keyframes emojiJump {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-20px) rotate(-14deg) scale(1.35); }
  65% { transform: translateY(0) scale(1); }
  80% { transform: translateY(-7px); }
  100% { transform: translateY(0); }
}

/* Stars that fly out of the tapped spot */
.float-star {
  position: fixed;
  font-size: 1.7rem;
  pointer-events: none;
  z-index: 90;
  animation: floatUp 0.9s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translate(0, 0) scale(0.5); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.5) rotate(var(--rot)); }
}

.routine-done-note {
  text-align: center; color: #fff;
  margin: 26px auto 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.done-big { font-size: 2rem; font-weight: 800; }
.done-small { font-size: 1.2rem; font-weight: 700; color: var(--yellow); }

/* ============ CELEBRATION ============ */
.celebrate {
  position: fixed; inset: 0;
  background: rgba(45, 52, 54, 0.55);
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.celebrate-card {
  background: #fff;
  border-radius: 32px;
  padding: 40px 48px;
  text-align: center;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  animation: cardIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cardIn { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.celebrate-emoji { font-size: 5rem; animation: bigBounce 0.8s ease infinite alternate; }
@keyframes bigBounce { from { transform: scale(1); } to { transform: scale(1.18) rotate(6deg); } }
.celebrate-card h2 { font-size: 2.2rem; font-weight: 800; margin: 10px 0 4px; }
.celebrate-card p { font-size: 1.25rem; color: var(--ink-soft); font-weight: 600; margin-bottom: 22px; }

.big-btn {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  border: none;
  border-radius: 999px;
  padding: 16px 44px;
  font-size: 1.4rem;
  font-weight: 800;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(225, 112, 85, 0.45);
  transition: transform 0.15s;
}
.big-btn:active { transform: scale(0.95); }

/* ============ SETTINGS ============ */
.settings-modal {
  position: fixed; inset: 0;
  background: rgba(45, 52, 54, 0.55);
  z-index: 70;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.settings-card {
  background: #fff;
  border-radius: 28px;
  padding: 26px 28px;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.settings-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.settings-head h2 { font-size: 1.5rem; font-weight: 800; }
.close-btn {
  background: #f1f2f6; border: none; border-radius: 50%;
  width: 44px; height: 44px; font-size: 1.2rem; cursor: pointer;
}

.settings-lock { text-align: center; padding: 10px 0 20px; }
.settings-lock p { color: var(--ink-soft); font-weight: 600; margin-bottom: 16px; line-height: 1.5; }
.hold-btn {
  background: var(--purple); color: #fff;
  border: none; border-radius: 999px;
  padding: 16px 36px;
  font-size: 1.2rem; font-weight: 800; font-family: inherit;
  cursor: pointer;
}
.hold-track { background: #eee; height: 12px; border-radius: 999px; margin-top: 16px; overflow: hidden; }
.hold-fill { height: 100%; width: 0%; background: var(--green); border-radius: 999px; }

.setting-row {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 14px 0;
  border-bottom: 2px solid #f1f2f6;
  font-weight: 700;
  font-size: 1.05rem;
}
.setting-row.col { flex-direction: column; align-items: flex-start; }
.setting-row small { display: block; color: var(--ink-soft); font-weight: 600; font-size: 0.85rem; }
.setting-row input[type="text"] {
  font-family: inherit; font-size: 1.1rem; font-weight: 700;
  padding: 10px 16px;
  border: 3px solid #dfe6e9; border-radius: 14px;
  width: 200px;
}
.setting-row input[type="text"]:focus { outline: none; border-color: var(--purple); }

.day-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.day-pill {
  border: 3px solid #dfe6e9;
  background: #fff;
  border-radius: 999px;
  padding: 10px 0;
  width: 58px;
  font-family: inherit; font-size: 1rem; font-weight: 800;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s;
}
.day-pill.on { background: var(--purple); border-color: var(--purple); color: #fff; }

/* Checklist editor (Parent Corner) */
#routineEditor { width: 100%; }
.edit-routine {
  border: 3px solid #f1f2f6;
  border-radius: 18px;
  padding: 12px 14px;
  margin-bottom: 12px;
  width: 100%;
}
.er-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 10px; }
.er-title { font-weight: 800; font-size: 1.05rem; }
.er-days { margin-bottom: 10px; }
.er-days .day-pill { width: 44px; padding: 6px 0; font-size: 0.8rem; border-width: 2px; }
.er-task {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 7px 2px;
  font-weight: 600; font-size: 0.95rem;
  border-bottom: 2px dashed #f1f2f6;
}
.er-task small { color: var(--ink-soft); font-weight: 600; }
.task-del {
  background: #ffe3e3; color: #d63031;
  border: none; border-radius: 50%;
  width: 34px; height: 34px;
  font-weight: 800; font-size: 0.95rem;
  cursor: pointer; flex-shrink: 0;
}
.er-add { display: flex; gap: 8px; margin-top: 10px; width: 100%; }
.er-add input {
  font-family: inherit; font-weight: 700; font-size: 0.95rem;
  border: 2px solid #dfe6e9; border-radius: 12px;
  padding: 8px 10px; min-width: 0;
}
.er-add input:focus { outline: none; border-color: var(--purple); }
.er-add .emoji-in, #newRoutineEmoji { width: 56px; text-align: center; flex-shrink: 0; }
.er-add .text-in, #newRoutineName { flex: 1; }
.add-btn { background: #efe9ff; color: var(--purple); flex-shrink: 0; }

.danger-zone { border-bottom: none; }
.danger-btns { display: flex; gap: 10px; }
.mini-btn {
  background: #f1f2f6; border: none; border-radius: 999px;
  padding: 10px 20px;
  font-family: inherit; font-size: 0.95rem; font-weight: 700;
  cursor: pointer;
}
.mini-btn.danger { background: #ffe3e3; color: #d63031; }

.save-btn { width: 100%; margin-top: 18px; background: linear-gradient(135deg, var(--green), #00cec9); box-shadow: 0 6px 18px rgba(0, 184, 148, 0.4); }

/* ============ CONFETTI ============ */
#confettiCanvas {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 80;
  width: 100vw; height: 100vh;
}

[hidden] { display: none !important; }

/* Phones (small) — still works, just stacks */
@media (max-width: 480px) {
  body { padding: 14px 12px 40px; }
  .day-banner { padding: 14px 18px; }
}
