:root {
  --bg-1: #fff5f7;
  --bg-2: #ffe0eb;
  --bg-3: #c1e9ff;
  --surface: #ffffff;
  --border: #ffd6e2;
  --text: #2d2438;
  --muted: #8a7f96;
  --accent: #ff6b9d;
  --accent-2: #b66bff;
  --ok: #4ade80;
  --warn: #f0b95c;
  --bad: #ff4d6d;
  --shadow: 0 6px 24px rgba(255, 107, 157, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Comic Sans MS", sans-serif;
  background:
    radial-gradient(circle at 20% 10%, var(--bg-2) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, var(--bg-3) 0%, transparent 50%),
    var(--bg-1);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.game {
  max-width: 600px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ---------- Screens ---------- */
.screen {
  display: none;
  animation: fadeIn 0.4s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Header ---------- */
.game-header {
  text-align: center;
  padding: 1rem 0 2rem;
}

.game-header.compact {
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  margin-bottom: 1rem;
}

.game-header h1 {
  margin: 0;
  font-size: 2.2rem;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.game-header .sub {
  color: var(--muted);
  margin: 0.5rem 0 0;
}

.pet-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pet-mini-emoji {
  font-size: 2rem;
}

.pet-info h2 {
  margin: 0;
  font-size: 1.1rem;
}

.pet-meta {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  gap: 0.75rem;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--bg-2);
}

/* ---------- Pet Picker ---------- */
.pet-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.pet-option {
  background: var(--surface);
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 1rem 0.5rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  font-family: inherit;
  color: inherit;
}

.pet-option:hover {
  border-color: var(--accent);
  transform: translateY(-4px) rotate(-1deg);
}

.pet-option.selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--bg-2), var(--surface));
  box-shadow: var(--shadow);
}

.pet-pick-emoji {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.pet-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.pet-trait {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* ---------- Name input ---------- */
.name-input {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.name-input label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.name-input input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 0.75rem;
  background: var(--bg-1);
  color: var(--text);
}

.name-input input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ---------- Big button ---------- */
.big-btn {
  display: block;
  width: 100%;
  padding: 0.95rem;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  box-shadow: var(--shadow);
}

.big-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(255, 107, 157, 0.35);
}

.big-btn:disabled {
  background: #d0c8d8;
  cursor: not-allowed;
  box-shadow: none;
}

/* ---------- Pet stage ---------- */
.pet-stage {
  background: linear-gradient(180deg, #c1e9ff 0%, #e8f5ff 60%, #d4f3a8 60%, #b8e88a 100%);
  border-radius: 20px;
  height: 240px;
  position: relative;
  overflow: hidden;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.pet-stage.night {
  background: linear-gradient(180deg, #1a1a3e 0%, #3d2c5c 60%, #2d4a2d 60%, #1d3d1d 100%);
}

.pet-stage.dirty::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(139, 90, 60, 0.3) 0%, transparent 8%),
    radial-gradient(circle at 60% 30%, rgba(139, 90, 60, 0.3) 0%, transparent 6%),
    radial-gradient(circle at 80% 70%, rgba(139, 90, 60, 0.3) 0%, transparent 7%),
    radial-gradient(circle at 40% 80%, rgba(139, 90, 60, 0.3) 0%, transparent 9%);
  pointer-events: none;
}

.pet-emoji {
  position: absolute;
  bottom: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 6rem;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.18));
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s ease;
  animation: idle 3s ease-in-out infinite;
}

.pet-emoji:hover {
  transform: translateX(-50%) scale(1.05);
}

@keyframes idle {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-6px); }
}

.pet-emoji.sleeping {
  animation: sleep 2.5s ease-in-out infinite;
}

@keyframes sleep {
  0%, 100% { transform: translateX(-50%) rotate(-3deg); }
  50%      { transform: translateX(-50%) rotate(3deg); }
}

.pet-emoji.happy {
  animation: bounce 0.6s ease-in-out 3;
}

@keyframes bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(-30px); }
}

.pet-emoji.sad {
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.18)) saturate(0.4) brightness(0.85);
}

.pet-emoji.sick {
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.18)) saturate(0.5) hue-rotate(80deg);
  animation: shiver 0.5s infinite;
}

@keyframes shiver {
  0%, 100% { transform: translateX(-50%) translateX(-2px); }
  50%      { transform: translateX(-50%) translateX(2px); }
}

.weather {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.floor {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40%;
}

.mood-bubble {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: white;
  border-radius: 16px;
  padding: 0.5rem 0.85rem;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: pop 0.3s ease;
}

.mood-bubble.hidden {
  display: none;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}

/* Floating particles */
.particle {
  position: absolute;
  pointer-events: none;
  animation: float-up 1.5s ease-out forwards;
  font-size: 1.5rem;
}

@keyframes float-up {
  0%   { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-80px); opacity: 0; }
}

/* ---------- Stats ---------- */
.stats {
  background: var(--surface);
  border-radius: 16px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.stat-bar {
  background: var(--bg-1);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.stat-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ok), #6efc9c);
  border-radius: 999px;
  transition: width 0.5s ease, background 0.3s ease;
  width: 100%;
}

.stat-fill.medium {
  background: linear-gradient(90deg, var(--warn), #ffd685);
}

.stat-fill.low {
  background: linear-gradient(90deg, var(--bad), #ff8a9c);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

.stat-value {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
}

/* ---------- Actions ---------- */
.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.action {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 0.25rem;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  box-shadow: 0 2px 6px rgba(255, 107, 157, 0.08);
}

.action:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 6px 14px rgba(255, 107, 157, 0.2);
}

.action:active {
  transform: translateY(-1px);
}

.action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-emoji {
  font-size: 1.6rem;
}

.action-label {
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---------- Log ---------- */
.log {
  background: var(--surface);
  border-radius: 16px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
  max-height: 100px;
  overflow-y: auto;
  font-size: 0.9rem;
}

.log-entry {
  padding: 0.2rem 0;
  color: var(--muted);
  animation: fadeIn 0.3s ease;
}

.log-entry.fresh {
  color: var(--text);
  font-weight: 500;
}

/* ---------- Game over screen ---------- */
.card {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.card h2 {
  margin: 0 0 1rem;
  color: var(--accent);
}

.stats-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.stats-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.stats-list li:last-child {
  border-bottom: none;
}

#gameover-title {
  font-size: 4rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .game { padding: 1rem 0.75rem; }
  .game-header h1 { font-size: 1.8rem; }
  .pet-emoji { font-size: 5rem; }
  .pet-stage { height: 200px; }
  .stats { grid-template-columns: 1fr; }
}
