/* 桑基鱼塘 · 6天生态手感样板样式（遵循 ui-taste：暖色半透明统一、浮光主按钮、弧形转盘、无黑粗描边） */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

:root {
  --glass-bg: rgba(34, 46, 36, 0.62);
  --glass-border: rgba(255, 250, 236, 0.28);
  --glass-text: #fcf7ea;
  --paper-bg: #f6efe0;
  --paper-ink: #342c21;
  --paper-sub: #6f624e;
  --accent-top: #f2b755;
  --accent-bot: #d4832a;
  --accent-edge: #935314;
  --ok-green: #58a665;
  --warn-amber: #e2a23b;
  --danger-red: #d95d4a;
  --font-ui: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-num: ui-monospace, "SF Mono", "Consolas", monospace;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #6ea36a;
  font-family: var(--font-ui);
  touch-action: none;
  color: var(--glass-text);
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #77ab70;
}

#cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* 统一半透明浮层基础 */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--glass-text);
  box-shadow: 0 4px 16px rgba(18, 28, 20, 0.22);
}

/* 顶栏：极简占屏 <1/10，图标+进度条为主 */
#topbar {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.top-pill {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  line-height: 1;
}

.day-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  white-space: nowrap;
}

.day-num {
  font-family: var(--font-num);
  font-size: 13px;
}

.weather-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: rgba(255, 250, 236, 0.14);
}

.money-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-num);
  font-weight: 700;
  color: #f9d976;
  white-space: nowrap;
}

/* 图形化迷你指示条（水色、溶氧、鱼长） */
.mini-meters {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: rgba(252, 247, 234, 0.9);
  white-space: nowrap;
}

.meter-bar {
  width: 34px;
  height: 7px;
  border-radius: 99px;
  background: rgba(15, 24, 17, 0.48);
  overflow: hidden;
  border: 1px solid rgba(255, 250, 236, 0.18);
}

.meter-fill {
  display: block;
  height: 100%;
  width: 60%;
  border-radius: 99px;
  transition: width 0.25s ease, background 0.25s ease;
}

.meter-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 250, 236, 0.65);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

.top-actions {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pill-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.15s ease;
}

.pill-btn:active {
  transform: scale(0.95);
}

.pill-btn.active {
  background: rgba(212, 131, 42, 0.82);
  border-color: rgba(255, 243, 210, 0.72);
}

/* 目标提示轻条：贴顶栏下方居中，无厚框投影 */
#goal-strip {
  position: fixed;
  top: calc(max(8px, env(safe-area-inset-top)) + 42px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.3;
  max-width: calc(100vw - 24px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
}

.goal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f2c35a;
  flex: none;
}

.goal-dot.urgent {
  background: #f0654a;
  animation: pulseDot 0.9s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.45); opacity: 0.55; }
}

/* 老农说话框：头像 + 一句话，完整显示或点掉，绝不缩成小条 */
#dialog-box {
  position: fixed;
  left: 50%;
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 10px);
  transform: translateX(-50%) translateY(18px);
  z-index: 14;
  width: min(440px, calc(100vw - 28px));
  padding: 10px 14px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 11px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

#dialog-box.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.npc-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: none;
  background: rgba(246, 239, 224, 0.92);
  border: 1.5px solid rgba(255, 250, 236, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.npc-body {
  flex: 1;
  min-width: 0;
}

.npc-name {
  font-size: 11px;
  color: #f4d68c;
  margin-bottom: 2px;
  font-weight: 600;
}

.npc-text {
  font-size: 13px;
  line-height: 1.45;
  color: #fcf7ea;
}

.npc-close {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 250, 236, 0.16);
  color: #fcf7ea;
  font-size: 14px;
  cursor: pointer;
}

/* 左下摇杆 */
#joyzone {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 42vw;
  height: 48vh;
  z-index: 7;
}

#joy {
  position: fixed;
  left: calc(max(18px, env(safe-area-inset-left)) + 8px);
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 8px);
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: rgba(34, 46, 36, 0.28);
  border: 1.5px solid rgba(255, 250, 236, 0.32);
  pointer-events: none;
  z-index: 8;
  transition: opacity 0.2s;
}

#knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(252, 247, 234, 0.68);
  box-shadow: 0 3px 10px rgba(18, 28, 20, 0.28);
}

/* 右下操作簇：浮光主动作大键 + 半透明快捷键 */
#ctrl-right {
  position: fixed;
  right: calc(max(16px, env(safe-area-inset-right)) + 6px);
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 8px);
  z-index: 11;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.sub-row {
  display: flex;
  gap: 8px;
}

.sub-btn {
  height: 38px;
  padding: 0 13px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: transform 0.12s ease;
}

.sub-btn:active {
  transform: scale(0.95);
}

/* 浮光主按钮（ui-taste 第2条：上浅下深渐变 + 仅顶部一条白高光 + 底部深色厚边，按下厚边消失下沉） */
.glossy-btn {
  position: relative;
  border: 0;
  color: #fffdf6;
  font-family: var(--font-ui);
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(180deg, var(--accent-top) 0%, var(--accent-bot) 100%);
  box-shadow: 0 5px 0 var(--accent-edge), 0 8px 18px rgba(45, 25, 6, 0.34);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.15s ease;
  overflow: hidden;
}

