:root {
  --theme: #FF8A3D;
  --theme-dark: #E86F22;
  --theme-soft: #FFE7D6;
  --ink: #3A2A1E;
  --ink-2: #7A6555;
  --ink-3: #A89684;
  --card: #FFFDF8;
  --line: #EADFD2;
  --soil: #8B5A34;
  --soil-dark: #6E4526;
  --grass: #7CC24A;
  --grass-dark: #5AA02E;
  --shadow: 0 6px 18px rgba(122, 84, 48, .16);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #FDF3E7;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  overscroll-behavior: none;
}

body { -webkit-user-select: none; user-select: none; }

.game {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px calc(env(safe-area-inset-bottom, 0px) + 96px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  background: linear-gradient(180deg, #FFE9D2 0%, #FFF6EA 46%, #FDF3E7 100%);
}

/* ---------- 天空远景 ---------- */
.sky { position: absolute; inset: 0 0 auto 0; height: 260px; pointer-events: none; overflow: hidden; }
.sun {
  position: absolute; top: 26px; right: 26px; width: 62px; height: 62px; border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #FFE08A, #FFB13D 70%);
  box-shadow: 0 0 0 10px rgba(255, 190, 90, .18), 0 0 34px rgba(255, 170, 60, .45);
}
.cloud {
  position: absolute; height: 26px; border-radius: 20px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 4px 10px rgba(255, 190, 140, .25);
}
.cloud::before, .cloud::after {
  content: ""; position: absolute; border-radius: 50%; background: inherit;
}
.cloud::before { width: 30px; height: 30px; top: -13px; left: 12px; }
.cloud::after { width: 22px; height: 22px; top: -9px; right: 14px; }
.c1 { width: 78px; top: 54px; left: 18px; animation: drift 26s linear infinite; }
.c2 { width: 62px; top: 104px; left: 46%; animation: drift 34s linear infinite; opacity: .8; }
@keyframes drift {
  0% { transform: translateX(-16px); }
  50% { transform: translateX(18px); }
  100% { transform: translateX(-16px); }
}
.hill {
  position: absolute; bottom: 0; border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}
.h1 { left: -12%; width: 78%; height: 120px; background: linear-gradient(180deg, #BFE39A, #9BD072); }
.h2 { right: -16%; width: 82%; height: 96px; background: linear-gradient(180deg, #D3ECB4, #B4DE8C); }

/* ---------- HUD ---------- */
.hud {
  position: relative; z-index: 2;
  display: flex; gap: 8px; justify-content: flex-end;
}
.hud-chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 34px; padding: 0 12px 0 9px;
  background: rgba(255, 253, 248, .94);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(150, 110, 70, .14);
  font-size: 14px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.hud-chip .mp-icon { font-size: 18px; }

/* ---------- 玩家卡 ---------- */
.player {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.avatar {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 14px;
  background: linear-gradient(160deg, #FFD9B8, #FFB27A);
  display: grid; place-items: center; overflow: hidden;
  border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(200, 130, 70, .28);
  font-size: 18px; font-weight: 800; color: #8A4A16;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.player-meta { flex: 1 1 auto; min-width: 0; }
.player-name {
  font-size: 15px; font-weight: 800; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-sub { margin-top: 2px; font-size: 11.5px; color: var(--ink-3); }
.exp-wrap { flex: 0 0 74px; text-align: right; }
.exp-bar {
  height: 7px; border-radius: 999px; background: #F0E6DA; overflow: hidden;
}
.exp-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, #FFB066, var(--theme));
  transition: width .35s ease;
}
.exp-txt { margin-top: 4px; font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- 田地 ---------- */
.field-wrap {
  position: relative; z-index: 2;
  flex: 1 1 auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 12px 12px;
  background: linear-gradient(180deg, #FFFDF8, #FFF7EC);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.field {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.plot {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  border: 2px solid #C99A6B;
  background:
    repeating-linear-gradient(180deg, rgba(0,0,0,.07) 0 2px, transparent 2px 12px),
    linear-gradient(180deg, #A9713F, var(--soil) 60%, var(--soil-dark));
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .18), 0 4px 10px rgba(120, 80, 40, .22);
  display: grid; place-items: center;
  overflow: hidden;
  transition: transform .12s ease, box-shadow .12s ease;
  cursor: pointer;
}
.plot:active { transform: scale(.96); }
.plot.empty::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(255,255,255,.16), transparent 62%);
}
.plot .crop {
  position: relative; z-index: 1;
  display: grid; place-items: center;
  width: 100%; height: 100%;
  font-size: 30px;
  transition: transform .3s cubic-bezier(.2, 1.4, .4, 1);
}
.plot .crop .mp-icon { font-size: 30px; color: #fff; filter: drop-shadow(0 2px 3px rgba(0,0,0,.28)); }
.plot.growing .crop { animation: sway 2.4s ease-in-out infinite; }
@keyframes sway {
  0%, 100% { transform: rotate(-4deg) translateY(0); }
  50% { transform: rotate(4deg) translateY(-2px); }
}
.plot.ready {
  border-color: #FFC24A;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.2), 0 0 0 3px rgba(255, 194, 74, .55), 0 6px 14px rgba(200, 140, 40, .3);
}
.plot.ready .crop { animation: pop 1.1s ease-in-out infinite; }
@keyframes pop {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.14); }
}
.plot .ring {
  position: absolute; left: 8px; right: 8px; bottom: 7px; height: 5px;
  border-radius: 999px; background: rgba(0, 0, 0, .3); overflow: hidden; z-index: 2;
}
.plot .ring > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #9BE36A, #4FBF3A);
  border-radius: 999px;
  transition: width .3s linear;
}
.plot .badge {
  position: absolute; top: 5px; right: 5px; z-index: 2;
  width: 18px; height: 18px; border-radius: 50%;
  background: #FFC24A; color: #6B3E00;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
  box-shadow: 0 2px 5px rgba(0,0,0,.25);
}
.plot .badge .mp-icon { font-size: 12px; color: #6B3E00; }

.field-tip {
  margin-top: auto;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--theme-soft);
  border-radius: 12px;
  padding: 8px 10px;
  line-height: 1.4;
}

/* ---------- 底部操作 ---------- */
.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  max-width: 520px;
  margin: 0 auto;
  padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
  display: flex; gap: 10px;
  background: linear-gradient(180deg, rgba(253, 243, 231, 0), rgba(253, 243, 231, .96) 34%);
}
.dock-btn {
  flex: 1 1 0;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  box-shadow: 0 4px 12px rgba(150, 110, 70, .16);
  transition: transform .1s ease, box-shadow .1s ease, background .15s ease;
  cursor: pointer;
}
.dock-btn .mp-icon { font-size: 20px; color: var(--theme-dark); }
.dock-btn:active { transform: translateY(2px) scale(.98); box-shadow: 0 2px 6px rgba(150, 110, 70, .18); }
.dock-btn.primary {
  background: linear-gradient(180deg, #FFA45E, var(--theme));
  border-color: var(--theme-dark);
  color: #fff;
  box-shadow: 0 6px 16px rgba(255, 138, 61, .42);
}
.dock-btn.primary .mp-icon { color: #fff; }
.dock-btn.primary:active { box-shadow: 0 3px 8px rgba(255, 138, 61, .4); }
.dock-btn[disabled] { opacity: .5; }

/* ---------- 探索面板 ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-mask {
  position: absolute; inset: 0;
  background: rgba(58, 42, 30, .42);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet-body {
  position: relative;
  width: 100%; max-width: 520px;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 14px 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
  box-shadow: 0 -8px 28px rgba(90, 60, 30, .22);
  animation: slideUp .26s cubic-bezier(.2, .9, .3, 1);
  max-height: 78vh;
  overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-title { font-size: 17px; font-weight: 800; }
.sheet-close {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: #FFF6EC;
  display: grid; place-items: center; cursor: pointer;
}
.sheet-close .mp-icon { font-size: 18px; color: var(--ink-2); }
.sheet-content { font-size: 14px; color: var(--ink-2); line-height: 1.6; }

.explore-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: #FFF9F1;
  margin-bottom: 10px;
}
.explore-card h3 { margin: 0 0 4px; font-size: 15px; color: var(--ink); }
.explore-card p { margin: 0; font-size: 12.5px; color: var(--ink-3); }
.explore-go {
  margin-top: 10px;
  width: 100%; height: 44px;
  border: none; border-radius: 12px;
  background: linear-gradient(180deg, #FFA45E, var(--theme));
  color: #fff; font-family: inherit; font-size: 14px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(255, 138, 61, .34);
  cursor: pointer;
}
.explore-go:active { transform: translateY(1px); }
.explore-go[disabled] { background: #E7DCD0; color: #A89684; box-shadow: none; }

/* ---------- 飘字 ---------- */
.float-layer { position: fixed; inset: 0; pointer-events: none; z-index: 30; }
.float-txt {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 15px; font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 6px rgba(120, 70, 20, .55);
  animation: floatUp .95s ease-out forwards;
  white-space: nowrap;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
  22% { opacity: 1; transform: translate(-50%, -70%) scale(1.06); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}

/* 小屏适配 */
@media (max-height: 640px) {
  .field { gap: 8px; }
  .plot .crop .mp-icon { font-size: 26px; }
  .dock-btn { height: 50px; }
}
