* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #dde3ec;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #2c3444;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
   -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body { display: flex; justify-content: center; }

#app {
  width: 100%;
  max-width: 430px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  border-left: 1px solid #cbd4e0;
  border-right: 1px solid #cbd4e0;
  box-shadow: 0 0 40px rgba(70, 90, 120, .22);
  overflow: hidden;
}

/* ===== 顶栏 ===== */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  background: linear-gradient(180deg, #ffffff, #eef2f8);
  border-bottom: 1px solid #d8dee9;
}

.game-title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #b07d1a;
  text-shadow: 0 1px 0 #fff;
}
.game-title .ver {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #9aa6b8;
  text-shadow: none;
}

/* ===== 通用按钮 ===== */
.btn {
  position: relative;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.2;
  color: #3a4557;
  background: linear-gradient(180deg, #ffffff, #f0f3f8);
  border: 1px solid #cfd7e3;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  user-select: none;
  text-align: center;
  box-shadow: 0 1px 1px rgba(60, 80, 110, .06);
  transition: background .12s, border-color .12s, transform .06s;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
}
.btn:hover {
  background: linear-gradient(180deg, #f7faff, #e8eef7);
  border-color: #b3c0d4;
}
.btn:active {
  transform: translateY(1px);
  background: #dde5f0;
  box-shadow: none;
}
.btn:disabled {
  opacity: .55;
  cursor: default;
  transform: none;
}

/* 按钮内部 4px 进度条 */
.btn > .bar {
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: 1px;
  height: 4px;
  border-radius: 0 0 6px 6px;
  background: #e4ebf5;
  overflow: hidden;
  pointer-events: none;
}
.btn > .bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: #307bf5;
  transition: width .12s linear;
}

.btn-settings {
  padding: 6px 15px;
  font-size: 13.5px;
  border-radius: 999px;
  color: #4a5568;
}

/* ===== 中间主区域 ===== */
.main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 8px;
  padding: 8px;
  overflow: hidden;
}

.col {
  display: flex;
  flex-direction: column;
  row-gap: 6px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.col-left  { flex: 1 1 44%; }
.col-right { flex: 1 1 56%; }

.panel-title {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12.5px;
  letter-spacing: 2px;
  font-weight: 600;
  color: #a8761a;
  padding: 0;
  border-bottom: 1px solid #e2e8f0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
}

/* ===== 左栏：技能行 ===== */
#skillsPanel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow: hidden;
}

.skill-row {
  position: relative;
  flex: 0 0 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 6px 7px;
  border-radius: 6px;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.2;
}
.skill-row.active { background: #f2f7ff; }

.skill-left {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}
.skill-name {
  font-weight: 600;
  color: #2c3444;
  white-space: nowrap;
}
.skill-mult {
  font-weight: 600;
  color: #4a90d9;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.skill-meta {
  flex: 0 0 auto;
  color: #7d8798;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.skill-meta .meta-space { display: inline; }   /* PC：熟练3 天赋2，中间有空格 */
.skill-row.active .skill-name,
.skill-row.active .skill-mult { color: #1c4f9c; }

.skill-row > .bar {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 1px;
  height: 4px;
  border-radius: 2px;
  background: #e4ebf5;
  overflow: hidden;
  pointer-events: none;
}
.skill-row > .bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: #8ab4f8;
  transition: width .12s linear;
}

/* ===== 右栏 ===== */
.col-right > * { flex: 0 0 auto; }

#worksPanel,
#exploresPanel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: flex-start;
  min-height: 0;
  overflow: hidden;
}

/* 按钮位于 action-row 内部，撑满按钮剩余空间 */
#worksPanel .btn,
#exploresPanel .btn {
  flex: 1 1 auto;
  min-width: 0;
}

/* ===== 状态显示 ===== */
.stat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(60, 80, 110, .05);
  overflow: hidden;
}
.stat {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.2;
}
.stat-name { color: #7d8798; }
.stat-val  { color: #2c3444; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ===== 状态栏右侧：数值在上，进度条在下 ===== */
.stat-right {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
}

.stat-bar {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #e4ebf5;
  overflow: hidden;
}

.stat-bar > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  transition: width .15s linear;
}

/* 寿元 —— 金黄色 */
.stat-bar > i.fill-life {
  background: #d9a520;
}

/* 气血 —— 红色 */
.stat-bar > i.fill-hp {
  background: #e04a4a;
}

/* ===== 底部故事区 ===== */
.story {
  flex: 0 0 auto;
  height: 20vh;
  min-height: 105px;
  max-height: 190px;
  display: flex;
  flex-direction: column;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: #ffffff;
  border-top: 1px solid #d8dee9;
  transition: opacity .18s ease;
}

.story-title {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}
.story-title-text {
  font-size: 12.5px;
  letter-spacing: 2px;
  font-weight: 600;
  color: #a8761a;
}

.story-zoom {
  padding: 2px 9px;
  font-size: 14px;
  line-height: 1.1;
  border-radius: 6px;
  color: #7d8798;
  letter-spacing: 0;
  min-height: 0;
}

.story-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 14px;
  line-height: 1.8;
  color: #55617a;
  padding-right: 6px;
}
.story-body p { margin-bottom: 8px; }
.story-body p:last-child { margin-bottom: 0; }

