/* Reset cơ bản */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Màu trời – cỏ – đất */
  --bg-body: #e6f4ff;
  --bg-app: transparent;
  --bg-card: #ffffff;
  --bg-card-soft: #fefcf6;

  --sky-top: #aee2ff;
  --sky-bottom: #e6f7ff;
  --field-green: #b9e6a5;
  --field-darker: #85c47c;

  --primary: #4caf50;
  --primary-soft: rgba(76, 175, 80, 0.12);

  --accent: #ffb74d;
  --accent-soft: rgba(255, 183, 77, 0.18);

  --text-main: #204022;
  --text-muted: #6b7b6a;

  --border-subtle: rgba(0, 0, 0, 0.06);
  --radius-lg: 18px;
  --radius-md: 10px;
  --shadow-soft: 0 12px 24px rgba(0, 0, 0, 0.08);
}

/* Nền tổng: trời + đồng cỏ */
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
  min-height: 100vh;
  background:
    linear-gradient(to bottom, var(--sky-top) 0%, var(--sky-bottom) 45%, #d9f0cf 46%, #c2e0b0 100%);
  color: var(--text-main);
}

/* Lớp “đồng cỏ” dưới app cho cảm giác mặt đất */
body::before {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 160px;
  background: radial-gradient(circle at top, var(--field-green), var(--field-darker));
  opacity: 0.7;
  pointer-events: none;
  z-index: -1;
}

/* Khung app */

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 12px 24px;
}

/* Header: giống bảng gỗ ở đầu làng */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 248, 235, 0.96));
  border: 1px solid rgba(169, 190, 164, 0.7);
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(141, 182, 139, 0.7);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5c7c42;
  background: rgba(223, 241, 214, 0.8);
}

.brand-title {
  font-size: 20px;
  font-weight: 650;
  color: #2f4b26;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 2px solid rgba(240, 181, 78, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at top, #ffe9ad, #ffcc80);
  color: #5a3b14;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.profile-name {
  font-size: 14px;
  font-weight: 600;
}

.profile-rank {
  font-size: 12px;
  color: var(--text-muted);
}

/* Content chính */

.app-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 14px 14px 16px;
  box-shadow: var(--shadow-soft);
}

/* Header nhỏ bên trong card */

.card-header {
  margin-bottom: 8px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.card-description {
  font-size: 13px;
  color: var(--text-muted);
}

/* Stats */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: -40%;
  background:
    radial-gradient(circle at top left, rgba(249, 224, 138, 0.3), transparent 50%);
  opacity: 0.9;
  pointer-events: none;
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 22px;
  font-weight: 650;
  margin-bottom: 4px;
  color: #30572c;
}

.stat-note {
  font-size: 12px;
  color: var(--text-muted);
}

/* Lưới chính: ruộng + chuồng */

.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.field-card {
  background: var(--bg-card-soft);
}

.barn-card {
  background: var(--bg-card-soft);
}

/* Toolbar ruộng */

.field-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
  margin-bottom: 10px;
}

.seed-select {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-main);
}

.seed-select select {
  flex: 1 1 auto;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(155, 186, 150, 0.9);
  background: #f6fbf3;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

/* Lưới ruộng – mô phỏng ô đất */

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.field-plot {
  position: relative;
  border-radius: var(--radius-md);
  border: 1px solid rgba(160, 140, 100, 0.45);
  background:
    linear-gradient(180deg, #f3e1b4 0%, #e0b070 45%, #c59655 100%);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.1s ease, border-color 0.12s ease, filter 0.1s ease;
  box-shadow: 0 4px 8px rgba(145, 104, 52, 0.2);
}

.field-plot:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 14px rgba(145, 104, 52, 0.35);
}

.field-plot:active {
  transform: translateY(0);
  box-shadow: 0 3px 7px rgba(145, 104, 52, 0.3);
  filter: brightness(0.97);
}

.plot-icon {
  font-size: 16px;
}

.plot-label {
  font-size: 12px;
  font-weight: 500;
  color: #3a2a0c;
}

.plot-timer {
  font-size: 11px;
  color: #6e5b32;
}

/* Trạng thái ruộng */

.field-plot--growing {
  border-color: rgba(126, 184, 94, 0.9);
  background:
    linear-gradient(180deg, #ddf4c7 0%, #d6eeaf 35%, #c6e08b 100%);
}

.field-plot--ready {
  border-color: rgba(255, 182, 65, 0.9);
  background:
    linear-gradient(180deg, #fff2c2 0%, #ffe4a5 45%, #f6c979 100%);
}

.field-plot--locked {
  opacity: 0.55;
  cursor: default;
}

/* Box gợi ý */

.hint-box {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: rgba(244, 252, 238, 0.9);
  border: 1px dashed rgba(151, 173, 144, 0.7);
}

.hint-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* Chuồng trại */

.barn-stats {
  margin-top: 6px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, #fdf7e8, #f8f0de);
  border: 1px solid rgba(221, 191, 130, 0.8);
}

.barn-stat-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 2px;
}

.barn-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* Shop */

.shop-section {
  margin-top: 8px;
}

.shop-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

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

.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: #f7fbf4;
  border: 1px solid rgba(167, 190, 162, 0.7);
}

.shop-item--muted {
  opacity: 0.7;
}

.shop-name {
  font-size: 13px;
  font-weight: 600;
}

.shop-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.shop-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* Log */

.log-section {
  margin-top: 10px;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.log-list {
  max-height: 130px;
  overflow-y: auto;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  background: #f7fbf4;
  border: 1px solid rgba(167, 190, 162, 0.6);
}

.log-entry {
  font-size: 12px;
  color: #33502f;
  margin-bottom: 2px;
}

.log-entry--dim {
  color: #7b9278;
}

/* Thông báo lưu */

.save-indicator {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Buttons */

.secondary-button,
.text-button {
  border: none;
  font-family: inherit;
  cursor: pointer;
  border-radius: 999px;
  transition: background 0.12s ease, transform 0.08s ease, box-shadow 0.1s ease, opacity 0.12s ease;
}

.secondary-button {
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
  color: #234323;
  background: var(--primary-soft);
  border: 1px solid rgba(132, 189, 120, 0.95);
}

.secondary-button:hover {
  background: rgba(144, 203, 132, 0.22);
  transform: translateY(-0.5px);
  box-shadow: 0 3px 7px rgba(118, 163, 109, 0.5);
}

.secondary-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(118, 163, 109, 0.45);
}

.secondary-button--disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
}

.text-button {
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 6px;
}

.text-button:hover {
  opacity: 0.8;
}

/* Hiệu ứng khi thiếu xu */

.not-enough {
  color: #d84545 !important;
  transform: scale(1.05);
  transition: transform 0.12s ease, color 0.12s ease;
}

/* Footer */

.app-footer {
  margin-top: 16px;
  font-size: 11px;
  text-align: center;
  color: var(--text-muted);
}

/* Responsive */

@media (min-width: 640px) {
  .app {
    padding: 20px 16px 30px;
  }

  .brand-title {
    font-size: 22px;
  }

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

  .main-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  }
}

@media (max-width: 480px) {
  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}