:root {
  --grass-1: #e4f2d3;
  --grass-2: #c6e2ae;
  --paper: #fffaf0;
  --paper-2: #fdf3df;
  --card: #fffdf8;
  --ink: #3a3026;
  --ink-soft: #796a58;
  --line: rgba(90, 68, 44, 0.16);
  --soil: #8d6141;
  --soil-deep: #5f412b;
  --gold: #f7c948;
  --gold-deep: #c9971c;
  --gold-soft: #ffe9a8;
  --green: #5fa463;
  --red: #e2574c;
  --blue: #6f8fd6;
  --shadow: 0 10px 24px rgba(80, 56, 30, 0.14);
  --radius: 18px;
}

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

[hidden] {
  display: none !important;
}

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

body {
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 240, 170, 0.9), transparent 42%),
    radial-gradient(circle at 100% 100%, rgba(120, 180, 110, 0.25), transparent 50%),
    linear-gradient(160deg, var(--grass-1) 0%, var(--grass-2) 100%);
  color: var(--ink);
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
}

.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px calc(10px + env(safe-area-inset-bottom));
  overflow: hidden;
}

.screen.is-active {
  display: flex;
}

#screen-home,
#screen-levels {
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ---------------- 通用 ---------------- */

.btn {
  appearance: none;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  min-height: 44px;
  padding: 9px 16px;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--ink);
}

.btn.primary {
  background: linear-gradient(180deg, #ffe582, var(--gold));
}

.btn.ghost {
  background: transparent;
  box-shadow: none;
  border-color: rgba(58, 48, 38, 0.28);
  color: var(--ink-soft);
}

.btn.danger {
  background: #ffe0da;
  color: #a3352c;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: 0 3px 0 rgba(58, 48, 38, 0.4);
}

.btn.big {
  min-height: 50px;
  font-size: 16px;
  border-radius: 16px;
}

.btn.small {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 13px;
  box-shadow: 0 2px 0 var(--ink);
  border-width: 1.6px;
}

.btn small {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.7;
}

.icon-btn {
  appearance: none;
  border: none;
  background: rgba(255, 253, 246, 0.75);
  color: var(--ink);
  width: 40px;
  height: 40px;
  border-radius: 13px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 0 rgba(58, 48, 38, 0.14);
  flex: 0 0 auto;
}

.icon-btn.ghost {
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 253, 246, 0.8);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-soft);
}

.pill b {
  color: var(--ink);
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-title h2,
.panel-title h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.02em;
}

.panel-title span {
  font-size: 11px;
  color: var(--ink-soft);
  text-align: right;
}

/* ---------------- 首页 ---------------- */

.home-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 10px;
}

.brand {
  position: relative;
  padding-left: 46px;
}

.sun-mark {
  position: absolute;
  left: 2px;
  top: 4px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #fff8cc, var(--gold) 62%, var(--gold-deep));
  box-shadow: 0 0 0 6px rgba(247, 201, 72, 0.16), 0 0 22px rgba(247, 201, 72, 0.55);
}

.brand h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: 0.1em;
  line-height: 1.06;
}

.brand p {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.home-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.garden-panel,
.dex-panel {
  background: rgba(255, 253, 246, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.garden-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.plot {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 92px;
  transition: transform 0.15s ease;
}

.plot.is-open {
  box-shadow: 0 3px 0 rgba(95, 65, 43, 0.16);
}

.plot.is-locked {
  opacity: 0.62;
  background: rgba(255, 253, 246, 0.55);
}

.plot-soil {
  flex: 1;
  min-height: 38px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 240, 200, 0.22), transparent 40%),
    linear-gradient(160deg, #a5734e, var(--soil) 60%, #7c5438);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  position: relative;
  overflow: hidden;
}

.plot-lock {
  font-size: 16px;
  filter: grayscale(0.2);
}

.plot b {
  font-size: 12px;
  letter-spacing: 0.04em;
}

.plot small {
  font-size: 10px;
  color: var(--ink-soft);
  line-height: 1.3;
}

.fd {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50% 50% 50% 0;
  background: var(--fd, #e2574c);
  transform: rotate(-45deg);
  box-shadow: 0 1px 2px rgba(60, 40, 20, 0.3), inset 0 0 0 2px rgba(255, 255, 255, 0.18);
}

.home-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

#btn-continue span {
  font-size: 18px;
  line-height: 1;
}

.dex-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.dex-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 2px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  font-size: 9.5px;
  color: var(--ink-soft);
  text-align: center;
}

.dex-item b {
  font-size: 12px;
  color: var(--ink);
}

.dex-dot {
  width: 16px;
  height: 16px;
  border-radius: 50% 50% 50% 0;
  background: var(--fd);
  transform: rotate(-45deg);
  box-shadow: 0 2px 3px rgba(60, 40, 20, 0.2);
}

.home-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-soft);
  padding: 2px 2px 4px;
  margin-top: auto;
}

