/* 孤屿 · 界面
 * 手机竖屏优先，桌面端加宽。深色底 + 暖色高亮，信息密度优先。
 */

:root {
  --bg: #0d1a24;
  --panel: #16293a;
  --panel2: #1d3546;
  --line: #2a465c;
  --ink: #e6eef4;
  --dim: #8ba3b5;
  --gold: #e8c34a;
  --good: #7fd18a;
  --bad: #e06a5a;
  --acc: #4ea8de;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}

/* ---------------- 顶栏 ---------------- */
#top {
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.top-left { display: flex; align-items: baseline; gap: 6px; }
#regionName { font-weight: 600; }
#regionLv { font-size: 11px; color: var(--good); }
.top-right { display: flex; align-items: baseline; gap: 4px; color: var(--dim); }
.top-right .num { color: var(--ink); font-variant-numeric: tabular-nums; }
.top-right .unit { margin-right: 8px; font-size: 11px; }
#coin { color: var(--gold); }

/* ---------------- 画布 ---------------- */
#stage {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  min-height: 180px;
}

#cv { display: block; touch-action: none; cursor: crosshair; }

.tip {
  position: absolute;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(8, 18, 26, 0.92);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
  white-space: nowrap;
}
.tip.on { opacity: 1; }

.toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%) translateY(6px);
  padding: 6px 14px;
  border-radius: 14px;
  background: rgba(8, 18, 26, 0.9);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--gold);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  white-space: nowrap;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 状态条 ---------------- */
#bars {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.bar { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.bar-label { color: var(--dim); width: 20px; flex: 0 0 20px; }
.track {
  flex: 1 1 auto;
  height: 8px;
  border-radius: 4px;
  background: #0a1620;
  overflow: hidden;
}
.track i { display: block; height: 100%; width: 0%; transition: width 0.1s linear; }
.hp .track i { background: linear-gradient(90deg, #4fae6a, #7fd18a); }
.smelt .track i { background: linear-gradient(90deg, #b0652a, #e8a24a); }
.bar-num {
  flex: 0 0 auto;
  min-width: 64px;
  text-align: right;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

/* ---------------- 页签 ---------------- */
#tabs {
  flex: 0 0 46px;
  display: flex;
  background: var(--panel2);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1 1 0;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 13px;
  font-family: inherit;
  position: relative;
  cursor: pointer;
}
.tab.on { color: var(--ink); }
.tab.on::after {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  bottom: 0;
  height: 2px;
  background: var(--gold);
  border-radius: 1px;
}

/* ---------------- 面板 ---------------- */
#panel {
  flex: 0 0 auto;
  height: 42vh;
  max-height: 340px;
  min-height: 180px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.page { display: none; padding: 10px 12px 16px; }
.page.on { display: block; }

/* 装备槽 */
.slots { display: flex; gap: 8px; margin-bottom: 10px; }
.slot {
  flex: 1 1 0;
  min-height: 58px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.slot.filled { border-color: #3d6b88; }
.slot-name { font-size: 10px; color: var(--dim); }
.slot-item { font-size: 13px; font-weight: 600; }
.slot-stat { font-size: 10px; color: var(--acc); line-height: 1.4; }
.dim { color: var(--dim); }

/* 配方行 */
.recipes { display: flex; flex-direction: column; gap: 6px; }

.recipe {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
  min-height: 52px;
}
.recipe:active { background: var(--panel2); }
.recipe.no { opacity: 0.45; }
.recipe.on { border-color: var(--gold); }

.recipe-main { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recipe-name { font-size: 13px; font-weight: 600; }
.recipe-stat { font-size: 10px; color: var(--acc); }

.recipe-cost { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.cost { font-size: 10px; color: var(--good); white-space: nowrap; }
.cost.lack { color: var(--bad); }

/* 熔炉 */
.smelt-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 12px;
}
.smelt-title { font-weight: 600; }
.smelt-fuel { color: var(--gold); }

/* 背包 */
.bag-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.cell {
  aspect-ratio: 1 / 0.8;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
}
.cell.empty { background: transparent; border-style: dashed; opacity: 0.35; }
.cell .dot { width: 12px; height: 12px; border-radius: 3px; }
.cell-name { color: var(--dim); }
.cell-num { font-weight: 600; font-variant-numeric: tabular-nums; }

/* 地区 */
.region {
  padding: 10px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 6px;
}
.region.on { border-color: var(--gold); }
.region.locked { opacity: 0.55; }
.region-title { font-size: 14px; font-weight: 600; }
.region-stat { font-size: 11px; color: var(--dim); margin-top: 2px; }
.region-state { font-size: 11px; color: var(--gold); margin-top: 4px; }
.region-state.dim { color: var(--dim); }

/* 按钮 */
.btn {
  border: 0;
  border-radius: 8px;
  background: var(--acc);
  color: #06202f;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  padding: 0 16px;
  height: 40px;
  cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--dim); border: 1px solid var(--line); }
.btn.small { height: 30px; font-size: 12px; margin-top: 8px; padding: 0 12px; }
.btn.wide { width: 100%; margin-top: 10px; }

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 16, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.modal.on { display: flex; }
.modal-box {
  width: 100%;
  max-width: 320px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px;
}
.modal-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.modal-body { font-size: 12px; color: var(--dim); line-height: 1.6; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-actions .btn { height: 36px; }

/* 桌面端：面板放右侧 */
@media (min-width: 760px) {
  #app {
    max-width: 1100px;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr 380px;
    grid-template-rows: 44px 1fr 46px;
    grid-template-areas:
      "top top"
      "stage panel"
      "bars tabs";
  }
  #top { grid-area: top; }
  #stage { grid-area: stage; min-height: 0; }
  #bars { grid-area: bars; justify-content: center; }
  #tabs { grid-area: tabs; }
  #panel { grid-area: panel; height: auto; max-height: none; min-height: 0; border-left: 1px solid var(--line); }
}
