/* ==========================================================================
   Le Jardin de Téo et Mica — Feuille de style Aquarelle, Taille Prune & Forêt
   ========================================================================== */

:root {
  --paper-bg: #FDFBF7;
  --paper-warm: #F5EFE4;
  --paper-card: rgba(253, 251, 247, 0.92);
  --ink-dark: #3B3026;
  --ink-soft: #6C5A49;
  --border-sketch: rgba(110, 80, 57, 0.22);

  --sage-main: #5C7D63;
  --sage-dark: #3F5B45;
  --sage-light: #DFECE0;

  --water-color: #6B9AC4;
  --nutrients-color: #D89B3C;
  --harmony-color: #6A996F;
  --protection-color: #D97972;

  --shadow-soft: 0 8px 24px rgba(59, 48, 38, 0.08);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: radial-gradient(circle at top, #F6F0E4 0%, #E7DEC9 100%);
  color: var(--ink-dark);
  font-family: 'Georgia', 'Palatino Linotype', 'Book Antiqua', serif;
  display: flex;
  justify-content: center;
  align-items: center;
}

.app-shell {
  width: 100%;
  max-width: 450px;
  height: 100dvh;
  max-height: 920px;
  background-color: var(--paper-bg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(45, 34, 24, 0.18);
}

@media (min-width: 500px) {
  .app-shell {
    height: 95dvh;
    border-radius: 30px;
    border: 6px solid #EFE7D8;
  }
}

/* ==========================================================================
   En-tête (Top Bar)
   ========================================================================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px 7px;
  background: linear-gradient(180deg, rgba(253,251,247,0.98) 0%, rgba(245,239,228,0.9) 100%);
  border-bottom: 1px dashed var(--border-sketch);
  z-index: 10;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  min-width: 0;
}

.avatar-emblem {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--sage-main);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  background: var(--paper-warm);
  flex-shrink: 0;
}

.title-group {
  min-width: 0;
}

.title-group h1 {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.season-pill,
.weather-pill {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.69rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--sage-light);
  color: var(--sage-dark);
}

.weather-pill {
  background: #EFE7D6;
  color: var(--ink-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.forest-switch-btn {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--sage-main);
  background: var(--sage-light);
  color: var(--sage-dark);
  cursor: pointer;
  transition: all 0.15s ease;
}

.forest-switch-btn.active-mode {
  background: var(--sage-main);
  color: #fff;
}

.icon-btn {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  border: 1px solid var(--border-sketch);
  background: var(--paper-bg);
  font-size: 0.98rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.04);
}

/* ==========================================================================
   Bandeau de Croissance (Growth Banner)
   ========================================================================== */
.growth-banner {
  padding: 7px 12px;
  background: rgba(245, 239, 228, 0.76);
  border-bottom: 1px solid var(--border-sketch);
  z-index: 10;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  gap: 6px;
}

.wallet-pills {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.currency-pill {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(110, 80, 57, 0.22);
}

.flower-currency {
  background: #FFF0F3;
  color: #9E3B4E;
  border-color: rgba(229, 143, 138, 0.45);
}

.fruit-currency {
  background: #FFF4E6;
  color: #9C4221;
  border-color: rgba(217, 83, 79, 0.4);
}

.quota-currency {
  background: #EEF5EE;
  color: #3F5B45;
  border-color: rgba(92, 125, 99, 0.38);
}

.quota-currency.quota-empty {
  background: #F4EFEA;
  color: #8C6A50;
  border-color: rgba(140, 106, 80, 0.35);
}

.harvest-action-btn:disabled {
  background: #E8E1D5;
  border-color: #B8AD9E;
  color: #7A6F63;
  cursor: not-allowed;
  animation: none;
  box-shadow: none;
}

.harvest-action-btn {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.71rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1.5px solid #D89B3C;
  background: linear-gradient(180deg, #FFF9EB 0%, #FCE38A 100%);
  color: #6B4416;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(216, 155, 60, 0.3);
  animation: alertPulse 1.6s infinite ease-in-out;
}

.shop-wallet-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--paper-warm);
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-sketch);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
}

.shop-wallet-badges {
  display: flex;
  gap: 6px;
}

.shop-requirement-box {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.76rem;
  line-height: 1.38;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--sage-light);
  color: var(--sage-dark);
  border: 1px solid rgba(92, 125, 99, 0.35);
}

.shop-requirement-box.locked-warning {
  background: #FFF4F3;
  color: #9E2A25;
  border-color: rgba(217, 83, 79, 0.5);
  font-weight: 600;
}

.cloud-auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.icon-btn.cloud-connected {
  border-color: var(--sage-main);
  background: var(--sage-light);
}

.animals-shop-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.animal-shop-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #FFFDF9;
  border: 1.5px solid rgba(110, 80, 57, 0.2);
}

