/* ============================================================
   Eastern Farm — Stylesheet
   Cozy, warm, mobile-first
   ============================================================ */

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

:root {
  --cream-bg:       #fdf8ee;
  --cream-card:     #fffdf6;
  --soil-brown:     #8b5a3c;
  --soil-dark:      #6d4528;
  --leaf-green:     #6ab04c;
  --leaf-dark:      #3a7d2c;
  --mature-glow:    #f7c948;
  --barn-red:       #c44536;
  --sky-blue:       #88c8e8;
  --warm-text:      #3a2e26;
  --warm-text-soft: #6b5d52;
  --gold-coin:      #f1c40f;
  --purple-points:  #9b59b6;
  --border-soft:    #e8dcc4;
  --shadow-card:    0 2px 6px rgba(139, 90, 60, 0.12), 0 1px 2px rgba(139, 90, 60, 0.08);
  --shadow-card-hover: 0 4px 12px rgba(139, 90, 60, 0.18);

  --font-zh: 'Noto Sans SC', 'PingFang SC', sans-serif;
  --font-en: 'Plus Jakarta Sans', 'Quicksand', sans-serif;
  --font-display: 'ZCOOL KuaiLe', 'Plus Jakarta Sans', sans-serif;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  height: 100%;
  font-family: var(--font-zh), var(--font-en);
  color: var(--warm-text);
  background: var(--cream-bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
  background: linear-gradient(180deg, #fef5e0 0%, #fdf8ee 30%, #f5ecd5 100%);
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: var(--cream-bg);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(139, 90, 60, 0.1);
}

/* =============== TOP BAR =============== */
#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(180deg, #fffaeb 0%, #faf0d8 100%);
  border-bottom: 2px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}

.currency {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--cream-card);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border-soft);
  font-weight: 700;
  font-size: 14px;
}
.currency.coins { color: #b8860b; }
.currency.points { color: var(--purple-points); }
.currency .icon { font-size: 18px; }

.level-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}
.level-label {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--barn-red);
  font-weight: 700;
}
.xp-bar {
  width: 70px;
  height: 5px;
  background: var(--border-soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--leaf-green), var(--mature-glow));
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

/* =============== FESTIVAL BANNER =============== */
.festival-banner {
  background: linear-gradient(90deg, #fff3d6, #ffe0a8);
  border-bottom: 2px solid #f0c674;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #8b4513;
}
.festival-banner.hidden { display: none; }
.festival-icon { font-size: 18px; }

/* =============== FARM GRID =============== */
#farm {
  flex: 1;
  padding: 20px 16px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 0%, #f0e3c1 0%, transparent 50%),
    var(--cream-bg);
}

.farm-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 380px;
  margin: 0 auto;
}

.plot {
  aspect-ratio: 1;
  background: linear-gradient(135deg, #a0734d 0%, var(--soil-brown) 60%, var(--soil-dark) 100%);
  border-radius: var(--radius-md);
  border: 2px solid var(--soil-dark);
  box-shadow: var(--shadow-card), inset 0 -3px 0 rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  position: relative;
  transition: transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
}
.plot:active {
  transform: scale(0.96);
}

.plot.empty {
  background: linear-gradient(135deg, #b58465 0%, var(--soil-brown) 100%);
}
.plot.empty::before {
  content: "+";
  font-size: 36px;
  color: rgba(255, 255, 255, 0.35);
  font-weight: 300;
}

.plot.locked {
  background: linear-gradient(135deg, #cccccc 0%, #999999 100%);
  cursor: not-allowed;
  opacity: 0.7;
}
.plot.locked::before {
  content: "🔒";
  font-size: 28px;
  opacity: 0.6;
}
.plot.locked .lock-hint {
  position: absolute;
  bottom: 4px;
  font-size: 9px;
  color: white;
  background: rgba(0,0,0,0.4);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
}

.plot .crop-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.plot .crop-icon svg {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.18));
}
.plot.growing .crop-icon {
  animation: gentleSway 3s ease-in-out infinite;
  transform-origin: 50% 90%;
}
.plot.growing .grow-bar {
  position: absolute;
  bottom: 4px;
  left: 6px;
  right: 6px;
  height: 4px;
  background: rgba(0,0,0,0.3);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.plot.growing .grow-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--leaf-green), var(--mature-glow));
  transition: width 1s linear;
}

.plot.ready {
  background: linear-gradient(135deg, #e8f4d2 0%, #c9e4a0 100%);
  border-color: var(--leaf-dark);
  box-shadow: var(--shadow-card), 0 0 0 3px rgba(247, 201, 72, 0.5);
  animation: readyPulse 2s ease-in-out infinite;
}
.plot.ready .crop-icon {
  animation: gentleBounce 1s ease-in-out infinite;
  transform-origin: 50% 90%;
}
.plot.ready .crop-icon svg {
  filter: drop-shadow(0 0 6px var(--mature-glow)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.18));
}
.plot.ready::after {
  content: "✨";
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 14px;
  animation: sparkle 1.5s ease-in-out infinite;
}

