@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

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

:root {
  --bg: #fef8f3;
  --bg-warm: #fdf2ea;
  --text: #5c4f4a;
  --text-light: #9a8e88;
  --primary: #f4a7b9;
  --primary-hover: #e8899e;
  --secondary: #b8c9d4;
  --accent: #a8d8c8;
  --accent2: #d4b5d8;
  --card: #fffcf8;
  --shadow: rgba(160, 130, 120, 0.08);
  --border: #f0e4d8;
}

body {
  font-family: 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Screen system */
.screen { display: none; position: absolute; inset: 0; overflow-y: auto; }
.screen.active { display: flex; justify-content: center; align-items: flex-start; }

/* ===== Title ===== */
.title-container {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh; gap: 16px;
}
.title-cat-scene { position: relative; }
.title-cat { font-size: 80px; animation: float 3s ease-in-out infinite; }
.title-paw {
  font-size: 24px; position: absolute; bottom: -15px; right: -20px;
  animation: float 3s ease-in-out infinite 0.5s; opacity: 0.6;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}
h1 { font-size: 48px; font-weight: 700; letter-spacing: 8px; color: #6a5a52; }
.subtitle { color: var(--text-light); font-size: 16px; font-weight: 300; margin-bottom: 12px; }
.version { color: var(--border); font-size: 12px; margin-top: 20px; }

/* ===== Buttons ===== */
.btn {
  padding: 12px 36px; border: none; border-radius: 25px;
  font-size: 16px; font-family: inherit; cursor: pointer;
  transition: all 0.3s ease;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 12px var(--shadow); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #b0a290; }
.btn-row { display: flex; gap: 12px; justify-content: center; margin-top: 24px; }
.btn-icon {
  width: 36px; height: 36px; border: none; border-radius: 50%;
  background: var(--card); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; box-shadow: 0 2px 6px var(--shadow);
}
.btn-icon:hover { transform: scale(1.1); background: var(--primary); color: white; }

/* ===== Setup ===== */
.setup-container { max-width: 600px; width: 100%; padding: 40px 24px; }
.setup-container h2 { text-align: center; margin-bottom: 30px; font-size: 28px; }
.setting-group { margin-bottom: 24px; }
.setting-group h3, .setting-group > label {
  display: block; font-size: 14px; font-weight: 500;
  color: var(--text-light); margin-bottom: 10px;
}
.setting-desc { font-size: 11px; color: var(--border); margin-top: 6px; }
.option-row { display: flex; gap: 8px; }
.option-row.wrap { flex-wrap: wrap; }
.option-btn {
  padding: 8px 18px; border: 2px solid var(--border); border-radius: 20px;
  background: var(--card); color: var(--text); font-size: 14px;
  font-family: inherit; cursor: pointer; transition: all 0.2s;
}
.option-btn:hover { border-color: var(--primary); }
.option-btn.active { border-color: var(--primary); background: var(--primary); color: white; }

.text-input {
  width: 100%; padding: 10px 16px; border: 2px solid var(--border);
  border-radius: 12px; background: var(--card); font-size: 16px;
  font-family: inherit; color: var(--text); outline: none;
}
.text-input:focus { border-color: var(--primary); }

/* Sliders */
.slider-group { display: flex; flex-direction: column; gap: 12px; }
.slider-row {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--text-light);
}
.slider-row span { width: 36px; text-align: center; flex-shrink: 0; }
.slider-row input[type="range"] {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 6px; border-radius: 3px; background: var(--border); outline: none;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); cursor: pointer; box-shadow: 0 2px 6px var(--shadow);
}

/* Cat Preview */
.cat-preview-area { display: flex; justify-content: center; margin-bottom: 20px; }
#cat-preview { background: var(--card); border-radius: 16px; border: 2px solid var(--border); }

/* Cat List */
.cat-list { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.cat-list-item {
  display: flex; align-items: center; gap: 6px; padding: 6px 14px;
  background: var(--card); border-radius: 16px; border: 1px solid var(--border); font-size: 13px;
}
.cat-list-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ===== Game Screen ===== */
#screen-game { flex-direction: column; }
.game-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: var(--card);
  border-bottom: 1px solid var(--border); z-index: 10;
  flex-shrink: 0; min-height: 44px;
}
.game-info {
  display: flex; gap: 10px; font-size: 13px; color: var(--text-light);
  flex-shrink: 0; white-space: nowrap;
}
.game-controls {
  display: flex; gap: 4px; flex-shrink: 0;
}
.game-controls .btn-icon { width: 32px; height: 32px; font-size: 14px; }
#game-canvas { flex: 1; width: 100%; cursor: pointer; min-height: 0; }

/* Scene Back */
.scene-back {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 16px; background: var(--card);
  border-bottom: 1px solid var(--border); z-index: 10;
  transition: all 0.3s;
}
.scene-back-hidden { display: none; }
.btn-scene-back {
  padding: 4px 14px; border: 1.5px solid var(--border); border-radius: 14px;
  background: white; font-size: 12px; font-family: inherit;
  color: var(--text); cursor: pointer; transition: all 0.2s;
}
.btn-scene-back:hover { border-color: var(--primary); background: var(--bg-warm); }
#scene-name { font-size: 14px; font-weight: 500; color: var(--text); }

/* ===== Build Bar ===== */
.build-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: var(--card);
  border-bottom: 1px solid var(--border); z-index: 10;
}
.build-bar.hidden { display: none; }
.build-coins {
  font-size: 13px; font-weight: 500; color: var(--text);
  white-space: nowrap; padding-right: 8px; flex-shrink: 0;
  border-right: 1px solid var(--border);
}
.build-items {
  display: flex; gap: 4px; overflow-x: auto;
  flex: 1; padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.build-items::-webkit-scrollbar { display: none; }
.build-item {
  display: flex; flex-direction: row; align-items: center; gap: 4px;
  padding: 4px 10px; border: 1.5px solid var(--border); border-radius: 16px;
  background: var(--card); cursor: pointer; transition: all 0.2s;
  font-family: inherit; white-space: nowrap; flex-shrink: 0;
}
.build-item:hover { border-color: var(--primary); background: #fef0e0; }
.build-item.selected { border-color: var(--primary); background: #fef0e0; box-shadow: 0 0 0 1px var(--primary); }
.build-item.disabled { opacity: 0.4; cursor: not-allowed; }
.build-item.disabled:hover { border-color: var(--border); background: var(--card); }
.build-icon { font-size: 14px; }
.build-name { font-size: 11px; color: var(--text); }
.build-cost { font-size: 10px; color: var(--primary); font-weight: 500; }
.coin-popup {
  position: absolute; pointer-events: none; font-size: 13px;
  font-weight: 500; color: var(--primary); z-index: 15;
  animation: coinFloat 1.5s ease-out forwards;
}
@keyframes coinFloat {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-30px); }
}

/* Hidden utility — scoped to avoid overriding screen.active */
.side-panel.hidden { transform: translateX(100%); pointer-events: none; }
.build-bar.hidden { display: none; }
.modal.hidden { display: none; }
#btn-continue.hidden { display: none; }

/* Continue button gap */
#btn-continue { margin-bottom: 4px; }

/* Badge on icon button */
.btn-icon { position: relative; }
.badge {
  position: absolute; top: -2px; right: -2px;
  font-size: 8px; background: var(--primary); color: white;
  border-radius: 6px; padding: 1px 3px; min-width: 14px;
  text-align: center; line-height: 1.2;
}

/* Toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(90, 74, 58, 0.85); color: white; padding: 8px 20px;
  border-radius: 20px; font-size: 13px; z-index: 100;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 1.7s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-50%) translateY(-10px); } }

/* Achievement Popup */
.achievement-popup {
  position: fixed; top: -80px; left: 50%; transform: translateX(-50%);
  background: var(--card); border: 2px solid var(--primary);
  border-radius: 16px; padding: 12px 20px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 8px 30px rgba(120, 90, 60, 0.2); z-index: 100;
  transition: top 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}
.achievement-popup.show { top: 20px; }
.ach-icon { font-size: 32px; }
.ach-title { font-size: 10px; color: var(--primary); text-transform: uppercase; letter-spacing: 1px; }
.ach-name { font-size: 15px; font-weight: 700; color: var(--text); }
.ach-desc { font-size: 11px; color: var(--text-light); }

/* Achievement Panel Items */
.ach-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; margin-bottom: 6px;
  transition: all 0.2s;
}
.ach-item.unlocked { background: var(--bg); }
.ach-item.locked { background: var(--bg); opacity: 0.5; }
.ach-item-icon { font-size: 22px; width: 30px; text-align: center; }
.ach-item-name { font-size: 13px; font-weight: 500; }
.ach-item-desc { font-size: 11px; color: var(--text-light); }

