:root {
  color-scheme: dark;
  --bg: #201530;
  --panel: rgba(24, 16, 38, 0.72);
  --panel-border: rgba(255, 255, 255, 0.08);
  --accent: #ff9f6b;
  --hunger: #ff8a65;
  --happiness: #ffd166;
  --energy: #6bcbef;
  --text: #f4ecff;
  --text-dim: rgba(244, 236, 255, 0.6);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: radial-gradient(circle at 50% 40%, #3a2a52, #1a1226);
  z-index: 50;
  transition: opacity 0.5s ease;
}
#loading.hidden { opacity: 0; pointer-events: none; }
.loading-cat { font-size: 48px; animation: bob 1.2s ease-in-out infinite; }
.loading-text { color: var(--text-dim); font-size: 14px; letter-spacing: 0.02em; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.hint {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 68px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--text-dim);
  background: var(--panel);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  z-index: 10;
  transition: opacity 0.6s ease;
  pointer-events: none;
  white-space: nowrap;
}
.hint.hidden { opacity: 0; }

#stats-bar {
  position: absolute;
  top: env(safe-area-inset-top, 0px);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 14px 16px 10px;
  z-index: 10;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
  backdrop-filter: blur(10px);
}
.stat-icon { font-size: 14px; line-height: 1; }
.stat-track {
  width: 60px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.stat-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  transform: scaleX(1);
  transform-origin: left;
  transition: transform 0.4s ease, background-color 0.4s ease;
}
.stat[data-stat="hunger"] .stat-fill { background: var(--hunger); }
.stat[data-stat="happiness"] .stat-fill { background: var(--happiness); }
.stat[data-stat="energy"] .stat-fill { background: var(--energy); }

#action-bar {
  position: absolute;
  bottom: env(safe-area-inset-bottom, 0px);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px calc(env(safe-area-inset-bottom, 0px) + 14px);
  z-index: 10;
}

.action-btn {
  flex: 0 1 140px;
  padding: 13px 18px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  backdrop-filter: blur(10px);
  transition: transform 0.12s ease, background 0.2s ease;
}
.action-btn:active { transform: scale(0.94); background: rgba(255, 255, 255, 0.14); }
.voice-btn { flex-basis: 160px; }
.voice-btn.recording {
  background: linear-gradient(135deg, #ff6b6b, #ff9f6b);
  border-color: transparent;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.5); }
  50% { box-shadow: 0 0 0 10px rgba(255, 107, 107, 0); }
}

.food-tray {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 76px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  padding: 10px;
  border-radius: 18px;
  backdrop-filter: blur(10px);
  z-index: 11;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.food-tray.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(8px); }
.food-item {
  width: 52px;
  height: 52px;
  font-size: 24px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
}
.food-item:active { transform: scale(0.9); }

.toast {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 90px);
  left: 50%;
  transform: translateX(-50%);
  max-width: 86%;
  background: rgba(20, 12, 32, 0.92);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  padding: 10px 16px;
  border-radius: 14px;
  z-index: 20;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(6px); }
