/* ======================================================
   GOBACHI — CORE THEME
   Mobile-first, emoji-first, minimal text
====================================================== */

/* ---------- RESET / BASE ---------- */

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg-neutral);
  color: #eef1ff;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- THEME VARIABLES ---------- */

:root {
  /* Backgrounds communicate state */
  --bg-neutral: radial-gradient(circle at top, #2a2f55, #0f1220);
  --bg-happy:   radial-gradient(circle at top, #3b6b9e, #142036);
  --bg-tired:   radial-gradient(circle at top, #3a3a3a, #121212);
  --bg-neglect: radial-gradient(circle at top, #4a2d2d, #1a0f0f);
  --bg-dead:    radial-gradient(circle at top, #1c1c1c, #000000);

  /* UI accents */
  --ui-faint: rgba(255,255,255,0.25);
  --ui-soft:  rgba(255,255,255,0.12);
}

/* ---------- APP ROOT ---------- */

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- HUD ---------- */

#hud {
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  opacity: 0.7;
}

#presence {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- MAIN VIEW ---------- */

#view {
  flex: 1;
  display: grid;
  place-items: center;
  position: relative;
}

/* ---------- SCREENS ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.hidden {
  display: none !important;
}

/* ---------- PET SELECTION (CRADLE) ---------- */

.cradle {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  align-items: center;
  width: 100%;
  max-width: 420px;
  padding: 0 16px;
}

.pet-slot {
  display: grid;
  place-items: center;
  font-size: 48px;
  opacity: 0.45;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.pet-center {
  font-size: 72px;
  opacity: 1;
  transform: scale(1.05);
}

.cradle-dots {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  justify-content: center;
  opacity: 0.6;
}

/* ---------- ACTIVE PET ---------- */

#pet-display {
  display: flex;
  justify-content: center;
  width: 100%;
}


#pet-display.flash-bad {
  background: rgba(255, 60, 60, 0.35);
}

#pet-display.flash-good {
  background: rgba(80, 255, 80, 0.25);
}

/* ---------- GRAVE ---------- */

#grave-display {
  font-size: 80px;
  opacity: 0.85;
}

/* ---------- OVERLAYS ---------- */

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: grid;
  place-items: center;
}

.overlay-content {
  background: rgba(0,0,0,0.65);
  border-radius: 14px;
  padding: 18px;
  min-width: 260px;
  text-align: center;
}

/* ---------- ANIMATIONS ---------- */

@keyframes idle-breathe {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* ---------- STATE CLASSES ---------- */
/* applied to <body> by app.js later */

body.state-happy    { background: var(--bg-happy); }
body.state-tired    { background: var(--bg-tired); }
body.state-neglect  { background: var(--bg-neglect); }
body.state-dead     { background: var(--bg-dead); }


/* ======================================================
   INTERACTIVE PET AFFORDANCE
====================================================== */

.pet-slot {
  cursor: pointer;
}

.pet-center {
  position: relative;
}

/* soft focus ring */
.pet-center::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 2px solid var(--ui-soft);
  opacity: 0.6;
}

/* hover / tap feedback */
.pet-slot:active {
  transform: scale(0.92);
}

/* subtle pulse to say "this one is selectable" */
.pet-center {
  animation: select-pulse 2.2s ease-in-out infinite;
}

@keyframes select-pulse {
  0%   { transform: scale(1.05); }
  50%  { transform: scale(1.09); }
  100% { transform: scale(1.05); }
}

/* ---------- CREATE BUTTON ---------- */

.create-btn {
  margin-top: 18px;
  padding: 10px 22px;
  font-size: 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #eef1ff;
  cursor: pointer;
}

.create-btn:active {
  transform: scale(0.95);
}

/* ======================================================
   CHAT OVERLAY (SLIDE-UP)
====================================================== */
/* Ensure the height is applied when the overlay is active */
#chat-overlay.open {
  height: 40vh; /* Changed from 40% to 40vh for consistency */
  display: block; /* Ensure display:none is overridden */
}

/* Ensure the view shrinks to make room for the chat */
body.chat-open #view {
  height: 60vh; /* Adjust view height when chat is open */
}
#chat-toggle {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 18px;
  color: #eef1ff;
  opacity: 0.8;
  cursor: pointer;
}

.chat {
  height: 0;
  background: rgba(0,0,0,0.85);
  overflow: hidden;
  transition: height 0.25s ease;
}


.chat.hidden {
  height: 0 !important;
  pointer-events: none;
}


.chat-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
  opacity: 0.9;
}
.chat-header-left { font-weight: 600; }
.chat-header-right { display: flex; gap: 6px; }
.chat-hbtn {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  color: #eef1ff;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0.9;
}
.chat-hbtn:hover { opacity: 1; }

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

#chat-messages {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  font-size: 14px;
}

.chat-line {
  margin-bottom: 8px;
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.chat-emoji {
  font-size: 18px;
}

.chat-input {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.15);
}

#chat-text {
  flex: 1;
  padding: 8px;
  border-radius: 10px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #eef1ff;
}

#chat-send {
  background: none;
  border: none;
  font-size: 18px;
  color: #eef1ff;
  cursor: pointer;
}
.chat.open {
  height: 40%;
}

.chat.min {
  height: 220px; /* ~10 lines */
}