@keyframes gentleSway {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}
@keyframes gentleBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes readyPulse {
  0%, 100% { box-shadow: var(--shadow-card), 0 0 0 3px rgba(247, 201, 72, 0.5); }
  50% { box-shadow: var(--shadow-card), 0 0 0 6px rgba(247, 201, 72, 0.3); }
}
@keyframes sparkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

/* =============== STOREKEEPER =============== */
.storekeeper {
  display: flex;
  align-items: flex-end;
  padding: 12px 16px;
  gap: 10px;
  background: linear-gradient(180deg, transparent 0%, #f5e9c8 100%);
}
.storekeeper-avatar {
  font-size: 42px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}
.storekeeper-bubble {
  background: var(--cream-card);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--warm-text);
  flex: 1;
  position: relative;
  box-shadow: var(--shadow-card);
}
.storekeeper-bubble::before {
  content: "";
  position: absolute;
  left: -8px;
  bottom: 16px;
  width: 0;
  height: 0;
  border-right: 8px solid var(--cream-card);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

/* =============== BOTTOM BAR =============== */
#bottombar {
  display: flex;
  background: linear-gradient(0deg, #fffaeb 0%, #faf0d8 100%);
  border-top: 2px solid var(--border-soft);
  padding: 8px 4px;
  gap: 2px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.action-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  border-radius: var(--radius-md);
  position: relative;
  transition: background var(--transition);
}
.action-btn:active {
  background: rgba(139, 90, 60, 0.1);
}
.action-icon { font-size: 24px; }
.action-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--warm-text-soft);
}

.task-badge {
  position: absolute;
  top: 4px;
  right: 16px;
  background: var(--barn-red);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  min-width: 14px;
  text-align: center;
}
.task-badge:empty { display: none; }

