/* Visual layer for the existing Hay Farm screens. */
body.hay-farm-mode .nav button .ni.tab-art {
  width: 36px;
  height: 36px;
  display: block;
  object-fit: contain;
  margin: 0 auto;
  filter: drop-shadow(0 2px 2px #170f09a0);
  transform: none;
}

body.hay-farm-mode .nav button .nt {
  font-size: clamp(8px, 2.45vw, 10px);
}

body.hay-farm-mode .nav button.on .ni.tab-art {
  transform: scale(1.06);
}

body.hay-farm-mode .nav button:active {
  transform: translateY(1px);
}

@media (max-width: 360px) {
  body.hay-farm-mode .nav button .ni.tab-art { width: 32px; height: 32px; }
  body.hay-farm-mode .nav button .nt { font-size: 8px; }
}
body.hay-farm-mode .hud {
  gap: 9px;
  padding: calc(env(safe-area-inset-top) + 7px) 9px 8px;
  border-radius: 15px;
}

body.hay-farm-mode .hud::after { content: none; }

body.hay-farm-mode .hud .avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-width: 2px;
  border-radius: 11px;
  transform: none;
}

.hud .who { min-width: 0; }

body.hay-farm-mode .hud .nm {
  display: block;
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.15;
}

.hud-level {
  display: flex;
  gap: 5px 8px;
  align-items: baseline;
  flex-wrap: wrap;
  margin-top: 3px;
  color: #e3c6a0;
  font-size: 10px;
}

.hud-progress {
  display: block;
  appearance: none;
  width: 100%;
  max-width: 180px;
  height: 4px;
  margin-top: 4px;
  border: 0;
  border-radius: 5px;
  background: #241911;
}

