*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Georgia", "Times New Roman", serif;
  -webkit-tap-highlight-color: transparent;
  background: linear-gradient(
    165deg,
    #e8e4df 0%,
    #d4cfc8 35%,
    #c5bdb4 70%,
    #b8b0a6 100%
  );
}

#garden {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
  touch-action: manipulation;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.garden-meta {
  margin: 0 0 0.5rem;
}

.garden-name-input {
  width: 100%;
  font: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.45rem;
  border: 1px solid rgba(90, 82, 74, 0.22);
  border-radius: 6px;
  background: rgba(255, 252, 248, 0.85);
  color: #3d3832;
}

.garden-name-input::placeholder {
  color: rgba(90, 82, 74, 0.45);
}

.garden-name-input:focus {
  outline: none;
  border-color: rgba(120, 140, 110, 0.55);
  box-shadow: 0 0 0 2px rgba(120, 140, 110, 0.15);
}

.game-panel {
  position: fixed;
  top: calc(0.75rem + env(safe-area-inset-top, 0px));
  left: calc(0.75rem + env(safe-area-inset-left, 0px));
  max-width: 16rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  color: #4a433c;
  background: rgba(255, 252, 248, 0.72);
  border: 1px solid rgba(90, 82, 74, 0.22);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  z-index: 2;
  box-shadow: 0 4px 24px rgba(60, 52, 44, 0.08);
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.level-tag {
  flex: 0 0 auto;
  min-width: 2.5rem;
  font-variant-numeric: tabular-nums;
}

.res-label {
  flex: 0 0 2.5rem;
}

.res-text {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
  min-width: 3.2rem;
  text-align: right;
}

.bar.track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(90, 82, 74, 0.12);
  overflow: hidden;
}

.bar.fill {
  height: 100%;
  border-radius: 999px;
  width: 0%;
  transition: width 0.25s ease;
}