/* =============== MODAL =============== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(58, 46, 38, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-content {
  position: relative;
  background: var(--cream-card);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  max-width: 380px;
  width: calc(100% - 40px);
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  animation: modalIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalIn {
  from { transform: scale(0.85) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--barn-red);
  margin-bottom: 4px;
  text-align: center;
}
.modal-subtitle {
  font-size: 13px;
  color: var(--warm-text-soft);
  text-align: center;
  margin-bottom: 20px;
}

/* Seed picker grid */
.seed-list, .crop-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.seed-card {
  background: var(--cream-bg);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.seed-card:active { transform: scale(0.95); }
.seed-card.locked { opacity: 0.4; cursor: not-allowed; }
.seed-card .seed-icon { font-size: 36px; display: block; margin-bottom: 4px; }
.seed-card .seed-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.seed-card .seed-cost { font-size: 11px; color: #b8860b; }
.seed-card .seed-time { font-size: 10px; color: var(--warm-text-soft); margin-top: 2px; }

/* Task list */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-card {
  background: var(--cream-bg);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.task-card.done {
  background: #e8f4d2;
  border-color: var(--leaf-green);
}
.task-info { flex: 1; }
.task-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.task-progress {
  font-size: 11px;
  color: var(--warm-text-soft);
  font-family: var(--font-en);
}
.task-reward {
  font-size: 11px;
  font-weight: 700;
  color: var(--barn-red);
  text-align: right;
  white-space: nowrap;
}

/* Reward tier card */
.reward-tier {
  background: linear-gradient(135deg, #fffaeb, #fff3d6);
  border: 2px solid #f0c674;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.reward-tier .reward-info { flex: 1; }
.reward-tier .reward-value {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--barn-red);
}
.reward-tier .reward-cost {
  font-size: 12px;
  color: var(--purple-points);
  font-weight: 600;
  margin-top: 2px;
}
.reward-tier .btn-exchange {
  background: var(--barn-red);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.reward-tier .btn-exchange:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Coupon code display */
.coupon-display {
  background: linear-gradient(135deg, #fff 0%, #fff8e1 100%);
  border: 3px dashed var(--barn-red);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  margin-bottom: 16px;
}
.coupon-code {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 3px;
  color: var(--barn-red);
  background: white;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin: 12px 0;
  border: 2px solid var(--border-soft);
}
.coupon-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--warm-text);
  margin-bottom: 4px;
}
.coupon-instruction {
  font-size: 12px;
  color: var(--warm-text-soft);
  margin-top: 8px;
}

/* Generic button */
.btn {
  background: var(--barn-red);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 4px rgba(196, 69, 54, 0.3);
}
.btn:active { transform: scale(0.95); }
.btn:disabled { background: #ccc; cursor: not-allowed; box-shadow: none; }
.btn.secondary {
  background: transparent;
  color: var(--warm-text);
  border: 2px solid var(--border-soft);
  box-shadow: none;
}
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.btn-row .btn { flex: 1; }

/* =============== TOAST =============== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--warm-text);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 200;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
}
.toast.hidden { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* Floating "+coins" effect after harvest */
.float-coin {
  position: absolute;
  font-weight: 700;
  font-size: 14px;
  color: var(--gold-coin);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  pointer-events: none;
  animation: floatUp 1.2s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-40px); }
}

/* =============== SPLASH SCREEN =============== */
.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 30%, #ffffff 0%, #fef5e0 30%, #f5ecd5 100%);
  padding: 24px;
  animation: splashIn 0.4s ease;
}
.splash.dismissed {
  animation: splashOut 0.5s ease forwards;
}
@keyframes splashIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes splashOut {
  to { opacity: 0; visibility: hidden; transform: scale(1.02); }
}
.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  max-width: 360px;
  width: 100%;
}
.splash-logo {
  width: 78%;
  max-width: 280px;
  height: auto;
  filter: drop-shadow(0 6px 20px rgba(232, 82, 42, 0.18));
  animation: splashLogoIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}
@keyframes splashLogoIn {
  from { opacity: 0; transform: scale(0.85) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.splash-title-zh {
  font-family: var(--font-display);
  font-size: 38px;
  color: #2a5c34;
  margin-top: 6px;
  letter-spacing: 4px;
  animation: splashSlideUp 0.6s ease 0.4s both;
}
.splash-title-en {
  font-family: var(--font-en);
  font-size: 16px;
  font-weight: 500;
  color: #E8522A;
  letter-spacing: 6px;
  text-transform: uppercase;
  margin-top: -4px;
  animation: splashSlideUp 0.6s ease 0.5s both;
}
.splash-tagline {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--warm-text-soft);
  animation: splashSlideUp 0.6s ease 0.6s both;
}
.splash-tagline-en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12px;
  opacity: 0.75;
}
@keyframes splashSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.splash-start {
  margin-top: 18px;
  background: linear-gradient(135deg, #3a8c50 0%, #2a5c34 100%);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(58, 140, 80, 0.35), inset 0 1px 0 rgba(255,255,255,0.2);
  animation: splashSlideUp 0.6s ease 0.75s both, splashPulse 2.5s ease-in-out 1.4s infinite;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.splash-start:active {
  transform: scale(0.96);
  box-shadow: 0 3px 10px rgba(58, 140, 80, 0.35);
}
.splash-start-icon { font-size: 22px; }
.splash-start-en {
  font-family: var(--font-en);
  font-size: 13px;
  opacity: 0.85;
  margin-left: 4px;
}
@keyframes splashPulse {
  0%, 100% { box-shadow: 0 6px 18px rgba(58, 140, 80, 0.35), inset 0 1px 0 rgba(255,255,255,0.2); }
  50% { box-shadow: 0 8px 24px rgba(232, 82, 42, 0.35), inset 0 1px 0 rgba(255,255,255,0.2); }
}
.splash-footer {
  margin-top: 24px;
  font-size: 11px;
  color: var(--warm-text-soft);
  opacity: 0.75;
  animation: splashSlideUp 0.6s ease 0.95s both;
}

/* =============== TABS (collection modal) =============== */
.tab-bar {
  display: flex;
  gap: 6px;
  background: var(--cream-bg);
  border-radius: var(--radius-pill);
  padding: 4px;
  border: 1.5px solid var(--border-soft);
}
.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 10px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--warm-text-soft);
  cursor: pointer;
  transition: all var(--transition);
}
.tab-btn.active {
  background: var(--cream-card);
  color: var(--barn-red);
  box-shadow: 0 1px 3px rgba(139, 90, 60, 0.18);
}
.tab-btn:active { transform: scale(0.97); }

/* =============== ACHIEVEMENTS =============== */
.ach-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ach-card {
  background: var(--cream-bg);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.ach-card.unlocked {
  background: linear-gradient(135deg, #fffaeb, #fff3d6);
  border-color: #f0c674;
}
.ach-card.locked { opacity: 0.7; }
.ach-icon {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ach-card.unlocked .ach-icon {
  filter: drop-shadow(0 0 4px rgba(247, 201, 72, 0.6));
}
.ach-body { flex: 1; min-width: 0; }
.ach-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--warm-text);
  margin-bottom: 2px;
}
.ach-desc {
  font-size: 11px;
  color: var(--warm-text-soft);
  line-height: 1.4;
}
.ach-bar {
  margin-top: 6px;
  height: 4px;
  background: var(--border-soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.ach-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--leaf-green), var(--mature-glow));
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}
.ach-progress {
  font-size: 10px;
  color: var(--warm-text-soft);
  margin-top: 2px;
  font-family: var(--font-en);
}
.ach-reward {
  font-size: 11px;
  font-weight: 700;
  color: var(--purple-points);
  white-space: nowrap;
  flex-shrink: 0;
}

.hidden { display: none !important; }
