/* =====================================================
   Gameko — Nameko Tamagotchi  |  style.css
   Pastel anime UI
   ===================================================== */

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

:root {
  --bg:         #FFF0F5;
  --card:       #FFFFFF;
  --border:     #F2C4CE;
  --shadow:     rgba(255, 150, 180, 0.18);
  --text:       #5A3E4B;
  --text-soft:  #A07080;
  --btn-feed:   #FFD6A5;
  --btn-play:   #CAFFBF;
  --btn-sleep:  #C7CEEA;
  --btn-clean:  #B5EAD7;
  --btn-med:    #FDFFB6;
  --btn-active: #FF8FAB;
  --radius:     18px;
  --radius-sm:  10px;
}

body {
  font-family: 'Nunito', 'Comic Neue', 'Comic Sans MS', cursive, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 8px 32px;
}

#app {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Header ── */
#header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #FFB6C1 0%, #C7CEEA 100%);
  border-radius: var(--radius);
  padding: 10px 16px;
  box-shadow: 0 4px 14px var(--shadow);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

#phase-icon { font-size: 1.3rem; }
#phase-label { font-size: 0.8rem; opacity: 0.85; margin-right: 4px; }
#pet-name { flex: 1; font-size: 1.1rem; }
#pet-age  { font-size: 0.78rem; opacity: 0.85; }

.btn-icon {
  background: rgba(255,255,255,0.35);
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: rgba(255,255,255,0.55); }

/* ── Canvas wrap ── */
#canvas-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 6px 24px var(--shadow);
  border: 3px solid var(--border);
  background: #87CEEB;
  line-height: 0;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: calc(var(--radius) - 3px);
}

/* Speech bubble */
#speech-bubble {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 3px 10px rgba(0,0,0,0.1);
  animation: bubble-in 0.3s ease;
}
#speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--border);
}
#speech-bubble.hidden { display: none; }

@keyframes bubble-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Stats ── */
#stats {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 4px 14px var(--shadow);
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.stat-icon  { font-size: 1rem; width: 22px; text-align: center; }
.stat-label { font-size: 0.78rem; font-weight: 700; color: var(--text-soft); width: 46px; }

.stat-bar-bg {
  flex: 1;
  height: 12px;
  background: #F0E0E8;
  border-radius: 6px;
  overflow: hidden;
}

.stat-bar {
  height: 100%;
  border-radius: 6px;
  width: 80%;
  transition: width 0.5s ease, background 0.5s ease;
}

.stat-val {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  width: 26px;
  text-align: right;
}

/* Low stat warning pulse */
.stat-bar.low {
  animation: pulse-low 1s infinite alternate;
}
@keyframes pulse-low {
  from { opacity: 1; }
  to   { opacity: 0.45; }
}

/* ── Action Buttons ── */
#actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: auto auto;
  gap: 8px;
}

#btn-medicine { grid-column: 3 / 5; }

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 4px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s;
  box-shadow: 0 3px 0 rgba(0,0,0,0.1);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  line-height: 1.2;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 rgba(0,0,0,0.12);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}
.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn-feed     { background: var(--btn-feed); }
.btn-play     { background: var(--btn-play); }
.btn-sleep    { background: var(--btn-sleep); }
.btn-clean    { background: var(--btn-clean); }
.btn-medicine { background: var(--btn-med); }

.btn.active-action {
  background: var(--btn-active);
  color: #fff;
  animation: btn-pulse 0.6s infinite alternate;
}
@keyframes btn-pulse {
  from { box-shadow: 0 3px 0 rgba(0,0,0,0.1); }
  to   { box-shadow: 0 3px 12px rgba(255,100,140,0.5); }
}

/* ── Stage Badge ── */
#stage-badge {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--card);
  border-radius: 20px;
  padding: 6px 18px;
  border: 2px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
  align-self: center;
}

/* ── Day/Night canvas themes applied via JS class on #canvas-wrap ── */
#canvas-wrap.night  { border-color: #6B5BCC; }
#canvas-wrap.dusk   { border-color: #E8855A; }
#canvas-wrap.dawn   { border-color: #FFB77A; }

/* ── Responsive ── */
@media (max-width: 360px) {
  .btn { font-size: 0.72rem; padding: 8px 2px; }
  #stats { padding: 10px 12px; }
}
