:root {
  --ink: #0C1341;
  --ink-2: #151d57;
  --ink-3: #1f2a70;
  --line: rgba(248, 182, 43, 0.22);
  --gold: #F8B62B;
  --gold-soft: #ffd77a;
  --text: #f3f1ea;
  --muted: #a9adc9;
  --danger: #ff7b7b;
  --ok: #7be0a8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { background: var(--ink); color: var(--text); }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  background: radial-gradient(1200px 600px at 50% -200px, #26307a 0%, var(--ink) 60%) fixed;
  min-height: 100vh;
}
h1, h2, h3, .serif { font-family: "Noto Serif TC", "Songti TC", serif; font-weight: 700; letter-spacing: 0.04em; margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

.wrap { max-width: 480px; margin: 0 auto; padding: 20px 16px 96px; }

.eyebrow { color: var(--gold); font-size: 12px; letter-spacing: 0.25em; margin: 0 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.card {
  background: linear-gradient(180deg, var(--ink-2), #111849);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin-top: 16px;
}

.btn {
  display: block; width: 100%;
  padding: 14px 18px; border-radius: 12px;
  font-weight: 700; font-size: 17px; letter-spacing: 0.05em;
  background: var(--gold); color: var(--ink);
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { filter: grayscale(0.8) brightness(0.7); cursor: default; }
.btn.ghost { background: transparent; color: var(--gold); border: 1px solid var(--gold); }
.btn.quiet { background: transparent; color: var(--muted); font-weight: 400; font-size: 14px; padding: 10px; }
.btn + .btn { margin-top: 10px; }

label { display: block; font-size: 14px; color: var(--muted); margin: 16px 0 6px; }
.input {
  width: 100%; padding: 13px 14px; border-radius: 10px;
  background: #0a0f33; border: 1px solid var(--ink-3); outline: none; font-size: 17px;
}
.input:focus { border-color: var(--gold); }
.pin { letter-spacing: 0.8em; text-align: center; font-size: 24px; }

.err { color: var(--danger); font-size: 14px; min-height: 22px; margin-top: 10px; }

.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatars button {
  aspect-ratio: 1; font-size: 28px; border-radius: 12px;
  background: #0a0f33; border: 2px solid transparent;
}
.avatars button.on { border-color: var(--gold); background: var(--ink-3); }

/* 角色卡 */
.hero { display: flex; gap: 16px; align-items: center; }
.hero .face {
  width: 76px; height: 76px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 42px; position: relative;
  background: radial-gradient(circle at 35% 30%, #2d3a8c, #0a0f33);
  border: 2px solid var(--gold);
}
.hero .badge {
  position: absolute; right: -6px; bottom: -4px; font-size: 22px;
  background: var(--ink); border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--gold);
}
.hero .who { min-width: 0; }
.hero .name { font-size: 22px; overflow-wrap: anywhere; }
.hero .title { color: var(--gold-soft); font-size: 14px; }
.lv { font-family: "Noto Serif TC", serif; color: var(--gold); font-size: 15px; }

.bar { height: 14px; border-radius: 99px; background: #0a0f33; border: 1px solid var(--ink-3); overflow: hidden; margin-top: 16px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #d98f00, var(--gold), var(--gold-soft)); border-radius: 99px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.bar-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 6px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stat { background: #0a0f33; border-radius: 12px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 22px; font-family: "Noto Serif TC", serif; color: var(--gold); line-height: 1.2; }
.stat span { font-size: 12px; color: var(--muted); }

.points { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.points button {
  aspect-ratio: 1; border-radius: 14px; font-family: "Noto Serif TC", serif; font-weight: 700;
  background: linear-gradient(180deg, #2a3688, var(--ink-3)); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform .08s ease;
}
.points button:active { transform: scale(0.93); }
.points button b { font-size: 28px; color: var(--gold); line-height: 1; }
.points button span { font-size: 11px; color: var(--muted); font-family: inherit; font-weight: 400; }

.log { list-style: none; margin: 0; padding: 0; }
.log li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed rgba(255,255,255,0.08); font-size: 15px; }
.log li:last-child { border-bottom: 0; }
.log .pt { flex: none; min-width: 44px; font-family: "Noto Serif TC", serif; font-weight: 700; color: var(--gold); }
.log .pt.neg { color: var(--danger); }
.log time { flex: none; margin-left: auto; color: var(--muted); font-size: 12px; }

.banner {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
  background: linear-gradient(90deg, rgba(248,182,43,0.18), rgba(248,182,43,0.05));
  border: 1px solid var(--gold); border-radius: 14px; padding: 14px 16px; margin-top: 16px;
  animation: glow 2s ease-in-out infinite;
}
.banner b { color: var(--gold); }
@keyframes glow { 50% { box-shadow: 0 0 18px rgba(248,182,43,0.35); } }

/* 排行榜 */
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; }
.rank li:nth-child(odd) { background: rgba(255,255,255,0.03); }
.rank li.me { background: rgba(248,182,43,0.16); outline: 1px solid var(--gold); }
.rank .no { width: 32px; text-align: center; font-family: "Noto Serif TC", serif; font-weight: 700; color: var(--muted); flex: none; }
.rank .no.top { color: var(--gold); font-size: 20px; }
.rank .fc { font-size: 26px; flex: none; }
.rank .nm { min-width: 0; flex: 1; }
.rank .nm div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .nm small { color: var(--muted); font-size: 12px; }
.rank .xp { flex: none; text-align: right; font-size: 13px; color: var(--muted); }
.rank .xp b { color: var(--gold); font-size: 16px; font-family: "Noto Serif TC", serif; }

/* 底部分頁 */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(8, 12, 40, 0.94); border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.tabs button { flex: 1; max-width: 220px; padding: 10px; border-radius: 10px; color: var(--muted); font-weight: 700; }
.tabs button.on { background: var(--ink-3); color: var(--gold); }

/* 彈出層 */
.layer {
  position: fixed; inset: 0; z-index: 20; background: rgba(4, 6, 24, 0.78);
  display: flex; align-items: flex-end; justify-content: center; padding: 0 12px;
}
.layer.mid { align-items: center; padding: 16px; }
.sheet {
  width: 100%; max-width: 480px; background: var(--ink-2); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  animation: up .25s cubic-bezier(.2,.8,.2,1);
  max-height: 92vh; overflow-y: auto;
}
.layer.mid .sheet { border-radius: 20px; animation: pop .35s cubic-bezier(.2,1.4,.4,1); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop { from { transform: scale(0.8); opacity: 0; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips button { padding: 8px 14px; border-radius: 99px; background: #0a0f33; border: 1px solid var(--ink-3); font-size: 15px; }
.chips button.on { border-color: var(--gold); color: var(--gold); background: var(--ink-3); }

.jobs { display: grid; gap: 10px; margin-top: 14px; }
.job { text-align: left; display: flex; gap: 12px; padding: 14px; border-radius: 14px; background: #0a0f33; border: 2px solid transparent; }
.job.on { border-color: var(--gold); background: var(--ink-3); }
.job .ic { font-size: 34px; flex: none; }
.job h3 { font-size: 18px; }
.job .sk { color: var(--gold); font-size: 13px; }
.job p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }

.levelup { text-align: center; }
.levelup .big { font-family: "Noto Serif TC", serif; font-weight: 700; font-size: 56px; color: var(--gold); line-height: 1.1; text-shadow: 0 0 30px rgba(248,182,43,0.5); }
.levelup .star { font-size: 44px; animation: spin 1.2s ease-out; display: inline-block; }
@keyframes spin { from { transform: rotate(-180deg) scale(0.2); } }

.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 30;
  background: var(--gold); color: var(--ink); font-weight: 700; padding: 10px 18px; border-radius: 99px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4); animation: up .25s ease; white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