.story-body::-webkit-scrollbar { width: 5px; }
.story-body::-webkit-scrollbar-track { background: #eef2f8; border-radius: 3px; }
.story-body::-webkit-scrollbar-thumb { background: #c3cddc; border-radius: 3px; }
.story-body::-webkit-scrollbar-thumb:hover { background: #aab7ca; }
.story-body { scrollbar-width: thin; scrollbar-color: #c3cddc #eef2f8; }

/* ===== 故事区展开 ===== */
.story.expanded {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: auto;
  min-height: 0;
  max-height: none;
  z-index: 100;
  border-top: none;
  box-shadow: 0 0 50px rgba(40, 60, 90, .35);
  opacity: 1;
}
.story.expanded .story-title-text { font-size: 14px; }
.story.expanded .story-body { font-size: 15px; }

/* ============================================================
   右栏行动行：[！空位] [按钮] [XX/50] [空位]
   ============================================================ */

/* 行动行容器：横向排列 + 垂直居中 */
.action-row {
  display: flex;
  align-items: center;
  gap: 6px;
}


/* 左侧「！」固定占位（不管有没有都占同样宽） */
.action-row .main-flag {
  flex: 0 0 auto;
  width: 14px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  color: #d99a1a;
}

/* 按钮撑满剩余空间；所有行宽度一致 */
.action-row .btn {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 4px 6px;
}

/* 按钮内文字（过长省略） */
.btn-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 右侧 XX/50 固定宽度（无物品的行也占位） */
.action-row .item-count {
  flex: 0 0 auto;
  width: 42px;
  text-align: right;
  font-size: 12px;
  line-height: 1.2;
  color: #7d8798;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 再右侧的动作标签槽（a0~a4 svg 图标 / 空槽位同宽） */
.action-row .action-tag {
  flex: 0 0 auto;
  width: 22px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;    
}

.action-tag img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
}

/* 物品已满：按钮变灰 */
.btn.full {
  background: #eef2f8;
  color: #aab7ca;
  border-color: #dbe3ee;
}
.btn.full:disabled { opacity: 1; }
 
/* ============================================================
   ★ 手机（触摸设备）专属调整 —— PC 完全不受影响
   ============================================================ */
@media (hover: none) and (pointer: coarse) {

  /* ---- 顶栏：更矮，标题更小 ---- */
  .topbar {
    padding: 7px 10px;
    gap: 8px;
  }
  .game-title {
    font-size: 16px;
    letter-spacing: 2px;
  }
  .game-title .ver {
    font-size: 10px;
  }
  .btn-settings {
    padding: 5px 12px;
    font-size: 13px;
  }

  /* ---- 左栏属性：左边距更小、行内更紧凑 ---- */
  .skill-row {
    padding: 0 3px 6px;
    gap: 3px;
  }
  .skill-left {
    gap: 3px;
  }
  .skill-name {
    font-size: 13px;
  }
  .skill-mult {
    font-size: 13px;
  }
  .skill-meta {
    font-size: 12px;
  }


   .skill-meta .meta-space { display: none; }   /* 手机：熟练3天赋2，去掉空格 */

  /* ---- 右栏行动行：间隙更小，按钮更宽更厚 ---- */
  /* ★ 加 #colRight 前缀，避免影响「自动设置」面板里的行 */
  #colRight .action-row {
    gap: 4px;
  }
  #colRight .action-row .main-flag {
    width: 12px;
    font-size: 14px;
  }
  #colRight .action-row .btn {
    padding: 4px 4px;
    font-size: 13px;
  }
  #colRight .action-row .item-count {
    width: 34px;
    font-size: 11px;
  }
  #colRight .action-row .action-tag {
    width: 18px;
  }

  /* ---- 底部故事：收成一条 34px 的横条 ---- */
  .story {
    flex: 0 0 auto;
    height: calc(34px + env(safe-area-inset-bottom));
    min-height: calc(34px + env(safe-area-inset-bottom));
    max-height: calc(34px + env(safe-area-inset-bottom));
    padding: 0 10px env(safe-area-inset-bottom);
    flex-direction: row;
    align-items: center;
  }
  .story-title {
    width: 100%;
    height: 100%;
    margin-bottom: 0;
    align-items: center;
  }
  .story-zoom {
    padding: 2px 8px;
    font-size: 14px;
  }
  .story-body {
    display: none;                 /* ★ 折叠时正文和滚动条都不显示 */
  }

  /* ---- 故事全屏展开时：恢复竖排、显示正文 ---- */
  .story.expanded {
    flex-direction: column;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    align-items: stretch;
  }
  .story.expanded .story-title {
    flex: 0 0 auto;
    height: auto;
    margin-bottom: 5px;
  }
  .story.expanded .story-body {
    display: block;
    flex: 1 1 auto;
  }
}