.animal-shop-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.animal-shop-info strong {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.82rem;
  color: var(--ink-dark);
}

.animal-shop-info span {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.69rem;
  color: var(--ink-soft);
}

.animal-cost-row {
  display: flex;
  gap: 6px;
  margin-top: 3px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
}

.buy-animal-btn {
  padding: 7px 11px;
  border-radius: 10px;
  border: none;
  background: var(--sage-main);
  color: #fff;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.buy-animal-btn:disabled,
.primary-cta-btn:disabled {
  background: #C9C1B4;
  color: #6E655B;
  cursor: not-allowed;
  box-shadow: none;
}

.stage-step {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--sage-main);
  color: #fff;
  white-space: nowrap;
}

.stage-name {
  font-size: 0.85rem;
  color: var(--ink-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.banner-btns {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.zen-time-btn {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(92, 125, 99, 0.4);
  background: #FFFDF9;
  color: var(--sage-dark);
  cursor: pointer;
}

.accent-seed-btn {
  background: #FFF6E6;
  border-color: rgba(216, 155, 60, 0.55);
  color: #875814;
}

.growth-progress-track {
  width: 100%;
  height: 8px;
  background: rgba(110, 80, 57, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.growth-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7BA57E 0%, #5C7D63 55%, #E58F8A 100%);
  border-radius: 999px;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.growth-caption {
  display: flex;
  justify-content: space-between;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.69rem;
  color: var(--ink-soft);
  margin-top: 4px;
}

/* ==========================================================================
   Scène Centrale Aquarelle (Canvas + Taille au doigt + Panorama Forêt)
   ========================================================================== */
.garden-stage-container {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 260px;
  overflow: hidden;
  background: #F7F1E5;
  touch-action: none;
}

#gardenCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.forest-overlay {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  z-index: 8;
}

.forest-banner-card {
  background: rgba(253, 251, 247, 0.94);
  border: 1.5px solid var(--sage-main);
  border-radius: 14px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 6px 18px rgba(45, 34, 24, 0.12);
}

.forest-banner-card strong {
  font-size: 0.84rem;
  color: var(--sage-dark);
  display: block;
}

.forest-banner-card p {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.71rem;
  color: var(--ink-soft);
  margin-top: 2px;
}

.primary-pill-btn {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 7px 11px;
  border-radius: 999px;
  border: none;
  background: var(--sage-main);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.event-alert {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  background: rgba(255, 246, 230, 0.95);
  border: 1.5px solid #D89B3C;
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  color: #6B4416;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  z-index: 9;
  pointer-events: none;
  animation: alertPulse 1.8s infinite ease-in-out;
}

.event-alert.critical-alert {
  background: rgba(255, 240, 238, 0.97);
  border: 2px solid #D9534F;
  color: #8E2824;
  box-shadow: 0 6px 20px rgba(217, 83, 79, 0.28);
}

@keyframes alertPulse {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.01); }
}

.stat-card.critical-stat {
  border: 1.5px solid #D9534F;
  background: #FFF4F3;
  animation: statBlink 1.4s infinite ease-in-out;
}

.stat-card.critical-stat .stat-val,
.stat-card.critical-stat .stat-name {
  color: #B52B27;
}

.stat-card.critical-stat .stat-fill {
  background: #D9534F !important;
}

.care-btn.urgent-care {
  border: 2px solid #D9534F;
  background: linear-gradient(180deg, #FFF9F8 0%, #FFE4E1 100%);
  box-shadow: 0 0 12px rgba(217, 83, 79, 0.35);
}

@keyframes statBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

.hidden {
  display: none !important;
}

.story-bubble {
  position: absolute;
  bottom: 8px;
  left: 12px;
  right: 12px;
  background: rgba(253, 251, 247, 0.94);
  backdrop-filter: blur(4px);
  border: 1.5px solid rgba(110, 80, 57, 0.28);
  border-radius: 16px;
  padding: 8px 11px;
  box-shadow: 0 6px 18px rgba(59, 48, 38, 0.12);
  z-index: 5;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.story-speaker-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--sage-main);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  background: var(--paper-warm);
}

.story-content-wrap {
  flex: 1;
  min-width: 0;
}

.speaker-tag {
  display: inline-block;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--sage-dark);
  background: var(--sage-light);
  padding: 1px 7px;
  border-radius: 99px;
  margin-bottom: 2px;
}

#storyText {
  font-size: 0.8rem;
  line-height: 1.32;
  color: var(--ink-dark);
  font-style: italic;
}

/* ==========================================================================
   Grille des 4 Besoins & Barre d'Actions
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 7px 11px;
  background: var(--paper-warm);
  border-top: 1px solid var(--border-sketch);
  z-index: 10;
}

.stat-card {
  background: var(--paper-bg);
  border: 1px solid rgba(110, 80, 57, 0.16);
  border-radius: 10px;
  padding: 5px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.68rem;
}

.stat-name {
  font-weight: 600;
  color: var(--ink-soft);
}

.stat-val {
  font-weight: 700;
  color: var(--ink-dark);
}

.stat-bar {
  width: 100%;
  height: 5px;
  background: rgba(110, 80, 57, 0.12);
  border-radius: 99px;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.35s ease;
}

.water-fill { background: var(--water-color); }
.nutrients-fill { background: var(--nutrients-color); }
.harmony-fill { background: var(--harmony-color); }
.protection-fill { background: var(--protection-color); }

.care-toolbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  padding: 7px 11px 12px;
  background: var(--paper-bg);
  border-top: 1px dashed var(--border-sketch);
  z-index: 10;
}

.care-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  border-radius: 14px;
  border: 1.5px solid rgba(110, 80, 57, 0.2);
  background: linear-gradient(180deg, #FFFFFF 0%, #F6EFE2 100%);
  color: var(--ink-dark);
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(59, 48, 38, 0.06);
  transition: transform 0.14s ease;
}

.care-btn:active,
.care-btn.active-pulse {
  transform: translateY(2px) scale(0.96);
}

.care-icon {
  font-size: 1.3rem;
  margin-bottom: 1px;
}

.care-title {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.74rem;
  font-weight: 700;
}

.care-sub {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.62rem;
  color: var(--ink-soft);
}

/* ==========================================================================
   Modales (Nouvel Arbre & Herbier de la Forêt)
   ========================================================================== */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(42, 33, 25, 0.48);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.modal-sheet {
  width: 100%;
  max-height: 86%;
  background: var(--paper-bg);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border-top: 3px solid var(--sage-main);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.22);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: var(--paper-warm);
  border-bottom: 1px dashed var(--border-sketch);
}