.glossy-btn::before {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  top: 4px;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.48);
  pointer-events: none;
}

.glossy-btn:active,
.glossy-btn.pressed {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--accent-edge), 0 3px 8px rgba(45, 25, 6, 0.28);
}

.glossy-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

#act-btn {
  min-width: 118px;
  height: 54px;
  padding: 0 20px;
  border-radius: 28px;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  letter-spacing: 0.5px;
}

/* 怀里抱着的东西徽章 */
#carry-chip {
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  display: none;
  align-items: center;
  gap: 5px;
}

#carry-chip.show {
  display: inline-flex;
}

/* 轻提示 Toast（置于弹窗之下，不遮挡剖面与苗摊） */
#toast {
  position: fixed;
  left: 50%;
  top: calc(max(8px, env(safe-area-inset-top)) + 78px);
  transform: translateX(-50%) translateY(-6px);
  z-index: 16;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===========================
   水下三层剖面透视窗（原视频灵魂）
   =========================== */
#xray-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(16, 24, 18, 0.52);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

#xray-modal.open {
  display: flex;
}

.xray-sheet {
  width: min(640px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
  background: var(--paper-bg);
  color: var(--paper-ink);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 46px rgba(10, 18, 12, 0.45);
}

.sheet-head {
  padding: 11px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(52, 44, 33, 0.1);
}

.sheet-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-sub {
  font-size: 12px;
  color: var(--paper-sub);
  font-weight: 400;
}

.close-x {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: rgba(52, 44, 33, 0.09);
  color: var(--paper-ink);
  font-size: 17px;
  cursor: pointer;
}

.xray-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 54vh;
  background: #8cc9e8;
  touch-action: none;
}

#xray-cv {
  width: 100%;
  height: 100%;
  display: block;
}

.xray-foot {
  padding: 10px 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.secchi-status {
  flex: 1;
  min-width: 180px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--paper-sub);
}

.secchi-status strong {
  color: var(--paper-ink);
}

.xray-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.paper-btn {
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(52, 44, 33, 0.18);
  background: #fffaf0;
  color: var(--paper-ink);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.primary-pill {
  height: 40px;
  padding: 0 20px;
  border-radius: 999px;
  font-size: 14px;
}

/* ===========================
   苗摊 · 弧形转盘（ui-taste 第1条）
   =========================== */
#shop-modal {
  position: fixed;
  inset: 0;
  z-index: 22;
  background: rgba(16, 24, 18, 0.56);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

#shop-modal.open {
  display: flex;
}

.shop-sheet {
  width: min(560px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
  background: var(--paper-bg);
  color: var(--paper-ink);
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(10, 18, 12, 0.48);
}

.carousel-stage {
  position: relative;
  height: 196px;
  overflow: hidden;
  touch-action: pan-y;
  background: radial-gradient(ellipse at 50% 95%, rgba(212, 165, 92, 0.24), transparent 72%);
}

.carousel-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 146px;
  height: 158px;
  margin-left: -73px;
  margin-top: -82px;
  border-radius: 18px;
  background: #fffbf2;
  border: 1.5px solid rgba(118, 92, 54, 0.18);
  box-shadow: 0 10px 24px rgba(52, 44, 33, 0.16);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease, filter 0.28s ease;
}

.carousel-card.center {
  border-color: #d4832a;
  box-shadow: 0 14px 30px rgba(154, 92, 22, 0.24);
}

.card-art {
  width: 82px;
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-tag {
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(88, 166, 101, 0.14);
  color: #2f6b3a;
  font-weight: 600;
}

.card-tag.warn {
  background: rgba(217, 93, 74, 0.14);
  color: #a93b2a;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: rgba(52, 44, 33, 0.1);
  color: var(--paper-ink);
  font-size: 18px;
  cursor: pointer;
  z-index: 5;
}

.carousel-arrow.prev { left: 10px; }
.carousel-arrow.next { right: 10px; }

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding-bottom: 6px;
}

.c-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(52, 44, 33, 0.2);
  transition: width 0.2s, background 0.2s;
}

.c-dot.on {
  width: 18px;
  border-radius: 99px;
  background: #d4832a;
}

/* 只给中间选中项展示详细信息 */
.shop-detail {
  padding: 8px 18px 16px;
  text-align: center;
}

.shop-item-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--paper-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.shop-price {
  font-family: var(--font-num);
  font-size: 15px;
  color: #b46615;
}

.shop-item-desc {
  margin: 5px auto 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--paper-sub);
  max-width: 420px;
}

.shop-warn {
  margin: 0 auto 10px;
  padding: 5px 11px;
  border-radius: 10px;
  font-size: 12px;
  background: rgba(217, 93, 74, 0.12);
  color: #a63726;
  display: inline-block;
}

.shop-warn:empty {
  display: none;
}

.shop-buy-btn {
  height: 44px;
  min-width: 180px;
  padding: 0 26px;
  border-radius: 22px;
  font-size: 15px;
}

