:root {
  --bg1: #fff1f6;
  --bg2: #ffe7d1;
  --accent: #ff5c8a;
  --text: #332531;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Comfortaa", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% 10%, #ffe4ef, transparent 55%),
              radial-gradient(800px 600px at 90% 20%, #fff0dc, transparent 60%),
              linear-gradient(135deg, var(--bg1), var(--bg2));
  overflow-x: hidden;
}

body.night-mode {
  color: #e7e2f5;
  background: radial-gradient(1200px 600px at 10% 10%, rgba(83, 102, 160, 0.4), transparent 55%),
              radial-gradient(800px 600px at 90% 20%, rgba(38, 45, 78, 0.55), transparent 60%),
              linear-gradient(135deg, #0c1124, #181b35);
}

body.night-mode .pet-sidebar,
body.night-mode .pet-scene {
  background: rgba(20, 24, 46, 0.92);
  box-shadow: 0 20px 50px rgba(7, 10, 24, 0.6);
}

body.night-mode .pet-balance,
body.night-mode .pet-current,
body.night-mode .stat,
body.night-mode .custom-block,
body.night-mode .pet-daily,
body.night-mode .pet-status,
body.night-mode .pet-stats-overlay {
  background: rgba(18, 22, 44, 0.85);
  border-color: rgba(126, 148, 220, 0.35);
  color: #d7d0f2;
}

body.night-mode .stat-title,
body.night-mode .section-title,
body.night-mode .custom-label,
body.night-mode .pet-card h4 {
  color: #c9bff4;
}

body.night-mode .pet-daily-item {
  background: rgba(19, 22, 42, 0.85);
  border-color: rgba(126, 148, 220, 0.32);
}

body.night-mode .pet-balance {
  color: #ffd9f0;
}

body.night-mode .pet-card,
body.night-mode .theme-chip {
  background: rgba(19, 22, 42, 0.95);
  border-color: rgba(126, 148, 220, 0.35);
  color: #e3dcff;
}

body.night-mode .decor-card {
  background: rgba(19, 22, 42, 0.95);
  border-color: rgba(126, 148, 220, 0.35);
  color: #e3dcff;
}

body.night-mode .decor-placement {
  background: rgba(8, 12, 24, 0.75);
}

body.night-mode .decor-placement-card {
  background: rgba(16, 20, 40, 0.95);
  border-color: rgba(126, 148, 220, 0.45);
  color: #e3dcff;
}

body.night-mode .decor-placement-title {
  color: #c9bff4;
}

body.night-mode .decor-placement-hint {
  color: #c6c0e8;
}

body.night-mode .decor-placement-grid {
  background: rgba(16, 20, 40, 0.8);
  border-color: rgba(126, 148, 220, 0.45);
}

body.night-mode .decor-slot {
  border-color: rgba(143, 180, 255, 0.9);
  background: rgba(24, 28, 50, 0.9);
  box-shadow: 0 6px 12px rgba(76, 95, 160, 0.35);
}

body.night-mode .decor-slot.is-busy {
  border-color: rgba(126, 148, 220, 0.4);
  background: rgba(24, 28, 50, 0.5);
}

body.night-mode .theme-chip.active {
  box-shadow: 0 12px 24px rgba(105, 128, 214, 0.35);
}

body.night-mode .btn-ghost {
  color: #e6ddff;
  border-color: rgba(126, 148, 220, 0.45);
}

body.night-mode .pet-canvas {
  border-color: rgba(126, 148, 220, 0.35);
}

body.morning-mode {
  color: #3c2d33;
  background: radial-gradient(1200px 600px at 10% 10%, rgba(255, 170, 120, 0.4), transparent 55%),
              radial-gradient(800px 600px at 90% 20%, rgba(255, 120, 170, 0.35), transparent 60%),
              linear-gradient(135deg, #ffe3cd, #ffe9f2);
}

body.morning-mode .pet-sidebar,
body.morning-mode .pet-scene {
  background: rgba(255, 244, 236, 0.92);
  box-shadow: 0 20px 40px rgba(255, 140, 120, 0.25);
}

body.morning-mode .pet-balance,
body.morning-mode .pet-current,
body.morning-mode .stat,
body.morning-mode .custom-block,
body.morning-mode .pet-daily,
body.morning-mode .pet-status,
body.morning-mode .pet-stats-overlay {
  background: rgba(255, 245, 236, 0.9);
  border-color: rgba(255, 160, 120, 0.35);
  color: #5b3e3e;
}

body.morning-mode .stat-title,
body.morning-mode .section-title,
body.morning-mode .custom-label,
body.morning-mode .pet-card h4 {
  color: #d56b5d;
}

body.morning-mode .pet-daily-item {
  background: rgba(255, 250, 246, 0.92);
  border-color: rgba(255, 160, 120, 0.25);
}

body.morning-mode .pet-balance {
  color: #e45b77;
}

body.morning-mode .pet-card,
body.morning-mode .theme-chip {
  background: rgba(255, 250, 246, 0.95);
  border-color: rgba(255, 160, 120, 0.35);
  color: #6a4b4b;
}

body.morning-mode .decor-card {
  background: rgba(255, 250, 246, 0.95);
  border-color: rgba(255, 160, 120, 0.35);
  color: #6a4b4b;
}

body.morning-mode .decor-placement {
  background: rgba(255, 236, 224, 0.6);
}

body.morning-mode .decor-placement-card {
  background: rgba(255, 248, 242, 0.95);
  border-color: rgba(255, 160, 120, 0.35);
  color: #6a4b4b;
}

body.morning-mode .decor-placement-title {
  color: #d56b5d;
}

body.morning-mode .decor-placement-hint {
  color: #7a5350;
}

body.morning-mode .decor-placement-grid {
  background: rgba(255, 250, 246, 0.85);
  border-color: rgba(255, 160, 120, 0.35);
}

body.morning-mode .decor-slot {
  border-color: rgba(228, 91, 119, 0.9);
  background: #fff;
  box-shadow: 0 6px 12px rgba(228, 91, 119, 0.25);
}

body.morning-mode .theme-chip.active {
  box-shadow: 0 12px 24px rgba(255, 150, 120, 0.35);
}

body.morning-mode .btn-ghost {
  color: #6a4b4b;
  border-color: rgba(255, 160, 120, 0.5);
}

body.morning-mode .pet-canvas {
  border-color: rgba(255, 160, 120, 0.35);
}

.pet-page {
  display: grid;
  grid-template-columns: minmax(260px, 380px) 1fr;
  gap: 18px;
  padding: 18px;
  height: 100vh;
  overflow: hidden;
}

.pet-sidebar {
  background: #fff;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 20px 40px rgba(255, 92, 138, 0.18);
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: calc(100vh - 36px);
  position: sticky;
  top: 18px;
  overflow: hidden;
}

.pet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.pet-header h1 {
  margin: 0;
  font-family: "Pacifico", cursive;
  color: var(--accent);
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-ok {
  background: var(--accent);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: #6c5064;
  border: 1px solid rgba(108, 80, 100, 0.3);
}

.pet-balance {
  background: #fff7fb;
  border: 1px solid rgba(255, 92, 138, 0.2);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 600;
  color: #ff5c8a;
  text-align: center;
  align-self: start;
}

.pet-current {
  background: #fff7fb;
  border: 1px solid rgba(255, 92, 138, 0.18);
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 700;
  color: #6c5064;
  text-align: center;
  align-self: start;
}

.pet-stats {
  display: grid;
  gap: 10px;
}

.stat {
  background: #fff7fb;
  border: 1px solid rgba(255, 92, 138, 0.15);
  border-radius: 12px;
  padding: 10px;
}

.stat-title {
  font-weight: 700;
  color: #ff5c8a;
  margin-bottom: 6px;
}

.stat-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 92, 138, 0.15);
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff7ca4, #ff5c8a);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.stat-value {
  margin-top: 6px;
  font-weight: 700;
  color: #6c5064;
}

.section-title {
  font-weight: 700;
  color: #ff5c8a;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.pet-shop {
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 0;
}

.pet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.pet-custom {
  display: grid;
  gap: 10px;
  flex: 0 0 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.pet-toggle-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}

.toggle-btn.active {
  border-color: rgba(255, 92, 138, 0.8);
  color: #ff5c8a;
}

.collapsible {
  display: none;
}

.collapsible.is-open {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.pet-custom.is-open {
  display: grid;
  grid-auto-rows: min-content;
  overflow: auto;
  padding-right: 4px;
}

.custom-block {
  background: #fff7fb;
  border: 1px solid rgba(255, 92, 138, 0.15);
  border-radius: 12px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.custom-label {
  font-weight: 700;
  color: #ff5c8a;
}

.custom-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.custom-row input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 92, 138, 0.35);
  font-size: 0.95rem;
  font-family: "Comfortaa", system-ui, sans-serif;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.theme-chip {
  border: 1px solid rgba(255, 92, 138, 0.2);
  border-radius: 999px;
  padding: 8px 10px;
  background: #fff;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.theme-chip.active {
  border-color: rgba(255, 92, 138, 0.7);
  box-shadow: 0 8px 16px rgba(255, 92, 138, 0.2);
}

.theme-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.8);
}

.pet-card {
  background: #fff;
  border: 1px solid rgba(255, 92, 138, 0.2);
  border-radius: 14px;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.pet-card h4 {
  margin: 0;
  color: #ff5c8a;
}

.pet-card p {
  margin: 0;
  font-size: 0.85rem;
  color: #6c5064;
}

.pet-decor {
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
}

.pet-daily {
  background: #fff7fb;
  border: 1px solid rgba(255, 92, 138, 0.16);
  border-radius: 12px;
  padding: 6px;
  display: grid;
  gap: 6px;
}

.pet-daily-toggle {
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  color: #ff5c8a;
  font-weight: 700;
  font-size: 0.94rem;
  cursor: pointer;
}

.pet-daily-toggle:hover {
  background: #fff0f7;
}

.pet-daily-arrow {
  font-size: 0.82rem;
  transition: transform 0.2s ease;
}

.pet-daily.is-open .pet-daily-arrow {
  transform: rotate(180deg);
}

.pet-daily-content {
  display: grid;
  gap: 8px;
  padding: 0 4px 4px;
}

.pet-daily-content[hidden] {
  display: none !important;
}

.pet-daily-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.85rem;
  color: #6c5064;
}

.pet-daily-list {
  display: grid;
  gap: 6px;
}

.pet-daily-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 92, 138, 0.15);
  background: #fff;
  font-size: 0.84rem;
  color: #6c5064;
}