.link-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
  padding: 8px;
  cursor: pointer;
}

/* ---------------- 选关 ---------------- */

.top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.bar-title {
  flex: 1;
  text-align: center;
  line-height: 1.15;
}

.bar-title h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0.04em;
}

.bar-title small {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.level-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 16px;
}

.chapter-block {
  background: rgba(255, 253, 246, 0.74);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.7);
  padding: 12px;
  box-shadow: var(--shadow);
}

.chapter-block h3 {
  margin: 0 0 9px;
  font-size: 14.5px;
  letter-spacing: 0.04em;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.chapter-block h3 small {
  font-size: 10px;
  color: var(--ink-soft);
  font-weight: 500;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.level-card {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  min-height: 54px;
  padding: 5px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(95, 65, 43, 0.13);
  font: inherit;
  color: var(--ink);
}

.level-card:active {
  transform: translateY(2px);
  box-shadow: none;
}

.level-card.is-locked {
  opacity: 0.45;
  background: rgba(255, 253, 246, 0.5);
  box-shadow: none;
  cursor: default;
}

.lc-id {
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.lc-stars {
  display: flex;
  gap: 1px;
  line-height: 1;
}

.star {
  font-size: 9px;
  color: rgba(90, 68, 44, 0.2);
}

.star.on {
  color: var(--gold-deep);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.lc-lock {
  font-size: 10px;
}

/* ---------------- 游戏 ---------------- */

#screen-play {
  gap: 8px;
}

.goal-card {
  flex: 0 0 auto;
  background: rgba(255, 253, 246, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 15px;
  padding: 9px 12px 10px;
  box-shadow: 0 3px 0 rgba(95, 65, 43, 0.12);
  position: relative;
  overflow: hidden;
}

.goal-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--gold), var(--green));
}

.goal-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.goal-top b {
  color: var(--ink);
  font-size: 13.5px;
  letter-spacing: 0.01em;
}

.goal-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.goal-stats div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  background: rgba(255, 250, 240, 0.8);
  border-radius: 9px;
  padding: 4px 2px;
}

.goal-stats span {
  font-size: 9.5px;
  color: var(--ink-soft);
}

.goal-stats b {
  font-size: 15px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.goal-track {
  height: 5px;
  margin-top: 7px;
  border-radius: 99px;
  background: rgba(95, 65, 43, 0.12);
  overflow: hidden;
}

.goal-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), #8fce6f);
  transition: width 0.3s ease;
}

.goal-card.is-done .goal-top b {
  color: var(--green);
}

.board-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 244, 190, 0.55), transparent 55%),
    linear-gradient(170deg, rgba(255, 255, 255, 0.35), rgba(118, 176, 100, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  padding: 2px 0;
  overflow: hidden;
}

#board {
  display: block;
  touch-action: none;
  border-radius: 16px;
  cursor: pointer;
  max-width: 100%;
}

#board.is-water {
  cursor: crosshair;
}

.play-hint {
  margin: 0;
  min-height: 17px;
  font-size: 11.5px;
  color: var(--ink-soft);
  text-align: center;
  letter-spacing: 0.01em;
  padding: 0 8px;
}

.play-hint.is-ready {
  color: #7d5f11;
  font-weight: 700;
}

