:root {
  --bg: #12100e;
  --panel: #1d1915;
  --panel-raised: #25201b;
  --text: #e9dfc8;
  --text-soft: #a3967f;
  --line: rgba(233, 223, 200, 0.16);
  --line-strong: rgba(233, 223, 200, 0.34);
  --cinnabar: #c0463a;
  --cinnabar-deep: #8e2a22;
  --jade: #5fa68e;
  --el-金: #b8954a;
  --el-木: #5f8f58;
  --el-水: #4f7aa0;
  --el-火: #c0463a;
  --el-土: #9b7a50;
  --el-無: #7a7266;
  --font: "LXGW WenKai TC", "DFKai-SB", "BiauKai", "標楷體", "KaiTi", "Noto Serif TC", serif;
  --emoji: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Symbol", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  background-color: var(--bg);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.92 0 0 0 0 0.87 0 0 0 0 0.78 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% -10%, rgba(70, 82, 96, 0.35), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, 0.6), transparent 60%);
  background-attachment: fixed;
}

button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.scenery { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.moon { position: absolute; top: 12px; left: 2%; width: 96px; height: 96px; opacity: 0.4; }
.mountains { position: absolute; left: 0; bottom: 0; width: 100%; height: 34vh; }
.bamboo { position: absolute; right: -10px; top: -20px; width: 110px; height: 300px; }

html, body { height: 100%; overflow: hidden; }

main {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px 0;
  height: 100vh;
  height: 100dvh;
}
main:not([hidden]) { display: flex; flex-direction: column; }
main > header, main > .status, main > .tabs { flex: none; }

#tab-forge:not([hidden]) { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#tab-forge > * { flex: none; }
#tab-forge > .inventory {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  align-content: flex-start;
  padding: 2px 2px 24px;
  margin: 0 -2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(233, 223, 200, 0.25) transparent;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 10px, #000 calc(100% - 24px), transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 10px, #000 calc(100% - 24px), transparent 100%);
}
.pane:not([hidden]) { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 24px; scrollbar-width: thin; scrollbar-color: rgba(233, 223, 200, 0.25) transparent; }

.muted { color: var(--text-soft); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: #e07a6c; min-height: 1.6em; margin: 10px 0 0; }

/* 印章 */
.seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cinnabar);
  color: #f6ecd6;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 8px;
  letter-spacing: 0.08em;
  box-shadow: inset 0 0 0 2px rgba(246, 236, 214, 0.3), inset 0 0 6px rgba(0, 0, 0, 0.3);
  transform: rotate(-2deg);
}
.seal-small { font-size: 12px; padding: 1px 5px; }
.name-seal { font-size: 15px; max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;; cursor: pointer; }

