:root {
  color-scheme: light;
  font-family: 'Trebuchet MS', system-ui, sans-serif;
  color: #38260f;
  background: #8db758 url("./assets/ground.webp") 0 0 / var(--ground-size, 100vw) repeat;
  image-rendering: pixelated;
  font-synthesis: none;
  --parchment: #efddb1;
  --dark: #382910;
  --outline: #805d32;
  --light: #fff2c8;
  --green: #2c720f;
  --row: 62px;
  --space: clamp(5px, 1.4dvh, 11px);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body { min-width: 260px; }
html, body, dialog, dialog * { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
[hidden] { display: none !important; }
img { display: block; object-fit: contain; pointer-events: none; }
button {
  border: 1px solid #684719;
  border-radius: 5px;
  min-height: 36px;
  padding: 4px 7px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  font-size: clamp(10px, 1.31vw, 14px);
  font-weight: 850;
  line-height: 1.12;
  background: linear-gradient(#fff0c6, #e5c18c);
  box-shadow: inset 0 1px 0 #fff5d6, 0 2px 0 #614c2870;
  touch-action: manipulation;
}
button:not(:disabled):hover { filter: brightness(1.09); }
button:not(:disabled):active { transform: translateY(1px); }
button:focus-visible, canvas:focus-visible { outline: 3px solid #fff6a3; outline-offset: 2px; }
button:disabled { cursor: default; }
#game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(248px, 29%);
  height: 100dvh;
  padding: var(--space);
  gap: clamp(7px, 1.25vw, 16px);
  overflow: hidden;

}
.garden { min-height: 0; min-width: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.hud { display: flex; align-items: center; gap: clamp(5px, 1vw, 13px); min-width: 0; }
.gear {
  width: clamp(38px, 4vw, 54px);
  height: clamp(38px, 4vw, 54px);
  padding: 0;
  flex: none;
  font-family: system-ui, sans-serif;
  font-size: clamp(24px, 3.3vw, 39px);
  color: #284729;
  background: #f6f0d5;
  text-shadow: none;
  border: 1px solid #617849;
  box-shadow: 0 2px 0 #728950;
}
.wallet {
  display: flex;
  align-items: center;
  position: relative;
  flex: 0 1 clamp(70px, 12vw, 144px);
  height: clamp(28px, 3.5vw, 41px);
  min-width: 64px;
  border: 1px solid #95733e;
  border-radius: 7px;
  background: #fff4cc;
  color: #49371a;
  box-shadow: 0 2px 0 #867044;
  font-size: clamp(13px, 2vw, 23px);
  line-height: 1;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.wallet.gem { color: #4b325d; background: #f3e8f6; border-color: #88669c; box-shadow: 0 2px 0 #806090; }
.wallet img { width: 31%; height: 140%; margin-left: -4%; object-fit: contain; flex: none; }
.wallet output { padding: 0 3px; text-align: center; flex: 1; }
.event {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 4px 7px;
  min-width: 0;
  flex: 0 1 clamp(175px, 25vw, 310px);
  border: 1px solid #718154;
  border-inline-start: 3px solid color-mix(in srgb, var(--event-color, #d6de96) 65%, #456337);
  border-radius: 8px;
  background: #f0f4cf;
  box-shadow: 0 2px 0 #748850;
  color: #324327;
  font-size: clamp(9px, 1.3vw, 14px);
  line-height: 1.14;
}
.event div { min-width: 0; color: #314c24; }
.event strong { letter-spacing: .04em; }
.event small { display: block; margin-top: 2px; font-size: clamp(8px, 1vw, 12px); font-weight: 800; }
.event time { white-space: nowrap; font-weight: 900; font-variant-numeric: tabular-nums; }
.lawn-wrap { position: relative; display: grid; place-items: center; min-height: 0; min-width: 0; padding: 2px 0; container-type: size; }
.tutorial-guide {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: max-content;
  max-width: calc(100% - 16px);
  padding: 8px 12px;
  border: 2px solid #ffe28c;
  border-radius: 7px;
  box-shadow: 0 3px 0 #1d3018;
  background: #254423;
  color: #fffbe7;
  font-size: clamp(16px, 2vw, 24px);
  line-height: 1.15;
  font-weight: 900;
  text-align: center;
  pointer-events: none;
  transform: translate(var(--guide-x, 0px), var(--guide-y, 0px)) translate(-50%, -100%);
}
.tutorial-guide::after {
  content: '';
  position: absolute;
  left: var(--pointer-x, 50%);
  bottom: -10px;
  width: 19px;
  height: 9px;
  background: #ffe28c;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform: translateX(-50%);
}
.tutorial-guide[data-below] { transform: translate(var(--guide-x), var(--guide-y)) translateX(-50%); }
.tutorial-guide[data-below]::after {
  top: -10px;
  bottom: auto;
  transform: translateX(-50%) rotate(180deg);
}
.tutorial-guide[data-side] { transform: translate(var(--guide-x), var(--guide-y)) translate(-50%, -50%); }
.tutorial-guide[data-side]::after { top: calc(var(--pointer-y) - 4.5px); bottom: auto; }
.tutorial-guide[data-side="left"]::after { left: auto; right: -14px; transform: rotate(-90deg); }
.tutorial-guide[data-side="right"]::after { left: -14px; transform: rotate(90deg); }
button.tutorial-target { outline: 2px solid #f1ca62; outline-offset: -3px; box-shadow: 0 0 0 1px #704b21; }
button.tutorial-target:focus-visible { outline: 3px solid #fff6a3; outline-offset: 2px; }
#field {
  width: min(100cqw, 150cqh);
  aspect-ratio: 3 / 2;
  display: block;
  touch-action: none;
  cursor: grab;
  mask-image: linear-gradient(90deg, transparent, #000 1.8%, #000 98.2%, transparent),
    linear-gradient(transparent, #000 2.7%, #000 97.3%, transparent);
  mask-composite: intersect;
}
#field:focus-visible { outline: none; }
#field.dragging { cursor: grabbing; }
.boosts { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; min-height: 39px; min-width: 0; }
.boosts > [data-action="reward"] {
  display: grid;
  grid-template-columns: 20px auto;
  align-items: center;
  column-gap: 4px;
  background: #f3efd2;
  border-color: #89965d;
  box-shadow: 0 2px 0 #829359;
}
.boosts img { width: 19px; grid-row: span 2; }
.boosts small:empty, #notice:empty { display: none; }
.boosts small { color: #305c11; font-size: 10px; }
#notice { color: #fff7d1; background: #274511; border-radius: 4px; padding: 4px 7px; font-size: 11px; }
.workshop {
  display: grid;
  align-self: start;
  max-height: 100%;
  min-height: 0;
  min-width: 0;
  gap: 6px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid #7c8d58;
  border-radius: 9px;
  padding: 6px;
  background: #ebe9cb;
  box-shadow: 0 3px 0 #728950;
}
.workshop nav { display: flex; align-items: stretch; gap: 3px; min-width: 0; }
.workshop nav button, .garage-tabs button {
  min-width: 0;
  flex: 1;
  padding-inline: 4px;
  border: 1px solid #a6a477;
  background: #f6f1d7;
  box-shadow: none;
}
.workshop nav button { font-size: clamp(9px, 1.05vw, 14px); }
.workshop nav #quantity { flex: 0 0 auto; min-width: 29px; }
.workshop nav #quantity[hidden] { display: none; }
.workshop nav button[aria-pressed="true"],
.workshop .garage-tabs button[aria-pressed="true"], .green {
  color: #fffdf1;
  background: #315f36;
  border-color: #254d2a;
  box-shadow: none;
}
.green:disabled { color: #3b4e35; background: #dce1c5; border-color: #adb58d; }
  .panel { overflow: auto; overscroll-behavior: contain; min-height: 0; scrollbar-width: thin; scrollbar-color: #6f7b29 #bccb5c; }
.rows { display: grid; gap: var(--space); padding: 2px 2px 3px; }
.parchment {
  background: #fff8e1;
  border: 1px solid #c1b788;
  border-radius: 5px;
  box-shadow: 0 1px 0 #b6a875;
}
.row {
  display: grid;
  grid-template-columns: clamp(25px, 3.7vw, 43px) minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(4px, .8vw, 9px);
  padding: 3px 5px;
  min-height: var(--row);
}
.row img, .prestige > img { width: 100%; max-height: 44px; }
.row strong { display: block; font-size: clamp(12px, 1.5vw, 17px); line-height: 1.08; }
.row small, .prestige small { display: block; font-size: clamp(9px, 1.08vw, 12px); font-weight: 700; line-height: 1.15; }
.row .level { color: #356523; margin: 2px 0; }
.row button { min-width: clamp(50px, 6vw, 75px); align-self: center; }
.row button span { display: flex; align-items: center; justify-content: center; margin-top: 2px; gap: 2px; }
.row button span img { width: 13px; height: 13px; }
.upgrade-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; padding: 1px 1px 4px; }
.upgrade-grid .row {
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  justify-items: start;
  gap: 5px;
  padding: 8px;
}
.upgrade-grid .row > img {
  width: clamp(22px, 3vw, 44px);
  height: clamp(22px, 3vw, 44px);
}
.upgrade-grid .row > div { min-width: 0; }
.upgrade-grid .row > button {
  align-self: end;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  width: 100%;
}
.upgrade-grid .row > button span { margin: 0; }
.upgrade-grid .row > button.tutorial-target {
  background: #f8d36b;
  color: #233b19;
  border-color: #6b4b13;
  animation: tutorial-buy-pulse 1s ease-in-out infinite alternate;
}
@keyframes tutorial-buy-pulse {
  from { box-shadow: inset 0 0 0 1px #fff3b8, 0 0 0 1px #d6a53a; filter: brightness(1); }
  to { box-shadow: inset 0 0 0 2px #fffbea, 0 0 0 3px #eebf49, 0 0 12px #e8bd38b3; filter: brightness(1.18); }
}
.upgrade-grid .row > button.tutorial-target::after {
  content: '';
  flex: 0 0 20px;
  height: 16px;
  background: #233b19;
  clip-path: polygon(0 50%, 45% 0, 45% 29%, 100% 29%, 100% 71%, 45% 71%, 45% 100%);
  animation: tutorial-point .8s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes tutorial-point {
  from { transform: translateX(4px); }
  to { transform: translateX(-4px); }
}
@media (prefers-reduced-motion: reduce) {
  .upgrade-grid .row > button.tutorial-target { animation: none; box-shadow: inset 0 0 0 1px #fff3b8, 0 0 0 2px #d6a53a; }
  .upgrade-grid .row > button.tutorial-target::after { animation: none; }
}
.prestige { display: grid; grid-template-columns: clamp(25px, 3.6vw, 42px) 1fr auto; align-items: center; column-gap: 7px; padding: 4px 5px 5px; border: 1px solid #b092a9; background: #f1e3ef; box-shadow: none; }
.prestige strong { display: block; color: #653787; line-height: 1; }
.prestige strong + small { color: #64437a; }
.prestige-values { display: flex; gap: clamp(8px, 2vw, 27px); margin-top: 3px; font-size: 9px; font-weight: 800; }
.prestige-values b { display: block; font-size: 13px; }
#prestige-next { color: #226329; }
#prestige-note { grid-column: 1/-1; margin-top: 3px; }
#prestige-button { background: linear-gradient(#aa55b5,#703384); color: #fff4ff; border-color: #5e2d71; box-shadow: inset 0 1px 0 #d3a1e2; }
#prestige-button:disabled { color: #fff0f9; }
.meter { display: block; position: relative; overflow: hidden; height: 12px; margin-top: 3px; background: #5a411e; color: white; border-radius: 2px; text-align: center; }
.meter i { position: absolute; inset: 0 auto 0 0; width: 0; background: #558611; }
.meter b { position: relative; display: block; font-size: 9px; line-height: 12px; }
.milestone { display: block; min-height: auto; padding: 4px 6px; }
.milestone > div:first-child { display: flex; justify-content: space-between; gap: 4px; }
.milestone > div:first-child small { color: #376426; text-align: right; }
.garage-tabs { display: flex; gap: 6px; }
.garage-tabs button { flex: 1; }
.parts-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.parts-grid button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 62px; padding: 4px 1px; overflow-wrap: anywhere; }
.parts-grid img { width: 25px; height: 25px; }
.parts-grid b { color: #356523; }
.boot { display: grid; place-content: center; justify-items: center; text-align: center; min-height: 100dvh; padding: 14px; }
.boot img { width: 72px; }
.boot h1 { margin: 8px 0 0; color: #f8f4cd; text-shadow: 0 2px 1px #31550e; }
.boot p { margin: 8px 0; color: #fff6c4; background: #284313; border-radius: 4px; padding: 6px 10px; }
dialog {
  width: min(94vw, 430px);
  max-height: 94dvh;
  margin: auto;
  padding: 0;
  border: 3px solid #75965e;
  border-radius: 14px;
  color: #293c27;
  background: #f3f0d6;
  box-shadow: inset 0 0 0 1px #dbe4a9, 0 6px 17px #20371080;
  overflow: auto;
}
dialog::backdrop { background: #182b0fb3; }
.dialog-card { position: relative; padding: clamp(13px, 3vw, 24px); }
.dialog-card h2 {
  display: flex;
  align-items: center;
  min-height: 38px;
  margin: 0 46px 12px 0;
  font-size: clamp(18px, 2vw, 24px);
}
.dialog-card p { margin: 8px 0 0; }
.dialog-card > .close { position: absolute; top: 7px; right: 8px; width: 42px; min-height: 42px; font-size: 19px; padding: 0; }
.dialog-card footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 9px; margin-top: 12px; }
.dialog-card footer button { min-width: 107px; }
.dialog-summary { display: flex; align-items: center; gap: 12px; padding: 10px; }
.dialog-summary img { width: 42px; height: 42px; flex: none; }
.dialog-summary > div { display: grid; gap: 3px; }
.dialog-summary strong { font-size: 1.1rem; }
.dialog-summary small { color: #4e6141; }
.dialog-notice:not(:empty) { display: block; margin-top: 8px; }
dialog[data-kind="settings"] { width: min(94vw, 390px); }
dialog[data-kind="daily"] { width: min(94vw, 530px); }
.dialog-card .daily-earned { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 21px; color: #5a3574; }
.daily-earned img { width: 30px; height: 30px; }
.daily-grid { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 4px; }
.daily-grid > div {
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 6px 1px;
  color: #483c20;
  font-size: clamp(9px, 1.7vw, 13px);
}
.daily-grid .today { color: #213c17; border-color: #799644; background: #d5e8a7; }
.daily-amount { display: flex; align-items: center; gap: 3px; }
.daily-amount img { width: clamp(10px, 2vw, 14px); height: clamp(10px, 2vw, 14px); }
dialog[data-kind="daily"] footer { justify-content: space-between; align-items: center; }
dialog[data-kind="daily"] footer p { margin: 0; font-size: 13px; }
.option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 4px 11px;
  margin-top: 5px;
  background: #fff8e1;
  border: 1px solid #cec193;
  border-radius: 6px;
}
.setting-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 74px;
  padding-inline: 9px;
  background: #e5dec1;
  border-color: #a69873;
  color: #493d28;
  box-shadow: none;
}
.setting-toggle::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #80745a;
}
.setting-toggle[aria-pressed="true"] { background: #315f36; border-color: #254d2a; color: #fffdf1; }
.setting-toggle[aria-pressed="true"]::before { background: #cbe89a; }
  .hold { position: relative; overflow: hidden; touch-action: none; }
.hold::before { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--fill,0%); background: #e5ff9690; }
.hold span { position: relative; }
@media (pointer: coarse) {
  button { min-height: 42px; }
  .parts-grid button { min-height: 64px; }
}
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  :root { --space: 5px; --row: 48px; }
  #game { grid-template-columns: minmax(0, 1fr) minmax(237px, 30%); }
  .garden { grid-template-rows: auto minmax(0,1fr); }
  .lawn-wrap { grid-column: 1; grid-row: 2; padding: 1px 0 0 31px; }
  .boosts { position: absolute; bottom: 6px; left: 5px; display: grid; gap: 4px; width: 83px; }
  .boosts > [data-action="reward"] { min-height: 31px; padding: 3px 4px; }
  #offline-earnings { min-height: 42px; }
  .boosts #notice { position: absolute; bottom: 0; left: 89px; width: max-content; max-width: 190px; }
  .workshop { padding: 3px; }
  .workshop nav button { font-size: 9px; padding-inline: 2px; min-height: 38px; }
  #prestige-note { display: none; }
  .dialog-card { padding: 12px 15px; }
  .dialog-card h2 { margin-bottom: 8px; }
  .dialog-card footer { margin-top: 8px; }
  .dialog-card p { margin: 5px 0; }
  .option { padding-block: 3px; }
  .setting-toggle { min-height: 42px; }
  .wallet { font-size: clamp(12px, 2.5dvh, 18px); height: 28px; }
  .hud { gap: 6px; }
  .event { padding: 3px 4px; }
  .gear { width: 39px; height: 39px; min-height: 39px; }
  .row { padding-block: 3px; }
  .row button { min-height: 38px; }
  .upgrade-grid .row {
    grid-template-columns: 21px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 4px;
    padding: 4px;
  }
  .upgrade-grid .row > img { width: 21px; height: 21px; }
  .upgrade-grid .row > button { grid-column: 1/-1; min-height: 42px; }
  .upgrade-grid .row strong { font-size: 11px; }
  .upgrade-grid .row small { font-size: 9px; }
  .prestige { padding-block: 3px; }
}
@media (max-aspect-ratio: 1/1) {
  #game { height: auto; min-height: 100dvh; grid-template-columns: 1fr; overflow: visible; }
  .garden { grid-template-rows: auto auto auto; gap: 5px; }
  .lawn-wrap { container-type: normal; }
  #field { width: 100%; }
  .workshop { grid-template-rows: auto auto auto; max-height: none; }
  .panel { overflow: visible; }
}

@media (max-height: 210px) and (min-aspect-ratio: 1/1) {
  .tutorial-guide { max-width: 104px; padding: 5px 8px; }
  .workshop:has(.upgrade-grid button.tutorial-target) .prestige { display: none; }
  .upgrade-grid .row:has(button.tutorial-target) {
    align-self: start;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
  }
  .upgrade-grid .row:has(button.tutorial-target) > img,
  .upgrade-grid .row:has(button.tutorial-target) .level { display: none; }
}