.pet-daily-item.is-done {
  border-color: rgba(47, 138, 78, 0.35);
  background: #e8f7ef;
  color: #2f8a4e;
}

.pet-daily-bonus {
  font-size: 0.82rem;
  color: #8b667e;
}

.pet-daily-bonus.is-done {
  color: #2f8a4e;
  font-weight: 700;
}

.pet-passive-box {
  border-radius: 10px;
  border: 1px dashed rgba(255, 92, 138, 0.28);
  padding: 8px 10px;
  display: grid;
  gap: 4px;
}

.pet-passive-line {
  font-size: 0.82rem;
  color: #6c5064;
}

.pet-streak-note {
  font-size: 0.8rem;
  color: #8b667e;
}

.decor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.decor-card {
  background: #fff;
  border: 1px solid rgba(255, 92, 138, 0.2);
  border-radius: 14px;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.decor-card h4 {
  margin: 0;
  color: #ff5c8a;
  font-size: 0.95rem;
}

.decor-card p {
  margin: 0;
  font-size: 0.82rem;
  color: #6c5064;
}

.decor-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 6px;
}

.pet-kind {
  font-size: 0.75rem;
  color: rgba(108, 80, 100, 0.8);
}

.pet-card.active {
  border-color: rgba(255, 92, 138, 0.8);
  box-shadow: 0 12px 24px rgba(255, 92, 138, 0.2);
}