/* 按鈕 */
.seal-btn {
  position: relative;
  border: none;
  background: linear-gradient(180deg, #c8493c, var(--cinnabar-deep));
  color: #f6ecd6;
  font-weight: 700;
  border-radius: 6px;
  padding: 10px 22px;
  letter-spacing: 0.25em;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(246, 236, 214, 0.22), 0 2px 10px rgba(192, 70, 58, 0.25);
  transition: transform 0.1s, filter 0.2s;
}
.seal-btn:hover:not(:disabled) { filter: brightness(1.1); }
.seal-btn:active:not(:disabled) { transform: translateY(1px); }
.seal-btn:disabled { background: #2c2620; color: #7d7262; cursor: default; box-shadow: inset 0 0 0 1px var(--line); }
.seal-btn.wide { display: block; width: 100%; padding: 13px; font-size: 19px; letter-spacing: 0.5em; }
#act.seal-btn.wide { padding: 10px; font-size: 17px; }

.ink-btn {
  border: 1.5px solid var(--line-strong);
  background: transparent;
  border-radius: 6px;
  padding: 9px 18px;
  cursor: pointer;
  letter-spacing: 0.15em;
}
.ink-btn:hover { border-color: var(--text); }
.ink-btn.danger { color: #e07a6c; border-color: rgba(224, 122, 108, 0.6); }

/* 卷軸 */
.scroll {
  position: relative;
  background: linear-gradient(180deg, #241f19, #1c1813);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 30px 22px 26px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  margin: 14px 0;
}
.scroll::before, .scroll::after {
  content: "";
  position: absolute;
  left: -12px;
  right: -12px;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(180deg, #7a5634, #3d2a19 70%, #24180d);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.scroll::before { top: -10px; }
.scroll::after { bottom: -10px; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(5, 4, 3, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 28px;
}
.overlay[hidden] { display: none; }
#login { background: transparent; }

.login-scroll { width: 100%; max-width: 380px; text-align: center; animation: unroll 0.6s ease-out; }
.login-title { display: flex; align-items: center; justify-content: center; gap: 10px; }
.brand { margin: 0; font-size: 42px; letter-spacing: 0.2em; font-weight: 700; text-shadow: 0 0 18px rgba(233, 223, 200, 0.25); }
.lead { color: var(--text-soft); margin: 12px 0 22px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-form .seal-btn { margin-top: 4px; }
.login-note { margin: 12px 0 0; }
.auth-tabs { display: flex; justify-content: center; gap: 4px; margin: 6px 0 14px; border-bottom: 1px solid var(--line); }
.auth-tab { flex: 1; background: none; border: none; color: var(--text-soft); padding: 8px 0; cursor: pointer; letter-spacing: 0.15em; font: inherit; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.auth-tab.active { color: var(--text); border-bottom-color: var(--cinnabar); font-weight: 700; }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; min-width: 0; letter-spacing: 0.3em; }
.code-row .ink-btn { flex: none; padding: 8px 12px; white-space: nowrap; }
#naming-form { display: flex; flex-direction: column; gap: 12px; }
.small-brand { font-size: 30px; margin: 0; }
.rename-form { display: flex; gap: 8px; }
.rename-form input { flex: 1; min-width: 0; }
.rename-form .seal-btn { flex: none; padding: 8px 18px; }
.account-actions { margin-top: 14px; }

input, .search {
  background: rgba(233, 223, 200, 0.05);
  border: none;
  border-bottom: 1.5px solid var(--line-strong);
  padding: 9px 6px;
  outline: none;
}
input::placeholder { color: rgba(163, 150, 127, 0.75); }
input:focus { border-bottom-color: var(--cinnabar); }

/* 頂部 */
.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.logo { font-size: 26px; font-weight: 700; letter-spacing: 0.15em; text-shadow: 0 0 14px rgba(233, 223, 200, 0.2); }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.badge { font-size: 12px; border: 1px solid #e07a6c; color: #e07a6c; border-radius: 4px; padding: 0 6px; }

.status { padding: 10px 0 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.status-row { display: flex; justify-content: space-between; }
.status b { font-size: 18px; }
.ink-bar { height: 10px; margin: 6px 0 4px; background: rgba(233, 223, 200, 0.07); border-radius: 6px 3px 7px 2px; overflow: hidden; }
#stamina-bar {
  height: 100%;
  background: linear-gradient(90deg, rgba(95, 166, 142, 0.55), var(--jade) 85%, #8fd1b8);
  border-radius: 6px 10px 3px 7px;
  box-shadow: 0 0 8px rgba(95, 166, 142, 0.5);
  transition: width 0.4s;
}

/* 分頁 */
.tabs { display: flex; justify-content: space-around; gap: 4px; margin-bottom: 8px; }
.tab {
  background: none;
  border: none;
  padding: 4px 6px 8px;
  font-size: 18px;
  letter-spacing: 0.15em;
  cursor: pointer;
  color: var(--text-soft);
  position: relative;
  white-space: nowrap;
}
.tab.active { color: var(--text); font-weight: 700; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 2px;
  height: 4px;
  background: var(--cinnabar);
  border-radius: 50% 40% 60% 30%;
  transform: rotate(-1.5deg);
}

/* 悟道台 */
.forge-stage { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 2px 0 10px; }
.taiji-stage { width: 92px; height: 92px; flex: none; color: var(--text); overflow: visible; }
.taiji-stage .bagua { opacity: 0.45; transform-box: fill-box; transform-origin: center; animation: spin 90s linear infinite; }
.taiji-stage .taiji { transform-box: fill-box; transform-origin: center; transition: filter 0.3s; }
.forge-stage.brewing .taiji { animation: spin 1.4s linear infinite; filter: drop-shadow(0 0 10px rgba(233, 223, 200, 0.55)); }
.forge-stage.brewing .bagua { animation: spin 6s linear infinite reverse; opacity: 0.85; }

.slot {
  flex: 1;
  max-width: 112px;
  aspect-ratio: 1;
  border: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M62 9 C86 14 96 38 90 60 C84 84 58 95 36 88 C14 81 5 58 10 38 C14 22 26 11 44 8' fill='none' stroke='%23e9dfc8' stroke-width='4' stroke-linecap='round' opacity='0.7'/%3E%3C/svg%3E") center / contain no-repeat;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px;
  gap: 2px;
  text-align: center;
}
.slot-hint { color: var(--text-soft); font-size: 14px; letter-spacing: 0.2em; }
.slot-emoji { font-size: 26px; line-height: 1.1; }
.slot-name { font-size: 14px; font-weight: 700; word-break: break-all; line-height: 1.25; }
.slot.filled { background-color: rgba(233, 223, 200, 0.06); border-radius: 50%; }

.busy::after {
  content: "推演天機中…";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: inherit;
  border-radius: inherit;
  letter-spacing: 0.2em;
  font-size: 17px;
}

.search-wrap { margin: 10px 0 8px; }
.search { width: 100%; }

/* 道庫：籤條 */
.inventory { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 5px 12px 5px 8px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.1s, border-color 0.2s, background 0.2s;
}
.chip:hover { border-color: var(--line-strong); background: var(--panel-raised); transform: translateY(-1px); }
.chip.picked { border-color: var(--cinnabar); box-shadow: 0 0 0 1px var(--cinnabar), 0 0 10px rgba(192, 70, 58, 0.35); }
.chip .el {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 11px;
  font-weight: 700;
  color: #f6ecd6;
  background: var(--el-無);
  border-radius: 3px;
}
.chip[data-el="金"] .el { background: var(--el-金); }
.chip[data-el="木"] .el { background: var(--el-木); }
.chip[data-el="水"] .el { background: var(--el-水); }
.chip[data-el="火"] .el { background: var(--el-火); }
.chip[data-el="土"] .el { background: var(--el-土); }
.chip .em { filter: saturate(0.75); }
.em, .slot-emoji, .big-emoji { font-family: var(--emoji); }

/* 結果與詳情 */
/* 確認視窗（取代瀏覽器的 confirm） */
#confirm { z-index: 30; }
.confirm-scroll { width: 100%; max-width: 360px; animation: unroll 0.3s ease-out; }
.confirm-text { margin: 4px 0 18px; font-size: 16px; line-height: 1.7; text-align: center; white-space: pre-line; }

.result-scroll, .detail-scroll {
  width: 100%;
  max-width: 400px;
  text-align: center;
  padding: 0;
  animation: unroll 0.45s ease-out;
}
.scroll-body { max-height: calc(100vh - 90px); overflow-y: auto; padding: 30px 22px 26px; }
.kind { font-size: 15px; letter-spacing: 0.3em; color: var(--text-soft); margin-bottom: 4px; padding: 0 56px; }
.kind.found { color: #e0786b; font-weight: 700; }
.big-emoji { font-size: 64px; line-height: 1.25; margin: 4px 0; filter: drop-shadow(0 0 12px rgba(233, 223, 200, 0.18)); }
.result-name { font-size: 30px; font-weight: 700; letter-spacing: 0.08em; line-height: 1.3; }
.meta { color: var(--text-soft); font-size: 14px; }
.formula { margin-top: 8px; color: var(--text-soft); }
.desc { margin: 14px 0; font-size: 16px; text-align: left; text-indent: 2em; }
.reward { color: var(--jade); margin: 0 0 16px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.stamp {
  position: absolute;
  top: 18px;
  right: 16px;
  z-index: 1;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.05;
  color: var(--cinnabar);
  border: 3px solid var(--cinnabar);
  border-radius: 8px;
  transform: rotate(-12deg);
  opacity: 0.9;
  writing-mode: vertical-rl;
  letter-spacing: 0.05em;
  animation: stamp 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) 0.25s both;
}
.stamp:empty { display: none; }
.stamp.fail { color: var(--text-soft); border-color: var(--text-soft); opacity: 0.75; }
.stamp.found { background: var(--cinnabar); color: #f6ecd6; }

.result-scroll.fail .big-emoji { filter: grayscale(1) brightness(0.8); }

.close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 1;
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-soft);
}
/* 造物詳情 */
.detail-tags { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 2px; }
.tier-badge { font-size: 13px; padding: 1px 8px; border-radius: 3px; border: 1px solid currentColor; letter-spacing: 0.15em; white-space: nowrap; }
.tier-base { color: var(--text-soft); }
.tier-0 { color: #b9ad97; }
.tier-1 { color: #7cc4a8; }
.tier-2 { color: #79a9d6; }
.tier-3 { color: #c69be8; box-shadow: 0 0 6px rgba(198, 155, 232, 0.35); }
.tier-4 { color: #f0c860; box-shadow: 0 0 10px rgba(240, 200, 96, 0.5); background: rgba(240, 200, 96, 0.08); }
.lore {
  margin: 0 0 14px;
  padding: 8px 12px;
  border-left: 3px solid var(--cinnabar);
  background: rgba(233, 223, 200, 0.04);
  text-align: left;
  font-size: 15px;
  line-height: 1.7;
  color: #d9cdb2;
}
.lore.pending { color: var(--text-soft); border-left-color: var(--line-strong); font-size: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0 0 14px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border: 1px solid var(--line); border-radius: 4px; background: rgba(233, 223, 200, 0.03); white-space: nowrap; }
.stat-label { font-size: 12px; color: var(--text-soft); letter-spacing: 0.1em; }
.stat-value { font-size: 15px; font-weight: 700; }
.products li.product { cursor: pointer; }
.products li.product:hover .product-result { color: #f3d27a; }
.product-result { white-space: nowrap; }
.sell-note { margin: 0 0 8px; text-align: center; }
@media (max-width: 380px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; text-align: left; margin: 0 0 16px; }
.facts dt { color: var(--text-soft); }
.facts dd { margin: 0; }
h4 { text-align: left; margin: 0 0 6px; letter-spacing: 0.2em; }
.recipes { list-style: none; padding: 0; margin: 0 0 18px; text-align: left; max-height: 180px; overflow-y: auto; }
.recipes li { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; justify-content: space-between; gap: 10px; }

/* 天道榜 */
.world { margin-bottom: 4px; }
.rank-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0 12px; }
.bang {
  background: rgba(29, 25, 21, 0.85);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px 14px;
}
.bang h3 { margin: 0 0 8px; font-size: 18px; display: flex; align-items: center; gap: 8px; letter-spacing: 0.15em; }
.bang ol { list-style: none; margin: 0; padding: 0; }
.bang li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
  white-space: nowrap;
}
.bang li:last-child { border-bottom: none; }
.bang li.empty { color: var(--text-soft); }
.bang-no { flex: none; width: 1.6em; text-align: right; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.bang li.top1 .bang-no { color: #e8c160; font-weight: 700; }
.bang li.top2 .bang-no { color: #cfd8e0; font-weight: 700; }
.bang li.top3 .bang-no { color: #cd8a5a; font-weight: 700; }
.bang-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bang-realm { flex: none; font-size: 13px; color: var(--text-soft); }
.bang-value { flex: none; min-width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; }
.recent { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.recent li { border: 1px solid var(--line); border-radius: 3px; padding: 2px 10px; font-size: 14px; background: var(--panel); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  border-radius: 6px;
  padding: 10px 18px;
  z-index: 20;
  max-width: calc(100% - 32px);
  letter-spacing: 0.05em;
}

/* 稱號與境界 */
.title-tag { font-size: 13px; color: #d8b56a; letter-spacing: 0.1em; white-space: nowrap; }
.realm-row {
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.realm-name { color: #d8b56a; letter-spacing: 0.1em; }
.ink-bar.thin { height: 5px; margin: 3px 0 8px; }
#cultivation-bar {
  height: 100%;
  background: linear-gradient(90deg, rgba(216, 181, 106, 0.45), #d8b56a);
  border-radius: 4px;
  box-shadow: 0 0 6px rgba(216, 181, 106, 0.5);
  transition: width 0.4s;
}
.realm-list { list-style: none; padding: 0; margin: 12px 0 0; text-align: left; }
.realm-list li { padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; margin-bottom: 8px; }
.realm-list li.passed { opacity: 0.55; }
.realm-list li.current { border-color: #d8b56a; box-shadow: 0 0 10px rgba(216, 181, 106, 0.25); }
.realm-head { display: flex; justify-content: space-between; align-items: baseline; }
.realm-title { font-size: 19px; font-weight: 700; letter-spacing: 0.2em; }
.realm-perks { color: #d8b56a; font-size: 14px; margin-top: 2px; }
.extra { color: #d8b56a; white-space: pre-line; margin: -6px 0 16px; }

/* 入門 */
.tutorial {
  border: 1px dashed rgba(192, 70, 58, 0.7);
  background: rgba(192, 70, 58, 0.08);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  margin: 4px 0 6px;
}

/* 典籍 */
.books { display: flex; flex-direction: column; gap: 12px; }
.book { border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; background: rgba(29, 25, 21, 0.85); }
.book-head { display: flex; align-items: center; gap: 10px; }
.book-name { font-size: 19px; font-weight: 700; letter-spacing: 0.15em; }
.book-progress { color: var(--text-soft); flex: 1; }
.book-desc { margin: 4px 0 10px; }
.book-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.book-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 2px;
  border: 1px dashed var(--line);
  border-radius: 4px;
  color: var(--text-soft);
  min-width: 0;
}
.book-cell .em { font-size: 18px; line-height: 1.2; }
.book-cell.done { border-style: solid; border-color: rgba(216, 181, 106, 0.55); color: var(--text); background: rgba(216, 181, 106, 0.06); }
.book-label { font-size: 13px; font-weight: 700; }
.book-item { font-size: 11px; color: var(--text-soft); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 市集 */
.subtabs { display: flex; gap: 8px; margin: 2px 0 10px; }
.subtab {
  flex: 1;
  background: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px;
  cursor: pointer;
  color: var(--text-soft);
  letter-spacing: 0.2em;
}
.subtab.active { border-color: var(--cinnabar); color: var(--text); }
.lock-note { border: 1px solid var(--line); border-radius: 4px; padding: 8px 12px; color: var(--text-soft); font-size: 14px; }
.trade-form { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.trade-form select, .trade-form input:first-child { flex: 1; min-width: 0; }
.trade-form input[type="number"] { width: 90px; }
.trade-form .seal-btn { padding: 8px 14px; letter-spacing: 0.15em; }
select {
  background: rgba(233, 223, 200, 0.05);
  color: var(--text);
  border: none;
  border-bottom: 1.5px solid var(--line-strong);
  padding: 9px 4px;
  outline: none;
  font: inherit;
}
select option { background: #1d1915; color: var(--text); }
.trade-list { list-style: none; padding: 0; margin: 10px 0 0; }
.trade-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px dashed var(--line); }
.trade-list li.empty { justify-content: center; border: none; }
.trade-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trade-name { font-weight: 700; }
.trade-side { display: flex; align-items: center; gap: 10px; flex: none; }
.price { color: #d8b56a; white-space: nowrap; }
.small-btn { padding: 5px 12px; font-size: 14px; letter-spacing: 0.1em; }

/* 渡劫 */
#cultivation-bar.peak { background: linear-gradient(90deg, #d8b56a, #fff0c4); animation: peak-glow 1.6s ease-in-out infinite alternate; }
.break-btn { display: block; width: 100%; margin: 2px 0 10px; padding: 8px; letter-spacing: 0.3em; animation: break-pulse 1.8s ease-in-out infinite; }
.trib-scroll { overflow: visible; }
.trib-scroll .stamp { right: auto; left: 16px; transform: rotate(12deg); }
.trib-rate { font-size: 20px; margin: 6px 0 2px; }
.trib-rate b { color: #d8b56a; font-size: 26px; }
.trib-pills { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 4px 0 16px; }
.trib-outcome { white-space: pre-line; font-size: 17px; margin: 18px 0; }
.trib-outcome.ok { color: #d8b56a; }
.trib-outcome.bad { color: #e0786b; }
.trib-scroll.thunder { animation: thunder-shake 0.25s linear 5; }
.overlay:has(.trib-scroll.thunder) { animation: thunder-flash 1.6s ease-out; }
.trib-bolt {
  position: fixed;
  top: 0;
  left: 50%;
  width: 90px;
  height: 60vh;
  transform: translateX(-50%);
  fill: #fff6d8;
  filter: drop-shadow(0 0 14px #fff0c4) drop-shadow(0 0 30px rgba(160, 180, 255, 0.8));
  pointer-events: none;
  z-index: 15;
  animation: bolt 1.6s ease-out both;
}

@keyframes peak-glow { from { box-shadow: 0 0 4px rgba(255, 240, 196, 0.4); } to { box-shadow: 0 0 14px rgba(255, 240, 196, 0.9); } }
@keyframes break-pulse { 0%, 100% { box-shadow: 0 0 0 rgba(192, 70, 58, 0); } 50% { box-shadow: 0 0 18px rgba(255, 120, 90, 0.7); } }
@keyframes thunder-shake { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(-3px, 1px); } 75% { transform: translate(3px, -1px); } }
@keyframes thunder-flash {
  0% { background: rgba(5, 4, 3, 0.7); }
  8% { background: rgba(230, 236, 255, 0.55); }
  14% { background: rgba(5, 4, 3, 0.8); }
  30% { background: rgba(230, 236, 255, 0.35); }
  40% { background: rgba(5, 4, 3, 0.75); }
  100% { background: rgba(5, 4, 3, 0.7); }
}
@keyframes bolt {
  0% { opacity: 0; clip-path: inset(0 0 100% 0); }
  10% { opacity: 1; clip-path: inset(0 0 0 0); }
  25% { opacity: 0.2; }
  35% { opacity: 1; }
  100% { opacity: 0; }
}

/* 戰力 */
.power { color: #e0786b; letter-spacing: 0.05em; }
.power-rules { text-align: left; line-height: 1.7; }

/* 論道 */
#tab-chat:not([hidden]) { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-note { margin: 2px 0 8px; flex: none; }
.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 4px 2px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(233, 223, 200, 0.25) transparent;
}
.chat-list li { max-width: 88%; align-self: flex-start; }
.chat-list li.mine { align-self: flex-end; }
.chat-list li.empty { align-self: center; max-width: none; margin-top: 30px; }
.chat-head { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 3px; flex-wrap: nowrap; white-space: nowrap; min-width: 0; }
.chat-list li.mine .chat-head { justify-content: flex-end; }
.chat-realm { font-size: 11px; padding: 0 4px; }
.chat-name { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chat-head > :not(.chat-name) { flex: none; }
.chat-time { color: var(--text-soft); font-size: 12px; }

/* 論道名次 */
.chat-rank {
  font-size: 12px;
  line-height: 1.5;
  padding: 0 6px;
  border-radius: 3px;
  border: 1px solid var(--line-strong);
  color: var(--text-soft);
  white-space: nowrap;
  letter-spacing: 0.05em;
}
.chat-rank.r1,
.chat-rank.r2,
.chat-rank.r3 {
  font-weight: 700;
  color: transparent;
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: rank-sheen 3s linear infinite, rank-glow 2.4s ease-in-out infinite alternate;
}
.chat-rank.r1 {
  background-image: linear-gradient(100deg, #b8862e 20%, #fff1c2 45%, #e8c160 55%, #b8862e 80%);
  border-color: #e0b85a;
  --glow: rgba(240, 196, 90, 0.75);
  padding: 0 8px;
}
.chat-rank.r1::before { content: "✦ "; color: #f3d27a; -webkit-text-fill-color: #f3d27a; }
.chat-rank.r2 {
  background-image: linear-gradient(100deg, #8f9aa6 20%, #ffffff 45%, #cfd8e0 55%, #8f9aa6 80%);
  border-color: #c9d2da;
  --glow: rgba(214, 226, 238, 0.6);
}
.chat-rank.r3 {
  background-image: linear-gradient(100deg, #9a5a32 20%, #f2c6a0 45%, #cd8a5a 55%, #9a5a32 80%);
  border-color: #c98457;
  --glow: rgba(214, 140, 90, 0.55);
}
.chat-rank.r4 {
  color: #d9b8f0;
  border-color: rgba(176, 128, 220, 0.75);
  background: rgba(120, 70, 170, 0.18);
  --glow: rgba(176, 128, 220, 0.55);
  animation: rank-glow 2.8s ease-in-out infinite alternate;
}
.chat-rank.r7 {
  color: #9fd8c4;
  border-color: rgba(95, 166, 142, 0.7);
  background: rgba(95, 166, 142, 0.12);
  box-shadow: 0 0 6px rgba(95, 166, 142, 0.35);
}
@keyframes rank-sheen { from { background-position: 110% 0; } to { background-position: -110% 0; } }
@keyframes rank-glow { from { box-shadow: 0 0 2px var(--glow); } to { box-shadow: 0 0 10px var(--glow); } }
@media (prefers-reduced-motion: reduce) {
  .chat-rank { animation: none !important; }
}
.chat-text {
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 2px 10px 10px 10px;
  padding: 7px 12px;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-list li.mine .chat-text { background: rgba(192, 70, 58, 0.16); border-color: rgba(192, 70, 58, 0.45); border-radius: 10px 2px 10px 10px; }
.chat-form { flex: none; display: flex; gap: 8px; padding: 10px 0 16px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; }
.chat-form .seal-btn { padding: 8px 16px; letter-spacing: 0.15em; }
.chat-form.locked { opacity: 0.6; }

@media (max-width: 420px) {
  .tab { font-size: 16px; letter-spacing: 0.08em; padding: 4px 2px 8px; }
}

@keyframes unroll {
  from { clip-path: inset(48% 0 48% 0); opacity: 0.3; }
  to { clip-path: inset(-20px -20px -20px -20px); opacity: 1; }
}
@keyframes stamp {
  from { transform: rotate(-12deg) scale(2.4); opacity: 0; }
  to { transform: rotate(-12deg) scale(1); opacity: 0.9; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (max-width: 480px) {
  .slot { max-width: 96px; padding: 12px; }
  .taiji-stage { width: 84px; height: 84px; }
  .forge-stage { margin: 0 0 8px; }
}

@media (max-width: 380px) {
  .taiji-stage { width: 80px; height: 80px; }
  .rank-grid { grid-template-columns: 1fr; }
  .brand { font-size: 36px; }
}

@media (max-width: 700px) {
  .moon { display: none; }
}

@media (max-height: 720px) {
  .forge-stage { margin: 0 0 8px; }
  .slot { max-width: 96px; padding: 12px; }
  .taiji-stage { width: 80px; height: 80px; }
  .status { padding: 6px 0 8px; margin-bottom: 8px; }
}

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