.device-panel {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  background: rgba(255, 253, 246, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 15px;
  padding: 9px 10px;
  box-shadow: 0 3px 0 rgba(95, 65, 43, 0.12);
}

.device-info {
  flex: 1 1 44%;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 7px;
  min-width: 0;
}

.tag {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #7d5f11;
  background: var(--gold-soft);
  border-radius: 99px;
  padding: 2px 7px;
}

.device-info b {
  font-size: 15px;
  letter-spacing: 0.02em;
}

.device-info small {
  flex: 1 1 100%;
  font-size: 10.5px;
  color: var(--ink-soft);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-next {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 8px;
  border-left: 1px dashed var(--line);
  border-right: 1px dashed var(--line);
  min-width: 52px;
}

.device-next span {
  font-size: 9px;
  color: var(--ink-soft);
}

.device-next b {
  font-size: 11.5px;
  margin-top: 1px;
}

#btn-rotate {
  flex: 0 0 auto;
}

.color-row {
  flex: 1 1 100%;
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
}

.color-dot {
  appearance: none;
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  background: var(--fd);
  border: 2px solid rgba(58, 48, 38, 0.25);
  transform: rotate(-45deg);
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(60, 40, 20, 0.18);
}

.color-dot.is-active {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-color: var(--ink);
}

#btn-fire {
  flex: 1 1 100%;
  min-height: 46px;
  font-size: 15.5px;
  letter-spacing: 0.06em;
}

.ad-bar {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
}

.ad-bar .btn {
  flex: 1;
  background: rgba(255, 253, 246, 0.85);
}

.ad-bar .btn small {
  font-size: 10px;
}

/* ---------------- 弹窗 ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(34, 27, 20, 0.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.overlay.is-hidden {
  display: none;
}

.modal {
  width: 100%;
  max-width: 356px;
  max-height: 88dvh;
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 240, 170, 0.5), transparent 55%),
    var(--paper);
  border: 2.5px solid #2c231a;
  border-radius: 22px;
  padding: 22px 19px 18px;
  box-shadow: 0 14px 0 rgba(44, 35, 26, 0.22), var(--shadow);
  text-align: center;
}

.modal h2 {
  margin: 8px 0 6px;
  font-size: 21px;
  letter-spacing: 0.03em;
}

.modal-sub {
  margin: 6px 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.65;
}

.modal-sub b {
  color: var(--ink);
}

.modal-sub.warn {
  color: #a3352c;
}

.modal-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--gold-soft);
  color: #7d5f11;
}

.modal-badge.fail {
  background: #ffe0da;
  color: #a3352c;
}

.modal-badge.ad {
  background: #dfe9ff;
  color: #35558f;
}

.win-stars {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 8px 0 2px;
  font-size: 38px;
  line-height: 1;
}

.win-stars .star {
  font-size: 38px;
  color: rgba(90, 68, 44, 0.16);
  transform: scale(0.9);
}

.win-stars .star.on {
  color: var(--gold);
  text-shadow: 0 3px 0 var(--gold-deep), 0 0 18px rgba(247, 201, 72, 0.7);
  animation: star-pop 0.45s ease backwards;
}

.win-stars .star.on:nth-child(2) {
  animation-delay: 0.1s;
}

.win-stars .star.on:nth-child(3) {
  animation-delay: 0.2s;
}

@keyframes star-pop {
  from {
    transform: scale(0.2) rotate(-25deg);
    opacity: 0;
  }
  to {
    transform: scale(0.9) rotate(0);
    opacity: 1;
  }
}

.unlock-line {
  color: var(--green);
  font-weight: 700;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.modal-actions .btn {
  width: 100%;
}

.ad-note {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(111, 143, 214, 0.1);
  border: 1px dashed rgba(111, 143, 214, 0.45);
  font-size: 11px;
  color: #4a5f86;
  line-height: 1.5;
}

.settings-modal {
  text-align: left;
}

.settings-modal h2 {
  text-align: center;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.setting-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--gold-deep);
}

/* ---------------- 提示 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(86vw, 360px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(44, 35, 26, 0.92);
  color: #fff6df;
  font-size: 12.5px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 8px 20px rgba(44, 35, 26, 0.28);
  animation: toast-in 0.18s ease;
}

.toast.is-hidden {
  display: none;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ---------------- 适配 ---------------- */

