/* 金币水果园 · 竖屏合成小游戏 */
:root {
  --orange: #FF8A3D;
  --orange-deep: #F26A1B;
  --orange-soft: #FFB06E;
  --cream: #FFF8EC;
  --cream-deep: #FFEFD8;
  --ink: #55301A;
  --ink-soft: #8A5A38;
  --muted: #AA7E5C;
  --line: #EEC9A4;
  --green: #63B65A;
  --gold: #FFC13D;
  --shadow: rgba(150, 78, 26, 0.14);
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #F0B77F;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}

body {
  display: flex;
  justify-content: center;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 236, 205, 0.9) 0%, rgba(255, 205, 160, 0) 60%),
    linear-gradient(180deg, #F5C08B 0%, #E9A367 100%);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}

.app {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #FFF1DB;
  box-shadow: 0 0 90px rgba(110, 50, 10, 0.28);
  isolation: isolate;
}

.game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------------- 顶部 HUD ---------------- */
.hud {
  position: absolute;
  z-index: 6;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.wallet-card {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 6px 15px 6px 7px;
  border-radius: 19px;
  border: 2px solid #E9C09A;
  background: linear-gradient(180deg, #FFFDF8 0%, #FFF2DE 100%);
  box-shadow: 0 4px 0 rgba(191, 118, 55, 0.18), 0 9px 20px rgba(130, 65, 20, 0.12);
}

.coin {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #8A4A00;
  border: 2px solid #E29200;
  background: radial-gradient(circle at 32% 26%, #FFEB9C 0%, #FFD35C 38%, #FFB51D 72%, #F09000 100%);
  box-shadow: inset 0 -3px 0 rgba(168, 89, 0, 0.24), 0 2px 0 rgba(255, 255, 255, 0.4);
  animation: coinFloat 3.2s ease-in-out infinite;
}

.coin .mp-icon {
  width: 21px;
  height: 21px;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.4));
}

.wallet-main {
  display: flex;
  flex-direction: column;
  min-width: 72px;
  line-height: 1;
}

#coinTotal {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #4E2A12;
  font-variant-numeric: tabular-nums;
  transition: transform 0.14s ease;
  transform-origin: left center;
}

#coinTotal.bump {
  transform: scale(1.1);
}

.wallet-sub {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  font-size: 10px;
  font-weight: 800;
  color: #A97750;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.wallet-sub em {
  font-style: normal;
  color: #E06F16;
  font-size: 11px;
}

.pulse-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(99, 182, 90, 0.5);
  animation: pulse 1.9s infinite;
}

.hud-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: #8A5430;
  border: 2px solid #E9C09A;
  background: linear-gradient(180deg, #FFFDF8 0%, #FFF2DE 100%);
  box-shadow: 0 4px 0 rgba(191, 118, 55, 0.2), 0 8px 16px rgba(130, 65, 20, 0.1);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.icon-btn .mp-icon {
  width: 23px;
  height: 23px;
}

.icon-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(191, 118, 55, 0.2), 0 3px 8px rgba(130, 65, 20, 0.1);
}

/* ---------------- 底部操作坞 ---------------- */
.dock {
  position: absolute;
  z-index: 7;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  padding: 10px 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: linear-gradient(180deg, #FFF9EE 0%, #FFF3DF 58%, #FFEACB 100%);
  border-top: 3px solid #EEC9A4;
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -12px 28px rgba(140, 75, 25, 0.13);
}

.dock::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 46px;
  height: 5px;
  border-radius: 4px;
  transform: translateX(-50%);
  background: #E7B98D;
  opacity: 0.55;
}

.next-card {
  flex: 0 0 auto;
  width: 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 3px 2px 4px;
  border-radius: 18px;
  border: 2px solid #EDC79F;
  background: linear-gradient(180deg, #FFFDF8 0%, #FFF2DE 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 2px 5px rgba(150, 90, 40, 0.08);
}

.next-card span {
  font-size: 9px;
  font-weight: 800;
  color: #AA7953;
  letter-spacing: 0.04em;
  line-height: 1;
}

#nextFruit {
  width: 48px;
  height: 48px;
  display: block;
}

.dock-mid {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 1px;
}

.run-score {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 12px;
  font-weight: 800;
  color: #9B6B46;
  white-space: nowrap;
}

.run-score b {
  font-size: 25px;
  line-height: 1;
  color: #4E2A12;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.run-score small {
  font-size: 10px;
  color: #B08A67;
  font-weight: 700;
}

.hint {
  margin-top: 6px;
  font-size: 10.5px;
  font-weight: 700;
  color: #B48B66;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.best-card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  padding-right: 2px;
}

.best-card span {
  font-size: 9.5px;
  font-weight: 800;
  color: #B08A67;
  letter-spacing: 0.06em;
}