.hud-progress[hidden] { display: none; }
.hud-progress::-webkit-progress-bar { background: #241911; border-radius: 5px; }
.hud-progress::-webkit-progress-value { background: #adc681; border-radius: 5px; }
.hud-progress::-moz-progress-bar { background: #adc681; border-radius: 5px; }

body.hay-farm-mode .hud .purse {
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

body.hay-farm-mode .hud .coin {
  min-width: 0;
  padding: 4px 7px 4px 3px;
  font-variant-numeric: tabular-nums;
}

body.hay-farm-mode .hud .lang-toggle {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  justify-content: center;
  font-size: 11px;
}

body.hay-farm-mode .hud .lang-toggle:focus-visible {
  outline: 2px solid #e5b96f;
  outline-offset: 2px;
}

body.hay-farm-mode.desktop-preview::before {
  position: static;
  display: table;
  margin: 5px auto 2px;
  padding: 2px 8px;
}

body.hay-farm-mode :is(#s-farm, #s-store, #s-task, #s-orders, #s-ref, #s-wallet) .scrn-head {
  min-height: 100px;
  justify-content: center;
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
  padding: 12px min(31vw, 123px) 12px 15px;
  background:
    radial-gradient(ellipse at 85% 72%, var(--season-gleam, #80663a) 0, transparent 53%),
    linear-gradient(140deg, #503620, #2d221a);
  overflow: hidden;
  text-align: left;
}

body.hay-farm-mode :is(#s-farm, #s-store, #s-task, #s-orders, #s-ref, #s-wallet) .scrn-head :is(h2, .sub) {
  flex: initial;
  max-width: 100%;
  text-align: left;
}

body.hay-farm-mode :is(#s-farm, #s-store, #s-task, #s-orders, #s-ref, #s-wallet) .scrn-head h2::before {
  content: none;
}

@media (max-width: 360px) {
  body.hay-farm-mode .hud { gap: 6px; }
  body.hay-farm-mode .hud .coin { font-size: 11px; }
}
body.hay-farm-mode #s-farm .crop-section {
  background: linear-gradient(155deg, #39291c, #241b16);
  border-color: #6b5034;
}

body.hay-farm-mode #s-farm .crop-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 8px;
}

.crop-head .t, .crop-head .sub { grid-column: 1; }
.crop-head .pill { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

body.hay-farm-mode #s-farm .crop-grid {
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 10px;
}

body.hay-farm-mode #s-farm .crop-card {
  min-width: 0;
  padding: 6px 6px 10px;
  background: linear-gradient(165deg, #483321, #302219);
  border: 1px solid #735335;
  border-radius: 15px;
  box-shadow: 0 4px #211710, inset 0 1px #a67a4840;
}

body.hay-farm-mode #s-farm .crop-card.ready {
  border-color: #d2a35b;
  background: linear-gradient(155deg, #66502d, #3d2a1a);
}

body.hay-farm-mode #s-farm .crop-card.locked {
  opacity: 1;
  background: #30241c;
  border-color: #564332;
}

body.hay-farm-mode #s-farm .plot-scene {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 74px;
  margin-bottom: 4px;
  align-items: flex-end;
  padding-bottom: 11px;
  background: radial-gradient(ellipse at 50% 80%, #bf8b413f, transparent 72%);
}

.plot-scene::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: auto 9% 8px;
  height: 22px;
  border: 1px solid #9d693e;
  border-radius: 50%;
  background: repeating-linear-gradient(108deg, #684125 0 7px, #855532 7px 10px);
  box-shadow: 0 4px #40291c;
}

.plot-empty .plot-scene::before, .locked .plot-scene::before { display: none; }
.locked .plot-scene { filter: saturate(.48); }

body.hay-farm-mode #s-farm .plot-scene .c-img {
  width: 67px;
  height: 62px;
  max-width: 100%;
  filter: drop-shadow(0 4px 2px #2417088c);
  transform-origin: 50% 92%;
}

body.hay-farm-mode #s-farm .crop-card .c-name { font-size: 13px; }
body.hay-farm-mode #s-farm .crop-card .c-status { font-size: 10px; }
body.hay-farm-mode #s-farm .crop-card .pill { max-width: 100%; margin-bottom: 3px; white-space: normal; }
body.hay-farm-mode #s-farm .crop-card.ready .c-status { color: #ffe098; }

.crop-progress {
  appearance: none;
  width: 86%;
  height: 5px;
  margin: 0 0 7px;
  border: 0;
  border-radius: 8px;
  background: #21180f;
}

.crop-progress::-webkit-progress-bar { background: #21180f; border-radius: 8px; }
.crop-progress::-webkit-progress-value { background: #b9c17d; border-radius: 8px; }
.crop-progress::-moz-progress-bar { background: #b9c17d; border-radius: 8px; }

.plot-effect {
  position: absolute;
  z-index: 2;
  bottom: 20px;
  left: 50%;
  color: #ffe6a7;
  font: 800 15px/1 system-ui, sans-serif;
  text-shadow: 0 2px 4px #26180a;
  pointer-events: none;
  animation: farm-rise 680ms ease-out both;
}

.plot-effect-plant { color: #dceda0; font-size: 25px; }
@keyframes farm-rise {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(.8); }
  20% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -38px); }
}

@keyframes farm-sway {
  0%, 100% { transform: rotate(0); }
  32% { transform: rotate(-3deg); }
  67% { transform: rotate(3deg); }
}

@keyframes farm-arrive {
  from { opacity: .72; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.tab-scene {
  position: absolute;
  inset: 0 4px 0 auto;
  width: min(29vw, 118px);
  display: grid;
  place-items: center;
  isolation: isolate;
  pointer-events: none;
}

.tab-scene img {
  display: block;
  width: min(27vw, 108px);
  height: auto;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center 82%;
}

.tab-scene::before {
  content: '';
  position: absolute;
  inset: 12% 0;
  z-index: -1;
  background: radial-gradient(ellipse, #efb95760, transparent 68%);
  opacity: .45;
}

.tab-scene::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 16% 70%, #ffdc90 0 1px, transparent 2px),
    radial-gradient(circle at 24% 32%, #fff2b4 0 1px, transparent 2px),
    radial-gradient(circle at 79% 22%, #ffdc90 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 90% 61%, #fff2b4 0 1px, transparent 2px);
  opacity: 0;
}

.delivery-road {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  height: 132px;
  margin: 8px 10px 0;
  border: 1px solid #856743;
  border-radius: 12px;
  background: linear-gradient(#84885e, #edd39a 60%, #79704a 61%);
  pointer-events: none;
}

.road-hills, .road-hedge, .road-track {
  position: absolute;
  left: 0;
  width: calc(100% + 64px);
}

.road-hills {
  top: 15%;
  bottom: 35%;
  background:
    radial-gradient(ellipse 49px 37px at 44px 100%, #657452 98%, transparent) 0 0 / 128px 100%,
    radial-gradient(ellipse 70px 45px at 88px 100%, #8d9465 98%, transparent) 0 0 / 128px 100%;
  width: calc(100% + 128px);
}

.road-hedge {
  bottom: 34%;
  height: 27px;
  background:
    radial-gradient(ellipse at 30% 100%, #78845a 0 29%, transparent 32%),
    radial-gradient(ellipse at 67% 100%, #4f6945 0 37%, transparent 40%);
  background-size: 64px 100%;
}

.road-track {
  top: 64%;
  bottom: 0;
  background:
    repeating-linear-gradient(90deg, transparent 0 18px, #d9ae75 19px 24px, transparent 26px 48px) center 55% / auto 2px no-repeat,
    linear-gradient(#b69360 0 8%, #a8784b 9% 87%, #795937 88%);
  border-top: 2px solid #e0b681;
}

.road-vehicle {
  position: absolute;
  width: 86px;
  height: 86px;
  left: -43px;
  bottom: 0;
  transform-origin: 50% 85%;
}

.road-vehicle::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: auto 6px 7px;
  height: 10px;
  border-radius: 50%;
  background: #33251580;
  filter: blur(2px);
}

.road-vehicle img { width: 100%; height: 100%; display: block; }

.delivery-countdown {
  justify-content: center;
  padding: 10px 12px;
  color: #f3d19b;
  font-weight: 700;
}

.road-wheel {
  position: absolute;
  box-sizing: border-box;
  width: 8%;
  height: 9%;
  border: 1px solid #743d1c;
  border-radius: 50%;
  background: repeating-conic-gradient(#663a22 0 30deg, #f1b86a 32deg 58deg, #663a22 60deg);
}

.road-wheel-rear { left: 13%; top: 68%; }
.road-wheel-front { left: 43%; top: 76%; }

.road-dust {
  position: absolute;
  width: 59px;
  height: 21px;
  left: -78px;
  bottom: 3px;
  background:
    radial-gradient(circle at 19% 61%, #e7ba83 0 3px, transparent 5px),
    radial-gradient(circle at 52% 46%, #e2b986 0 5px, transparent 8px),
    radial-gradient(circle at 83% 72%, #f1ca99 0 5px, transparent 8px);
  opacity: 0;
}

.road-journey { position: absolute; inset: 0 44px 12px; }
.road-position { position: absolute; left: var(--trip-progress, 0%); bottom: 0; }
.road-stop {
  position: absolute;
  z-index: 1;
  top: 3px;
  width: 64px;
  text-align: center;
  color: #fff0ca;
  font-size: 9px;
  font-weight: 800;
  text-shadow: 0 1px 3px #22170c;
}
.road-stop img { display: block; width: 49px; height: 49px; margin: auto; object-fit: contain; }
.road-stop-farm { left: 5px; }
.road-stop-town { right: 5px; }
.has-arrived .road-stop-town { color: #fff3ad; text-shadow: 0 0 7px #412409, 0 1px 2px #22170c; }
.road-route-meter { position: absolute; inset: auto 30px 6px; height: 4px; border-radius: 5px; background: #54391f; }
.road-route-meter i { display: block; width: var(--trip-progress, 0%); height: 100%; border-radius: inherit; background: #ffe2a0; }
.farm-order-deliver[hidden] { display: none; }
.farm-order-deliver[data-act="town-order-claim"] { background: #dfa956; color: #302114; }

.season-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 5px 9px;
  padding: 5px 10px;
  border: 1px solid #735335;
  border-radius: 11px;
  background: #38271c;
  color: #f1dab1;
  font-size: 11px;
  font-weight: 700;
}
.season-picker select {
  max-width: 63%;
  padding: 6px;
  font: inherit;
  color: #ffe6bc;
  background: #493124;
  border: 1px solid #98724e;
  border-radius: 7px;
}
body[data-farm-season="spring"] {
  --season-gleam: #93634f;
  --weather-art: radial-gradient(ellipse at 20% 26%, #eaa3af 0 2px, transparent 3px), radial-gradient(ellipse at 66% 73%, #f3bfba 0 2px, transparent 3px);
  --weather-size: 43px 46px;
  --weather-motion: weather-petals 3.8s linear infinite;
}
body[data-farm-season="summer"] {
  --season-gleam: #aa793f;
  --weather-art: radial-gradient(ellipse at 83% 0%, #ffd280, transparent 65%);
  --weather-motion: weather-sun 5s ease-in-out infinite;
}
body[data-farm-season="autumn"] {
  --season-gleam: #657379;
  --weather-art: linear-gradient(109deg, transparent 44%, #d0e9ef 49% 51%, transparent 55%);
  --weather-size: 13px 27px;
  --weather-motion: weather-rain .62s linear infinite;
}
body[data-farm-season="winter"] {
  --season-gleam: #7c8281;
  --weather-art: radial-gradient(ellipse at 30% 68%, #e0eeeb, transparent 64%);
  --weather-motion: weather-mist 5s ease-in-out infinite;
}
body[data-farm-season="autumn"] .delivery-road { background: linear-gradient(#53666c, #a4a49a 62%, #78734d 63%); }
body[data-farm-season="autumn"] .road-dust { display: none; }
body[data-farm-season="winter"] .delivery-road { background: linear-gradient(#838d92, #c1c5b3 62%, #7d775a 63%); }
.delivery-road::after, #s-farm .weather-layer {
  position: absolute;
  content: '';
  z-index: 3;
  inset: 0;
  pointer-events: none;
  background: var(--weather-art, none);
  background-size: var(--weather-size, auto);
  opacity: .22;
}
@keyframes weather-petals { to { background-position: -43px 46px; } }
@keyframes weather-rain { to { background-position: -13px 27px; } }
@keyframes weather-sun { 50% { opacity: .43; } }
@keyframes weather-mist { 50% { transform: translateX(18px); opacity: .36; } }

@keyframes scene-enter {
  from { opacity: .45; transform: translate3d(10px, 5px, 0) scale(.91); }
  68% { opacity: 1; transform: translate3d(-1px, -2px, 0) scale(1.035); }
  to { opacity: 1; transform: none; }
}

@keyframes scene-sway {
  0%, 100% { transform: none; }
  28% { transform: translateY(-2px) rotate(-2deg); }
  72% { transform: translateY(-1px) rotate(1.5deg); }
}

@keyframes scene-light {
  0%, 100% { opacity: .45; transform: scale(1); }
  45% { opacity: .95; transform: scale(1.16); }
}

@keyframes scene-motes {
  from { opacity: 0; transform: translateY(7px); }
  40% { opacity: .85; }
  to { opacity: 0; transform: translateY(-9px); }
}

@keyframes road-pan-48 { to { transform: translateX(-48px); } }
@keyframes road-pan-64 { to { transform: translateX(-64px); } }
@keyframes road-pan-128 { to { transform: translateX(-128px); } }
@keyframes wheel-roll { to { transform: rotate(360deg); } }
@keyframes truck-bounce {
  32% { transform: translateY(-2px) rotate(-.8deg); }
  66% { transform: translateY(-1px) rotate(.6deg); }
}
@keyframes road-wake {
  from { opacity: 0; transform: translateX(7px) scale(.65); }
  40% { opacity: .72; }
  to { opacity: 0; transform: translate(-14px, -4px) scale(1.22); }
}

@media (prefers-reduced-motion: no-preference) {
  .road-position { transition: left .8s linear; }
  .delivery-road.has-arrived .road-position { transition: none; }
  .delivery-road::after, #s-farm .weather-layer { animation: var(--weather-motion, none); }
  .delivery-road.is-driving .road-hills { animation: road-pan-128 12s linear infinite; }
  .delivery-road.is-driving .road-hedge { animation: road-pan-64 2.1s linear infinite; }
  .delivery-road.is-driving .road-track { animation: road-pan-48 .62s linear infinite; }
  .delivery-road.is-driving .road-wheel { animation: wheel-roll .48s linear infinite; }
  .delivery-road.is-driving .road-vehicle { animation: truck-bounce .65s ease-in-out infinite; }
  .delivery-road.is-driving .road-dust { animation: road-wake .8s ease-out infinite; }
  .plot-growing .plot-scene .c-img { animation: farm-sway 1800ms ease-in-out; }
  .screen.on.screen-arriving { animation: farm-arrive 180ms ease-out; }
  .screen.on .tab-scene img {
    animation: scene-enter 510ms ease-out, scene-sway 2350ms 510ms ease-in-out 2;
  }
  .screen.on .tab-scene::before { animation: scene-light 1700ms ease-in-out 2; }
  .screen.on .tab-scene::after { animation: scene-motes 1400ms 220ms ease-out 2; }
  body.hay-farm-mode .nav button.on .tab-art { transition: transform 160ms ease-out; }
}

@media (prefers-reduced-motion: reduce) {
  .plot-effect { display: none; }
  body.hay-farm-mode :is(.pill, .nav button, .screen, #sheet, #scrim, #toast) {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
