@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --sky: #87CEEB;
  --grass: #5DBB63;
  --ui-bg: rgba(255,248,220,0.95);
  --ui-border: #c8a96e;
  --pink: #FF8FAB;
  --purple: #C77DFF;
  --gold: #FFD700;
  --text: #3d2b1f;
}

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

body {
  font-family: 'Nunito', sans-serif;
  background: #1a0a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
}

#game-wrapper { position: relative; width: 100vw; height: 100vh; }

.screen { position: absolute; inset: 0; display: none; overflow: hidden; }
.screen.active { display: block; }

/* TITLE */
#title-screen {
  background: linear-gradient(180deg, #1a0a2e 0%, #2d1b69 40%, #4a2882 60%, #6b4fa0 80%, #5DBB63 80%, #3d8c42 100%);
  flex-direction: column; align-items: center; justify-content: center; color: white;
}
#title-screen.active { display: flex; }
.title-stars { position: absolute; inset: 0; pointer-events: none; }
.star { position: absolute; background: white; border-radius: 50%; animation: twinkle 2s ease-in-out infinite; }
@keyframes twinkle { 0%,100%{opacity:0.3;transform:scale(1)} 50%{opacity:1;transform:scale(1.3)} }
.title-moon { position: absolute; top: 30px; right: 80px; width: 60px; height: 60px; background: #FFF3B0; border-radius: 50%; box-shadow: 0 0 30px #FFF3B0, 0 0 60px rgba(255,243,176,0.4); }
.title-pony { font-size: 80px; animation: float 3s ease-in-out infinite; position: relative; z-index: 10; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-12px)} }
.game-title { font-family: 'Fredoka One', cursive; font-size: 58px; color: #FFD700; text-shadow: 3px 3px 0 #8B5E00, 0 0 40px rgba(255,215,0,0.5); letter-spacing: 2px; margin: 8px 0; position: relative; z-index: 10; }
.game-subtitle { font-size: 18px; color: #FFB3CC; font-weight: 700; letter-spacing: 4px; margin-bottom: 30px; position: relative; z-index: 10; }

/* BUTTONS */
.btn {
  background: linear-gradient(135deg, #FF8FAB, #FF6B9D);
  color: white; border: none; padding: 14px 40px; border-radius: 50px;
  font-family: 'Fredoka One', cursive; font-size: 22px; cursor: pointer;
  box-shadow: 0 6px 0 #c4527a, 0 8px 20px rgba(255,107,157,0.4);
  transition: all 0.1s; position: relative; z-index: 10; letter-spacing: 1px;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #c4527a, 0 12px 25px rgba(255,107,157,0.5); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #c4527a; }
.btn-green { background: linear-gradient(135deg, #5DBB63, #3d8c42); box-shadow: 0 6px 0 #2a5e2d, 0 8px 20px rgba(61,140,66,0.4); }
.btn-green:hover { box-shadow: 0 8px 0 #2a5e2d, 0 12px 25px rgba(61,140,66,0.5); }
.btn-green:active { box-shadow: 0 2px 0 #2a5e2d; }

/* CHAR CREATION */
#char-screen {
  background: linear-gradient(180deg, #87CEEB 0%, #b8e4f9 50%, #5DBB63 70%, #3d8c42 100%);
  flex-direction: column; align-items: center; padding: 30px;
}
#char-screen.active { display: flex; }
#char-screen h2 { font-family: 'Fredoka One', cursive; font-size: 32px; color: var(--text); text-shadow: 2px 2px 0 rgba(255,255,255,0.7); margin-bottom: 20px; }
.char-panel { background: rgba(255,248,220,0.92); border-radius: 20px; padding: 25px; border: 3px solid var(--ui-border); width: 100%; max-width: 500px; }
.char-options { display: flex; gap: 15px; margin-bottom: 20px; justify-content: center; }
.char-option { background: white; border: 3px solid #ddd; border-radius: 16px; padding: 15px 25px; cursor: pointer; font-size: 40px; text-align: center; transition: all 0.2s; flex: 1; }
.char-option:hover { border-color: var(--pink); transform: scale(1.05); }
.char-option.selected { border-color: var(--pink); background: #FFE4EF; box-shadow: 0 0 0 3px rgba(255,143,171,0.3); }
.char-option p { font-size: 14px; font-weight: 700; color: var(--text); margin-top: 6px; }
.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-weight: 700; color: var(--text); margin-bottom: 6px; font-size: 15px; }
.input-group input { width: 100%; padding: 10px 16px; border: 2px solid var(--ui-border); border-radius: 12px; font-family: 'Nunito', sans-serif; font-size: 16px; color: var(--text); background: white; outline: none; }
.input-group input:focus { border-color: var(--pink); }

/* GAME */
#game-screen { background: var(--sky); position: relative; overflow: hidden; }
#game-canvas { display: block; image-rendering: pixelated; width: 100%; height: 100%; }

/* HUD */
#hud { position: absolute; top: 0; left: 0; right: 0; padding: 10px 14px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; z-index: 50; }
.hud-box { background: var(--ui-bg); border: 2px solid var(--ui-border); border-radius: 12px; padding: 8px 14px; font-size: 13px; font-weight: 700; color: var(--text); pointer-events: auto; box-shadow: 0 3px 10px rgba(0,0,0,0.15); }
.hud-time { font-family: 'Fredoka One', cursive; font-size: 15px; }
.hud-zone { color: #5DBB63; }
.stat-bars { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.stat-row { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.stat-bar-bg { flex: 1; height: 8px; background: #e0d0b0; border-radius: 4px; overflow: hidden; }
.stat-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.bar-hunger { background: linear-gradient(90deg, #FF8FAB, #ff6b9d); }
.bar-happy { background: linear-gradient(90deg, #FFD700, #FFA500); }
.bar-energy { background: linear-gradient(90deg, #87CEEB, #4a90d9); }

/* DIALOGUE */
#dialogue-box { position: absolute; bottom: 60px; left: 20px; right: 180px; background: var(--ui-bg); border: 3px solid var(--ui-border); border-radius: 16px; padding: 14px 18px; z-index: 100; box-shadow: 0 4px 20px rgba(0,0,0,0.2); display: none; }
#dialogue-box.visible { display: block; }
.dialogue-speaker { font-family: 'Fredoka One', cursive; font-size: 14px; color: var(--pink); margin-bottom: 4px; }
#dialogue-text { font-size: 15px; color: var(--text); line-height: 1.5; font-weight: 600; }
.dialogue-continue { text-align: right; font-size: 12px; color: var(--ui-border); margin-top: 6px; animation: blink 1s ease-in-out infinite; }
@keyframes blink { 0%,100%{opacity:0.4} 50%{opacity:1} }

/* MISSION */
#mission-panel { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: var(--ui-bg); border: 2px solid var(--ui-border); border-radius: 12px; padding: 8px 16px; font-size: 13px; font-weight: 700; color: var(--text); z-index: 50; box-shadow: 0 3px 10px rgba(0,0,0,0.15); max-width: 300px; text-align: center; display: none; }
#mission-panel.visible { display: block; }
.mission-title { color: var(--purple); font-family: 'Fredoka One', cursive; font-size: 14px; }

/* CONTROLS */
#controls-hint { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; z-index: 50; }
.key { background: rgba(255,248,220,0.9); border: 2px solid var(--ui-border); border-radius: 8px; padding: 4px 9px; font-size: 12px; font-weight: 700; color: var(--text); }

/* SLEEP */
#sleep-overlay { position: absolute; inset: 0; background: rgba(10,5,30,0); z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; transition: background 1.5s; }
#sleep-overlay.sleeping { background: rgba(10,5,30,0.95); pointer-events: auto; }
.sleep-text { font-family: 'Fredoka One', cursive; font-size: 36px; color: #FFD700; opacity: 0; text-shadow: 0 0 30px rgba(255,215,0,0.6); transition: opacity 1s; }
#sleep-overlay.sleeping .sleep-text { opacity: 1; }
.sleep-stars-anim { font-size: 40px; opacity: 0; transition: opacity 1s 0.5s; letter-spacing: 10px; }
#sleep-overlay.sleeping .sleep-stars-anim { opacity: 1; }

/* NOTIFICATION */
#notification { position: absolute; top: 70px; left: 50%; transform: translateX(-50%) translateY(-20px); background: linear-gradient(135deg, #FFD700, #FFA500); color: var(--text); padding: 10px 20px; border-radius: 50px; font-family: 'Fredoka One', cursive; font-size: 16px; z-index: 150; opacity: 0; transition: all 0.4s; box-shadow: 0 4px 15px rgba(255,165,0,0.5); white-space: nowrap; }
#notification.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ACTION MENU */
#action-menu { position: absolute; bottom: 60px; right: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 100; }
.action-btn { background: var(--ui-bg); border: 2px solid var(--ui-border); border-radius: 10px; padding: 8px 14px; font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 13px; color: var(--text); cursor: pointer; transition: all 0.15s; box-shadow: 0 3px 8px rgba(0,0,0,0.1); text-align: left; }
.action-btn:hover { background: #FFE4EF; border-color: var(--pink); transform: translateX(-3px); }
.action-btn:disabled { opacity: 0.4; cursor: default; transform: none; }