.best-card b {
  font-size: 16px;
  font-weight: 900;
  color: #7A4A2A;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 轻提示 ---------------- */
.toast {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 108px);
  max-width: calc(100% - 48px);
  padding: 9px 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(72, 38, 16, 0.84);
  color: #FFF4E2;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px) scale(0.96);
  transition: opacity 0.22s ease, transform 0.22s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 20px rgba(60, 28, 8, 0.2);
}

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

/* ---------------- 弹层 ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background: rgba(70, 35, 14, 0.46);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.24s ease, visibility 0.24s ease;
}

.overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.panel {
  width: 100%;
  max-width: 336px;
  padding: 26px 23px 22px;
  border-radius: 30px;
  border: 3px solid #F0CDA7;
  background: linear-gradient(180deg, #FFFDF8 0%, #FFF6E6 62%, #FFEDD4 100%);
  box-shadow: 0 22px 48px rgba(72, 34, 10, 0.3), inset 0 -5px 0 rgba(238, 201, 164, 0.45);
  text-align: center;
  transform: translateY(16px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.22, 1.25, 0.36, 1);
}

.overlay.show .panel {
  transform: translateY(0) scale(1);
}

.panel-badge {
  width: 62px;
  height: 62px;
  margin: -54px auto 10px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px solid #FFE0B8;
  color: #A95A18;
  background: radial-gradient(circle at 32% 26%, #FFE7A4 0%, #FFC65B 48%, #FFB02E 100%);
  box-shadow: 0 7px 0 rgba(190, 110, 30, 0.22), 0 12px 22px rgba(130, 65, 20, 0.18);
}

.panel-badge .mp-icon {
  width: 30px;
  height: 30px;
}

.panel-badge.medal {
  color: #8A4A00;
}

.panel-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #B4815B;
}

.panel-title {
  margin: 0 0 15px;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #4A2812;
}

.panel-copy {
  margin: 0 0 18px;
  font-size: 12.5px;
  line-height: 1.6;
  color: #A17450;
  font-weight: 600;
}

.big-score {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 14px;
  padding: 14px 10px 13px;
  border-radius: 20px;
  background: linear-gradient(180deg, #FFF0D6, #FFE4BC);
  border: 2px solid #F3D3AD;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55);
}

.big-score span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #AD7B53;
}

.big-score b {
  font-size: 40px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: #4E2A12;
  font-variant-numeric: tabular-nums;
}

.stat-row {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.stat-cell {
  flex: 1;
  padding: 10px 6px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.65);
  border: 1.5px solid #F1D6B7;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-cell span {
  font-size: 9.5px;
  font-weight: 800;
  color: #B08A67;
  letter-spacing: 0.05em;
}

.stat-cell b {
  font-size: 16px;
  font-weight: 900;
  color: #6D4226;
  font-variant-numeric: tabular-nums;
}

.btn {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 17px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.02em;
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.18s ease;
}

.btn + .btn {
  margin-top: 9px;
}

.btn .mp-icon {
  width: 19px;
  height: 19px;
}

.btn-primary {
  color: #FFF9F0;
  background: linear-gradient(180deg, #FFAA62 0%, #FF8A3D 42%, #F87420 100%);
  border: 2px solid #F27A28;
  box-shadow: 0 5px 0 #D65D0D, 0 12px 22px rgba(248, 116, 32, 0.28);
  text-shadow: 0 1px 0 rgba(150, 60, 0, 0.2);
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #D65D0D, 0 5px 10px rgba(248, 116, 32, 0.2);
}

.btn-ghost {
  color: #8A5430;
  background: #FFFAF2;
  border: 2px solid #EBC49D;
  box-shadow: 0 4px 0 rgba(191, 118, 55, 0.16);
}

.btn-ghost:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(191, 118, 55, 0.16);
}

.btn-coin {
  color: #7C4500;
  background: linear-gradient(180deg, #FFF5CF 0%, #FFE7A0 50%, #FFD879 100%);
  border: 2px solid #E8B84B;
  box-shadow: 0 4px 0 #D6A63A, 0 10px 18px rgba(210, 150, 30, 0.18);
}

.btn-coin:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #D6A63A;
}

.btn[disabled] {
  opacity: 0.48;
  box-shadow: 0 3px 0 rgba(170, 120, 60, 0.18);
}

.btn[disabled]:active {
  transform: none;
}

/* ---------------- 动画 ---------------- */
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 182, 90, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(99, 182, 90, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 182, 90, 0); }
}

@keyframes coinFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-2px) rotate(2deg); }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-height: 640px) {
  .dock { min-height: 82px; padding-top: 8px; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 9px); }
  .next-card { width: 56px; }
  #nextFruit { width: 42px; height: 42px; }
  .run-score b { font-size: 22px; }
  .panel { padding: 22px 20px 18px; }
  .big-score b { font-size: 34px; }
}

@media (min-width: 521px) {
  .app {
    border-radius: 26px;
    height: min(100dvh, 940px);
    margin: auto;
  }
  body { align-items: center; }
}