.pet-card button {
  justify-self: start;
}

.pet-scene {
  background: #fff;
  border-radius: 24px;
  padding: 16px;
  box-shadow: 0 20px 40px rgba(255, 92, 138, 0.18);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  height: calc(100vh - 36px);
}

.pet-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: grid;
  gap: 10px;
  z-index: 2;
  pointer-events: none;
}

.decor-placement {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 3;
}

.decor-placement.is-active {
  opacity: 1;
  pointer-events: auto;
}

.decor-placement-card {
  width: min(620px, 92%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 92, 138, 0.25);
  border-radius: 24px;
  padding: 18px;
  display: grid;
  gap: 12px;
  box-shadow: 0 18px 40px rgba(255, 92, 138, 0.2);
}

.decor-placement-title {
  font-weight: 700;
  color: #ff5c8a;
  font-size: 1.1rem;
}

.decor-placement-hint {
  margin: 0;
  color: #6c5064;
  font-size: 0.9rem;
}

.decor-placement-grid {
  width: min(520px, 86%);
  height: min(260px, 42vh);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  gap: 10px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px dashed rgba(255, 92, 138, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 92, 138, 0.08);
}

.decor-slot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #ff5c8a;
  background: #fff;
  box-shadow: 0 6px 12px rgba(255, 92, 138, 0.2);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.decor-slot:hover {
  transform: scale(1.08);
  background: #ffeaf3;
  box-shadow: 0 8px 14px rgba(255, 92, 138, 0.28);
}

