:root {
  --bg: #0e1020;
  --panel: #1a1d35;
  --panel-2: #232745;
  --line: #2e3357;
  --gold: #f4c84a;
  --green: #38d39f;
  --red: #ff6b6b;
  --text: #e7e9f5;
  --muted: #9aa0c3;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: radial-gradient(circle at 50% -10%, #1d2147, var(--bg));
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--gold); }
.wrap { max-width: 960px; margin: 0 auto; padding: 24px; }
header.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
}
header.bar h1 { font-size: 18px; margin: 0; letter-spacing: 1px; }
header.bar .nav a { margin-left: 16px; font-size: 14px; text-decoration: none; }
.tag-poc {
  font-size: 11px; color: #0e1020; background: var(--gold);
  padding: 2px 8px; border-radius: 99px; margin-left: 8px; font-weight: 700;
}
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 20px; margin-bottom: 18px;
}
.panel h2 { margin: 0 0 14px; font-size: 15px; color: var(--gold); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

select, input, button {
  font: inherit; color: var(--text); background: #12152b;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
button {
  cursor: pointer; background: #2b2f57; transition: .15s;
}
button:hover { background: #383e72; }
button.primary { background: var(--gold); color: #0e1020; font-weight: 700; border: 0; }
button.danger { background: #4a2330; color: var(--red); border-color: #6b2f3f; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > div { flex: 1; min-width: 130px; }

/* C 端展示 */
.hero { text-align: center; }
.hero canvas { display: block; margin: 0 auto; }
.lvl { font-size: 40px; font-weight: 800; color: var(--gold); }
.lvl small { font-size: 14px; color: var(--muted); font-weight: 400; }
.quote {
  font-style: italic; color: #cdd2ff; margin: 10px 0 0;
  border-left: 3px solid var(--gold); padding-left: 12px; text-align: left;
}
.bar-track { background: #12152b; border-radius: 99px; height: 14px; overflow: hidden; margin-top: 12px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #f4c84a, #ff9f43); transition: width .6s; }
.bar-fill.debt { background: linear-gradient(90deg, #ff6b6b, #b03a3a); }
.stat-row { display: flex; justify-content: space-around; margin-top: 14px; }
.stat-row .s { text-align: center; }
.stat-row .s b { display: block; font-size: 22px; color: var(--gold); }
.stat-row .s span { font-size: 12px; color: var(--muted); }
.debt-flag { color: var(--red); font-size: 13px; margin-top: 8px; }

.frozen {
  border: 1px dashed #5a4bd6; background: #1c1a3a; border-radius: 10px;
  padding: 10px 12px; margin-top: 8px; font-size: 13px;
}
.frozen .badge { color: #b9aaff; font-weight: 700; }
.frozen.voided { opacity: .45; text-decoration: line-through; }
.frozen.settled { border-color: var(--green); }

/* 四軌進度條 */
.track { margin: 10px 0 14px; }
.track-head { display: flex; justify-content: space-between; align-items: baseline; }
.track-name { font-size: 13px; color: var(--text); font-weight: 600; }
.track-level { font-size: 13px; color: var(--gold); font-weight: 700; }
.track-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.track-meta small { color: var(--muted); font-size: 11px; }
.bar-track { position: relative; }
.bar-preview {
  position: absolute; top: 0; height: 100%;
  background: repeating-linear-gradient(45deg, #b9aaff66, #b9aaff66 6px, transparent 6px, transparent 12px);
  border-right: 1px dashed #b9aaff;
}
.flag {
  display: inline-block; font-size: 10px; padding: 2px 6px; border-radius: 99px; margin-left: 4px;
}
.flag-cap { background: #4a3b1f; color: #f4c84a; }
.flag-max { background: #1f4a32; color: var(--green); }
.flag-debt { background: #4a1f2a; color: var(--red); }

.inherited-title {
  margin-top: 10px; font-size: 13px; color: #b9aaff;
  background: #261d4a; border: 1px dashed #5a4bd6;
  border-radius: 8px; padding: 8px 12px;
}

.ticket {
  background: #2b2240; border: 1px solid #5a4bd6;
  border-radius: 10px; padding: 8px 12px; margin-top: 6px;
  font-size: 13px; display: flex; justify-content: space-between; align-items: center;
}
.ticket small { color: var(--muted); }

/* 會員錢包 */
.wallet-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.wallet-cell {
  flex: 1; min-width: 100px;
  background: #12152b; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; text-align: center;
}
.wallet-cell .w-icon { font-size: 18px; display: block; }
.wallet-cell b { display: block; font-size: 22px; color: var(--gold); margin-top: 2px; }
.wallet-cell small { color: var(--muted); font-size: 11px; }
.w-vouchers { width: 100%; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.w-voucher {
  font-size: 11px; padding: 4px 8px; border-radius: 99px;
  background: #2b2240; color: #b9aaff; border: 1px solid #5a4bd6;
}

/* 戰利品箱 */
.lootbox {
  margin: 10px 0 18px; padding: 12px; background: #15182e;
  border: 1px solid var(--line); border-radius: 10px;
}
.lootbox-head { display: flex; justify-content: space-between; align-items: baseline; }
.lootbox-name { font-weight: 700; color: var(--text); font-size: 14px; }
.lootbox-progress { color: var(--muted); font-size: 12px; }
.lootbox-track-bar {
  height: 6px; background: #0e1020; border-radius: 99px; margin: 6px 0 10px; overflow: hidden;
}
.lootbox-track-fill { height: 100%; transition: width .6s; }
.lootbox-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
}
.lb-slot {
  background: #12152b; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; text-align: center; min-height: 110px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; font-size: 12px;
}
.lb-slot.empty { opacity: .35; }
.lb-slot.locked { opacity: .55; }
.lb-slot.unclaimed { border-color: var(--gold); box-shadow: 0 0 8px rgba(244, 200, 74, .2); }
.lb-slot.claimed { border-color: var(--green); opacity: .75; }
.lb-slot.voided { opacity: .35; text-decoration: line-through; }
.lb-lv { color: var(--gold); font-weight: 700; font-size: 12px; }
.lb-icon { font-size: 22px; line-height: 1; }
.lb-name { font-weight: 600; color: var(--text); margin: 2px 0; line-height: 1.2; }
.lb-value { color: var(--muted); font-size: 11px; }
.lb-btn {
  background: var(--gold); color: #0e1020; font-weight: 700;
  border: 0; padding: 4px 0; border-radius: 6px; font-size: 12px;
  cursor: pointer;
}
.lb-btn:hover { background: #ffd968; }
.lb-btn:disabled { opacity: .6; cursor: wait; }
.lb-claimed { color: var(--green); font-size: 11px; font-weight: 700; padding: 4px 0; }
.lb-lock { color: var(--muted); font-size: 11px; padding: 4px 0; }

.log { font-size: 12px; color: var(--muted); max-height: 220px; overflow: auto; }
.log div { padding: 4px 0; border-bottom: 1px solid #20243f; }

.zone-green { color: var(--green); }
.zone-red { color: var(--red); }
.empty-slot { color: var(--muted); font-style: italic; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
.note {
  font-size: 12px; color: var(--muted); background: #15182e;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-top: 12px;
}

/* 華麗轉生 overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(8,9,20,.92);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  z-index: 50; text-align: center; transition: opacity .5s;
}
.overlay h2 { font-size: 30px; color: var(--gold); letter-spacing: 4px; animation: pulse 1.4s infinite; }
.overlay p { color: var(--muted); }
.overlay.hide { opacity: 0; pointer-events: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.hidden { display: none !important; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: #0e1020; padding: 10px 18px;
  border-radius: 99px; font-weight: 700; font-size: 13px; opacity: 0;
  transition: opacity .3s; pointer-events: none;
}
.toast.show { opacity: 1; }
