@font-face {
  font-family: "DotGothic16 Embedded";
  src: url("DotGothic16-subset.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  background: #535353;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  font-family: "DotGothic16", "DotGothic16 Embedded", sans-serif;
  color: #535353;
}
#fit {
  /* Visible viewport: 100dvh (toolbar-aware) with 100vh fallback.
     --vv-w/--vv-h may be set from visualViewport in game.js. */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --fit-w: calc(var(--vv-w, 100vw) - var(--safe-l) - var(--safe-r));
  --fit-h: calc(var(--vv-h, 100vh) - var(--safe-t) - var(--safe-b));
  --fit-h: calc(var(--vv-h, 100dvh) - var(--safe-t) - var(--safe-b));
  --fit-scale: min(1, calc(var(--fit-w) / 390px));
  position: relative;
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  box-sizing: border-box;
}
#phone {
  --phone-h: min(844px, calc(var(--fit-h) / var(--fit-scale)));
  position: absolute;
  left: calc(var(--safe-l) + var(--fit-w) / 2);
  top: calc(var(--safe-t) + var(--fit-h) / 2);
  width: 390px;
  height: var(--phone-h);
  margin: 0;
  background: #f7f7f7;
  overflow: hidden;
  transform: translate(-50%, -50%) scale(var(--fit-scale));
  transform-origin: center center;
  border: none;
  box-sizing: border-box;
  box-shadow: inset 0 0 0 4px #535353;
  container-type: size;
}
#phone, #phone * { font-family: inherit; }
img.pixel { image-rendering: pixelated; image-rendering: crisp-edges; pointer-events: none; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  background: #f7f7f7;
}
.screen.active { display: block; }

#growth-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  pointer-events: none;
  color: #535353;
  background: #f7f7f7;
  padding: 16px 16px 8px;
  box-sizing: border-box;
}
#growth-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
#growth-label, #growth-value {
  font-size: 28px;
  line-height: 32px;
  letter-spacing: 0;
  white-space: nowrap;
  text-shadow: 2px 0 #f7f7f7, -2px 0 #f7f7f7, 0 2px #f7f7f7, 0 -2px #f7f7f7;
}
#growth-label { flex: 0 0 auto; }
#growth-value { text-align: right; flex: 0 0 auto; margin-left: auto; }
#growth-track {
  margin-top: 8px;
  height: 24px;
  border: 4px solid #535353;
  background: #f7f7f7;
  box-sizing: border-box;
  display: flex;
  gap: 2px;
  padding: 2px;
}
#growth-track span {
  flex: 1;
  display: block;
  background: #f7f7f7;
  min-width: 0;
}
#growth-track span.on { background: #535353; }

/* ---- seed select ---- */
#title-hatake {
  position: absolute;
  top: 80px;
  left: 0; right: 0;
  text-align: center;
  font-size: 48px;
  line-height: 48px;
}
#title-sub {
  position: absolute;
  top: 140px;
  left: 0; right: 0;
  text-align: center;
  font-size: 32px;
  line-height: 32px;
}
#bag-grid {
  position: absolute;
  left: 0; right: 0;
  top: 190px;
}
.bag {
  position: absolute;
  width: 160px;
  height: 252px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: #535353;
}
.bag:nth-child(1) { left: 26px; top: 0; }
.bag:nth-child(2) { left: 204px; top: 0; }
.bag:nth-child(3) { left: 26px; top: 288px; }
.bag:nth-child(4) { left: 204px; top: 288px; }
.bag img { display: block; width: 160px; height: 220px; }
.bag span {
  display: block;
  margin-top: 8px;
  text-align: center;
  font-size: 32px;
  line-height: 32px;
  white-space: nowrap;
}
.bag:active { transform: translateY(2px); }
#select-footer {
  position: absolute;
  top: 790px;
  left: 0; right: 0;
  text-align: center;
  font-size: 32px;
  line-height: 32px;
}

/* ---- care ---- */
#care-bg {
  position: absolute;
  left: 0;
  bottom: 0;
  top: auto;
  width: 390px;
  height: 844px;
}
/* Actions stay pinned to the bottom (120+14+120 plus the original 61/62 gaps).
   The plant/sky area above them shrinks; art is bottom-aligned so the horizon stays put. */
#plant-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 390px;
  height: auto;
  bottom: 377px;
  overflow: hidden;
  z-index: 1;
}
#plant-stage {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 390px;
  height: 464px;
}
#plant-img, #weed-img, #pest-c, #pest-a1, #pest-a2 {
  position: absolute;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
}
#plant-img { left: 0; top: 0; width: 390px; height: 464px; }
#weed-img {
  left: 30px;
  top: 416px;
  width: 80px;
  height: 48px;
  display: none;
}
#pest-c {
  left: 0;
  top: 0;
  width: 100px;
  height: 48px;
  display: none;
  transform-origin: center center;
}
#pest-a1, #pest-a2 {
  left: 0;
  top: 0;
  width: 32px;
  height: 28px;
  display: none;
}
#weed-img.show, #pest-c.show, #pest-a1.show, #pest-a2.show { display: block; }