.decor-slot.is-busy {
  border-color: rgba(108, 80, 100, 0.35);
  background: rgba(108, 80, 100, 0.12);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.5;
}

.decor-placement-actions {
  display: flex;
  justify-content: flex-end;
}

.pet-status {
  position: relative;
  align-self: flex-start;
  background: rgba(255, 247, 251, 0.95);
  border: 1px solid rgba(255, 92, 138, 0.35);
  border-radius: 16px;
  padding: 12px 16px 12px 44px;
  font-weight: 700;
  color: #ff5c8a;
  box-shadow: 0 12px 24px rgba(255, 92, 138, 0.18);
  backdrop-filter: blur(8px);
}

.pet-status::before {
  content: "🐾";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
}

/* .pet-status::after {
  content: "";
  position: absolute;
  left: 22px;
  bottom: -10px;
  width: 14px;
  height: 14px;
  background: rgba(255, 247, 251, 0.95);
  border-left: 1px solid rgba(255, 92, 138, 0.25);
  border-bottom: 1px solid rgba(255, 92, 138, 0.25);
  transform: rotate(45deg);
} */

.pet-status.is-ping {
  animation: petBubble 0.45s ease-out;
}

@keyframes petBubble {
  0% {
    transform: translateY(6px) scale(0.96);
    opacity: 0.85;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.pet-stats-overlay {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 92, 138, 0.2);
  border-radius: 14px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  backdrop-filter: blur(6px);
}

.pet-canvas {
  width: 100%;
  height: 100%;
  min-height: 420px;
  border-radius: 18px;
  background: radial-gradient(circle at top, #fff7fb, #fff);
  border: 1px solid rgba(255, 92, 138, 0.15);
  position: relative;
  overflow: hidden;
}

.pet-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 600;
  color: #c35b7b;
  text-align: center;
  padding: 12px;
}

@media (max-width: 980px) {
  .pet-page {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 12px;
    gap: 12px;
  }

  .pet-sidebar {
    position: static;
    top: auto;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .pet-scene {
    height: min(72vh, 680px);
    min-height: 420px;
  }

  .pet-canvas {
    min-height: 360px;
  }

  .pet-stats-overlay {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pet-grid,
  .pet-custom,
  .pet-decor {
    max-height: 260px;
  }
}

@media (max-width: 680px) {
  .pet-page {
    padding: 10px;
    gap: 10px;
  }

  .pet-header {
    flex-wrap: wrap;
  }

  .pet-toggle-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pet-scene {
    padding: 12px;
    height: min(68vh, 600px);
    min-height: 360px;
  }

  .pet-canvas {
    min-height: 300px;
  }

  .pet-stats-overlay {
    grid-template-columns: 1fr;
  }

  .pet-status {
    font-size: 0.9rem;
    padding: 10px 12px 10px 40px;
  }

  .decor-placement-card {
    width: min(94vw, 620px);
    padding: 14px;
  }

  .decor-placement-grid {
    width: min(92vw, 520px);
    height: min(200px, 38vh);
    padding: 12px;
    gap: 6px;
  }

  .decor-slot {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 480px) {
  .pet-toggle-row {
    grid-template-columns: 1fr;
  }

  .action-grid {
    grid-template-columns: 1fr;
  }

  .pet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .decor-slot {
    width: 20px;
    height: 20px;
  }
}