@media (max-height: 720px) {
  .screen {
    gap: 7px;
    padding-top: max(7px, env(safe-area-inset-top));
    padding-bottom: calc(7px + env(safe-area-inset-bottom));
  }

  .home-head {
    padding-top: 2px;
  }

  .brand h1 {
    font-size: 23px;
  }

  .garden-panel,
  .dex-panel {
    padding: 10px;
  }

  .plot {
    min-height: 76px;
  }

  .goal-card {
    padding: 7px 10px 8px;
  }

  .goal-top {
    margin-bottom: 4px;
  }

  .goal-stats b {
    font-size: 14px;
  }

  .device-panel {
    padding: 7px 9px;
  }

  #btn-fire {
    min-height: 42px;
  }
}

@media (max-height: 640px) {
  .home-head {
    gap: 6px;
  }

  .brand h1 {
    font-size: 20px;
  }

  .brand p,
  .home-stats {
    display: none;
  }

  .garden-grid {
    gap: 6px;
  }

  .plot {
    min-height: 62px;
    padding: 6px;
  }

  .plot-soil {
    min-height: 26px;
  }

  .plot small {
    display: none;
  }

  .dex-panel {
    display: none;
  }

  .goal-top {
    display: none;
  }
}

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

  .brand {
    padding-left: 40px;
  }

  .brand h1 {
    font-size: 23px;
  }

  .sun-mark {
    width: 28px;
    height: 28px;
  }

  .plot b {
    font-size: 11px;
  }

  .device-info small {
    font-size: 9.5px;
  }

  .device-next {
    padding: 2px 5px;
    min-width: 44px;
  }
}

@media (min-width: 620px) {
  body {
    padding: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #app {
    height: min(900px, calc(100dvh - 44px));
    border-radius: 30px;
    box-shadow: 0 30px 70px rgba(60, 42, 22, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.4);
    overflow: hidden;
  }
}

/* ---------------- V0.2 HUD ---------------- */

.stamina-pill {
  color: #7d5f11;
  background: rgba(255, 233, 168, 0.72);
  border-color: rgba(201, 151, 28, 0.3);
}

.stamina-pill b {
  color: #7d5f11;
}

.source-line {
  margin-top: 6px;
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--ink-soft);
  text-align: center;
  letter-spacing: 0.01em;
}

.durability-text {
  flex: 0 0 auto;
  font-size: 9.5px;
  font-weight: 700;
  color: #7d5f11;
  background: rgba(255, 233, 168, 0.65);
  border: 1px solid rgba(201, 151, 28, 0.28);
  border-radius: 99px;
  padding: 1px 6px;
}

.device-next small {
  display: block;
  margin-top: 1px;
  font-size: 9px;
  color: var(--ink-soft);
  line-height: 1.1;
}

.action-bar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.action-bar .btn {
  min-height: 38px;
  padding: 5px 3px;
  font-size: 11.5px;
  border-width: 1.4px;
  border-radius: 11px;
  box-shadow: 0 2px 0 var(--ink);
  white-space: nowrap;
}

.action-bar .btn small {
  display: block;
  font-size: 9px;
  line-height: 1.1;
  margin-left: 1px;
}