/* ===========================
   结算 / 桑基合龙大卡片
   =========================== */
#summary-modal {
  position: fixed;
  inset: 0;
  z-index: 26;
  background: rgba(16, 24, 18, 0.62);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

#summary-modal.open {
  display: flex;
}

.summary-sheet {
  width: min(500px, calc(100vw - 22px));
  max-height: calc(100vh - 22px);
  overflow: auto;
  background: var(--paper-bg);
  color: var(--paper-ink);
  border-radius: 22px;
  padding: 20px 20px 18px;
  box-shadow: 0 22px 54px rgba(10, 18, 12, 0.5);
}

.summary-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(88, 166, 101, 0.16);
  color: #2f6b3a;
  font-size: 12px;
  font-weight: 700;
}

.summary-sheet h2 {
  margin: 8px 0 6px;
  font-size: 20px;
}

.summary-lead {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--paper-sub);
}

.loop-diagram {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 10px 10px;
  border-radius: 14px;
  background: #fffaf0;
  border: 1px solid rgba(118, 92, 54, 0.16);
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.loop-step {
  flex: 1;
}

.loop-arrow {
  color: #c8832c;
  font-weight: 700;
}

.ledger {
  background: #fffaf0;
  border-radius: 14px;
  padding: 10px 14px;
  border: 1px solid rgba(118, 92, 54, 0.14);
  margin-bottom: 12px;
}

.ledger-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px dashed rgba(118, 92, 54, 0.15);
}

.ledger-row:last-child {
  border-bottom: 0;
  font-weight: 700;
  padding-top: 7px;
  color: #9e5612;
}

.ledger-val {
  font-family: var(--font-num);
}

.summary-note {
  font-size: 12px;
  line-height: 1.5;
  color: var(--paper-sub);
  background: rgba(88, 166, 101, 0.1);
  padding: 8px 12px;
  border-radius: 12px;
  margin-bottom: 14px;
}

.summary-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* 窄屏竖屏适配（375×667 / 390×844）：顶栏两行整洁排布，确保零裁切 */
@media (max-width: 620px) {
  #topbar {
    flex-wrap: wrap;
    row-gap: 6px;
  }
  .top-pill {
    width: 100%;
    justify-content: space-between;
    padding: 5px 10px;
    gap: 6px;
    font-size: 12px;
  }
  .top-actions {
    width: 100%;
    justify-content: flex-end;
  }
  #goal-strip {
    top: calc(max(8px, env(safe-area-inset-top)) + 78px);
    font-size: 11px;
    padding: 4px 11px;
  }
  #toast {
    top: calc(max(8px, env(safe-area-inset-top)) + 110px);
  }
  .mini-meters {
    gap: 6px;
  }
  .meter-bar {
    width: 28px;
  }
  .pill-btn {
    height: 30px;
    padding: 0 10px;
    font-size: 11px;
  }
  #joy {
    width: 96px;
    height: 96px;
    left: 14px;
    bottom: 18px;
  }
  #knob {
    width: 42px;
    height: 42px;
    margin: -21px 0 0 -21px;
  }
  #act-btn {
    min-width: 104px;
    height: 50px;
    padding: 0 16px;
    font-size: 15px;
  }
  .sub-btn {
    height: 34px;
    padding: 0 10px;
    font-size: 11px;
  }
  #dialog-box {
    bottom: 126px;
    width: calc(100vw - 20px);
  }
  .carousel-stage {
    height: 174px;
  }
  .carousel-card {
    width: 132px;
    height: 142px;
    margin-left: -66px;
    margin-top: -74px;
  }
}

/* 矮横屏适配（844×390） */
@media (max-height: 440px) {
  #joy {
    width: 92px;
    height: 92px;
    bottom: 12px;
  }
  #ctrl-right {
    bottom: 12px;
  }
  #act-btn {
    height: 46px;
    font-size: 15px;
  }
  #dialog-box {
    bottom: 12px;
    width: min(390px, 52vw);
    padding: 8px 12px;
  }
  .xray-stage {
    max-height: 48vh;
  }
  .carousel-stage {
    height: 148px;
  }
  .carousel-card {
    width: 126px;
    height: 130px;
    margin-left: -63px;
    margin-top: -66px;
  }
  .card-art {
    width: 64px;
    height: 64px;
  }
  .shop-detail {
    padding: 4px 16px 12px;
  }
  .summary-sheet {
    padding: 12px 16px 12px;
  }
  .summary-sheet h2 {
    margin: 4px 0 3px;
    font-size: 16px;
  }
  .summary-lead {
    margin: 0 0 7px;
    font-size: 12px;
    line-height: 1.4;
  }
  .loop-diagram {
    padding: 6px 8px;
    margin-bottom: 7px;
    font-size: 11px;
  }
  .ledger {
    padding: 6px 10px;
    margin-bottom: 7px;
  }
  .ledger-row {
    padding: 2px 0;
    font-size: 12px;
  }
  .summary-note {
    padding: 5px 9px;
    margin-bottom: 8px;
    font-size: 11px;
  }
}