.modal-header h2 {
  font-size: 1rem;
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-sketch);
  background: var(--paper-bg);
  cursor: pointer;
}

.modal-body {
  padding: 14px 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-intro-text {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ink-soft);
  background: var(--paper-warm);
  padding: 9px 12px;
  border-radius: 10px;
}

.form-label {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink-dark);
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

.text-input {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border-sketch);
  background: #FFF;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--ink-dark);
  user-select: text;
}

.dice-btn {
  width: 40px;
  border-radius: 10px;
  border: 1.5px solid var(--border-sketch);
  background: var(--paper-warm);
  font-size: 1.1rem;
  cursor: pointer;
}

.species-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.species-card {
  padding: 9px 10px;
  border-radius: 12px;
  border: 2px solid rgba(110, 80, 57, 0.18);
  background: #FFFDF9;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.15s ease;
}

.species-card.selected {
  border-color: var(--sage-main);
  background: var(--sage-light);
}

.species-card strong {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.8rem;
}

.species-card span {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.69rem;
  color: var(--ink-soft);
}

.primary-cta-btn {
  width: 100%;
  padding: 11px 16px;
  border-radius: 14px;
  border: none;
  background: var(--sage-main);
  color: #fff;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(92, 125, 99, 0.28);
}

.herbier-poster-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper-warm);
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border-sketch);
}

.herbier-full-poster {
  width: 82px;
  height: 110px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid var(--sage-main);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14);
  flex-shrink: 0;
}

.herbier-poster-text {
  font-size: 0.8rem;
  line-height: 1.38;
}

.herbier-poster-text strong {
  display: block;
  color: var(--sage-dark);
  margin-bottom: 4px;
  font-size: 0.88rem;
}

.modal-body h3 {
  font-size: 0.9rem;
  color: var(--sage-dark);
  border-bottom: 1px solid var(--border-sketch);
  padding-bottom: 4px;
}

.stages-timeline {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.stages-timeline li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 10px;
  background: #F6F1E7;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.78rem;
  cursor: pointer;
}

.stages-timeline li.unlocked {
  background: var(--sage-light);
  border: 1.5px solid var(--sage-main);
  font-weight: 600;
}

.journal-logs {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.76rem;
  color: var(--ink-soft);
}

.journal-logs li {
  padding: 6px 10px;
  background: #F8F4EC;
  border-left: 3px solid var(--sage-main);
  border-radius: 4px;
}

.modal-footer-actions {
  margin-top: 6px;
  display: flex;
  justify-content: center;
}

.secondary-danger-btn {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.76rem;
  padding: 8px 14px;
  border-radius: 99px;
  border: 1px solid rgba(217, 121, 114, 0.5);
  background: #FFF5F4;
  color: #A9443C;
  cursor: pointer;
}