/* ===== Side Panel ===== */
.side-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 300px; background: var(--card);
  border-left: 1px solid var(--border);
  padding: 16px; overflow-y: auto; z-index: 20;
  transition: transform 0.3s ease;
  box-shadow: -4px 0 12px var(--shadow);
}
.side-panel.hidden { transform: translateX(100%); pointer-events: none; }
.side-panel h3 { margin-bottom: 14px; font-size: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* Cat Cards */
.cat-card {
  padding: 10px 12px; background: var(--bg); border-radius: 12px;
  margin-bottom: 8px; cursor: pointer; transition: all 0.2s;
}
.cat-card:hover { background: var(--bg-warm); transform: translateX(-4px); }
.cat-card-name { font-weight: 500; font-size: 14px; }
.cat-card-info { font-size: 12px; color: var(--text-light); margin-top: 3px; }
.cat-card-bars { display: flex; gap: 3px; margin-top: 6px; }
.cat-card-friend { font-size: 11px; color: var(--primary); margin-top: 4px; }
.need-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.need-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s; }

/* Event Log */
.event-item {
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 13px; line-height: 1.5;
}
.event-item.milestone {
  background: linear-gradient(90deg, rgba(232,168,124,0.1), transparent);
  padding-left: 8px; border-left: 3px solid var(--primary);
  margin-left: -8px; border-radius: 0 4px 4px 0;
}
.event-time { font-size: 11px; color: var(--text-light); }

