/* 炼金工厂 frontend — mobile-first (390px base), dark theme, no outer card shells.
   Global rules honored: G-02 (flat background, no big rounded card), G-03 (system font stack, no webfont),
   G-04 (hollow stroke title), F-10 (mobile portrait only). */
:root {
  --bg: #1A1A2E;
  --bg-grad-1: #16213E;
  --bg-grad-2: #0F3460;
  --primary: #E94560;
  --accent: #F5A623;
  --success: #4CAF50;
  --danger: #FF5252;
  --text: #FFFFFF;
  --text-2: #B0B0B0;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-2: rgba(255, 255, 255, 0.08);
  --stroke: #F5A623;
  --radius: 8px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: #0b0b16;
  font-size: 14px; font-weight: 400; line-height: 1.5;
}

/* phone frame: centered 390px column, full height, portrait only */
#phone {
  position: relative;
  width: 100%; max-width: 390px;
  height: 100vh; height: 100dvh;
  margin: 0 auto;
  background: linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2));
  background-color: var(--bg);
  overflow: hidden;
  display: flex; flex-direction: column;
}

#app { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding-bottom: 64px; }
#app::-webkit-scrollbar { width: 0; }

/* ---------- hollow stroke title (G-04) ---------- */
#stroke-title {
  position: absolute; top: 14px; left: 14px; z-index: 40;
  font-size: 22px; font-weight: 600; letter-spacing: 2px;
  color: transparent;
  -webkit-text-stroke: 1.4px var(--stroke);
  text-stroke: 1.4px var(--stroke);
  pointer-events: none;
  text-shadow: 0 0 12px rgba(245, 166, 35, 0.25);
}
#stroke-title.reveal { animation: bounceIn 0.6s cubic-bezier(.34,1.56,.64,1) both; }
@keyframes bounceIn {
  0% { transform: translateY(-26px) scale(0.7); opacity: 0; }
  60% { transform: translateY(4px) scale(1.08); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.hidden { display: none !important; }

/* ---------- generic elements ---------- */
.page { padding: 70px 14px 14px; min-height: 100%; }
.section-title { font-size: 18px; font-weight: 600; margin: 0 0 12px; }
.sub { font-size: 12px; color: var(--text-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius); padding: 11px 16px;
  font-size: 14px; font-weight: 500; color: #fff; cursor: pointer;
  background: var(--primary); transition: transform 0.12s ease, filter 0.12s ease;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn.block { width: 100%; }
.btn.accent { background: var(--accent); color: #1A1A2E; }
.btn.ghost { background: var(--panel-2); color: var(--text); }
.btn.success { background: var(--success); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

input, select {
  width: 100%; padding: 11px 12px; border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.12); background: var(--panel);
  color: var(--text); font-size: 14px; font-family: inherit; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }

.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle .track { width: 44px; height: 24px; border-radius: 12px; background: var(--panel-2); position: relative; transition: background .2s; }
.toggle .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle.on .track { background: var(--success); }
.toggle.on .track::after { transform: translateX(20px); }

.amount { font-size: 16px; font-weight: 600; }
.amount.gold { color: var(--accent); }
.amount.red { color: var(--primary); }

/* inner light panels (G-02: small components may use <=8px radius) */
.card { background: var(--panel); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row + .row { margin-top: 8px; }

/* ---------- splash ---------- */
#splash { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; z-index: 50; background: linear-gradient(160deg, #0f1830, #0a0f22); }
#splash .logo { width: 110px; height: 110px; animation: spin 3.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#splash .st { font-size: 30px; font-weight: 600; letter-spacing: 4px; color: transparent; -webkit-text-stroke: 1.6px var(--stroke); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs .tab { flex: 1; text-align: center; padding: 9px 0; border-radius: var(--radius); background: var(--panel); color: var(--text-2); font-size: 13px; cursor: pointer; }
.tabs .tab.active { background: var(--primary); color: #fff; font-weight: 500; }

/* ---------- dock (bottom nav) ---------- */
#dock {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 45; height: 56px;
  display: flex; background: rgba(10, 12, 24, 0.96); border-top: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(6px);
}
#dock .dock-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-2); font-size: 11px; cursor: pointer; }
#dock .dock-item .ic { font-size: 19px; line-height: 1; }
#dock .dock-item.active { color: var(--primary); font-weight: 600; }
#dock .dock-item.active .ic { transform: translateY(-1px); }

/* ---------- progress ---------- */
.bar { height: 10px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--primary)); }

/* ---------- backpack grid (F-12: 4-col grid, not list) ---------- */
.grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  height: 56vh; overflow-y: auto; padding: 2px;
}
.cell {
  position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius);
  background: var(--panel); border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
}
.cell.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(245,166,35,.25); }
.cell .gem { width: 30px; height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.cell .tier { position: absolute; top: 3px; right: 4px; font-size: 10px; color: var(--text-2); }
.cell .nm { font-size: 10px; color: var(--text-2); transform: scale(.92); white-space: nowrap; }
.cell .badge { position: absolute; top: 3px; left: 3px; font-size: 9px; background: var(--primary); color:#fff; padding: 1px 4px; border-radius: 4px; }

/* ore color by tier */
.t0 { background:#5a5a5a; } .t1 { background:#b87333; } .t2 { background:#8a8a8a; } .t3 { background:#6e6e8a; }
.t4 { background:#9aa0a6; } .t5 { background:#7d8a5a; } .t6 { background:#9eb4c9; } .t7 { background:#b0a08a; }
.t8 { background:#c08a8a; } .t9 { background:#d4af37; } .t10 { background:#c0c0c8; } .t11 { background:#e0e0e8; }
.t12 { background:#ffd700; } .t13 { background:#7fffd4; } .t14 { background:#a0e0ff; } .t15 { background:#c0a0ff; }
.t16 { background:#ff9ff0; } .t17 { background:#9fffe0; } .t18 { background:#fff0a0; }

/* ---------- detail panel ---------- */
.detail { position: fixed; left: 0; right: 0; bottom: 56px; background: rgba(12,14,28,.98); border-top: 1px solid rgba(255,255,255,.1); padding: 12px 14px; z-index: 44; }
.detail .pbar { height: 7px; border-radius: 4px; background: var(--panel-2); overflow: hidden; margin-top: 3px; }
.detail .pbar > i { display:block; height:100%; background: var(--accent); }
.detail .pbar.bad > i { background: var(--danger); }

/* ---------- toast ---------- */
#toast-layer { position: absolute; top: 0; left: 0; right: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 10px; pointer-events: none; }
.toast { background: rgba(0,0,0,.82); color: #fff; padding: 9px 16px; border-radius: 20px; font-size: 13px; transform: translateY(-24px); opacity: 0; transition: all .25s ease; max-width: 86%; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

/* ---------- modal ---------- */
#modal-layer { position: absolute; inset: 0; z-index: 70; display: none; }
#modal-layer.show { display: block; }
#modal-layer .mask { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
#modal-layer .sheet {
  position: absolute; left: 0; right: 0; bottom: 0; background: #161a2e; border-radius: 14px 14px 0 0;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .25s ease;
  max-height: 80%; overflow-y: auto;
}
#modal-layer.show .sheet { transform: translateY(0); }
#modal-layer .sheet.center { top: 50%; bottom: auto; transform: translateY(-50%) scale(.9); border-radius: 14px; opacity: 0; transition: all .2s ease; }
#modal-layer.show .sheet.center { transform: translateY(-50%) scale(1); opacity: 1; }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }

/* market listing rows etc. */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--panel); border-radius: var(--radius); padding: 10px 12px; }
.item .top { display: flex; justify-content: space-between; align-items: center; }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: var(--panel-2); color: var(--text-2); }
.tag.mine { background: var(--primary); color:#fff; }
.tag.waste { background: #555; }
.pill { display:inline-block; font-size:11px; padding:1px 6px; border-radius:4px; background: var(--panel-2); color: var(--text-2); margin-left:4px; }

.avatar-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 16px; }
.avatar-opt { width: 52px; height: 52px; border-radius: var(--radius); background: var(--panel); display: flex; align-items: center; justify-content: center; font-size: 26px; cursor: pointer; border: 2px solid transparent; }
.avatar-opt.sel { border-color: var(--accent); }

.empty { text-align: center; color: var(--text-2); padding: 40px 0; font-size: 13px; }
.flex { display: flex; } .between { justify-content: space-between; } .center { align-items: center; } .gap8 { gap: 8px; } .col { flex-direction: column; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.banner { background: linear-gradient(90deg, rgba(233,69,96,.25), rgba(245,166,35,.25)); border: 1px solid var(--accent); border-radius: var(--radius); padding: 9px 12px; font-size: 13px; margin-bottom: 12px; }
.muted { color: var(--text-2); font-size: 12px; }
.big-num { font-size: 22px; font-weight: 600; }
