/* =============================================================
   Katzen-Tamagotchi — warmes Abendlicht statt kaltem Retro-Look
   Palette: dunkles Pflaume + Bernstein (Lampenlicht am Abend)
   ============================================================= */

:root {
  --bg-1: #3b2033;          /* dunkles Pflaume */
  --bg-2: #58304a;
  --card: rgba(255, 244, 230, 0.08);
  --card-border: rgba(255, 200, 150, 0.18);
  --text: #ffe9d6;
  --text-soft: #e8c9b8;
  --amber: #ffb86b;
  --amber-deep: #e08a3c;
  --heart: #ff9d76;
  --heart-empty: rgba(255, 233, 214, 0.25);
  --bubble-bg: #fff4e6;
  --bubble-text: #4a2b3d;
  --radius: 22px;
}

* { box-sizing: border-box; }

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

body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 70%, #2a1622 100%);
  background-attachment: fixed;
  display: flex;
  justify-content: center;
  transition: background 1.5s ease;
}

/* Nacht: dunkler, ruhiger, wärmer */
body.night {
  --bg-1: #241224;
  --bg-2: #34203a;
  background: linear-gradient(180deg, #2c1a33 0%, #241224 70%, #180b18 100%);
}

.app {
  width: 100%;
  max-width: 460px;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- Kopf ---------- */
.top {
  text-align: center;
  margin-top: 4px;
}
.top h1 {
  font-family: "Fredoka", "Nunito", sans-serif;
  font-weight: 600;
  font-size: 2rem;
  margin: 0;
  letter-spacing: 0.5px;
}
.days {
  margin: 4px 0 0;
  font-size: 0.95rem;
  color: var(--text-soft);
}

/* ---------- Szene ---------- */
.scene {
  position: relative;
  flex: 1;
  min-height: 340px;
  background:
    radial-gradient(ellipse 90% 55% at 50% 108%, rgba(255, 184, 107, 0.28), transparent 70%),
    var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  padding: 18px 14px 26px;
  transition: filter 1s ease;
}
body.night .scene {
  background:
    radial-gradient(ellipse 80% 45% at 50% 110%, rgba(255, 170, 90, 0.16), transparent 70%),
    rgba(20, 10, 22, 0.35);
}
.scene.dimmed { filter: brightness(0.6) saturate(0.85); }

.scene.wiggle .cat-wrap { animation: wiggle 0.9s ease; }
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-2deg) scale(1.02); }
  60% { transform: rotate(2deg) scale(1.02); }
}

.cat-wrap {
  position: relative;
  width: min(78%, 300px);
  display: flex;
  justify-content: center;
}
.cat-photo {
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 46dvh;
  object-fit: cover;
  object-position: 50% 45%;
  border-radius: 24px;
  border: 5px solid rgba(255, 244, 230, 0.92);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
  transition: opacity 0.25s ease;
}
.cat-photo.fading { opacity: 0; }
.cat-fallback {
  display: none;
  place-items: center;
  font-size: 7rem;
  width: 100%;
  min-height: 200px;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.4));
}