/* Diary */
.diary-day {
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}
.diary-day-title {
  font-size: 13px; font-weight: 500; color: var(--primary);
  margin-bottom: 6px;
}
.diary-entry {
  font-size: 12px; color: var(--text); line-height: 1.6;
  padding-left: 10px; border-left: 2px solid var(--border);
  margin-bottom: 3px;
}

/* ===== Modal ===== */
.modal {
  position: absolute; inset: 0;
  background: rgba(90, 74, 58, 0.4);
  display: flex; justify-content: center; align-items: center; z-index: 30;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--card); border-radius: 20px; padding: 28px;
  max-width: 420px; width: 90%; position: relative;
  box-shadow: 0 10px 40px var(--shadow); max-height: 85vh; overflow-y: auto;
}
.modal-close {
  position: absolute; top: 12px; right: 16px;
  border: none; background: none; font-size: 24px;
  color: var(--text-light); cursor: pointer;
}
/* Interaction Section */
.interact-section {
  background: linear-gradient(135deg, #fef6e8, #fdf0dc);
  border-radius: 14px; padding: 14px; margin-bottom: 16px;
  border: 1.5px solid var(--primary);
}
.interact-buttons {
  display: flex; gap: 8px; margin-bottom: 10px;
}
.interact-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 8px; border: 1.5px solid var(--border); border-radius: 12px;
  background: white; cursor: pointer; font-family: inherit;
  transition: all 0.15s; font-size: 12px; color: var(--text);
}
.interact-btn:hover { border-color: var(--primary); background: #fff8f0; transform: scale(1.05); }
.interact-btn:active { transform: scale(0.95); background: var(--primary); color: white; }
.interact-icon { font-size: 22px; }
.interact-happy {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-light);
}
.happy-pct { font-weight: 500; color: var(--primary); min-width: 32px; text-align: right; }

/* Gifts */
.gifts-section {
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}
.gifts-title {
  font-size: 12px; color: var(--primary); font-weight: 500;
  margin-bottom: 8px;
}
.gifts-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.gift-item {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  background: var(--bg); border-radius: 10px; font-size: 18px;
  border: 1px solid var(--border); cursor: default;
  transition: transform 0.2s;
}
.gift-item:hover { transform: scale(1.15); }

/* Collapsible sections */
.collapsible .collapse-content { display: none; }
.collapsible.open .collapse-content { display: block; }
.collapsible h4 { cursor: pointer; }
.collapsible.open h4 { color: var(--primary); }

.detail-name { font-size: 22px; font-weight: 700; }
.detail-breed { font-size: 13px; color: var(--text-light); margin-bottom: 16px; }
.detail-section { margin-bottom: 14px; }
.detail-section h4 { font-size: 12px; color: var(--text-light); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px; }
.detail-need-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 13px; }
.detail-need-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.detail-need-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.detail-status { padding: 8px 12px; background: var(--bg); border-radius: 10px; font-size: 13px; line-height: 1.6; }
.detail-no-data { font-size: 12px; color: var(--text-light); font-style: italic; }

/* Relationship rows */
.detail-rel-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0; font-size: 13px;
}
.rel-name { font-weight: 500; min-width: 50px; }
.rel-label { font-size: 11px; color: var(--text-light); min-width: 60px; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Responsive */
@media (max-width: 768px) {
  .game-header { padding: 6px 8px; }
  .game-info { gap: 6px; font-size: 12px; }
  .game-controls .btn-icon { width: 28px; height: 28px; font-size: 12px; }
  .build-bar { padding: 4px 8px; gap: 6px; }
  .build-item { padding: 3px 8px; }
  .build-name { font-size: 10px; }
  .build-cost { font-size: 9px; }
}
@media (max-width: 600px) {
  h1 { font-size: 32px; letter-spacing: 4px; }
  .side-panel { width: 260px; }
  .setup-container { padding: 24px 16px; }
  .option-btn { padding: 6px 12px; font-size: 13px; }
  .modal-content { padding: 20px; }
}
