* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: Georgia, serif;
  background: linear-gradient(180deg, #f5f1e8 0%, #e8dfc8 100%);
  color: #2a1810;
  transition: background 600ms ease-in-out;
}

#room {
  position: relative;
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#creature-container {
  position: relative;
  margin-bottom: 24px;
}

#whisper {
  font-style: italic;
  font-size: 14px;
  color: #7a6a4a;
  min-height: 20px;
  text-align: center;
  margin-bottom: 32px;
  transition: color 600ms ease-in-out;
}

#mood-form {
  position: absolute;
  bottom: 48px;
}

#mood-input {
  width: 320px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 20px;
  background: rgba(255,255,255,0.6);
  color: inherit;
  text-align: center;
  outline: none;
}

#mood-input:focus {
  border-color: rgba(0,0,0,0.4);
  background: rgba(255,255,255,0.9);
}

.blob {
  background: #d8c5a0;
  border-radius: 50% 50% 48% 48% / 60% 60% 40% 40%;
  width: 110px;
  height: 100px;
  position: relative;
  box-shadow: 0 8px 0 #b8a580, inset -10px -10px 0 #c8b590;
  transform-origin: center bottom;
  animation: blob-breathe var(--blob-breath, 3.4s) ease-in-out infinite;
  transition: background 600ms ease-in-out, box-shadow 600ms ease-in-out;
}

.blob.dissolve {
  animation: blob-dissolve 600ms ease-in-out forwards;
}

.blob .eye {
  position: absolute;
  top: 38px;
  width: 10px;
  height: 10px;
  background: #2a1810;
  border-radius: 50%;
  transform-origin: center;
  transition: transform 0.15s ease-out, height 600ms ease-in-out;
}
.blob .eye.left { left: 28px; }
.blob .eye.right { right: 28px; }
.blob .eye.blink { animation: blob-blink 6s infinite; }

.blob .mouth {
  position: absolute;
  top: 58px;
  left: 46px;
  width: 18px;
  height: 0;
  background: #2a1810;
  border-radius: 0 0 18px 18px;
  opacity: 0;
  animation: blob-mouth 7s infinite;
}

.shadow {
  width: 60px;
  height: 8px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.25) 0%, transparent 70%);
  margin: 6px auto 0;
}

@keyframes blob-breathe {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.04) translateY(-3px); }
}

@keyframes blob-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  94%, 98% { transform: scaleY(0.1); }
}

@keyframes blob-mouth {
  0%, 85%, 100% { opacity: 0; height: 0; }
  90% { opacity: 1; height: 6px; }
}

@keyframes blob-dissolve {
  0% { filter: blur(0); opacity: 1; transform: scale(1); }
  45% { filter: blur(6px); opacity: 0.4; transform: scale(0.9); }
  55% { filter: blur(6px); opacity: 0.4; transform: scale(1.1); }
  100% { filter: blur(0); opacity: 1; transform: scale(1); }
}

/* Mood-driven energy ceiling — set via CSS variables on body. */
body {
  --blob-breath: 3.4s;
  --blob-blink-speed: 6s;
  --particle-opacity: 1;
}
body.energy-low .blob { animation-duration: 5s; }
body.energy-low .blob .mouth { animation: none; opacity: 0; }
body.energy-high .blob { animation: blob-bounce 1.6s ease-in-out infinite; }

@keyframes blob-bounce {
  0%, 100% { transform: scale(1) translateY(0); }
  40% { transform: scale(1.08, 0.94) translateY(-2px); }
  50% { transform: scale(1.1, 1.05) translateY(-8px); }
  60% { transform: scale(1.08, 0.94) translateY(-2px); }
}

