* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --orange: #FF8A3D;
  --orange-dark: #D96524;
  --orange-soft: #FFF0DF;
  --green: #568B46;
  --green-dark: #315B35;
  --green-soft: #E7EFD8;
  --cream: #FFF9EA;
  --soil: #9A683D;
  --soil-soft: #EEDCB5;
  --ink: #3D372C;
  --muted: #887C68;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #C9D9AF;
  user-select: none;
  -webkit-user-select: none;
}

button {
  margin: 0;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid #FFF;
  outline-offset: 2px;
}

.game {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 540px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 14px calc(12px + env(safe-area-inset-bottom));
  overflow: hidden;
}

.game-art {
  position: absolute;
  z-index: -3;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

.game-shade {
  position: absolute;
  z-index: -2;
  inset: 0;
  background: linear-gradient(180deg, rgba(34, 55, 25, .24) 0%, rgba(255, 249, 224, .02) 25%, rgba(255, 247, 218, .06) 64%, rgba(38, 48, 24, .4) 100%);
  pointer-events: none;
}

.resource-bar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 56px;
}

.resource-pill {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 54px;
  padding: 6px 11px 6px 7px;
  gap: 8px;
  border: 1.5px solid rgba(255, 255, 255, .86);
  border-radius: 18px;
  background: rgba(255, 250, 235, .95);
  box-shadow: 0 5px 16px rgba(64, 56, 32, .16), inset 0 1px 0 #FFF;
  backdrop-filter: blur(8px);
}

.resource-icon {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 13px;
  color: #FFF;
  background: var(--orange);
  box-shadow: inset 0 -2px 0 rgba(141, 69, 23, .13);
}

.seed-pill .resource-icon {
  background: var(--green);
  box-shadow: inset 0 -2px 0 rgba(36, 77, 36, .16);
}

.resource-icon .mp-icon {
  width: 23px;
  height: 23px;
  font-size: 23px;
}

.resource-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 1;
}

.resource-copy small {
  margin-bottom: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.resource-copy strong {
  overflow: hidden;
  font-size: 20px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ready-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  height: 43px;
  padding: 0 10px;
  gap: 5px;
  border: 1.5px solid rgba(255, 255, 255, .4);
  border-radius: 15px;
  color: #FFF;
  background: rgba(49, 91, 53, .93);
  box-shadow: 0 5px 14px rgba(36, 66, 32, .22);
  font-size: 11px;
  white-space: nowrap;
}

.ready-pill .mp-icon {
  width: 17px;
  height: 17px;
  font-size: 17px;
  color: #FFE09A;
}

.ready-pill strong {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.ready-pill.has-ready {
  background: var(--orange-dark);
}

.farm-board {
  display: flex;
  flex: 0 0 auto;
  min-height: 0;
  margin-top: 12px;
  padding: 15px 13px 12px;
  flex-direction: column;
  border: 1.5px solid rgba(255, 255, 255, .88);
  border-radius: 26px;
  background: rgba(255, 249, 234, .95);
  box-shadow: 0 13px 32px rgba(66, 55, 29, .21), inset 0 1px 0 #FFF;
  backdrop-filter: blur(10px);
}

.board-heading {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  padding: 0 3px 13px;
  gap: 8px;
}

.board-title-wrap {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.title-icon {
  display: grid;
  flex: 0 0 39px;
  width: 39px;
  height: 39px;
  place-items: center;
  border-radius: 13px;
  color: var(--green-dark);
  background: var(--green-soft);
}

.title-icon .mp-icon {
  width: 24px;
  height: 24px;
  font-size: 24px;
}

.board-heading h1 {
  margin: 0;
  color: var(--green-dark);
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: .5px;
}

.board-heading p {
  margin: 4px 0 0;
  color: #958771;
  font-size: 10px;
  line-height: 1;
}

.growth-tip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  height: 31px;
  padding: 0 9px;
  gap: 4px;
  border: 1px solid #DCE6C9;
  border-radius: 11px;
  color: #527044;
  background: #EDF3E3;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.growth-tip .mp-icon {
  width: 15px;
  height: 15px;
  font-size: 15px;
}

.plot-grid {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  width: 100%;
  height: clamp(238px, 36vh, 318px);
  gap: 10px;
}

.plot {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  padding: 15px 6px 10px;
  overflow: hidden;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid #DAC296;
  border-radius: 18px;
  background: var(--soil-soft);
  box-shadow: inset 0 -4px 0 rgba(128, 88, 47, .07), 0 3px 0 rgba(128, 88, 47, .09);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.plot::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 4px;
  background: rgba(127, 87, 47, .07);
  content: "";
  pointer-events: none;
}

.plot:active {
  transform: scale(.96);
}

.plot-number {
  position: absolute;
  top: 8px;
  left: 9px;
  color: rgba(98, 75, 44, .52);
  font-size: 9px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: .6px;
}

.plot-status-dot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 7px;
  height: 7px;
  border: 2px solid rgba(255, 255, 255, .65);
  border-radius: 50%;
  background: #B59A6E;
  box-sizing: content-box;
}

.plot-visual {
  display: grid;
  height: 42px;
  margin-bottom: 4px;
  place-items: center;
}

.crop-icon {
  display: none;
  width: 40px;
  height: 40px;
  color: #9C8050;
  font-size: 40px;
  line-height: 1;
}

.plot.state-empty .icon-empty,
.plot.state-growing .icon-growing,
.plot.state-ready .icon-ready {
  display: inline-block;
}

.plot.state-empty {
  background: #F0E1BF;
  border-color: #DAC296;
}

.plot.state-growing {
  border-color: #B8C88F;
  background: #E8EDCF;
}

.plot.state-growing .crop-icon {
  color: #68984C;
}

.plot.state-growing .plot-status-dot {
  background: #74A154;
}

.plot.state-ready {
  border-color: #EFB34D;
  background: #FFF0C7;
  box-shadow: inset 0 -4px 0 rgba(212, 141, 31, .06), 0 3px 0 rgba(176, 119, 39, .12);
}

.plot.state-ready .crop-icon {
  color: #ED9432;
}

.plot.state-ready .plot-number,
.plot.state-ready .plot-state {
  color: #A96120;
}

.plot.state-ready .plot-status-dot {
  background: var(--orange);
}

.plot.selected {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 138, 61, .22), inset 0 -4px 0 rgba(128, 88, 47, .06);
}