.action-bar .btn.is-active {
  background: linear-gradient(180deg, #d7f0ff, #9fd8ef);
}

.action-bar .btn:disabled {
  box-shadow: 0 2px 0 rgba(58, 48, 38, 0.35);
}

@media (max-width: 350px) {
  .action-bar {
    gap: 4px;
  }

  .action-bar .btn {
    font-size: 10.5px;
    padding: 4px 2px;
  }

  .source-line {
    font-size: 9.5px;
  }
}

.diamond-pill {
  color: #315d7d;
  background: rgba(200, 230, 255, 0.72);
  border-color: rgba(80, 130, 170, 0.28);
}

.diamond-pill b {
  color: #315d7d;
}

.reward-line {
  color: #7d5f11;
  font-weight: 700;
  background: rgba(255, 233, 168, 0.42);
  border-radius: 9px;
  padding: 5px 8px;
}

.play-resources {
  margin-top: 4px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

/* ---------------- 无尽花园 ---------------- */

.endless-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.endless-entry span {
  font-size: 11px;
  color: var(--ink-soft);
}

.endless-entry:disabled {
  opacity: 0.48;
}

#screen-endless {
  gap: 8px;
}

.endless-hud {
  flex: 0 0 auto;
  background: linear-gradient(180deg, rgba(255, 253, 246, 0.92), rgba(255, 245, 220, 0.82));
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 15px;
  padding: 8px 12px 9px;
  box-shadow: 0 3px 0 rgba(95, 65, 43, 0.12);
}

.endless-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  line-height: 1;
}

.endless-score b {
  font-size: 32px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.endless-score span {
  font-size: 11px;
  color: var(--ink-soft);
}

.endless-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 7px;
}

.endless-stats div {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 250, 240, 0.75);
  border-radius: 8px;
  padding: 3px 2px;
}

.endless-stats span {
  font-size: 9px;
  color: var(--ink-soft);
}

.endless-stats b {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.endless-tray {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tray-slot {
  appearance: none;
  border: 1.6px solid var(--line);
  background: rgba(255, 253, 246, 0.86);
  border-radius: 13px;
  min-height: 54px;
  padding: 5px 8px;
  color: var(--ink);
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(95, 65, 43, 0.14);
}

.tray-slot b {
  font-size: 13.5px;
}

.tray-slot small {
  font-size: 9.5px;
  color: var(--ink-soft);
}

.tray-slot .tray-dots {
  display: flex;
  gap: 3px;
  margin-top: 1px;
}

.tray-slot .tray-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #ffd86a;
  box-shadow: 0 0 0 1px rgba(120, 80, 20, 0.2);
}

.tray-slot.is-selected {
  border-color: var(--gold-deep);
  background: linear-gradient(180deg, rgba(255, 246, 190, 0.96), rgba(255, 233, 168, 0.82));
  outline: 2px solid rgba(247, 201, 72, 0.55);
  outline-offset: 1px;
}

.tray-slot.is-empty {
  opacity: 0.45;
  cursor: default;
}

.tray-slot .tray-special {
  color: #9a6b0c;
  font-size: 9px;
  font-weight: 800;
}

.endless-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.endless-board-wrap {
  min-height: 0;
}

#endless-board {
  display: block;
  touch-action: none;
  border-radius: 16px;
  cursor: pointer;
  max-width: 100%;
}

/* ---------------- 排行榜 ---------------- */

.rank-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rank-entry span {
  font-size: 11px;
  color: var(--ink-soft);
}

.rank-entry:disabled {
  opacity: 0.48;
}

#screen-rank {
  gap: 8px;
}

.rank-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(255, 253, 246, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 14px;
  padding: 8px 11px;
  box-shadow: 0 3px 0 rgba(95, 65, 43, 0.12);
}

.rank-tier {
  font-size: 12px;
  font-weight: 800;
  color: #7d5f11;
  background: var(--gold-soft);
  border-radius: 99px;
  padding: 3px 9px;
}

#rank-countdown {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.rank-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 8px;
}

.rank-list {
  background: rgba(255, 253, 246, 0.82);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  padding: 6px;
  box-shadow: var(--shadow);
}

.rank-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border-radius: 9px;
  font-size: 12.5px;
}

.rank-row:nth-child(odd) {
  background: rgba(255, 250, 240, 0.55);
}

.rank-row.is-me {
  background: rgba(255, 233, 168, 0.75);
  outline: 1.5px solid rgba(201, 151, 28, 0.55);
}

.rank-row.no-score {
  opacity: 0.6;
}

