:root {
  --sky-top: #6FCBFF;
  --sky-bottom: #CFEFFF;
  --ink: #14213D;
  --red: #D92D20;
  --red-dark: #9F1D14;
  --blue: #1F6FEB;
  --blue-dark: #174FA8;
  --green: #1F7A2E;
  --green-dark: #155420;
  --gold: #FFD93B;
  --gold-dark: #C99A00;
  --orange: #FF8A1F;
  --purple: #8E44D6;
  --plate: #4FB848;
  --plate-light: #7BDB6F;
  --plate-dark: #2E7D32;
  --display: "Titan One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: "Figtree", system-ui, sans-serif;
}

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

html {
  background: var(--sky-bottom);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
  color: var(--ink);
  font-family: var(--body);
  font-weight: 500;
  font-size: 1.0625rem;
  line-height: 1.5;
  overflow-x: hidden;
}

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

/* Blocky clouds */
.sky {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 70%);
}
.cloud {
  position: absolute;
  left: -260px;
  width: 140px;
  height: 36px;
  background: #fff;
  border-radius: 6px;
  animation: cloud-drift linear infinite;
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 6px;
}
.cloud::before { left: 26px; top: -22px; width: 60px; height: 30px; }
.cloud::after { left: 70px; top: -12px; width: 50px; height: 24px; }
.c1 { top: 9%; animation-duration: 140s; }
.c2 { top: 28%; transform: scale(1.4); animation-duration: 190s; animation-delay: -80s; }
.c3 { top: 52%; transform: scale(0.8); animation-duration: 160s; animation-delay: -40s; }
@keyframes cloud-drift {
  from { margin-left: 0; }
  to { margin-left: calc(100vw + 560px); }
}

/* Layout */
.stage {
  position: relative;
  z-index: 1;
  flex: 1;
  width: min(1120px, 100% - 32px);
  margin-left: auto;
  margin-right: auto;
  padding: clamp(24px, 5vw, 56px) 0 150px;
  padding-top: max(clamp(24px, 5vw, 56px), env(safe-area-inset-top));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "main today"
    "week week";
  gap: clamp(28px, 4vw, 56px);
  align-items: start;
}
.main { grid-area: main; }
.today { grid-area: today; }
.week { grid-area: week; }

.kicker {
  margin: 0 0 18px;
  font-weight: 700;
}

/* Block-letter headline */
h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.6rem, 9vw, 5.4rem);
  line-height: 1;
}
.line { display: block; white-space: nowrap; }
.line i {
  display: inline-block;
  font-style: normal;
  margin-right: 0.02em;
  text-shadow:
    1px 1px 0 var(--ink), 2px 2px 0 var(--ink), 3px 3px 0 var(--ink),
    4px 4px 0 var(--ink), 5px 5px 0 var(--ink);
}
.line i:nth-child(6n+1) { color: var(--red); }
.line i:nth-child(6n+2) { color: var(--orange); }
.line i:nth-child(6n+3) { color: var(--gold); }
.line i:nth-child(6n+4) { color: #3BB54A; }
.line i:nth-child(6n+5) { color: #2F80ED; }
.line i:nth-child(6n)   { color: var(--purple); }
.line i:nth-child(odd)  { transform: rotate(-2deg); }
.line i:nth-child(even) { transform: translateY(2px) rotate(2deg); }

/* Brick countdown */
.clock {
  display: flex;
  gap: clamp(8px, 1.6vw, 14px);
  margin-top: clamp(34px, 5vw, 48px);
}
.tile {
  --b: var(--red);
  --bd: var(--red-dark);
  --on: #fff;
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(14px, 2vw, 22px) 6px clamp(10px, 1.6vw, 16px);
  background: var(--b);
  color: var(--on);
  border-radius: 8px;
  box-shadow:
    inset 0 5px 0 rgba(255, 255, 255, 0.28),
    inset 0 -8px 0 rgba(0, 0, 0, 0.2),
    0 6px 0 var(--bd);
}
.tile::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 14px;
  right: 14px;
  height: 10px;
  border-radius: 4px 4px 0 0;
  background: repeating-linear-gradient(90deg, var(--b) 0 22px, transparent 22px 34px);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.3);
}
#t-hours { --b: var(--blue); --bd: var(--blue-dark); }
#t-minutes { --b: var(--green); --bd: var(--green-dark); }
#t-seconds { --b: var(--gold); --bd: var(--gold-dark); --on: var(--ink); }
.tile[hidden] { display: none; }
.digit {
  font-family: var(--display);
  font-size: clamp(2.1rem, 7vw, 4.2rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.22);
}
#t-seconds .digit { text-shadow: 0 3px 0 rgba(255, 255, 255, 0.45); }
.unit {
  margin-top: 6px;
  font-size: 0.9375rem;
  font-weight: 700;
}
.tile.tick { animation: bob 0.5s ease-out; }
@keyframes bob {
  0% { transform: translateY(0); }
  30% { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}

.born {
  margin: 30px 0 0;
  max-width: 34rem;
  font-weight: 700;
}

.again {
  margin-top: 16px;
  padding: 12px 22px;
  font: 700 1rem var(--body);
  color: #fff;
  background: var(--blue);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
.again:hover { background: #3C86F5; }
.again:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.again[hidden] { display: none; }

/* Birthday mode: every brick turns gold */
body.is-birthday .tile {
  --b: var(--gold);
  --bd: var(--gold-dark);
  --on: var(--ink);
}
body.is-birthday .digit { text-shadow: 0 3px 0 rgba(255, 255, 255, 0.45); }
body.is-over .clock { display: none; }

/* Photo frame */
.polaroid {
  position: relative;
  margin: 18px 0 0;
  padding: 10px 10px 14px;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 10px;
  transform: rotate(-1.5deg);
  box-shadow: 8px 8px 0 var(--blue);
}
.polaroid::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 18px;
  right: 18px;
  height: 10px;
  border-radius: 4px 4px 0 0;
  background: repeating-linear-gradient(90deg, var(--gold) 0 22px, transparent 22px 34px);
  box-shadow: 0 0 0 3px var(--ink);
  clip-path: inset(-3px -3px 0 -3px);
}
.polaroid img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 160px;
  background: var(--sky-bottom);
  border-radius: 4px;
}
.polaroid figcaption {
  margin-top: 10px;
  font-weight: 700;
}
.polaroid figcaption:empty { display: none; }

.today h2 {
  margin: 34px 0 6px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.7rem, 3.6vw, 2.3rem);
  line-height: 1.05;
}
.today p {
  margin: 0;
  max-width: 30rem;
}

