/* Nông Trại Nhỏ: a sunny field. Light by design (a farm in daylight). */
:root {
  color-scheme: light;
  --sky: #bfe6ff;
  --sky-2: #e8f7ff;
  --grass: #7cc46b;
  --grass-2: #5aa64d;
  --grass-dark: #3f7f37;
  --soil: #9a6a45;
  --soil-2: #7a5034;
  --soil-wet: #6b4430;
  --cream: #fffaf0;
  --card: #ffffff;
  --text: #2d2a26;
  --muted: #776f66;
  --line: rgba(60, 40, 20, 0.12);
  --primary: #f5a623;
  --primary-2: #e08a00;
  --ok: #3f9d3f;
  --danger: #d9473a;
  --gold: #ffcf3f;
  font-family: ui-rounded, 'SF Pro Rounded', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  color: var(--text);
  background: linear-gradient(180deg, var(--sky) 0, var(--sky-2) 120px, var(--grass) 121px, var(--grass-2) 100%) fixed;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
input { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
  font-size: 17px;
  font-weight: 700;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 3px 0 var(--primary-2); }
.btn.danger { background: var(--danger); color: #fff; box-shadow: 0 3px 0 #a3322a; }
.btn.small { width: auto; padding: 8px 12px; font-size: 14px; border-radius: 11px; flex: 0 0 auto; }
.btn:disabled { opacity: 0.5; }
.link { border: 0; background: none; padding: 6px; color: var(--grass-dark); font-weight: 700; text-decoration: underline; }

/* ---------- logging in ---------- */
.welcome {
  max-width: 440px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.hero { font-size: 64px; display: flex; justify-content: center; gap: 6px; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.12)); }
.hero span:nth-child(2) { font-size: 84px; }
.welcome h1 { margin: 0; font-size: 34px; color: #fff; text-shadow: 0 3px 0 var(--grass-dark); }
.lead { margin: 0; font-size: 16px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }
.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: 20px;
  background: var(--cream);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
  text-align: left;
}
.card label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 700; color: var(--muted); }
.card input {
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 17px; /* iOS doesn't zoom in */
}
.or { margin: 0; text-align: center; color: var(--muted); font-size: 14px; }
.switch { margin: 0; text-align: center; font-size: 15px; }
.error { margin: 0; padding: 10px 12px; border-radius: 12px; background: #ffe4df; color: #8a2016; font-weight: 600; }
.note { margin: 0; font-size: 13px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }
.welcome .lang { color: #fff; }

/* ---------- the game ---------- */
.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 12px calc(84px + env(safe-area-inset-bottom));
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 4px 10px; }
.who h1 { margin: 0; font-size: 20px; line-height: 1.2; text-shadow: 0 1px 0 #fff; }
.level { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 13px; }
.level b { white-space: nowrap; }
.xp { width: 96px; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.7); overflow: hidden; }
.xp span { display: block; height: 100%; background: linear-gradient(90deg, #8fd16a, #3f9d3f); transition: width 300ms; }
.purse { display: flex; align-items: center; gap: 8px; }
.coins { padding: 7px 12px; border-radius: 999px; background: var(--cream); font-weight: 800; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12); white-space: nowrap; }
.gift { border: 0; width: 40px; height: 40px; border-radius: 50%; background: var(--gold); font-size: 22px; box-shadow: 0 2px 0 #c89a10; animation: wiggle 1.6s infinite; }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-12deg); } 90% { transform: rotate(12deg); } 95% { transform: rotate(-6deg); } }

.visiting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  padding: 8px 8px 8px 14px;
  border-radius: 14px;
  background: #fff3c4;
  font-weight: 700;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

.tools { display: flex; gap: 8px; overflow-x: auto; margin: 0 0 10px; min-height: 0; }
.tool {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--cream);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.14);
  font-size: 14px;
}

/* The field: plots of soil. */
.field {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 12px;
  border-radius: 22px;
  background: rgba(63, 127, 55, 0.35);
}
.plot {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 16px;
  /* Furrows. */
  background:
    repeating-linear-gradient(180deg, transparent 0 14px, rgba(0, 0, 0, 0.09) 14px 17px),
    radial-gradient(circle at 30% 25%, var(--soil) 0, var(--soil-2) 100%);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.18), 0 3px 0 rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
}
.plot:active { transform: scale(0.96); }
.plot .crop { font-size: clamp(30px, 11vw, 52px); line-height: 1; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.2)); }
.plot.seed .crop { font-size: 34px; color: #e9d3b3; letter-spacing: 6px; }
.plot.sprout .crop { font-size: clamp(24px, 8vw, 36px); }
.plot.ripe { box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.18), 0 3px 0 rgba(0, 0, 0, 0.15), 0 0 0 3px var(--gold); }
.plot.ripe .crop { animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) scale(1.05); } }
.plot.empty .label, .plot.land .label { position: absolute; bottom: 8px; left: 0; right: 0; font-size: 12px; font-weight: 700; color: #f6e5cc; }
.plot.empty .label { position: static; font-size: 30px; color: rgba(255, 240, 220, 0.6); }
.plot .time {
  position: absolute;
  left: 6px;
  bottom: 12px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.plot.ripe .time { background: var(--gold); color: #5a3d00; }
.plot .bar { position: absolute; left: 8px; right: 8px; bottom: 5px; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, 0.3); }
.plot .bar span { display: block; height: 100%; border-radius: 2px; background: #9be36c; }
.plot .troubles { position: absolute; top: 4px; right: 4px; display: flex; gap: 2px; font-size: 20px; font-style: normal; animation: shake 1.2s infinite; }
.plot .troubles i { font-style: normal; }
.plot .troubles i.mine { opacity: 0.5; }
@keyframes shake { 0%, 90%, 100% { transform: translateX(0); } 93% { transform: translateX(-2px); } 97% { transform: translateX(2px); } }
.plot.land { background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.16) 0 10px, transparent 10px 20px), var(--grass-2); flex-direction: column; }
.plot.land .crop { font-size: 34px; color: #fff; }
.plot.land .time { position: static; margin-top: 4px; background: rgba(0, 0, 0, 0.25); }
.plot.land .label { position: static; color: #fff; }
.plot.land.locked { opacity: 0.75; }
.hint { color: #fff; text-align: center; }

/* Lists: the barn, neighbours, news. */
.list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: var(--cream);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}
.item .emoji { font-size: 32px; flex: 0 0 auto; }
.item .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .info b { font-size: 16px; overflow-wrap: anywhere; }
.item .info small { color: var(--muted); font-size: 13px; }
.neighbour { cursor: pointer; }
.none { padding: 24px 16px; border-radius: 16px; background: rgba(255, 250, 240, 0.85); text-align: center; color: var(--muted); }
.row { display: flex; gap: 10px; justify-content: center; }

/* Tabs. */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--cream);
  box-shadow: 0 -2px 0 rgba(0, 0, 0, 0.08);
}
.tabs button {
  position: relative;
  flex: 1;
  max-width: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border: 0;
  border-radius: 12px;
  background: none;
  font-size: 12px;
}
.tabs button span { font-size: 24px; }
.tabs button.on { background: #ffe9b8; }
.badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 24px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  font-style: normal;
  line-height: 18px;
}

/* Sheets from the bottom. */
.sheet-back { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; background: rgba(30, 20, 10, 0.4); }
.sheet {
  width: min(560px, 100%);
  max-height: 85dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--cream);
  animation: up 200ms ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin: 0; font-size: 19px; text-align: center; }
.seeds { display: flex; flex-direction: column; gap: 8px; }
.seed {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
  text-align: left;
}
.seed .emoji { font-size: 32px; }
.seed .info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.seed .info small { color: var(--muted); font-size: 12px; }
.seed .price { font-weight: 800; white-space: nowrap; }
.seed.locked { opacity: 0.45; }
.sheet-text { display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; }
.sheet-text p { margin: 0; font-size: 16px; }
.sheet-text .big { font-size: 56px; }
.pranks { display: flex; gap: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 20;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(45, 42, 38, 0.92);
  color: #fff;
  font-weight: 600;
  text-align: center;
}
.float {
  position: fixed;
  left: 50%;
  top: 40%;
  z-index: 20;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: #fff;
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  pointer-events: none;
  animation: rise 1.4s ease-out forwards;
}
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 100% { opacity: 0; transform: translate(-50%, -80px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