/* pest left/top come from #plant-layer.pest-<sprite> rules below */


.care-btn {
  position: absolute;
  width: 170px;
  height: 120px;
  background: #f7f7f7;
  color: #535353;
  border: 4px solid #535353;
  font-size: 32px;
  line-height: 32px;
  cursor: pointer;
  padding: 0;
}
.care-btn:disabled {
  background: #d6d6d6;
  color: #969696;
  border-color: #969696;
  cursor: default;
}
.care-btn:not(:disabled):active { transform: translateY(2px); }
#btn-water { left: 18px; top: auto; bottom: 196px; }
#btn-weed  { left: 202px; top: auto; bottom: 196px; }
#btn-pest  { left: 18px; top: auto; bottom: 62px; }
#btn-harvest { left: 202px; top: auto; bottom: 62px; }

#toast {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 92px;
  z-index: 6;
  text-align: center;
  font-size: 32px;
  line-height: 40px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  text-shadow: 2px 0 #f7f7f7, -2px 0 #f7f7f7, 0 2px #f7f7f7, 0 -2px #f7f7f7;
}
#toast.show { opacity: 1; }

/* ---- overlays (event / away) ---- */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  background: #f7f7f7;
  z-index: 20;
  flex-direction: column;
  align-items: center;
}
.overlay.active { display: flex; }
.overlay h2 {
  margin-top: 48px;
  font-size: 32px;
  line-height: 40px;
  font-weight: normal;
  text-align: center;
  padding: 0 16px;
}
.overlay .pic {
  margin-top: 24px;
  width: 390px;
  height: auto;
  max-height: 420px;
  max-height: min(420px, calc(100% - 280px));
  object-fit: contain;
  image-rendering: pixelated;
}
.overlay .line {
  margin-top: 24px;
  font-size: 32px;
  line-height: 40px;
  text-align: center;
  padding: 0 20px;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: normal;
}
.overlay .body {
  margin-top: 28px;
  font-size: 28px;
  line-height: 44px;
  text-align: left;
  padding: 0 28px;
  white-space: pre-wrap;
  width: 100%;
  word-break: keep-all;
  overflow-wrap: normal;
}
.overlay .ok {
  position: absolute;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  width: 240px;
  height: 80px;
  background: #f7f7f7;
  color: #535353;
  border: 4px solid #535353;
  font-size: 32px;
  cursor: pointer;
}
.overlay .ok:active { transform: translateX(-50%) translateY(2px); }

/* ---- harvest ---- */
#screen-harvest {
  background: #f7f7f7;
}
#harvest-title {
  position: absolute;
  top: 40px;
  left: 0; right: 0;
  text-align: center;
  font-size: 32px;
  line-height: 40px;
}
#harvest-pic {
  position: absolute;
  top: 100px;
  left: 0;
  width: 390px;
  height: 400px;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: pixelated;
}
#harvest-line {
  position: absolute;
  top: 520px;
  left: 16px; right: 16px;
  text-align: center;
  font-size: 32px;
  line-height: 40px;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: normal;
}
#btn-again {
  position: absolute;
  left: 35px;
  top: 730px;
  width: 320px;
  height: 80px;
  background: #f7f7f7;
  color: #535353;
  border: 4px solid #535353;
  font-size: 32px;
  cursor: pointer;
}
#btn-again:active { transform: translateY(2px); }