/* Accessories — overlaid above the blob. */
.accessory {
  position: absolute;
  left: 50%;
  pointer-events: none;
}
.accessory.umbrella {
  top: -28px;
  transform: translateX(-50%);
  width: 90px;
  height: 30px;
  background: var(--accessory-color, #4a3a78);
  border-radius: 50% 50% 0 0;
  box-shadow: 0 3px 0 rgba(0,0,0,0.3);
}
.accessory.umbrella::after {
  content: '';
  position: absolute;
  top: 26px; left: 50%;
  width: 2px; height: 16px;
  background: inherit;
  transform: translateX(-50%);
}
.accessory.sunglasses {
  top: 32px;
  transform: translateX(-50%);
  width: 70px; height: 18px;
  background: #1a1a1a;
  border-radius: 12px 12px 4px 4px;
}
.accessory.shawl {
  top: 50px;
  transform: translateX(-50%);
  width: 130px; height: 40px;
  background: var(--accessory-color, #8a4a3a);
  border-radius: 50% 50% 30% 30% / 80% 80% 20% 20%;
  z-index: -1;
}
.accessory.tea, .accessory.flower, .accessory.headphones,
.accessory.hat, .accessory.scarf, .accessory.popsicle {
  /* Placeholder shape — visual polish iterated later. */
  top: -16px;
  transform: translateX(-50%);
  width: 24px; height: 24px;
  background: var(--accessory-color, #888);
  border-radius: 50%;
}

/* Particles layer */
.particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.particles.rain {
  background-image: repeating-linear-gradient(105deg, transparent 0, transparent 10px, rgba(180,200,230,0.18) 10px, rgba(180,200,230,0.18) 11px);
  animation: particles-rain 0.7s linear infinite;
}
.particles.snow::before, .particles.snow::after {
  content: '·  ·   ·    ·  ·';
  position: absolute;
  color: rgba(255,255,255,0.7);
  font-size: 24px;
  inset: 0;
  letter-spacing: 36px;
  line-height: 30px;
  white-space: pre-wrap;
  animation: particles-fall 12s linear infinite;
}
.particles.sparkles {
  background-image: radial-gradient(circle, rgba(255,220,80,0.6) 1px, transparent 2px);
  background-size: 60px 60px;
  animation: particles-twinkle 2s ease-in-out infinite;
}
.particles.dust {
  background-image: radial-gradient(circle, rgba(255,255,255,0.3) 1px, transparent 2px);
  background-size: 80px 80px;
}
/* embers, bubbles, stars, leaves, static: extend with additional .particles.X styles in a future polish pass. */

@keyframes particles-rain { 0% { background-position-y: 0; } 100% { background-position-y: 22px; } }
@keyframes particles-fall { 0% { transform: translateY(-100%); } 100% { transform: translateY(100%); } }
@keyframes particles-twinkle { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

.particles { transition: opacity 600ms ease-in-out; }
#whisper { transition: color 400ms, font-family 0ms, font-style 0ms; }

#sound-toggle {
  position: absolute;
  top: 16px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.2);
  background: rgba(255,255,255,0.5);
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  z-index: 10;
  opacity: 0.7;
  transition: opacity 200ms;
}
#sound-toggle:hover { opacity: 1; }
#sound-toggle.off { text-decoration: line-through; opacity: 0.4; }

#naming-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#naming-modal[hidden] { display: none; }
#naming-form {
  background: #f5f1e8;
  padding: 32px 40px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
#naming-form label {
  font-family: Georgia, serif;
  font-style: italic;
  color: #2a1810;
  font-size: 16px;
}
#naming-form input {
  padding: 10px 14px;
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 8px;
  font: inherit;
  outline: none;
}
#naming-form button {
  padding: 8px 16px;
  border: none;
  background: #2a1810;
  color: #f5f1e8;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}

#year-toggle {
  position: absolute;
  top: 16px; right: 60px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.2);
  background: rgba(255,255,255,0.5);
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  z-index: 10;
  opacity: 0.7;
  transition: opacity 200ms;
}
#year-toggle:hover { opacity: 1; }

#year-view {
  position: absolute;
  inset: 60px 40px 40px 40px;
  background: rgba(255,255,255,0.85);
  border-radius: 16px;
  padding: 24px;
  overflow: auto;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 8px;
}
#year-view[hidden] { display: none; }
.year-month {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.year-month-label {
  font-size: 10px;
  letter-spacing: 1px;
  color: #2a1810;
  margin-bottom: 4px;
  text-align: center;
  font-family: Georgia, serif;
}
.year-cell {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid rgba(0,0,0,0.05);
  background: transparent;
  cursor: default;
  transition: transform 100ms;
}
.year-cell.has-mood { cursor: pointer; }
.year-cell.has-mood:hover { transform: scale(1.4); z-index: 5; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

#year-view.collapsed-creature ~ #creature-container {
  position: absolute;
  bottom: 20px;
  right: 20px;
  transform: scale(0.5);
  transform-origin: bottom right;
  z-index: 30;
}