.xp-fill {
  background: linear-gradient(90deg, #7a9e7a, #5a8a6a);
}

.water-fill {
  background: linear-gradient(90deg, #6a9ebc, #4a7aa8);
}

.harmony-line {
  margin: 0.35rem 0 0.35rem;
  font-size: 0.68rem;
  opacity: 0.75;
}

.coins-line {
  margin: 0 0 0.4rem;
  font-size: 0.68rem;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
  color: #6a5c48;
}

.theme-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  font-size: 0.68rem;
}

.theme-row label {
  opacity: 0.6;
}

.theme-row select {
  flex: 1;
  font: inherit;
  font-size: 0.7rem;
  padding: 0.2rem 0.35rem;
  border: 1px solid rgba(90, 82, 74, 0.28);
  border-radius: 6px;
  background: rgba(255, 252, 248, 0.9);
  color: #4a433c;
}

.obj-heading {
  margin: 0 0 0.35rem;
  font-size: 0.65rem;
  font-weight: normal;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.55;
}

.objectives {
  margin: 0;
  padding-left: 1.1rem;
}

.objectives li {
  margin-bottom: 0.35rem;
  line-height: 1.35;
}

.objectives li.done {
  opacity: 0.45;
  text-decoration: line-through;
}

.hud {
  position: fixed;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  right: calc(1.25rem + env(safe-area-inset-right, 0px));
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  max-width: min(100vw - 2rem, 22rem);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 2;
}

body:hover .hud {
  opacity: 0.5;
}

.hud:hover {
  opacity: 0.95;
}

.hud button {
  font: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  padding: 0.45rem 0.85rem;
  border: 1px solid rgba(90, 82, 74, 0.35);
  background: rgba(255, 252, 248, 0.55);
  color: #5a524a;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.hud button:hover {
  background: rgba(255, 252, 248, 0.85);
  border-color: rgba(90, 82, 74, 0.5);
}

@media (pointer: coarse) {
  .hud button {
    min-height: 44px;
    min-width: 44px;
    padding: 0.55rem 1rem;
  }

  .top-right-actions .support-link,
  .save-image-btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sound-toggle {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.05rem;
  }

  .game-panel {
    max-height: min(70vh, 22rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fx-particle {
    animation-duration: 0.35s !important;
    animation-timing-function: ease-out !important;
  }
}

html.reduce-motion .fx-particle {
  animation: none !important;
  opacity: 0 !important;
}

.hint {
  position: fixed;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: rgba(90, 82, 74, 0.4);
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.5s ease;
  text-align: center;
  max-width: 90vw;
}

body:hover .hint {
  opacity: 0.12;
}

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0.65rem 1.1rem;
  font-size: 0.8rem;
  color: #3d3832;
  background: rgba(255, 252, 248, 0.92);
  border: 1px solid rgba(90, 82, 74, 0.2);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(40, 36, 32, 0.15);
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.toast.show {
  opacity: 1;
}

.arcade-bar {
  position: fixed;
  top: calc(0.65rem + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: #3d3832;
  background: rgba(255, 252, 248, 0.88);
  border: 1px solid rgba(90, 82, 74, 0.22);
  border-radius: 999px;
  box-shadow: 0 4px 20px rgba(60, 52, 44, 0.1);
  z-index: 3;
  backdrop-filter: blur(8px);
}

.arcade-time {
  font-variant-numeric: tabular-nums;
  min-width: 2.75rem;
  font-weight: 600;
}

.arcade-stress {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 8rem;
}

.arcade-label {
  opacity: 0.55;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.arcade-stress .stress-track {
  width: 6.5rem;
  height: 6px;
}

.stress-fill {
  background: linear-gradient(90deg, #c4a574, #b85c4a);
  transition: width 0.12s linear;
}

.arcade-run {
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

body.arcade-active .game-panel .theme-row,
body.arcade-active .game-panel .obj-heading,
body.arcade-active .game-panel .objectives {
  opacity: 0.55;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(45, 40, 36, 0.45);
  z-index: 20;
  backdrop-filter: blur(4px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  max-width: 18rem;
  width: 100%;
  padding: 1.35rem 1.5rem;
  background: rgba(255, 252, 248, 0.96);
  border: 1px solid rgba(90, 82, 74, 0.2);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(40, 36, 32, 0.2);
  text-align: center;
  color: #3d3832;
  transition: border-color 0.35s ease, box-shadow 0.35s ease;
}

.modal-card--triumph {
  border-color: rgba(180, 150, 90, 0.55);
  box-shadow: 0 16px 48px rgba(120, 100, 60, 0.18), 0 0 0 1px rgba(200, 170, 110, 0.25);
}

.modal-card--wilt {
  border-color: rgba(140, 100, 90, 0.4);
  background: rgba(252, 248, 245, 0.98);
}

.modal-card--early {
  border-color: rgba(110, 120, 130, 0.35);
}

.modal-title {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-weight: normal;
  letter-spacing: 0.06em;
}

.modal-reflection {
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  line-height: 1.5;
  font-style: italic;
  color: #5a5248;
  opacity: 0.92;
}

.modal-newbest {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7a6a4a;
}

.modal-score {
  margin: 0.35rem 0;
  font-size: 1.05rem;
}

.modal-rank {
  margin: 0.5rem 0;
  font-size: 2rem;
  letter-spacing: 0.2em;
  font-weight: 600;
  color: #5a524a;
}

.modal-best {
  margin: 0.65rem 0 1rem;
  font-size: 0.78rem;
  opacity: 0.7;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.modal-actions button {
  font: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(90, 82, 74, 0.35);
  background: rgba(255, 252, 248, 0.9);
  color: #5a524a;
  border-radius: 999px;
  cursor: pointer;
}

.modal-actions button:hover {
  background: #fff;
  border-color: rgba(90, 82, 74, 0.55);
}

.shop-card {
  max-width: 20rem;
  text-align: left;
}

.shop-card .modal-title {
  text-align: center;
}

.shop-sub {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #4a433c;
  opacity: 0.88;
  text-align: center;
}

.shop-balance {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  text-align: center;
}

.shop-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.shop-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(90, 82, 74, 0.1);
}

.shop-item:last-child {
  border-bottom: none;
}

.shop-item-name {
  flex: 1 1 8rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #3d3832;
}

.shop-item-desc {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.4;
  opacity: 0.72;
}

.shop-item-price {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: #6a5c48;
}

.shop-item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.shop-item button {
  font: inherit;
  font-size: 0.72rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(90, 82, 74, 0.35);
  background: rgba(255, 252, 248, 0.95);
  color: #5a524a;
  cursor: pointer;
}

.shop-item button:hover:not(:disabled) {
  background: #fff;
}

.shop-item button:disabled {
  opacity: 0.45;
  cursor: default;
}

.shop-actions {
  margin-top: 0.75rem;
  justify-content: center;
}

.modal-stats {
  margin: 0 0 1rem;
  padding: 0.65rem 0.5rem;
  font-size: 0.72rem;
  line-height: 1.55;
  text-align: left;
  color: #4a433c;
  background: rgba(90, 82, 74, 0.06);
  border-radius: 8px;
}

.modal-stats p {
  margin: 0.2rem 0;
}

.modal-stats strong {
  font-weight: 600;
}

.top-right-actions {
  position: fixed;
  top: calc(0.65rem + env(safe-area-inset-top, 0px));
  right: calc(0.65rem + env(safe-area-inset-right, 0px));
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.45rem;
  max-width: min(96vw, 20rem);
}

.top-right-actions .support-link {
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border: 1px solid rgba(90, 82, 74, 0.32);
  border-radius: 999px;
  background: rgba(255, 252, 248, 0.72);
  color: #5a524a;
  backdrop-filter: blur(6px);
  opacity: 0.45;
  transition: opacity 0.35s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

body:hover .top-right-actions .support-link {
  opacity: 0.92;
}

.top-right-actions .support-link:hover {
  background: rgba(255, 252, 248, 0.92);
  border-color: rgba(90, 82, 74, 0.48);
  color: #3d3832;
}

.save-image-btn {
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  padding: 0.45rem 0.85rem;
  border: 1px solid rgba(90, 82, 74, 0.32);
  border-radius: 999px;
  background: rgba(255, 252, 248, 0.72);
  color: #5a524a;
  cursor: pointer;
  backdrop-filter: blur(6px);
  opacity: 0.45;
  transition: opacity 0.35s ease, background 0.2s ease, border-color 0.2s ease;
}

body:hover .top-right-actions .save-image-btn {
  opacity: 0.92;
}

.save-image-btn:hover {
  background: rgba(255, 252, 248, 0.92);
  border-color: rgba(90, 82, 74, 0.48);
}

.sound-toggle {
  position: fixed;
  bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  left: calc(0.65rem + env(safe-area-inset-left, 0px));
  z-index: 4;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1;
  border: 1px solid rgba(90, 82, 74, 0.25);
  border-radius: 999px;
  background: rgba(255, 252, 248, 0.65);
  color: #5a524a;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.25s ease, background 0.2s ease;
}

.sound-toggle:hover {
  opacity: 0.9;
  background: rgba(255, 252, 248, 0.9);
}

.sound-toggle.muted {
  opacity: 0.25;
}

.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  overflow: hidden;
}

.fx-particle {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  margin-top: -3.5px;
  border-radius: 50%;
  opacity: 0.95;
  animation: fx-burst 1.85s ease-out forwards;
}

.fx-particle--gold {
  background: radial-gradient(circle at 30% 30%, #fff4d0, #c9a050 55%, #8a6a30);
  box-shadow: 0 0 8px rgba(200, 160, 80, 0.45);
}

.fx-particle--leaf {
  width: 8px;
  height: 5px;
  border-radius: 50% 50% 50% 0;
  background: linear-gradient(135deg, #a8c8a0, #6a9a6a);
  opacity: 0.88;
}

@keyframes fx-burst {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0.35) rotate(260deg);
    opacity: 0;
  }
}