.plot.selected::before {
  position: absolute;
  top: 0;
  left: 50%;
  width: 28px;
  height: 4px;
  border-radius: 0 0 5px 5px;
  background: var(--orange);
  content: "";
  transform: translateX(-50%);
}

.plot-state {
  margin-top: 2px;
  color: #5D503B;
  font-size: 14px;
  line-height: 1.2;
}

.plot-time {
  width: 100%;
  min-height: 14px;
  margin-top: 5px;
  overflow: hidden;
  color: #887961;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.plot.state-ready .plot-time {
  color: #A8752D;
  font-weight: 700;
}

.progress-track {
  width: 68%;
  height: 5px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(116, 91, 51, .13);
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #7EA65B;
  transition: width .45s linear;
}

.state-ready .progress-fill {
  background: #F3A83B;
}

.play-hint {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 17px;
  margin: 10px 0 0;
  gap: 5px;
  color: #7B725E;
  font-size: 10px;
  line-height: 1.3;
  text-align: center;
}

.play-hint .mp-icon {
  width: 15px;
  height: 15px;
  color: var(--orange-dark);
  font-size: 15px;
}

.action-dock {
  flex: 0 0 auto;
  margin-top: auto;
  padding: 10px 10px 11px;
  border: 1.5px solid rgba(255, 255, 255, .72);
  border-radius: 24px;
  background: rgba(255, 249, 232, .94);
  box-shadow: 0 10px 28px rgba(43, 46, 26, .25), inset 0 1px 0 #FFF;
  backdrop-filter: blur(10px);
}

.selection-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 20px;
  padding: 0 4px 8px;
  gap: 8px;
  font-size: 10px;
  line-height: 1.2;
}

.selection-label {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  color: #756951;
  font-weight: 700;
  white-space: nowrap;
}

.selection-label .mp-icon {
  width: 15px;
  height: 15px;
  color: var(--orange-dark);
  font-size: 15px;
}

.selection-action {
  overflow: hidden;
  color: var(--green);
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.action-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.action-button {
  position: relative;
  display: flex;
  min-width: 0;
  height: 66px;
  padding: 8px 10px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1.5px solid rgba(255, 255, 255, .62);
  border-radius: 18px;
  color: #FFF;
  box-shadow: 0 5px 0 rgba(86, 65, 31, .18), 0 8px 15px rgba(61, 49, 29, .13);
  text-align: left;
}

.action-button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(86, 65, 31, .18);
}

.plant-button {
  background: var(--orange);
}

