/* Farm chrome: warm paper, dark leaf ink and one clear next action.
   The canvas keeps its existing world, lighting, camera and economics. */
body[data-game="farm"] {
  --farm-ink: #244b36;
  --farm-muted: #655c49;
  --farm-paper: #fffbef;
  --farm-rim: #d9c9a5;
  --farm-shadow: 0 4px 12px rgba(64, 49, 26, .16), inset 0 1px 0 #fffdf6;
  --farm-header: calc(112px + env(safe-area-inset-top));
  --farm-bottom: env(safe-area-inset-bottom, 0px);
}

.hud-en { display: none; }
html:lang(en) .hud-en { display: inline; }
html:lang(en) .hud-zh { display: none; }

body[data-game="farm"] :where(button, a, input, select, textarea):focus-visible {
  outline: 3px solid #285c3e;
  outline-offset: 3px;
}
body[data-game="farm"] ::selection { background: #d8e5be; color: #213e2b; }
body[data-game="farm"] :where(input, textarea) { caret-color: #285c3e; }
body[data-game="farm"] :where(.modal-body, #isoPalette) {
  scrollbar-color: #9caa83 #f7f0dd;
  scrollbar-width: thin;
}

#topbar {
  min-height: var(--farm-header);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: center;
  gap: 8px 12px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 10px;
  background: linear-gradient(180deg, #fffcf3, #f4ecd8);
  border-bottom: 1px solid #d5c5a1;
  box-shadow: 0 3px 14px rgba(69, 58, 31, .10);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  z-index: 21;
}
#brandbar.brand-cluster { min-width: 0; gap: 10px; }
.brandbar-logo-link { display: flex; flex: 0 1 76px; min-width: 52px; min-height: 44px; align-items: center; }
.brandbar-logo { width: 76px; max-width: 100%; height: auto; max-height: 38px; object-fit: contain; }
.farm-identity { display: flex; flex-direction: column; gap: 2px; min-width: 0; color: var(--farm-ink); white-space: nowrap; }
.farm-identity-zh { font: 400 21px/1.1 var(--font-display); letter-spacing: .05em; }
.farm-identity-en { font: 700 12px/1.3 var(--font-en); letter-spacing: .01em; }
.hud-level { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 0 0 auto; }
.topbar-level { color: #244b36; background: none; padding: 0; font-size: 11px; }
.hud-xp { width: 34px; height: 5px; border-radius: 3px; background: #d8d8b9; overflow: hidden; }
.hud-xp > span { display: block; width: 0; height: 100%; background: #507441; transition: width .25s ease-out; }
#brandbar .weather-chip, #brandbar [id*="weather"] { display: none; }
#topbar .farm-home {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 8px;
  gap: 3px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  color: var(--farm-ink);
  font: 600 11px/1.3 var(--font-zh);
  white-space: nowrap;
}
.farm-home .ui-icon { width: 18px; height: 18px; }
#topbar .topbar-right { grid-column: 1 / -1; gap: 6px; display: flex; width: 100%; min-width: 0; }
.topbar-cur {
  position: relative;
  flex: 1 1 0;
  min-width: 70px;
  min-height: 44px;
  gap: 7px;
  padding: 5px 9px;
  border: 1px solid #dcc796;
  border-radius: 13px;
  box-shadow: inset 0 1px 0 #fffef8, 0 2px 4px rgba(95, 74, 28, .06);
  color: #624815;
  background: #fff6db;
  justify-content: center;
}
.topbar-cur.points { border-color: #d0ceb1; background: #f2f2df; color: #405039; }
.topbar-cur.currency-tappable::after { display: none; }
.topbar-cur .icon { width: 18px; height: 18px; }
.currency-info { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.currency-name { font: 500 11px/1.1 var(--font-zh); white-space: nowrap; }
.topbar-cur .value { font: 700 14px/1.1 var(--font-num); font-variant-numeric: tabular-nums; }
#topbar :where(.member-btn, .today-button, .hamburger-button) { min-width: 44px; width: 44px; min-height: 44px; height: 44px; padding: 6px; border-radius: 13px; box-shadow: none; animation: none; }
#topbar .member-btn { background: #f9f4e5; border: 1px solid var(--farm-rim); color: #425238; overflow: hidden; }
#topbar .member-name { display: none; }
#topbar .today-button { background: #f5e7bd; border: 1px solid #d6bf88; color: #6b4b17; }
#topbar .hamburger-button { background: #e4ead5; border: 1px solid #b6c29e; color: #244b36; }
.hamburger-button::after { inset: 0; }

.harvest-status-bar {
  top: calc(var(--farm-header) + 10px);
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  max-width: min(420px, calc(100% - 128px));
  width: max-content;
  z-index: 20;
}
.harvest-status-bar .harvest-status-center {
  min-width: 44px;
  min-height: 44px;
  padding: 9px 13px;
  border-radius: 14px;
  background: #fff9e9;
  border: 1px solid #d7c59a;
  box-shadow: var(--farm-shadow);
  color: #4b5433;
  justify-content: center;
  line-height: 1.5;
  cursor: default;
}
.harvest-status-text { font: 500 12px/1.5 var(--font-zh); white-space: normal; text-align: center; }
.harvest-status-bar .harvest-status-center.is-actionable {
  color: #fffdf1;
  background: linear-gradient(180deg, #4b7548, #365b36);
  border-color: #2b512f;
  box-shadow: 0 4px 10px rgba(48, 72, 29, .22), inset 0 1px 0 rgba(247, 255, 216, .28);
  cursor: pointer;
}
.harvest-status-center.is-actionable::after { color: #ffefb5; position: static; flex: 0 0 auto; }
.harvest-status-bar .harvest-status-center.is-warning { background: #80502d; border-color: #653d22; color: #fff8e6; }
.harvest-status-center:disabled { opacity: 1; }
.harvest-status-center.is-working::before { content: ''; width: 7px; height: 7px; background: #64854d; border-radius: 50%; flex: 0 0 auto; }

#isoZoom, #isoLeftUI { gap: 6px !important; }
#isoZoom > button, #isoLeftUI > button {
  width: 44px !important;
  min-width: 44px;
  height: 44px !important;
  min-height: 44px;
  border: 1px solid #d5c69e !important;
  border-radius: 14px !important;
  background-color: #fff8e6 !important;
  color: #325034 !important;
  box-shadow: var(--farm-shadow) !important;
}
#isoZoom > button:hover, #isoLeftUI > button:hover { background-color: #f4e9cb !important; }
#isoZoom > button:active, #isoLeftUI > button:active { transform: translateY(1px) scale(.96); }

#bottombar {
  left: 12px;
  right: 12px;
  bottom: calc(12px + var(--farm-bottom));
  max-width: 456px;
  padding: 5px 8px;
  gap: 4px;
  border: 1px solid #d2c19b;
  border-radius: 23px;
  background: #fffaec;
  box-shadow: 0 6px 20px rgba(56, 49, 25, .20), inset 0 1px 0 #fff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
#bottombar .action-btn { min-width: 44px; min-height: 55px; gap: 4px; border-radius: 16px; padding: 5px 3px; }
#bottombar .action-label { font: 600 12px/1.2 var(--font-zh); letter-spacing: 0; }
#bottombar .action-btn:hover { background: #f0ecd7; }
#bottombar .action-btn:active { background: #e2e9ce; transform: scale(.96); }
#bottombar [data-action="shop"] { background: #e9edda; }
#bottombar [data-action="shop"] .action-icon { color: #33583a; }
body:not(.iso-build-fullscreen) #isoBuildBtn { bottom: calc(90px + var(--farm-bottom)) !important; }
body:not(.iso-build-fullscreen) #isoCommunityBtn { bottom: calc(90px + var(--farm-bottom)) !important; right: max(116px, calc((100% - 480px) / 2 + 116px)) !important; }
body:not(.iso-build-fullscreen) #isoDriveOutBtn { bottom: calc(144px + var(--farm-bottom)) !important; }
#isoBuildBtn, #isoCommunityBtn, #isoDriveOutBtn { min-width: 44px; min-height: 44px; border: 1px solid #365a36 !important; border-radius: 15px !important; box-shadow: 0 3px 9px rgba(47, 67, 30, .23), inset 0 1px 0 rgba(247, 255, 216, .24) !important; font: 600 13px/1.2 var(--font-zh) !important; padding: 10px 13px !important; background: #3e653f !important; }
.iso-build-fullscreen #isoBuildBtn { background: #80502d !important; }
#isoCommunityBtn { color: #294c36 !important; background: #f9f2df !important; border-color: #bdbb94 !important; }
#isoDriveOutBtn { background: #80502d !important; }
.storekeeper { left: max(14px, calc((100% - 480px) / 2 + 14px)); bottom: calc(90px + var(--farm-bottom)); width: 44px; height: 44px; border: 1px solid #c8bb92; background: #f8eed3; }
.storekeeper .storekeeper-avatar { width: 44px; height: 44px; }
body.modal-open :where(#isoZoom, #isoLeftUI, #isoBuildBtn, #isoCommunityBtn, #isoDriveOutBtn, #harvestStatusBar, #storekeeper) { visibility: hidden; }

#isoPalette { background: #fff9e9 !important; border-top: 1px solid #d1be91; padding-bottom: calc(9px + var(--farm-bottom)) !important; }
#isoPalette button { min-width: 44px; min-height: 44px; }
#isoPalette button[data-type], #isoPalette button[data-brush] { border-radius: 13px !important; box-shadow: 0 2px 5px rgba(76, 66, 37, .10); }
#isoBuildHint { top: calc(var(--farm-header) + 14px) !important; padding: 0 58px; }
#isoBuildHint > span { display: inline-block; font-size: 12px; background: #375337 !important; color: #fff8e5; }

.modal-content { border: 1px solid #d5c59d; width: calc(100% - 24px); max-width: 440px; padding: 27px 20px 20px; border-radius: 25px; background: #fffbf0; box-shadow: 0 16px 48px rgba(52, 43, 23, .30), inset 0 1px 0 #fff; }
.modal-backdrop { background: rgba(42, 46, 27, .46); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal-title { width: auto; min-width: 0; max-width: calc(100% - 34px); margin: 3px 34px 18px 0; padding: 0; border-radius: 0; background: none; box-shadow: none; text-shadow: none; text-align: left; font-size: 25px; font-weight: 400; letter-spacing: .02em; color: #2c5034; text-wrap: balance; }
.modal-close-x { width: 44px; height: 44px; top: 9px; right: 9px; box-shadow: 0 2px 6px rgba(80, 60, 28, .16), inset 0 1px 0 #fff; border: 1px solid #e0d0ad; background: #fff8e9; }
.modal-close-x::after { inset: 0; }
.nav-menu-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.nav-menu-item { min-width: 44px; min-height: 86px; padding: 11px 5px; gap: 9px; font-size: 12px; line-height: 1.4; box-shadow: 0 2px 5px rgba(74, 61, 30, .08), inset 0 1px 0 #fff; border: 1px solid #e2d5b7; background: #faf3e3; }
.nav-menu-item:hover { background: #edf0db; border-color: #b0bd95; }
.nav-menu-label { overflow-wrap: anywhere; }
.nav-menu-item[data-nav="orders"] { color: #2a5034; background: #e8edd8; border-color: #bdc7a4; }
.nav-menu-item[data-nav="guide"] { color: #5b4c26; background: #f5ebcd; }
.modal-body :where(button, [role="button"], select) { min-height: 44px; min-width: 44px; }
.modal-body :where(button, [role="button"]):disabled { cursor: not-allowed; filter: saturate(.55); }
.modal-body :where(input, textarea, select) { font-size: 16px; }
.seed-card { position: relative; }
.seed-card-select { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: inherit; background: transparent; cursor: pointer; z-index: 1; }
.seed-card .seed-fill-btn { position: relative; z-index: 2; }
.seed-card-select:focus-visible { outline-offset: -4px !important; }
.tutorial-step { border: 0; background: #f5efdF; }
.tutorial-steps { gap: 10px; }
.tutorial-step-body { color: #655a43; line-height: 1.7; }
.email-nudge { top: var(--farm-header); }
.toast-stack { top: calc(var(--farm-header) + 112px); }
.pwa-install-banner { bottom: calc(200px + var(--farm-bottom)); }
.pwa-install-action, .pwa-install-close { min-width: 44px; min-height: 44px; }
#visitBar { top: calc(var(--farm-header) + 10px); max-width: calc(100% - 120px); }
.statusbar, .status-level, .status-title, .status-xp-text { color: #2f5634; }
.splash .splash-login.splash-login--hero .splash-login-en { font-size: 12px; }
.splash .splash-reward-main b { color: #a04423; }
.splash .splash-reward-en { font-size: 12px; color: #6b542d; }

@media (min-width: 700px) {
  body[data-game="farm"] { --farm-header: calc(70px + env(safe-area-inset-top)); }
  #topbar { grid-template-columns: minmax(0, 1fr) auto auto; padding-inline: 20px; column-gap: 20px; min-height: var(--farm-header); }
  #topbar .topbar-right { grid-column: 2; grid-row: 1; width: auto; }
  #topbar .farm-home { grid-column: 3; grid-row: 1; }
  .brandbar-logo-link { flex-basis: 104px; }
  .brandbar-logo { width: 104px; max-height: 40px; }
  .farm-identity { flex-direction: row; align-items: baseline; gap: 12px; }
  .farm-identity-en { font-size: 16px; }
  .topbar-cur { min-width: 112px; }
  #topbar .farm-home { font-size: 12px; }
  .harvest-status-text { font-size: 13px; }
  body:not(.iso-build-fullscreen) #isoCommunityBtn { right: 116px !important; }
  .storekeeper { left: 20px; }
  #bottombar { max-width: 456px; }
}
@media (min-width: 700px) and (max-width: 1050px) {
  #topbar { padding-inline: 12px; gap: 10px; }
  .brandbar-logo-link { flex-basis: 66px; }
  .brandbar-logo { width: 66px; }
  .farm-identity { flex-direction: column; gap: 2px; }
  .farm-identity-en { font-size: 12px; }
  .farm-identity-zh { font-size: 19px; }
  .topbar-cur { min-width: 88px; }
}
@media (max-width: 375px) {
  #topbar { padding-inline: 10px; column-gap: 6px; }
  #brandbar.brand-cluster { gap: 7px; }
  .brandbar-logo-link { flex-basis: 62px; min-width: 52px; }
  .farm-identity-zh { font-size: 19px; }
  .farm-identity-en { font-size: 11px; }
  #topbar .topbar-right { gap: 5px; }
  .topbar-cur { padding-inline: 6px; gap: 4px; }
  .currency-name { font-size: 11px; }
  .topbar-cur .icon { width: 16px; height: 16px; }
  .harvest-status-text { font-size: 11px; }
  .modal-content { padding-inline: 15px; }
}
@media (max-height: 540px) and (orientation: landscape) {
  body[data-game="farm"] { --farm-header: calc(64px + env(safe-area-inset-top)); }
  #topbar { grid-template-columns: minmax(0, 1fr) auto auto; }
  #topbar .topbar-right { grid-column: 2; grid-row: 1; width: auto; }
  #topbar .farm-home { grid-column: 3; grid-row: 1; }
  #brandbar .brandbar-logo-link, .hud-level { display: none; }
  .farm-identity-zh { font-size: 18px; }
  .topbar-cur { min-width: 78px; }
  #bottombar { max-width: 340px; bottom: calc(8px + var(--farm-bottom)); }
  #bottombar .action-btn { min-height: 44px; }
  #bottombar .action-icon .ui-icon { width: 18px; height: 18px; }
  body:not(.iso-build-fullscreen) #isoBuildBtn, body:not(.iso-build-fullscreen) #isoCommunityBtn, .storekeeper { bottom: calc(12px + var(--farm-bottom)) !important; }
  body:not(.iso-build-fullscreen) #isoCommunityBtn { bottom: calc(66px + var(--farm-bottom)) !important; right: 14px !important; }
  .harvest-status-bar { top: calc(var(--farm-header) + 7px); }
  .pwa-install-banner { bottom: calc(120px + var(--farm-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  body[data-game="farm"] *, body[data-game="farm"] *::before, body[data-game="farm"] *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