/* pest leaf anchors — generated; positions via classes, not element.style */
#plant-layer.pest-flip #pest-c { transform: scaleX(-1); }
#plant-layer.pest-tomato_seed #pest-c { left: 70px; top: 405px; }
#plant-layer.pest-tomato_seed #pest-a1 { left: 174px; top: 397px; }
#plant-layer.pest-tomato_seed #pest-a2 { left: 210px; top: 430px; }
#plant-layer.pest-tomato_sprout #pest-c { left: 144px; top: 347px; }
#plant-layer.pest-tomato_sprout #pest-a1 { left: 176px; top: 436px; }
#plant-layer.pest-tomato_sprout #pest-a2 { left: 176px; top: 403px; }
#plant-layer.pest-tomato_small #pest-c { left: 178px; top: 292px; }
#plant-layer.pest-tomato_small #pest-a1 { left: 126px; top: 273px; }
#plant-layer.pest-tomato_small #pest-a2 { left: 142px; top: 306px; }
#plant-layer.pest-tomato_flower #pest-c { left: 138px; top: 184px; }
#plant-layer.pest-tomato_flower #pest-a1 { left: 98px; top: 187px; }
#plant-layer.pest-tomato_flower #pest-a2 { left: 242px; top: 221px; }
#plant-layer.pest-tomato_fruit #pest-c { left: 134px; top: 260px; }
#plant-layer.pest-tomato_fruit #pest-a1 { left: 194px; top: 151px; }
#plant-layer.pest-tomato_fruit #pest-a2 { left: 156px; top: 173px; }
#plant-layer.pest-tomato_wilt #pest-c { left: 150px; top: 380px; }
#plant-layer.pest-tomato_wilt #pest-a1 { left: 158px; top: 243px; }
#plant-layer.pest-tomato_wilt #pest-a2 { left: 152px; top: 305px; }
#plant-layer.pest-tomato_sprout_wilt #pest-c { left: 170px; top: 376px; }
#plant-layer.pest-tomato_sprout_wilt #pest-a1 { left: 182px; top: 425px; }
#plant-layer.pest-tomato_sprout_wilt #pest-a2 { left: 182px; top: 437px; }
#plant-layer.pest-tomato_small_wilt #pest-c { left: 146px; top: 394px; }
#plant-layer.pest-tomato_small_wilt #pest-a1 { left: 162px; top: 295px; }
#plant-layer.pest-tomato_small_wilt #pest-a2 { left: 200px; top: 339px; }
#plant-layer.pest-tomato_flower_wilt #pest-c { left: 184px; top: 268px; }
#plant-layer.pest-tomato_flower_wilt #pest-a1 { left: 158px; top: 219px; }
#plant-layer.pest-tomato_flower_wilt #pest-a2 { left: 196px; top: 221px; }
#plant-layer.pest-pumpkin_seed #pest-c { left: 70px; top: 405px; }
#plant-layer.pest-pumpkin_seed #pest-a1 { left: 174px; top: 397px; }
#plant-layer.pest-pumpkin_seed #pest-a2 { left: 210px; top: 430px; }
#plant-layer.pest-pumpkin_sprout #pest-c { left: 49px; top: 400px; }
#plant-layer.pest-pumpkin_sprout #pest-a1 { left: 12px; top: 399px; }
#plant-layer.pest-pumpkin_sprout #pest-a2 { left: 40px; top: 438px; }
#plant-layer.pest-pumpkin_vine #pest-c { left: 79px; top: 320px; }
#plant-layer.pest-pumpkin_vine #pest-a1 { left: 180px; top: 365px; }
#plant-layer.pest-pumpkin_vine #pest-a2 { left: 32px; top: 367px; }
#plant-layer.pest-pumpkin_flower #pest-c { left: 79px; top: 320px; }
#plant-layer.pest-pumpkin_flower #pest-a1 { left: 232px; top: 353px; }
#plant-layer.pest-pumpkin_flower #pest-a2 { left: 180px; top: 365px; }
#plant-layer.pest-pumpkin_fruit #pest-c { left: 91px; top: 320px; }
#plant-layer.pest-pumpkin_fruit #pest-a1 { left: 226px; top: 341px; }
#plant-layer.pest-pumpkin_fruit #pest-a2 { left: 58px; top: 357px; }
#plant-layer.pest-pumpkin_wilt #pest-c { left: 70px; top: 377px; }
#plant-layer.pest-pumpkin_wilt #pest-a1 { left: 70px; top: 389px; }
#plant-layer.pest-pumpkin_wilt #pest-a2 { left: 130px; top: 397px; }
#plant-layer.pest-pumpkin_sprout_wilt #pest-c { left: 170px; top: 376px; }
#plant-layer.pest-pumpkin_sprout_wilt #pest-a1 { left: 182px; top: 425px; }
#plant-layer.pest-pumpkin_sprout_wilt #pest-a2 { left: 182px; top: 437px; }
#plant-layer.pest-pumpkin_vine_wilt #pest-c { left: 132px; top: 384px; }
#plant-layer.pest-pumpkin_vine_wilt #pest-a1 { left: 70px; top: 389px; }
#plant-layer.pest-pumpkin_vine_wilt #pest-a2 { left: 54px; top: 423px; }
#plant-layer.pest-pumpkin_flower_wilt #pest-c { left: 132px; top: 384px; }
#plant-layer.pest-pumpkin_flower_wilt #pest-a1 { left: 70px; top: 389px; }
#plant-layer.pest-pumpkin_flower_wilt #pest-a2 { left: 233px; top: 393px; }
#plant-layer.pest-daikon_seed #pest-c { left: 70px; top: 405px; }
#plant-layer.pest-daikon_seed #pest-a1 { left: 174px; top: 397px; }
#plant-layer.pest-daikon_seed #pest-a2 { left: 210px; top: 430px; }
#plant-layer.pest-daikon_sprout #pest-c { left: 144px; top: 347px; }
#plant-layer.pest-daikon_sprout #pest-a1 { left: 176px; top: 436px; }
#plant-layer.pest-daikon_sprout #pest-a2 { left: 176px; top: 403px; }
#plant-layer.pest-daikon_grow #pest-c { left: 90px; top: 330px; }
#plant-layer.pest-daikon_grow #pest-a1 { left: 172px; top: 261px; }
#plant-layer.pest-daikon_grow #pest-a2 { left: 124px; top: 285px; }
#plant-layer.pest-daikon_ripe #pest-c { left: 90px; top: 330px; }
#plant-layer.pest-daikon_ripe #pest-a1 { left: 172px; top: 261px; }
#plant-layer.pest-daikon_ripe #pest-a2 { left: 124px; top: 285px; }
#plant-layer.pest-daikon_wilt #pest-c { left: 219px; top: 401px; }
#plant-layer.pest-daikon_wilt #pest-a1 { left: 226px; top: 369px; }
#plant-layer.pest-daikon_wilt #pest-a2 { left: 186px; top: 417px; }
#plant-layer.pest-daikon_sprout_wilt #pest-c { left: 170px; top: 376px; }
#plant-layer.pest-daikon_sprout_wilt #pest-a1 { left: 182px; top: 425px; }
#plant-layer.pest-daikon_sprout_wilt #pest-a2 { left: 182px; top: 437px; }
#plant-layer.pest-mystery_seed #pest-c { left: 70px; top: 405px; }
#plant-layer.pest-mystery_seed #pest-a1 { left: 174px; top: 397px; }
#plant-layer.pest-mystery_seed #pest-a2 { left: 210px; top: 430px; }
#plant-layer.pest-mystery_sprout #pest-c { left: 144px; top: 347px; }
#plant-layer.pest-mystery_sprout #pest-a1 { left: 176px; top: 436px; }
#plant-layer.pest-mystery_sprout #pest-a2 { left: 176px; top: 403px; }
#plant-layer.pest-mystery_grow #pest-c { left: 144px; top: 242px; }
#plant-layer.pest-mystery_grow #pest-a1 { left: 194px; top: 339px; }
#plant-layer.pest-mystery_grow #pest-a2 { left: 142px; top: 361px; }
#plant-layer.pest-mystery_ripe #pest-c { left: 144px; top: 170px; }
#plant-layer.pest-mystery_ripe #pest-a1 { left: 150px; top: 219px; }
#plant-layer.pest-mystery_ripe #pest-a2 { left: 206px; top: 219px; }
#plant-layer.pest-mystery_wilt #pest-c { left: 173px; top: 361px; }
#plant-layer.pest-mystery_wilt #pest-a1 { left: 182px; top: 410px; }
#plant-layer.pest-mystery_wilt #pest-a2 { left: 234px; top: 412px; }
#plant-layer.pest-mystery_sprout_wilt #pest-c { left: 170px; top: 376px; }
#plant-layer.pest-mystery_sprout_wilt #pest-a1 { left: 182px; top: 425px; }
#plant-layer.pest-mystery_sprout_wilt #pest-a2 { left: 182px; top: 437px; }
#plant-layer.pest-mystery_grow_wilt #pest-c { left: 173px; top: 361px; }
#plant-layer.pest-mystery_grow_wilt #pest-a1 { left: 182px; top: 410px; }
#plant-layer.pest-mystery_grow_wilt #pest-a2 { left: 234px; top: 412px; }