.harvest-button {
  background: var(--green);
}

.action-button:disabled {
  cursor: default;
  filter: grayscale(.35);
  opacity: .48;
  box-shadow: 0 3px 0 rgba(86, 65, 31, .12);
}

.action-icon {
  display: grid;
  flex: 0 0 37px;
  width: 37px;
  height: 37px;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, .2);
}

.action-icon .mp-icon {
  width: 24px;
  height: 24px;
  font-size: 24px;
}

.action-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.action-copy strong {
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 1px;
}

.action-copy small {
  margin-top: 4px;
  overflow: hidden;
  font-size: 9px;
  line-height: 1.2;
  opacity: .9;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ready-badge {
  position: absolute;
  top: -8px;
  right: -5px;
  display: grid;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  place-items: center;
  border: 2px solid #FFF;
  border-radius: 15px;
  color: #FFF;
  background: #F05E43;
  box-shadow: 0 2px 6px rgba(110, 48, 31, .2);
  font-size: 12px;
  font-weight: 800;
}

.ready-badge.is-empty {
  display: none;
}

.toast {
  position: absolute;
  z-index: 10;
  bottom: calc(125px + env(safe-area-inset-bottom));
  left: 50%;
  max-width: calc(100% - 40px);
  padding: 11px 17px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 15px;
  color: #FFF;
  background: rgba(45, 55, 35, .95);
  box-shadow: 0 8px 24px rgba(32, 35, 24, .24);
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.mp-icon {
  flex: 0 0 auto;
}

@media (max-width: 370px) {
  .game {
    padding-right: 10px;
    padding-left: 10px;
  }

  .resource-bar {
    gap: 6px;
  }

  .resource-pill {
    height: 51px;
    padding-right: 7px;
    gap: 6px;
  }

  .resource-icon {
    flex-basis: 33px;
    width: 33px;
    height: 33px;
    border-radius: 11px;
  }

  .resource-icon .mp-icon {
    width: 20px;
    height: 20px;
    font-size: 20px;
  }

  .resource-copy strong {
    font-size: 18px;
  }

  .ready-pill {
    min-width: 66px;
    padding: 0 7px;
    font-size: 10px;
  }

  .farm-board {
    padding-right: 9px;
    padding-left: 9px;
  }

  .title-icon {
    display: none;
  }

  .plot-grid {
    gap: 7px;
  }

  .plot {
    padding-right: 4px;
    padding-left: 4px;
  }

  .action-dock {
    padding-right: 8px;
    padding-left: 8px;
  }

  .action-button {
    padding-right: 7px;
    padding-left: 7px;
    gap: 6px;
  }

  .action-icon {
    flex-basis: 33px;
    width: 33px;
    height: 33px;
  }
}

@media (max-height: 680px) {
  .game {
    padding-top: calc(8px + env(safe-area-inset-top));
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .resource-bar {
    min-height: 49px;
  }

  .resource-pill {
    height: 48px;
  }

  .resource-icon {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
  }

  .farm-board {
    margin-top: 8px;
    padding-top: 10px;
    padding-bottom: 8px;
  }

  .board-heading {
    padding-bottom: 8px;
  }

  .board-heading h1 {
    font-size: 18px;
  }

  .board-heading p {
    display: none;
  }

  .title-icon {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
  }

  .plot-grid {
    height: 218px;
    gap: 8px;
  }

  .plot {
    padding-top: 11px;
    padding-bottom: 7px;
  }

  .plot-visual {
    height: 33px;
    margin-bottom: 2px;
  }

  .crop-icon {
    width: 32px;
    height: 32px;
    font-size: 32px;
  }

  .progress-track {
    margin-top: 5px;
  }

  .play-hint {
    margin-top: 6px;
  }

  .action-dock {
    padding-top: 8px;
    padding-bottom: 9px;
  }

  .selection-row {
    padding-bottom: 6px;
  }

  .action-button {
    height: 60px;
  }

  .toast {
    bottom: calc(115px + env(safe-area-inset-bottom));
  }
}

@media (max-height: 560px) {
  .plot-grid {
    height: 190px;
  }

  .play-hint {
    display: none;
  }

  .selection-row {
    display: none;
  }

  .farm-board {
    margin-bottom: 8px;
  }
}

@media (min-width: 541px) {
  body {
    background: #C4D3A9;
  }

  .game {
    box-shadow: 0 0 45px rgba(45, 61, 35, .25);
  }
}