body.chat-min #view {
  height: 60vh;
}

body.chat-open #view {
  padding-bottom: 40vh;
  transition: padding-bottom 0.25s ease;
}

   /* ======================================================
   PET METERS (VISUAL ONLY)
====================================================== */

.meters {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
}

.meter {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
}

.meter-icon {
  opacity: 0.8;
}

.meter-pill {
  width: 18px;
  height: 8px;
  border-radius: 4px;
  background: #2a2a2a; /* default / unknown */
}
.meter-area {
  position: relative;
}
/* ---- States ---- */

.meter[data-level="5"] .meter-pill { background: #4cff4c; } /* bright green */
.meter[data-level="4"] .meter-pill { background: #2bb3a3; } /* teal = good */
.meter[data-level="3"] .meter-pill { background: #f1e05a; } /* yellow */
.meter[data-level="2"] .meter-pill { background: #ff9f1c; } /* orange */
.meter[data-level="1"] .meter-pill { background: #ff4d4d; } /* red */
.meter[data-level="0"] .meter-pill { background: #000000; } /* black */


.action-row {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;

  display: flex;
  align-items: center;
  gap: 10px;

  opacity: 1;
  transition: opacity 140ms ease;
}

.action-row.hidden {
  opacity: 0;
  pointer-events: none;
}

.action-row button {
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: inherit;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 600;
}

.resource-count {
  font-weight: 600;
  opacity: 0.85;
  margin-right: 6px;
}

@keyframes shake {
  0%   { transform: translateX(0); }
  25%  { transform: translateX(-3px); }
  50%  { transform: translateX(3px); }
  75%  { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

.shake {
  animation: shake 0.18s linear;
}
.chat-line.system {
  opacity: 0.7;
  font-style: italic;
}
.flash-bad {
  background: rgba(255, 0, 0, 0.35) !important;
}

/* ======================================================
   ACTION BUTTON FEEDBACK
   (tactile, non-layout-shifting)
====================================================== */

/* base interaction */
.action-row button {
  position: relative;
  transition:
    transform 80ms ease,
    background-color 120ms ease,
    box-shadow 120ms ease;
}

/* neutral press (always happens) */
.action-row button:active {
  transform: scale(0.95);
}

/* SUCCESS FEEDBACK */
.action-row button.flash-good {
  background: rgba(76, 255, 76, 0.25);
  box-shadow: 0 0 0 2px rgba(76, 255, 76, 0.45);
}

/* FAILURE FEEDBACK */
.action-row button.flash-bad {
  background: rgba(255, 77, 77, 0.25);
  box-shadow: 0 0 0 2px rgba(255, 77, 77, 0.45);
}

/* clear flash automatically (JS removes class) */
.action-row button.flash-good,
.action-row button.flash-bad {
  animation: button-flash 140ms ease-out;
}

@keyframes button-flash {
  0%   { opacity: 0.85; }
  100% { opacity: 1; }
}
.action-row button.disabled {
  opacity: 0.4;
  pointer-events: none;
}

#pet-playfield {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 260px;

  margin: 12px auto;
  border-radius: 16px;

  background: rgba(0,0,0,0.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);

  overflow: hidden;
}


#pet-emoji {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  pointer-events: none;
}


#pet-game {
   touch-action: none;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: auto; /* ✅ allow drops + visuals */
}


.bowl-area {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 80px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.bowl {
  font-size: 56px;
  opacity: 0.95;
}


.food-piece {
  position: absolute;
  top: -40px;
  font-size: 32px;
  animation: fall 2.2s linear forwards;
  cursor: pointer;
}

.food-piece.caught {
  animation: none;
  transform: scale(0.7);
  opacity: 0.6;
}

@keyframes fall {
  to { top: 75%; }
}



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

#fuse-bar {
  position: absolute;
  bottom: 4px;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(to right, #6f6, #ff6, #f66);
  transform-origin: left center;
  pointer-events: none;
}

#feeding-food-count {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  opacity: 0.85;
  pointer-events: none;
}
#feeding-field {
  position: absolute;
  inset: 0;
  z-index: 3;
  touch-action: none;     /* ✅ allow smooth pointermove on mobile */
  user-select: none;
  -webkit-user-select: none;
}

.feeding-result {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 2px;
  animation: popFade 0.9s ease-out forwards;
  pointer-events: none;
}

.feed-success { color: #7CFF7C; }
.feed-neutral { color: #FFD966; }
.feed-fail    { color: #FF6B6B; }

@keyframes popFade {
  0%   { transform: scale(0.9); opacity: 0; }
  20%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}
.feeding-stats {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}

.feeding-stats.show {
  opacity: 1;
  transform: scale(1);
}

.feeding-rating {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 2px;
}

.feeding-rating.success { color: #7CFF7C; }
.feeding-rating.neutral { color: #FFD966; }
.feeding-rating.fail    { color: #FF6B6B; }

.feeding-lines {
  font-size: 14px;
  opacity: 0.9;
  text-align: center;
  line-height: 1.4;
}
@keyframes ghost-fall {
  to { top: 75%; }
}
.ghost-drop {
  position: absolute;
  top: -40px;
  font-size: 26px;
  opacity: 0.65;
  animation: ghost-fall 2.2s linear forwards;
  pointer-events: none;
}