/* ---------- Sprechblase ---------- */
.bubble {
  position: relative;
  max-width: 88%;
  background: var(--bubble-bg);
  color: var(--bubble-text);
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.4;
  padding: 12px 18px;
  border-radius: 18px;
  margin-bottom: 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.bubble::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 9px solid transparent;
  border-top-color: var(--bubble-bg);
  border-bottom: 0;
}
.bubble.pop { animation: bubblePop 0.35s ease; }
@keyframes bubblePop {
  0% { transform: scale(0.85); opacity: 0.3; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Effekt-Ebene (Herzen, Zzz, Napf) ---------- */
.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.fx-heart {
  position: absolute;
  bottom: 22%;
  animation: floatUp 2.2s ease-out forwards;
  opacity: 0;
}
@keyframes floatUp {
  0%   { transform: translateY(0) scale(0.7); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translateY(-180px) scale(1.15) rotate(8deg); opacity: 0; }
}
.fx-zzz {
  position: absolute;
  bottom: 45%;
  font-family: "Fredoka", sans-serif;
  font-size: 1.6rem;
  color: var(--amber);
  animation: zzzUp 2.8s ease-out forwards;
  opacity: 0;
}
@keyframes zzzUp {
  0%   { transform: translateY(0) scale(0.7); opacity: 0; }
  20%  { opacity: 0.9; }
  100% { transform: translateY(-120px) translateX(24px) scale(1.4); opacity: 0; }
}

.bowl {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translate(-50%, 70px);
  font-size: 2rem;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}
.bowl.show { transform: translate(-50%, 0); }

/* ---------- Mond (nur nachts sichtbar) ---------- */
.moon {
  position: absolute;
  top: 14px;
  right: 18px;
  font-size: 1.6rem;
  opacity: 0;
  transition: opacity 1.5s ease;
  filter: drop-shadow(0 0 14px rgba(255, 220, 150, 0.6));
  pointer-events: none;
}
body.night .moon { opacity: 0.9; }

/* ---------- Wohlfühl-Balken (sanft, nie alarmierend) ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}
.stat {
  display: flex;
  align-items: center;
  gap: 7px;
}
.stat-emoji { font-size: 1.05rem; line-height: 1; }
.stat-track {
  flex: 1;
  height: 9px;
  border-radius: 99px;
  background: rgba(255, 233, 214, 0.16);
  overflow: hidden;
}
.stat-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--amber-deep), var(--amber));
  transition: width 0.9s ease;
}

/* ---------- Herz-Meter (die Signatur) ---------- */
.bond {
  text-align: center;
  padding: 10px 12px 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}
.hearts {
  font-size: 1.7rem;
  letter-spacing: 6px;
  line-height: 1;
}
.hearts.bump { animation: heartsBump 0.6s ease; }
@keyframes heartsBump {
  30% { transform: scale(1.14); }
  100% { transform: scale(1); }
}
.heart { color: var(--heart-empty); transition: color 0.6s ease; }
.heart.full { color: var(--heart); text-shadow: 0 0 14px rgba(255, 157, 118, 0.55); }
.bond-level {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: var(--text-soft);
}

/* ---------- Aktionen ---------- */
.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.action {
  font-family: "Nunito", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--bubble-text);
  background: linear-gradient(180deg, #ffd9a8, var(--amber));
  border: none;
  border-radius: 20px;
  padding: 14px 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--amber-deep), 0 10px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.3s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.action:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--amber-deep), 0 4px 10px rgba(0, 0, 0, 0.25);
}
.action:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}
.action-emoji { font-size: 1.7rem; line-height: 1; }
.action-label { font-size: 0.92rem; }

/* ---------- Fußzeile ---------- */
.foot {
  text-align: center;
  color: var(--text-soft);
  font-size: 0.85rem;
  opacity: 0.8;
  margin: 2px 0 4px;
}

/* ---------- Willkommens-Overlay ---------- */
.welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 10, 22, 0.82);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.welcome-overlay.show { display: flex; }
.welcome-card {
  background: linear-gradient(180deg, #fff7ec, #ffe9d0);
  color: var(--bubble-text);
  border-radius: 26px;
  padding: 28px 24px;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: cardIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cardIn {
  from { transform: translateY(30px) scale(0.92); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.welcome-emoji { font-size: 2.6rem; }
.welcome-card h2 {
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  margin: 8px 0 10px;
}
.welcome-note {
  font-size: 1.05rem;
  line-height: 1.55;
  margin: 0 0 20px;
  white-space: pre-line;
}
.welcome-btn { width: 100%; }

/* ---------- Reduzierte Bewegung ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.15s !important;
  }
  .fx-heart, .fx-zzz { display: none; }
}
