:root {
  --bg: #EFF6F2;
  --card: #E4F0EB;
  --card-hover: #D8EDE3;
  --white: #FFFFFF;
  --green-primary: #8DB5A0;
  --green-dark: #5C9080;
  --green-darker: #3D6B55;
  --green-light: #C4E0D4;
  --amber: #C8A96E;
  --amber-bg: #FDF3E3;
  --red: #C87070;
  --red-bg: #FCEAEA;
  --text: #2C4A3E;
  --text-muted: #7A9E91;
  --border: rgba(141, 181, 160, 0.25);
  --shadow-sm: 0 2px 8px rgba(61, 107, 85, 0.08);
  --shadow-md: 0 6px 20px rgba(61, 107, 85, 0.14);
  --shadow-lg: 0 16px 48px rgba(61, 107, 85, 0.2);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, var(--green-primary) 0%, var(--green-dark) 100%);
  padding: 1.75rem 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 50%, rgba(255,255,255,0.12) 0%, transparent 60%);
  pointer-events: none;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.03em;
}

/* ── Main grid ── */
main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.plant-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

@media (max-width: 950px) {
  .plant-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .plant-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  main { padding: 1.25rem 0.75rem 2rem; }
}

@media (max-width: 360px) {
  .pixel-container { width: 96px; height: 120px; }
  .pixel-plant { transform: scale(6); }
  .pixel-container--large { width: 120px; height: 150px; }
  .pixel-container--large .pixel-plant { transform: scale(7.5); }
}

.loading {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 3rem;
  font-size: 0.95rem;
}

/* ── Plant card ── */
.plant-card {
  background: var(--card);
  border-radius: 20px;
  padding: 1.25rem 1rem 1rem;
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.2s ease, border-color 0.2s ease;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  position: relative;
  border: 2px solid transparent;
  user-select: none;
}

.plant-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  background: var(--card-hover);
  border-color: var(--green-primary);
}

.plant-card:active { transform: translateY(-2px); }

.plant-number {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  background: var(--green-darker);
  color: #fff;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  z-index: 1;
}

/* ── Pixel art ── */
.pixel-container {
  width: 128px;
  height: 160px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.pixel-container--large {
  width: 160px;
  height: 200px;
}

.pixel-plant {
  width: 1px;
  height: 1px;
  position: absolute;
  top: 0;
  left: 0;
  transform: scale(8);
  transform-origin: 0 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.pixel-container--large .pixel-plant {
  transform: scale(10);
}

.plant-card.critical .pixel-plant {
  filter: saturate(0.45) brightness(0.9);
}

/* ── Plant name & health ── */
.plant-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  line-height: 1.35;
  max-width: 110px;
}

.health-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(141, 181, 160, 0.2);
  border-radius: 3px;
  overflow: hidden;
}

.health-bar-bg--modal {
  flex: 1;
  height: 8px;
}

.health-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease, background-color 0.5s ease;
  min-width: 2px;
}

.health--good  { background: var(--green-primary); }
.health--warn  { background: var(--amber); }
.health--critical { background: var(--red); }

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 55, 45, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  animation: fadeIn 0.18s ease;
}

.modal-overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Modal ── */
.modal {
  background: var(--white);
  border-radius: 28px;
  padding: 2rem;
  max-width: 460px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.22s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg);
  border: none;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  z-index: 1;
}

.modal-close:hover { background: var(--green-light); color: var(--text); }

.modal-pixel-art {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.modal-number {
  background: var(--green-darker);
  color: #fff;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.modal h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.modal-common {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 0.15rem;
  font-style: italic;
}

.modal-health-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.health-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 52px;
}

.modal-water-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  margin-bottom: 1.25rem;
  line-height: 1.7;
  border: 1px solid var(--border);
}

.modal-water-info.never {
  background: var(--red-bg);
  color: var(--red);
  border-color: rgba(200, 112, 112, 0.2);
}

.modal-water-info.overdue {
  background: var(--amber-bg);
  border-color: rgba(200, 169, 110, 0.3);
}

.modal-details {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.detail-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.detail-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-primary);
  flex-shrink: 0;
  margin-top: 0.45rem;
}

.detail-row strong {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.2rem;
}

.detail-row p {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.55;
}

/* ── Water button ── */
.water-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--green-primary), var(--green-dark));
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 0.9rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
  box-shadow: 0 3px 10px rgba(92, 144, 128, 0.35);
}

.water-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(92, 144, 128, 0.45);
}

.water-btn:active { transform: translateY(0); box-shadow: none; }

.water-btn.success {
  background: linear-gradient(135deg, #6BC49A, #3A8C68);
}

.water-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}
