:root {
  --primary: #ff8fa3;
  --primary-dark: #ff4d6d;
  --secondary: #ffccd5;
  --accent: #c9184a;
  --bg: #fff0f3;
  --card: #ffffff;
  --card-subtle: #fff5f7;
  --text: #4a4e69;
  --text-muted: #8d99ae;
  --border: #f8bbd0;
  --shadow: rgba(201, 24, 74, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#game-app {
  display: grid;
  grid-template-columns: 340px 1fr 390px;
  height: 100vh;
  width: 100vw;
  background: var(--bg);
}

.panel {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  border-right: 1.5px solid var(--border);
  background: var(--card);
}

.panel:last-child {
  border-right: none;
}

/* LEFT PANEL (MUNCHI & MAIN CLICKER) */
.left-panel {
  background: linear-gradient(180deg, #fff0f3 0%, #ffffff 100%);
  padding: 1.5rem;
  align-items: center;
  text-align: center;
  justify-content: space-between;
}

.game-logo {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 1px;
}

.bakery-name {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  font-weight: 600;
}

.score-container {
  margin: 0.8rem 0;
}

.fish-counter {
  font-size: 2.3rem;
  font-weight: 800;
  color: var(--accent);
}

.fish-rate {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Photo Target Container */
.cat-stage {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.big-cat-wrapper {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  padding: 6px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 10px 25px var(--shadow);
  cursor: pointer;
  transition: transform 0.08s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
}

.big-cat-wrapper:hover {
  transform: scale(1.05);
}

.big-cat-wrapper:active {
  transform: scale(0.92) rotate(-3deg);
}

.cat-photo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid white;
  pointer-events: none;
}

.fallback-emoji {
  font-size: 6rem;
  pointer-events: none;
}

.mood-box {
  margin: 0.8rem 0;
  min-height: 48px;
}

.badge {
  background: var(--secondary);
  color: var(--accent);
  padding: 0.25rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  display: inline-block;
  margin-bottom: 0.4rem;
}

#catReaction {
  font-size: 0.9rem;
  font-style: italic;
  color: #6c757d;
}

.panel-footer-actions {
  display: flex;
  gap: 0.4rem;
  width: 100%;
}

.panel-footer-actions .btn {
  flex: 1;
  font-size: 0.75rem;
  padding: 0.55rem 0.2rem;
}

/* Floating click text */
.floating-click {
  position: absolute;
  color: var(--accent);
  font-weight: 800;
  font-size: 1.25rem;
  pointer-events: none;
  animation: floatFade 0.8s ease-out forwards;
}

@keyframes floatFade {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-55px) scale(1.3); }
}

/* CENTER PANEL (Upgrades & Activities) */
.center-panel {
  padding: 1.5rem;
  background: var(--card-subtle);
  overflow-y: auto;
}

.section-title h2 {
  font-size: 1.25rem;
  color: var(--accent);
}

.section-title .subtext {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.upgrades-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
  padding-bottom: 0.5rem;
}

.upgrade-card {
  width: 62px;
  height: 62px;
  border-radius: 12px;
  background: white;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.upgrade-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 4px 10px var(--shadow);
}

.upgrade-card.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(80%);
}

.log-stream {
  background: white;
  border-radius: 14px;
  padding: 1rem;
  border: 1px solid var(--border);
  margin-top: 0.8rem;
  height: 250px;
  overflow-y: auto;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
}

.log-entry {
  color: #555;
  border-bottom: 1px dashed #f0d5db;
  padding-bottom: 0.3rem;
}

/* RIGHT PANEL (Buildings) */
.right-panel {
  background: white;
  display: flex;
  flex-direction: column;
}

.store-topbar {
  padding: 1.2rem 1.2rem 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.store-topbar h2 {
  font-size: 1.2rem;
  color: var(--accent);
}

.buy-multipliers {
  display: flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 2px;
}

.mult-btn {
  border: none;
  background: transparent;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
}

.mult-btn.active {
  background: var(--primary);
  color: white;
}

.building-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.building-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: var(--card-subtle);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.building-card:hover:not(.locked) {
  border-color: var(--primary);
  background: #ffffff;
  transform: translateX(-3px);
  box-shadow: 0 4px 10px var(--shadow);
}

.building-card.locked {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(70%);
}

.b-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.b-icon {
  font-size: 2rem;
  width: 44px;
  height: 44px;
  background: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.04);
}

.b-info h4 {
  font-size: 0.95rem;
  color: var(--text);
}

.b-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.b-right {
  text-align: right;
}

.b-cost {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}

.b-count {
  font-size: 1.2rem;
  font-weight: 800;
  color: #adb5bd;
}

/* BUTTONS */
.btn {
  border: none;
  border-radius: 10px;
  padding: 0.6rem 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: var(--accent); }
.btn-secondary:hover { background: var(--border); }
.btn-warn { background: #ffeaa7; color: #d63031; }
.btn-warn:hover { background: #fdcb6e; }

/* GOLDEN FISH EVENT */
.golden-fish {
  position: absolute;
  font-size: 2.5rem;
  cursor: pointer;
  display: none;
  z-index: 99;
  filter: drop-shadow(0 0 10px #ffeaa7);
  animation: pulseGlow 1.5s infinite alternate;
}

@keyframes pulseGlow {
  0% { transform: scale(1) rotate(0deg); }
  100% { transform: scale(1.25) rotate(15deg); }
}

/* MODALS */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal-card {
  background: white;
  width: 90%;
  max-width: 520px;
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1.5px solid var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.modal-header h3 {
  color: var(--accent);
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--text-muted);
}

.profile-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg);
  padding: 0.75rem;
  border-radius: 12px;
}

.stats-munchi-img {
  width: 55px;
  height: 55px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  max-height: 380px;
  overflow-y: auto;
}

.achieve-box {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.6rem;
  border-radius: 10px;
  text-align: center;
  font-size: 0.75rem;
}

.achieve-box.unlocked {
  background: #f0fff4;
  border-color: #68d391;
  color: #22543d;
}

/* TOASTS */
#toastContainer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
}

.toast {
  background: #2d3436;
  color: white;
  padding: 0.75rem 1.2rem;
  border-radius: 10px;
  font-size: 0.85rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 950px) {
  #game-app {
    grid-template-columns: 1fr;
    height: auto;
    overflow-y: auto;
  }
  .panel {
    height: auto;
    min-height: 500px;
  }
}