/* Level-select day strip */
.week ol {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0;
  padding: 0 0 6px;
  list-style: none;
}
.day {
  min-width: 80px;
  padding: 10px 14px;
  font: 700 1rem var(--body);
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
.day:hover:not(:disabled) { background: #E6F4FF; }
.day:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.day[aria-pressed="true"] { background: var(--gold); }
.day.birthday:not([aria-pressed="true"]) { background: var(--red); color: #fff; }
.day:disabled {
  background: #B8C4CF;
  color: #33445A;
  border-style: dashed;
  box-shadow: none;
  transform: translateY(5px);
  cursor: not-allowed;
}

:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }

/* Studded baseplate with a hopping Duckie */
.ground {
  position: relative;
  z-index: 1;
  height: 130px;
  background-color: var(--plate);
  background-image: radial-gradient(circle at 50% 50%, var(--plate-light) 0 9px, var(--plate-dark) 10px 11px, transparent 12px);
  background-size: 44px 44px;
  background-position: 0 14px;
  border-top: 12px solid var(--plate-light);
  box-shadow: inset 0 -26px 0 var(--plate-dark);
  padding-bottom: env(safe-area-inset-bottom);
}
.walker {
  position: absolute;
  left: 0;
  bottom: calc(100% - 8px);
  width: 70px;
  pointer-events: none;
  animation: walk 55s linear infinite;
}
.hop { display: block; animation: hop 3.2s ease-in-out infinite; }
@keyframes walk {
  from { transform: translateX(-100px); }
  to { transform: translateX(calc(100vw + 100px)); }
}
@keyframes hop {
  0%, 62% { transform: translateY(0); }
  74% { transform: translateY(-46px); }
  86%, 100% { transform: translateY(0); }
}

/* Confetti */
#confetti {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

/* Small screens */
@media (max-width: 760px) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "main"
      "today"
      "week";
  }
  .polaroid { max-width: 520px; }
  .today h2, .today p { max-width: none; }
  .day { min-width: 72px; padding: 9px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile.tick, .hop, .cloud { animation: none; }
  .cloud { left: 12vw; }
  .walker { animation: none; transform: translateX(12vw); }
}

/* Badges, quack button, achievement toast */
.extras {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
}
.badges {
  margin: 0;
  font-weight: 700;
}
.quack {
  padding: 10px 20px;
  font: 700 1rem var(--body);
  color: var(--ink);
  background: var(--orange);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}
.quack:hover { background: #FFA04A; }
.quack:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 220px;
  max-width: calc(100vw - 32px);
  padding: 12px 20px 12px 56px;
  color: #fff;
  background: var(--ink);
  border: 3px solid var(--gold);
  border-radius: 10px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
  transform: translateX(-50%);
}
.toast[hidden] { display: none; }
.toast::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 28px;
  height: 28px;
  margin-top: -14px;
  background: var(--gold);
  border: 3px solid var(--gold-dark);
  border-radius: 6px;
}
.toast strong { font-size: 0.9375rem; color: var(--gold); }
.toast span { font-family: var(--display); font-size: 1.35rem; line-height: 1.1; }
.toast.show { animation: toast-in 0.45s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes toast-in {
  from { transform: translate(-50%, 140%); }
  to { transform: translate(-50%, 0); }
}
@media (prefers-reduced-motion: reduce) { .toast.show { animation: none; } }
