/* ===== House Detective — Warm Sunset Orange Theme ===== */
:root {
  --bg-color: #FEF6E4;
  --text-color: #4A3520;
  --accent-color: #FF8C42;
  --secondary: #4A90E2;
  --tertiary: #7FB069;
  --card-bg: #FFFFFF;
  --card-border: rgba(255,140,66,0.18);
  --header-bg: rgba(254,246,228,0.92);
  --header-border: rgba(255,140,66,0.18);
  --nav-bg: rgba(255,255,255,0.95);
  --nav-border: rgba(255,140,66,0.15);
  --nav-text-inactive: rgba(74,53,32,0.45);
  --nav-active-bg: rgba(255,140,66,0.12);
  --btn-back-bg: rgba(255,140,66,0.12);
  --btn-primary-bg: linear-gradient(180deg, #FFA45C, #FF8C42 50%, #D9622A);
  --btn-primary-text: #FFF6E4;
  --btn-primary-shadow: #A8451B;
  --btn-ghost-bg: rgba(74,144,226,0.08);
  --btn-ghost-text: #2C5F8A;
  --btn-ghost-border: rgba(74,144,226,0.3);
  --glow-color: rgba(255,140,66,0.5);
  --progress-fill: linear-gradient(90deg, #FFE066, #FF8C42, #FF6B35);
  --intro-bg-1: rgba(255,140,66,0.85);
  --intro-bg-2: rgba(74,53,32,0.95);
  --intro-color: #FEF6E4;
  --intro-sub-color: #FFD9B3;
  --ai-hint-bg: rgba(127,176,105,0.12);
  --ai-hint-border: rgba(127,176,105,0.35);
}

body {
  background:
    radial-gradient(ellipse at top, #FFD9B3 0%, transparent 60%),
    linear-gradient(180deg, #FFE0B3 0%, #FEF6E4 50%, #FFEDDA 100%);
}

#bg-stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
#bg-stars::before, #bg-stars::after {
  content: ''; position: absolute; border-radius: 50%; opacity: 0.6;
  background: radial-gradient(circle, #FFB088 0%, transparent 70%);
}
#bg-stars::before { top: -100px; right: -80px; width: 280px; height: 280px; }
#bg-stars::after  { bottom: -120px; left: -60px; width: 260px; height: 260px; }

/* ─── Home: Detective's notebook ─────────────────────────── */
.detective-home {
  display: flex; flex-direction: column; gap: 16px;
  padding: 16px 18px 30px;
  animation: core-slideUp 0.5s ease;
}

.hero-banner {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, #FFF, #FFEFDC);
  border: 3px solid var(--accent-color);
  border-radius: 22px;
  padding: 14px 18px;
  box-shadow: 0 6px 16px rgba(255,140,66,0.18);
  position: relative;
}
.hero-banner::before {
  content: '🔍'; position: absolute; top: -14px; left: 14px;
  background: var(--accent-color); color: #FFF; padding: 4px 10px;
  border-radius: 12px; font-size: 14px; font-weight: 800;
  letter-spacing: 1px;
}
.hero-avatar {
  font-size: 54px; line-height: 1;
  animation: core-bob 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.15));
}
.hero-info { flex: 1; }
.hero-name { font-size: 17px; font-weight: 900; color: #4A3520; }
.hero-stats { display: flex; gap: 12px; margin-top: 4px; font-size: 13px; font-weight: 700; color: #8B5A2B; }

.mission-card {
  background:
    linear-gradient(180deg, #FFF8EC, #FFEFD7),
    repeating-linear-gradient(transparent 0, transparent 28px, rgba(255,140,66,0.06) 28px, rgba(255,140,66,0.06) 29px);
  border: 3px solid var(--accent-color);
  border-radius: 24px;
  padding: 22px 20px 18px;
  position: relative;
  box-shadow: 0 8px 24px rgba(74,53,32,0.15);
}
.mission-card::before {
  content: '📓 今日侦察任务';
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  background: var(--accent-color); color: #FFF;
  padding: 4px 16px; border-radius: 14px;
  font-size: 13px; font-weight: 900; letter-spacing: 1px;
  white-space: nowrap;
}
.unit-num-tag {
  display: inline-block;
  background: #4A90E2; color: #FFF;
  padding: 4px 14px; border-radius: 12px;
  font-size: 12px; font-weight: 900; margin-bottom: 10px;
  letter-spacing: 1px;
}
.unit-emoji { font-size: 60px; display: block; text-align: center; margin: 6px 0 8px; animation: core-float 3s ease-in-out infinite; }
.unit-name { font-size: 26px; font-weight: 900; color: #4A3520; text-align: center; }
.unit-name-en { font-size: 16px; color: #FF8C42; text-align: center; font-style: italic; margin-bottom: 8px; }
.unit-topic { font-size: 14px; color: #6B5740; text-align: center; margin-bottom: 12px; font-weight: 600; }
.unit-grammar-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.gc-chip {
  background: rgba(74,144,226,0.12); border: 2px solid rgba(74,144,226,0.35);
  color: #2C5F8A; padding: 5px 10px; border-radius: 10px;
  font-size: 12px; font-weight: 700;
}

.set-out-btn {
  width: 100%; padding: 18px 20px;
  background: linear-gradient(180deg, #FFB088, #FF8C42 50%, #D9622A);
  border: 4px solid #FFE0B3;
  border-radius: 22px;
  color: #FFF6E4;
  font-size: 22px; font-weight: 900;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  box-shadow: 0 6px 0 #A8451B, 0 12px 28px rgba(255,140,66,0.4);
  text-shadow: 2px 2px 0 rgba(0,0,0,0.25);
  animation: core-glow 2.5s ease-in-out infinite;
}
.set-out-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #A8451B; }
.set-out-btn .key-emoji { font-size: 28px; animation: core-bob 1.5s ease-in-out infinite; }

.detective-progress {
  background: rgba(255,140,66,0.12);
  border: 2px solid rgba(255,140,66,0.3);
  border-radius: 14px;
  padding: 12px 16px;
  text-align: center;
}
.detective-progress .progress-track {
  --track-bg: rgba(255,140,66,0.18);
  border: 2px solid rgba(255,140,66,0.2);
  margin-bottom: 6px;
}
.detective-progress-text { font-size: 13px; font-weight: 800; color: #B85C20; letter-spacing: 1px; }

/* ─── Map: Floor plan ─────────────────────────────────────── */
.apartment-map { padding: 16px 14px 80px; }
.apartment-banner {
  text-align: center; margin-bottom: 20px;
  background: linear-gradient(180deg, #FFF, #FFEFDC);
  border: 3px solid var(--accent-color);
  border-radius: 20px;
  padding: 14px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}
.apartment-title { font-size: 24px; font-weight: 900; color: #4A3520; }
.apartment-subtitle { font-size: 13px; color: #B85C20; margin-top: 4px; font-weight: 700; }

.rooms-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.room-card {
  background: linear-gradient(135deg, #FFF8EC, #FFEAC9);
  border: 3px solid var(--accent-color);
  border-radius: 20px;
  padding: 16px 12px;
  text-align: center; cursor: pointer;
  transition: transform 0.2s;
  box-shadow: 0 5px 0 rgba(168,69,27,0.6);
  position: relative;
  animation: core-slideUp 0.3s ease backwards;
}
.room-card:nth-child(1) { animation-delay: 0s; }
.room-card:nth-child(2) { animation-delay: 0.05s; }
.room-card:nth-child(3) { animation-delay: 0.1s; }
.room-card:nth-child(4) { animation-delay: 0.15s; }
.room-card:nth-child(5) { animation-delay: 0.2s; }
.room-card:nth-child(6) { animation-delay: 0.25s; }

.room-card:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(168,69,27,0.6); }
.room-card.current {
  background: linear-gradient(135deg, #FFE0B3, #FFB088);
  animation: core-glow 2s ease-in-out infinite, core-slideUp 0.3s backwards;
}
.room-card.completed {
  background: linear-gradient(135deg, #C8E8B0, #97C97A);
  border-color: #5A8A3A;
}
.room-card.completed::before {
  content: '✓'; position: absolute; top: -8px; right: -8px;
  background: #5A8A3A; color: #FFF; width: 30px; height: 30px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 16px; border: 2px solid #FFF;
}
.room-card.locked {
  background: linear-gradient(135deg, #D9D9D9, #BDBDBD);
  border-color: #999;
  opacity: 0.7; pointer-events: none;
}
.room-card.locked .room-emoji { filter: grayscale(1); }
.room-tag {
  background: var(--accent-color); color: #FFF;
  padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 900;
  display: inline-block; margin-bottom: 6px; letter-spacing: 1px;
}
.room-emoji { font-size: 48px; margin: 4px 0; animation: core-float 4s ease-in-out infinite; }
.room-name-en { font-size: 16px; font-weight: 900; color: #4A3520; }
.room-name-zh { font-size: 12px; color: #8B5A2B; margin-top: 2px; font-weight: 600; }
.room-stars { font-size: 14px; margin-top: 6px; }
.room-neighbor-hint { font-size: 11px; color: #6B5740; margin-top: 4px; font-style: italic; }

/* ─── Room screen: find objects + dialogue ──────────────── */
.room-stage {
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
}
.room-banner {
  background: linear-gradient(135deg, #FFF, #FFEFDC);
  border: 3px solid var(--accent-color);
  border-radius: 18px;
  padding: 14px;
  display: flex; align-items: center; gap: 12px;
}
.rb-emoji { font-size: 42px; }
.rb-info { flex: 1; }
.rb-en { font-size: 18px; font-weight: 900; color: #4A3520; }
.rb-zh { font-size: 13px; color: #8B5A2B; font-weight: 700; }
.rb-counter { font-size: 13px; color: var(--accent-color); font-weight: 900; }

.find-board {
  background: linear-gradient(180deg, #FFF8EC, #FFEFD7);
  border: 3px solid var(--accent-color);
  border-radius: 20px;
  padding: 14px;
  min-height: 280px;
  position: relative;
  overflow: hidden;
}
.find-target {
  background: rgba(74,144,226,0.12);
  border: 2px solid rgba(74,144,226,0.4);
  border-radius: 12px;
  padding: 10px 14px;
  text-align: center;
  margin-bottom: 12px;
}
.find-target-zh { font-size: 18px; font-weight: 900; color: #2C5F8A; }
.find-target-hint { font-size: 12px; color: #6B7280; margin-top: 4px; }
.objects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 6px 0;
}
.find-object {
  aspect-ratio: 1;
  background: #FFF;
  border: 3px solid rgba(255,140,66,0.3);
  border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 38px;
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
  box-shadow: 0 4px 0 rgba(168,69,27,0.25);
}
.find-object:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(168,69,27,0.25); }
.find-object .obj-label { font-size: 11px; color: #6B5740; margin-top: 2px; font-weight: 700; }
.find-object.correct {
  background: linear-gradient(135deg, #C8E8B0, #97C97A);
  border-color: #5A8A3A;
  animation: core-popIn 0.4s ease;
}
.find-object.wrong {
  background: rgba(248,113,113,0.2);
  border-color: #DC2626;
  animation: core-shake 0.4s ease;
}

/* ─── Neighbor dialogue ─────────────────────────────────── */
.neighbor-stage {
  display: flex; flex-direction: column; gap: 12px;
  padding: 4px 4px 14px;
}
.neighbor-intro {
  background: linear-gradient(135deg, #FFF, #FFEAC9);
  border: 3px solid var(--accent-color);
  border-radius: 18px;
  padding: 14px;
  display: flex; gap: 12px; align-items: center;
}
.neighbor-avatar {
  width: 64px; height: 64px;
  background: var(--accent-color); color: #FFF;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  flex-shrink: 0;
}
.neighbor-name { font-size: 16px; font-weight: 900; color: #4A3520; }
.neighbor-line { font-size: 13px; color: #8B5A2B; margin-top: 2px; font-style: italic; }

.chat-area {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 6px;
  min-height: 200px; max-height: 50vh;
}
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
  animation: core-slideUp 0.25s ease;
}
.chat-bubble.ai {
  align-self: flex-start;
  background: linear-gradient(135deg, #FFF, #FFEFDC);
  border: 2px solid var(--accent-color);
  color: #4A3520;
  border-bottom-left-radius: 4px;
}
.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #4A90E2, #2C5F8A);
  color: #FFF;
  border-bottom-right-radius: 4px;
}
.chat-options { display: flex; flex-direction: column; gap: 8px; padding: 6px 0; }
.chat-option {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px; font-weight: 700;
  cursor: pointer; text-align: left;
  background: linear-gradient(180deg, #FFF, #FFEFDC);
  border: 3px solid var(--accent-color);
  color: #4A3520;
  box-shadow: 0 3px 0 rgba(168,69,27,0.35);
  min-height: 50px;
}
.chat-option:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(168,69,27,0.35); }
.chat-option .opt-zh { font-size: 11px; color: #8B5A2B; display: block; margin-top: 2px; font-weight: 600; }

.speak-btn {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-color);
  color: #FFF;
  font-size: 26px;
  border: none; cursor: pointer;
  box-shadow: 0 4px 0 #A8451B;
  display: flex; align-items: center; justify-content: center;
}
.speak-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #A8451B; }
.speak-btn.big { width: 72px; height: 72px; font-size: 34px; }

/* ─── Pencil writing modal ──────────────────────────────── */
.write-modal {
  background: #FFF; border-radius: 22px;
  padding: 18px; max-width: 480px; width: 90vw;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.write-prompt { font-size: 18px; font-weight: 900; color: #4A3520; text-align: center; margin-bottom: 8px; }
.write-pad-wrap {
  height: 200px; margin-bottom: 12px;
  background:
    repeating-linear-gradient(0deg, transparent 0, transparent 39px, rgba(255,140,66,0.12) 39px, rgba(255,140,66,0.12) 40px);
  border: 3px dashed var(--accent-color);
  border-radius: 14px;
  overflow: hidden;
}
.write-actions { display: flex; gap: 8px; }
.write-actions .btn { flex: 1; }

/* ─── Complete screen ─────────────────────────────────── */
.complete-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 40px 20px;
  text-align: center; animation: core-slideUp 0.5s ease;
  min-height: 60vh;
}
.complete-emoji { font-size: 90px; animation: core-float 1.5s ease-in-out infinite; filter: drop-shadow(0 8px 14px rgba(255,140,66,0.5)); }
.complete-title { font-size: 28px; font-weight: 900; color: var(--accent-color); text-shadow: 2px 2px 0 #FFE0B3; }
.complete-stars { font-size: 40px; letter-spacing: 6px; }
.complete-coins {
  background: var(--accent-color); color: #FFF;
  padding: 10px 24px; border-radius: 14px;
  font-size: 18px; font-weight: 900;
  box-shadow: 0 4px 0 #A8451B;
}

/* ─── Journal ─────────────────────────────────────────── */
.journal-stage { padding: 16px; }
.journal-title { font-size: 24px; font-weight: 900; color: var(--accent-color); text-align: center; margin-bottom: 16px; }
.day-card {
  background: linear-gradient(135deg, #FFF, #FFF6E4);
  border: 3px solid var(--accent-color);
  border-radius: 18px;
  padding: 14px; margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(255,140,66,0.15);
}
.day-card-name { font-size: 17px; font-weight: 900; color: #4A3520; margin-bottom: 6px; }
.day-card-entry { font-size: 14px; color: #6B5740; min-height: 24px; }

/* ─── Settings ────────────────────────────────────────── */
.settings-stage { padding: 24px 18px; display: flex; flex-direction: column; gap: 14px; }
.settings-section {
  background: linear-gradient(135deg, #FFF, #FFEFDC);
  border: 3px solid var(--accent-color);
  border-radius: 18px; padding: 18px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.settings-label { font-size: 14px; font-weight: 900; color: var(--accent-color); }
.settings-stat { font-size: 14px; color: #4A3520; font-weight: 600; }

/* ─── iPad horizontal layout boost ────────────────────── */
@media (min-width: 768px) {
  .rooms-grid { grid-template-columns: repeat(3, 1fr); }
  .objects-grid { grid-template-columns: repeat(4, 1fr); }
  .unit-emoji { font-size: 72px; }
  .unit-name { font-size: 32px; }
}
