@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,560;9..144,700&family=IBM+Plex+Mono:wght@400;600&family=Literata:opsz,wght@7..72,420;7..72,600&family=Nunito:wght@800;900&family=Sniglet:wght@400;800&display=swap");

:root {
  color-scheme: light;
  --ink: #24302b;
  --paper: #ebe6dc;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  font-family: "Fraunces", "Iowan Old Style", Palatino, "Palatino Linotype", serif;
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.sun, .orb, .rain span, .confetti span, .still-clock, .metronome {
  display: none;
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 8vh 6vw;
}

.card {
  width: min(920px, 100%);
  text-align: center;
}

.kicker {
  margin: 0 0 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

h1 {
  margin: 0;
  font-weight: 560;
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.aside {
  margin: 1rem auto 0;
  max-width: 38rem;
  font-size: 1.15rem;
  line-height: 1.45;
}

.board {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 7.5rem;
  padding: 0.9rem 0.4rem 0.75rem;
}

.num {
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  line-height: 0.9;
  font-weight: 700;
}

.cap {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.done {
  margin: 1.4rem auto 0;
  max-width: 36rem;
  font-size: 1.35rem;
  line-height: 1.35;
}

.pulse-row { margin: 1rem 0 0; height: 0; }

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

/* ---------- empty: still paper, a stopped clock ---------- */

body[data-mood="empty"] {
  background:
    radial-gradient(ellipse at 50% 0%, #f7f4ee 0%, transparent 55%),
    #e7e2d6;
  color: #2c3330;
}

body[data-mood="empty"] .card {
  max-width: 28rem;
}

body[data-mood="empty"] .kicker {
  color: #6d746f;
  font-family: "Literata", Georgia, serif;
}

body[data-mood="empty"] .aside {
  color: #5c6560;
  font-family: "Literata", Georgia, serif;
  font-size: 1.05rem;
}

body[data-mood="empty"] .still-clock {
  display: block;
  width: 74px;
  height: 74px;
  margin: 0 auto 1.25rem;
  border: 1.5px solid #2c3330;
  border-radius: 50%;
  position: relative;
}

body[data-mood="empty"] .still-clock::before,
body[data-mood="empty"] .still-clock::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 1.5px;
  background: #2c3330;
  transform-origin: bottom center;
}

body[data-mood="empty"] .still-clock::before {
  height: 22px;
  transform: translateX(-50%) rotate(0deg);
}

body[data-mood="empty"] .still-clock::after {
  height: 16px;
  transform: translateX(-50%) rotate(90deg);
}

/* ---------- funny: stickers, dots, bounce ---------- */

body[data-mood="funny"] {
  background-color: #ffe56a;
  background-image: radial-gradient(#1c1a17 1.15px, transparent 1.25px);
  background-size: 22px 22px;
  color: #1c1a17;
  font-family: "Sniglet", "Chalkboard SE", "Comic Sans MS", "Segoe Print", cursive;
}

body[data-mood="funny"] .card {
  transform: rotate(-0.6deg);
}

body[data-mood="funny"] .kicker {
  display: inline-block;
  background: #fffdf6;
  border: 3px solid #1c1a17;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  letter-spacing: 0.08em;
  box-shadow: 4px 4px 0 #e23d28;
}

body[data-mood="funny"] h1 {
  font-weight: 800;
  font-size: clamp(2.6rem, 7vw, 5rem);
  line-height: 0.95;
  margin-top: 1rem;
}

body[data-mood="funny"] .aside {
  font-size: 1.25rem;
  min-height: 3.2em;
}

body[data-mood="funny"] .cell {
  background: #fffdf6;
  border: 3px solid #1c1a17;
  border-radius: 18px;
  box-shadow: 6px 6px 0 #e23d28;
  transform: rotate(var(--tilt));
  animation: floaty 2.2s ease-in-out infinite;
}

body[data-mood="funny"] .cell:nth-child(2) { animation-delay: 0.15s; box-shadow: 6px 6px 0 #2f6fed; }
body[data-mood="funny"] .cell:nth-child(3) { animation-delay: 0.3s; box-shadow: 6px 6px 0 #1c1a17; }
body[data-mood="funny"] .cell:nth-child(4) { animation-delay: 0.45s; box-shadow: 6px 6px 0 #148f4b; }

body[data-mood="funny"] .num {
  font-weight: 800;
}

body[data-mood="funny"] .done {
  display: inline-block;
  background: #fffdf6;
  border: 3px dashed #1c1a17;
  border-radius: 16px;
  padding: 0.8rem 1rem;
  transform: rotate(1.5deg);
}

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(var(--tilt)); }
  50% { transform: translateY(-12px) rotate(calc(var(--tilt) * -0.6)); }
}

/* ---------- sad: dim, slow rain, quiet type ---------- */

body[data-mood="sad"] {
  background: #14181d;
  color: #a9b3bd;
  font-family: "Literata", "Palatino Linotype", Palatino, Georgia, serif;
}

body[data-mood="sad"] .stage {
  align-items: end;
  justify-items: start;
  padding: 12vh 8vw 10vh;
}

body[data-mood="sad"] .card {
  text-align: left;
  width: min(640px, 100%);
}

body[data-mood="sad"] .kicker {
  letter-spacing: 0.28em;
  color: #7e8b98;
  font-size: 0.68rem;
}

body[data-mood="sad"] h1 {
  font-weight: 420;
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: 0.01em;
  color: #d5dde4;
}

body[data-mood="sad"] .aside,
body[data-mood="sad"] .done {
  color: #8e9aaa;
  font-size: 1.05rem;
  margin-left: 0;
}

body[data-mood="sad"] .board {
  gap: 1.5rem;
  max-width: 34rem;
}

body[data-mood="sad"] .cell {
  align-items: flex-start;
  min-height: 0;
  padding: 0;
}

body[data-mood="sad"] .num {
  font-weight: 420;
  color: #c5ced6;
  animation: dimbreath 8s ease-in-out infinite;
}

body[data-mood="sad"] .cap {
  letter-spacing: 0.22em;
  color: #6d7c8a;
}

body[data-mood="sad"] .rain span {
  display: block;
  position: absolute;
  left: var(--x);
  top: -30vh;
  width: 1px;
  height: var(--h);
  background: linear-gradient(to bottom, transparent, rgba(186, 198, 214, 0.55));
  animation: raindrop var(--dur) linear infinite;
  animation-delay: var(--delay);
}

@keyframes raindrop {
  0% { transform: translateY(0); }
  100% { transform: translateY(130vh); }
}

@keyframes dimbreath {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.95; }
}

/* ---------- anxious: tight, jitter, fast tick, no strobe ---------- */

body[data-mood="anxious"] {
  background-color: #d8d2c4;
  background-image: repeating-linear-gradient(
    180deg,
    transparent 0 27px,
    rgba(92, 26, 26, 0.07) 27px 28px
  );
  color: #3d1515;
  font-family: "IBM Plex Mono", ui-monospace, "Cascadia Code", monospace;
}

body[data-mood="anxious"] .stage {
  align-items: start;
  justify-items: start;
  padding: 7vh 0 8vh 8vw;
}

body[data-mood="anxious"] .card {
  width: min(26rem, calc(100vw - 2.2rem));
  text-align: left;
  border: 1px solid rgba(61, 21, 21, 0.55);
  padding: 0.85rem 0.8rem 0.7rem;
  background: rgba(216, 210, 196, 0.72);
  animation: uneasy 0.22s steps(2, end) infinite;
}

body[data-mood="anxious"] .kicker {
  letter-spacing: 0.02em;
  text-transform: none;
  font-size: 0.72rem;
  color: #7a2430;
}

body[data-mood="anxious"] h1 {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 600;
  font-size: 1.28rem;
  line-height: 1.2;
  letter-spacing: -0.03em;
  max-width: 18ch;
}

body[data-mood="anxious"] .aside,
body[data-mood="anxious"] .done {
  font-size: 0.86rem;
  line-height: 1.35;
  margin-left: 0;
  max-width: 24rem;
}

body[data-mood="anxious"] .board {
  gap: 0;
  margin-top: 0.9rem;
  border-top: 1px solid rgba(61, 21, 21, 0.4);
}

body[data-mood="anxious"] .cell {
  min-height: 4.4rem;
  padding: 0.45rem 0.15rem 0.35rem;
  border-right: 1px solid rgba(61, 21, 21, 0.28);
  align-items: flex-start;
}

body[data-mood="anxious"] .cell:last-child { border-right: 0; }

body[data-mood="anxious"] .num {
  font-size: clamp(1.45rem, 4vw, 1.9rem);
  font-weight: 600;
}

body[data-mood="anxious"] .cap {
  letter-spacing: 0.04em;
  font-size: 0.62rem;
}

body[data-mood="anxious"] .cell[data-unit="seconds"] .num {
  animation: tickpulse 0.35s ease-in-out infinite;
}

body[data-mood="anxious"] .pulse-row {
  height: auto;
  margin: 0.55rem 0 0;
}

body[data-mood="anxious"] .metronome {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7a1f1f;
  animation: beat 0.35s ease-in-out infinite;
}

@keyframes uneasy {
  0% { transform: translate(0, 0); }
  25% { transform: translate(0.7px, -0.4px); }
  50% { transform: translate(-0.6px, 0.5px); }
  75% { transform: translate(0.4px, 0.25px); }
  100% { transform: translate(0, 0); }
}

@keyframes tickpulse {
  0%, 100% { transform: translateX(0); }
  40% { transform: translateX(1px); }
  70% { transform: translateX(-0.6px); }
}

@keyframes beat {
  0%, 100% { transform: scale(1); opacity: 0.65; }
  50% { transform: scale(1.3); opacity: 1; }
}

/* ---------- happy: warm, soft, sunny ---------- */

body[data-mood="happy"] {
  color: #5c3b22;
  font-family: "Fraunces", "Iowan Old Style", Palatino, serif;
  background:
    radial-gradient(ellipse at 18% 12%, #ffe08a 0%, transparent 42%),
    radial-gradient(ellipse at 88% 78%, #ffc3a0 0%, transparent 46%),
    radial-gradient(ellipse at 60% 40%, #fff8ee 0%, #f3d2ae 78%);
}

body[data-mood="happy"] .sun {
  display: block;
  position: absolute;
  width: 220px;
  height: 220px;
  right: 8vw;
  top: 8vh;
  border-radius: 50%;
  background: radial-gradient(circle, #fff6c2 0%, #ffb703 58%, transparent 70%);
  animation: sundrift 16s ease-in-out infinite;
}

body[data-mood="happy"] .orb {
  display: block;
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.85;
}

body[data-mood="happy"] .o1 {
  width: 280px;
  height: 180px;
  left: -40px;
  bottom: 8vh;
  background: radial-gradient(circle, rgba(255, 214, 160, 0.9), transparent 70%);
  animation: blob 18s ease-in-out infinite;
}

body[data-mood="happy"] .o2 {
  width: 200px;
  height: 200px;
  right: 12vw;
  bottom: 6vh;
  background: radial-gradient(circle, rgba(255, 176, 122, 0.75), transparent 68%);
  animation: blob 14s ease-in-out infinite reverse;
}

body[data-mood="happy"] .o3 {
  width: 140px;
  height: 140px;
  left: 22vw;
  top: 18vh;
  background: radial-gradient(circle, rgba(255, 244, 214, 0.95), transparent 70%);
  animation: blob 12s ease-in-out infinite;
}

body[data-mood="happy"] .card {
  background: rgba(255, 250, 242, 0.72);
  border-radius: 36px;
  padding: 2.8rem 2.2rem 2.4rem;
  box-shadow: 0 24px 70px rgba(176, 104, 42, 0.16);
  backdrop-filter: blur(6px);
}

body[data-mood="happy"] .kicker {
  color: #b86a32;
  letter-spacing: 0.22em;
}

body[data-mood="happy"] h1 {
  color: #6a3e1e;
}

body[data-mood="happy"] .cell {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 22px;
}

body[data-mood="happy"] .num {
  color: #c46b2c;
  font-weight: 700;
}

body[data-mood="happy"] .cap {
  color: #a07858;
}

@keyframes sundrift {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-18px, 12px); }
}

@keyframes blob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(16px, -12px) scale(1.06); }
}

/* ---------- exuberant: huge type, confetti, high energy ---------- */

body[data-mood="exuberant"] {
  color: #fff8e7;
  font-family: "Nunito", "Arial Black", Impact, sans-serif;
  background: #101010;
}

body[data-mood="exuberant"]::before {
  content: "";
  position: fixed;
  inset: -30%;
  z-index: 0;
  background: repeating-linear-gradient(
    112deg,
    #ff3b30 0 16px,
    #ffd60a 16px 32px,
    #101010 32px 68px,
    #0a84ff 68px 84px,
    #32d74b 84px 100px,
    #101010 100px 148px
  );
  animation: stripes 22s linear infinite;
}

body[data-mood="exuberant"] .stage {
  padding: 6vh 4vw;
}

body[data-mood="exuberant"] .card {
  width: min(1100px, 100%);
}

body[data-mood="exuberant"] .kicker {
  font-weight: 800;
  letter-spacing: 0.28em;
  color: #101010;
  background: #ffd60a;
  display: inline-block;
  padding: 0.3rem 0.55rem;
}

body[data-mood="exuberant"] h1 {
  font-weight: 900;
  font-size: clamp(3.4rem, 13vw, 8.4rem);
  letter-spacing: -0.045em;
  text-transform: uppercase;
  line-height: 0.84;
  margin-top: 0.4rem;
  text-shadow: 0 6px 0 #101010;
}

body[data-mood="exuberant"] .aside,
body[data-mood="exuberant"] .done {
  font-weight: 800;
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

body[data-mood="exuberant"] .board {
  gap: 0.55rem;
}

body[data-mood="exuberant"] .cell {
  background: #101010;
  color: #fff8e7;
  border-radius: 8px;
  transform: rotate(var(--tilt));
}

body[data-mood="exuberant"] .cell:nth-child(1) { background: #ff3b30; }
body[data-mood="exuberant"] .cell:nth-child(2) { background: #ffd60a; color: #101010; }
body[data-mood="exuberant"] .cell:nth-child(3) { background: #32d74b; color: #101010; }
body[data-mood="exuberant"] .cell:nth-child(4) { background: #0a84ff; }

body[data-mood="exuberant"] .num {
  font-weight: 900;
  font-size: clamp(2.6rem, 7vw, 5rem);
  animation: popnum 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}

body[data-mood="exuberant"] .cell:nth-child(2) .num { animation-delay: 0.1s; }
body[data-mood="exuberant"] .cell:nth-child(3) .num { animation-delay: 0.2s; }
body[data-mood="exuberant"] .cell:nth-child(4) .num { animation-delay: 0.3s; }

body[data-mood="exuberant"] .cap {
  font-weight: 800;
}

body[data-mood="exuberant"] .confetti span {
  display: block;
  position: absolute;
  left: var(--x);
  top: -14vh;
  width: var(--w);
  height: var(--h);
  background: var(--c);
  border-radius: var(--r);
  animation: fallspin var(--dur) linear infinite;
  animation-delay: var(--delay);
}

@keyframes stripes {
  to { transform: translate3d(-120px, 0, 0); }
}

@keyframes popnum {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.06); }
}

@keyframes fallspin {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(120vh) rotate(520deg); }
}

body[data-phase="done"][data-mood="sad"] .num {
  animation: none;
  opacity: 0.45;
}

@media (max-width: 680px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body[data-mood="anxious"] .board { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  body[data-mood="anxious"] .stage { padding-left: 0.8rem; padding-right: 0.8rem; }
  body[data-mood="sad"] .stage { padding: 18vh 1.3rem 8vh; }
  body[data-mood="happy"] .card { padding: 1.8rem 1.1rem; border-radius: 26px; }
}

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