/* ===== RESET & BASE ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #0a0a14;
  --bg2: #12121f;
  --bg3: #1a1a2e;
  --accent: #6c63ff;
  --accent2: #ff6584;
  --green: #4ade80;
  --yellow: #fbbf24;
  --red: #f87171;
  --text: #e8e8ff;
  --text2: #8888aa;
  --border: #2a2a45;
  --shadow: rgba(108, 99, 255, 0.3);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  min-height: 100vh;
  overflow: hidden;
  user-select: none;
}

#app {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* ===== SCREENS ===== */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

.screen.active {
  display: flex;
}

.screen-title {
  font-size: 20px;
  font-weight: bold;
  color: var(--accent);
  text-align: center;
  margin-bottom: 8px;
  text-shadow: 0 0 20px var(--shadow);
  letter-spacing: 2px;
}

/* ===== LOADING ===== */
#loading-screen {
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.loading-egg {
  font-size: 80px;
  animation: pulse 1.5s ease-in-out infinite;
}

.loading-text {
  color: var(--text2);
  font-size: 14px;
  letter-spacing: 3px;
  animation: blink 1s step-end infinite;
}

/* ===== EGG SCREEN ===== */
#egg-screen {
  justify-content: center;
  gap: 24px;
}

.egg-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.egg {
  width: 160px;
  height: 190px;
  position: relative;
  cursor: pointer;
  transition: transform 0.1s;
  animation: float 3s ease-in-out infinite;
}

.egg:active {
  transform: scale(0.95);
}

.egg-emoji {
  font-size: 120px;
  line-height: 1;
  text-align: center;
  filter: drop-shadow(0 0 20px rgba(108, 99, 255, 0.6));
}

.egg-glow {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(108,99,255,0.2) 0%, transparent 70%);
  animation: glow-pulse 2s ease-in-out infinite;
}

.egg-hint {
  color: var(--text2);
  font-size: 14px;
  text-align: center;
  animation: blink 2s step-end infinite;
}

.hatching-status {
  color: var(--accent);
  font-size: 14px;
  text-align: center;
  min-height: 20px;
}

/* ===== CREATURE SCREEN ===== */
#creature-screen {
  justify-content: space-between;
  padding-bottom: 24px;
}

/* Stats bar */
.stats-bar {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg2);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.stat {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-label {
  font-size: 16px;
  min-width: 24px;
}

.stat-bar-bg {
  flex: 1;
  height: 10px;
  background: var(--bg3);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.stat-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
}

.hunger-bar {
  background: linear-gradient(90deg, var(--yellow), var(--green));
}

.happiness-bar {
  background: linear-gradient(90deg, var(--red), var(--accent2), var(--accent));
}

.stat-value {
  font-size: 12px;
  color: var(--text2);
  min-width: 28px;
  text-align: right;
}

/* Creature display */
.creature-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  gap: 8px;
}

.creature-sprite {
  width: 160px;
  height: 160px;
  position: relative;
}

.creature-mood {
  font-size: 28px;
  position: absolute;
  top: 0;
  right: 50%;
  transform: translateX(70px);
  animation: float 2s ease-in-out infinite;
}

/* Creature info */
.creature-info {
  text-align: center;
}

.creature-name {
  font-size: 22px;
  font-weight: bold;
  color: var(--text);
  text-shadow: 0 0 10px var(--shadow);
  margin-bottom: 4px;
}

.creature-meta {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  font-size: 13px;
  color: var(--text2);
}

.creature-type {
  font-size: 18px;
}

.creature-level {
  color: var(--yellow);
  font-weight: bold;
}

.creature-xp {
  color: var(--accent);
}

/* Action buttons */
.action-buttons {
  width: 100%;
  display: flex;
  gap: 12px;
  padding-top: 8px;
}

.action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  position: relative;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.action-btn:active {
  transform: scale(0.95);
  background: var(--bg3);
}

.feed-btn {
  border-color: var(--yellow);
}

.feed-btn:active, .feed-btn:hover {
  background: rgba(251, 191, 36, 0.1);
}

.chat-btn {
  border-color: var(--accent);
}

.chat-btn:active, .chat-btn:hover {
  background: rgba(108, 99, 255, 0.1);
}

.stats-btn {
  border-color: var(--accent2);
}

.stats-btn:active, .stats-btn:hover {
  background: rgba(255, 101, 132, 0.1);
}

.btn-icon {
  font-size: 24px;
}

.btn-label {
  font-size: 11px;
  color: var(--text2);
  letter-spacing: 1px;
}

.btn-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--yellow);
  color: #000;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 5px;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
}

.btn-badge.empty {
  background: var(--bg3);
  color: var(--text2);
}

/* ===== OVERLAYS ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: flex-end;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.overlay.hidden {
  display: none;
}

.chat-sheet, .stats-sheet {
  width: 100%;
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--border);
  padding: 0;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: bold;
  font-size: 16px;
}

.close-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

/* Chat messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  max-height: 50vh;
}

.chat-empty {
  text-align: center;
  color: var(--text2);
  font-size: 14px;
  margin-top: 40px;
}

.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.msg-creature {
  align-self: flex-start;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-thinking {
  align-self: flex-start;
  color: var(--text2);
  font-size: 13px;
  font-style: italic;
  padding: 4px 0;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.chat-input:focus {
  border-color: var(--accent);
}

.send-btn {
  background: var(--accent);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}

.send-btn:active {
  transform: scale(0.9);
}

/* Stats sheet */
.stats-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.stat-row-label {
  color: var(--text2);
  font-size: 14px;
}

.stat-row-value {
  font-size: 15px;
  font-weight: bold;
  color: var(--text);
}

.personality-section {
  background: var(--bg3);
  border-radius: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  margin-top: 4px;
}

.personality-title {
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.personality-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

/* ===== CREATURE SPRITES ===== */
/* Dragon */
.sprite-dragon {
  animation: bounce 2s ease-in-out infinite;
}

.sprite-dragon svg, .sprite-slime svg, .sprite-cat svg, .sprite-robot svg, .sprite-phoenix svg {
  width: 160px;
  height: 160px;
  filter: drop-shadow(0 8px 16px rgba(108,99,255,0.4));
}

/* ===== ANIMATIONS ===== */
@keyframes bounce {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-12px); }
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

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

@keyframes glow-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

@keyframes shake {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-5deg); }
  40% { transform: rotate(5deg); }
  60% { transform: rotate(-5deg); }
  80% { transform: rotate(5deg); }
}

@keyframes hatch-appear {
  0% { transform: scale(0) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.2) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes crack {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.hatching-shake {
  animation: shake 0.3s ease-in-out infinite;
}

.hatch-appear {
  animation: hatch-appear 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.feed-pop {
  animation: pulse 0.3s ease-out;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 200;
  pointer-events: none;
  transition: opacity 0.3s;
  text-align: center;
  max-width: 280px;
}

.toast.hidden {
  opacity: 0;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: var(--bg2);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