/* ---- short viewport: scale the seed-select 844px layout; care/harvest flex instead ---- */
#screen-select {
  inset: auto;
  top: 0;
  left: 0;
  width: 390px;
  height: 844px;
  transform-origin: top center;
  transform: scale(min(1, calc(var(--phone-h) / 844px)));
}

/* Harvest keeps the 844 layout when the phone is full height.
   On a shorter phone, the art shrinks and the button sits above the GAMES/pause gutter. */
@container (max-height: 843px) {
  #harvest-title { top: 24px; }
  #harvest-pic {
    top: 72px;
    height: auto;
    bottom: 278px;
  }
  #harvest-line {
    top: auto;
    bottom: 178px;
  }
  #btn-again {
    top: auto;
    bottom: 62px;
  }
}

/* Landscape: keep the full 844 layout and allow vertical scroll so buttons stay reachable. */
@media (orientation: landscape) and (max-height: 500px) {
  html, body {
    height: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  #fit {
    --fit-scale: min(1, calc(var(--fit-w) / 390px));
    height: 100%;
    height: 100vh;
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }
  #phone {
    --phone-h: 844px;
    position: relative;
    left: auto;
    top: auto;
    margin: 0 auto;
    height: 844px;
    transform: scale(var(--fit-scale));
    transform-origin: top center;
  }
}