.rank-no {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.rank-name {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-weight: 700;
}

.rank-name small {
  font-size: 8.5px;
  color: var(--ink-soft);
  font-weight: 500;
}

.rank-score {
  font-variant-numeric: tabular-nums;
}

.rank-self {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  background: rgba(255, 233, 168, 0.6);
  border: 1.5px solid rgba(201, 151, 28, 0.45);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
}

.rank-self b {
  font-size: 18px;
}

.rank-self span:last-child {
  text-align: right;
  color: var(--ink-soft);
}

.rank-section {
  background: rgba(255, 253, 246, 0.78);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  padding: 9px 11px;
  box-shadow: var(--shadow);
}

.rank-section h3 {
  margin: 0 0 7px;
  font-size: 13px;
}

.rank-reward-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(255, 233, 168, 0.45);
  margin-bottom: 6px;
}

.rank-reward-card div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rank-reward-card small {
  font-size: 10px;
  color: var(--ink-soft);
}

.rank-history-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
  padding: 4px 0;
  font-size: 11px;
  border-bottom: 1px dashed var(--line);
}

.rank-history-row span:last-child {
  text-align: right;
  color: var(--ink-soft);
}

.rank-empty {
  margin: 4px 0;
  font-size: 11px;
  color: var(--ink-soft);
}

.rank-species-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-soft);
  margin: 10px 0;
}

.rank-species-label select {
  font: inherit;
  padding: 9px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

/* ---------------- 种植花园 ---------------- */

.garden-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.garden-entry span {
  font-size: 11px;
  color: var(--ink-soft);
}

.garden-entry:disabled {
  opacity: 0.48;
}

#garden-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  overflow-y: auto;
  padding-bottom: 4px;
  flex: 1 1 auto;
  min-height: 0;
}

.garden-card {
  appearance: none;
  border: 1.4px solid var(--line);
  background: rgba(255, 253, 246, 0.86);
  border-radius: 13px;
  min-height: 78px;
  padding: 6px;
  color: var(--ink);
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(95, 65, 43, 0.13);
  text-align: left;
}

.garden-card b {
  font-size: 12.5px;
}

.garden-card small {
  font-size: 9.5px;
  color: var(--ink-soft);
  line-height: 1.25;
}

.garden-card.is-locked {
  opacity: 0.5;
  background: rgba(255, 253, 246, 0.5);
  box-shadow: none;
}

.garden-card.is-mature {
  background: linear-gradient(180deg, rgba(255, 246, 190, 0.95), rgba(255, 226, 150, 0.75));
  border-color: rgba(201, 151, 28, 0.5);
}

.garden-progress {
  display: block;
  width: 100%;
  height: 5px;
  border-radius: 99px;
  background: rgba(95, 65, 43, 0.12);
  overflow: hidden;
}

.garden-progress i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--gold), var(--green));
}

.garden-progress.big {
  height: 8px;
  margin: 8px 0;
}

.garden-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
}

.garden-actions .btn {
  flex: 1;
}

.garden-seed-panel {
  flex: 0 0 auto;
  background: rgba(255, 253, 246, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 13px;
  padding: 8px 11px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.garden-seed-panel b {
  color: var(--ink);
}

.garden-collection {
  flex: 0 0 auto;
}

.garden-collection-item {
  display: inline-block;
  margin: 2px 6px 2px 0;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(255, 233, 168, 0.5);
  font-size: 10px;
}

.garden-subtitle {
  margin: 12px 0 6px;
  font-size: 12px;
  color: var(--ink-soft);
  text-align: left;
}

.seed-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  text-align: left;
}

.seed-option {
  appearance: none;
  border: 1.4px solid var(--line);
  background: var(--paper);
  border-radius: 11px;
  padding: 7px 9px;
  font: inherit;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 1px;
  cursor: pointer;
}

.seed-option b {
  font-size: 12.5px;
}

.seed-option small {
  font-size: 10px;
  color: var(--ink-soft);
}

.seed-option.is-disabled {
  opacity: 0.45;
}

.bug-btn {
  width: 100%;
  margin-bottom: 6px;
}

.garden-ad-row {
  display: flex;
  gap: 6px;
  margin-top: 7px;
}

.garden-ad-row .btn {
  flex: 1;
}
