/* ============================================================
   skill-tree.css — スキルツリー (= SPEC-090)。 参考作の木の画面を、 ノード端末 (SPEC-055) の色で
   ============================================================
   タイトルの上に重ねる全画面。 上から 頭 / 道の帯 / 木 (つまんで動かす) / 下の欄。
   節は絶対配置の <button>、 線は 1 枚の SVG。
   ============================================================ */

.tree-screen {
  --t-surface: #1c1727;
  --t-raised:  #2b2342;
  --t-line:    #3d3550;
  --t-strong:  #56496e;
  --t-ink:     #e6e0f0;
  --t-ink2:    #a89cc4;
  --t-ink3:    #6f6488;
  --t-ok:      #5ecf8a;
  --t-ng:      #e76060;
  --t-gold:    #c4a35a;
  --t-gold-hi: #f6e2a0;
  position: fixed; inset: 0;
  right: var(--chat-dock, 0px);   /* SPEC-156: チャットのドック (= 右に 320px) のぶん狭める。 html の --chat-dock は chat-dock.js が置く */
  z-index: 260;   /* タイトル (200) の上、 モーダル (320) の下 */
  display: flex; flex-direction: column;
  color: var(--t-ink);
  background: #0f0c15;
  overflow: hidden;
}
/* 背景: ステージ 1 の背景を暗くしたもの (= 絵は JS が style に入れる) */
.tree-bg {
  position: absolute; inset: 0;
  background-position: center; background-size: cover;
  opacity: 0.22;
  filter: saturate(0.6) blur(1px);
  pointer-events: none;
}
.tree-bg::after {
  content: ""; position: absolute; inset: 0;
  background: var(--node-scan), radial-gradient(ellipse at 50% 45%, transparent 30%, rgba(8, 6, 12, 0.75) 100%);
}

/* ---- 頭 ---- */
.tree-head {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: max(6px, var(--safe-t, 0px)) 12px 6px;
  background: rgba(12, 9, 18, 0.88);
  border-bottom: 1px solid var(--t-line);
}
.tree-back {
  width: 36px; height: 36px; flex: none;
  border-radius: var(--r-sm);
  background: var(--t-raised); border: 1px solid var(--t-strong);
  color: var(--t-ink); font-size: 18px; cursor: pointer;
}
.tree-title { display: flex; align-items: baseline; gap: 8px; line-height: 1.1; flex: 1; min-width: 0; }
.tree-title b { font-family: var(--font-display); font-weight: 400; font-size: 17px; color: var(--t-gold-hi); letter-spacing: 0.04em; }
.tree-title small { font-family: var(--font-num); font-size: 9px; letter-spacing: 0.22em; color: var(--node-cyan); }
@media (max-width: 420px) { .tree-title small { display: none; } }
/* SPEC-156: チャットのドックを畳む・広げる (= PC でドックのときだけ) */
.tree-chat { display: inline-flex; align-items: center; gap: 6px; height: 32px; min-width: 0; padding: 0 10px; font-size: 14px; flex: none; }
.tree-chat span { font-size: 12px; font-weight: 700; }
@media (max-width: 1240px) { .tree-chat span { display: none; } }
/* 残高 (= 頭の右。 選んだ節の費用を「−40」と並べる) */
.tree-bals { display: flex; gap: 6px; flex: none; }
.tree-bal {
  display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 8px 0 5px;
  border-radius: 99px; background: var(--t-surface); border: 1px solid var(--t-line);
  font-size: 12px; white-space: nowrap;
}
.tree-bal img { width: 18px; height: 18px; image-rendering: pixelated; object-fit: contain; }
.tree-bal b { font-weight: 500; color: #fff; }
.tree-bal.dust b { color: var(--t-gold-hi); }
.tree-bal i { font-style: normal; font-size: 11px; font-weight: bold; }
.tree-bal.ok { border-color: rgba(94, 207, 138, 0.6); }
.tree-bal.ok i { color: var(--t-ok); }
.tree-bal.ng { border-color: rgba(231, 96, 96, 0.7); }
.tree-bal.ng i, .tree-bal.ng b { color: var(--t-ng); }

/* ---- 道の帯 ---- */
.tree-routebar {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px;
  padding: 4px 10px 5px;
  background: rgba(12, 9, 18, 0.72);
  border-bottom: 1px solid var(--t-line);
}
.route-pip {
  position: relative; height: 24px; display: flex; align-items: center; justify-content: center; gap: 4px;
  border-radius: 4px; background: var(--t-surface); border: 1px solid var(--t-line);
  color: var(--t-ink2); font-size: 10px; padding: 0 2px; cursor: pointer; overflow: hidden; white-space: nowrap;
}
.route-pip em { font-style: normal; font-size: 9px; color: var(--c); }
.route-pip.on { border-color: var(--c); color: var(--t-ink); box-shadow: 0 0 8px color-mix(in srgb, var(--c) 45%, transparent); }

/* ---- 木 (= SPEC-093: 木と、 その右の「いまの効果」) ---- */
.tree-main { position: relative; flex: 1; min-height: 0; display: flex; }
.tree-viewport { position: relative; flex: 1; min-width: 0; overflow: hidden; touch-action: none; cursor: grab; }
.tree-viewport:active { cursor: grabbing; }
.tree-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.tree-world.glide { transition: transform 0.42s cubic-bezier(0.2, 0, 0.2, 1); }
.tree-links { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
/* SPEC-133: 親から子へまっすぐ。 off: 親がまだ (= 点線) / open: 親は取った (= 道の色を薄く) / on: 両方取った (= 光る) */
.tree-links .link { fill: none; stroke-width: 4; stroke-linecap: round; }
.tree-links .link.off { stroke-dasharray: 5 8; opacity: 0.45; stroke-width: 3; }
.tree-links .link.open { opacity: 0.45; }
.tree-links .link.on { opacity: 0.95; }
.tree-links .link-flow { fill: none; stroke-width: 3; stroke-dasharray: 3 22; stroke-linecap: round; animation: tree-flow 1.6s linear infinite; opacity: 0.95; }
.tree-links .link.grow { animation: tree-grow 0.52s cubic-bezier(0.2, 0, 0.2, 1) forwards; }
.tree-links .route-label { font: 400 22px var(--font-display); opacity: 0.5; letter-spacing: 0.1em; }
@keyframes tree-flow { to { stroke-dashoffset: -25; } }
@keyframes tree-grow { to { stroke-dashoffset: 0; } }

.tnode {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 96px; padding: 0; margin: 0;
  background: none; border: 0; color: var(--t-ink); cursor: pointer;
  font-family: var(--font-body);
}
.tnode-panel {
  position: relative; width: 58px; height: 58px;
  display: grid; place-items: center;
  --cut: 9px;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  background: var(--t-surface);
  box-shadow: inset 0 0 0 2px var(--t-strong);
  transition: transform 0.12s;
}
@media (hover: hover) { .tnode:hover .tnode-panel { transform: scale(1.06); } }
.tnode-panel img { width: 42px; height: 42px; image-rendering: pixelated; pointer-events: none; }
.tnode-q { font-size: 26px; color: var(--t-ink3); }
.tnode-lv {
  position: relative; margin-top: -10px;
  font-size: 10px; font-weight: 700; padding: 1px 7px;
  border-radius: 99px; background: var(--t-raised); border: 1px solid var(--t-strong);
}
.tnode-name { font-size: 11px; line-height: 1.2; text-align: center; text-shadow: 0 1px 3px #000; max-width: 96px; }

/* 状態: 取れる＝緑 (脈打つ) / 足りない＝赤 / 条件が合わない＝点線 / その先＝灰の「？」 / 取った＝白 */
.tnode.can .tnode-panel { box-shadow: inset 0 0 0 2px var(--t-ok), 0 0 14px rgba(94, 207, 138, 0.45); animation: tree-pulse 1.4s ease-in-out infinite; }
.tnode.can .tnode-lv { border-color: var(--t-ok); color: var(--t-ok); }
.tnode.short .tnode-panel { box-shadow: inset 0 0 0 2px var(--t-ng), 0 0 10px rgba(231, 96, 96, 0.35); }
.tnode.short .tnode-panel img { opacity: 0.75; }
.tnode.short .tnode-lv { border-color: var(--t-ng); color: var(--t-ng); }
.tnode.locked .tnode-panel { box-shadow: inset 0 0 0 2px var(--t-line); opacity: 0.7; }
.tnode.locked .tnode-panel img { filter: grayscale(1) brightness(0.6); }
.tnode.teaser .tnode-panel { background: #15111d; box-shadow: inset 0 0 0 2px #3a3350; }
.tnode.teaser .tnode-q { color: #4f4866; font-size: 24px; font-weight: bold; }
.tnode.teaser .tnode-name { color: #5d5577; }
.tnode.has .tnode-panel { box-shadow: inset 0 0 0 2px #fff, 0 0 12px rgba(255, 255, 255, 0.35); background: color-mix(in srgb, var(--c) 22%, var(--t-surface)); }
.tnode.has .tnode-lv { border-color: #fff; color: #fff; }
.tnode.max .tnode-panel img { opacity: 0.85; }
.tnode.max .tnode-lv { color: var(--t-gold-hi); border-color: var(--t-gold-hi); }
/* SPEC-157: 選んだ節は黄色い枠 (= 詳しい欄を出しているあいだ、 どの節かが木の上で分かる)。
   盤の outline と box-shadow は clip-path に切られて見えないので、 節の ::after を盤の外側に重ねる (::before は案内の輪が使っている) */
.tnode.sel::after {
  content: ""; position: absolute; left: 50%; top: 29px; width: 72px; height: 72px; transform: translate(-50%, -50%);
  border: 3px solid #ffd54a; border-radius: 12px; pointer-events: none; z-index: 2;
  box-shadow: 0 0 18px rgba(255, 213, 74, 0.75), inset 0 0 10px rgba(255, 213, 74, 0.3);
  animation: tree-sel 1.1s ease-in-out infinite;
}
.tnode.k-root.sel::after { top: 38px; width: 92px; height: 92px; border-radius: 50%; }
.tnode.sel .tnode-name { color: #ffd54a; font-weight: 800; text-shadow: 0 0 6px rgba(0, 0, 0, 0.9); }
@keyframes tree-sel { 0%, 100% { border-color: #ffd54a; } 50% { border-color: #fff3b0; } }
:root[data-reduce-fx] .tnode.sel::after { animation: none; }
@keyframes tree-pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.25); } }

/* 根: 金の円 */
.tnode.k-root .tnode-panel {
  width: 76px; height: 76px; clip-path: none; border-radius: 50%;
  background: radial-gradient(circle, #3a2f10, var(--t-surface));
  box-shadow: 0 0 0 3px var(--t-gold), 0 0 22px rgba(196, 163, 90, 0.55);
}
.tnode.k-root .tnode-panel img { width: 50px; height: 50px; }
.tnode.k-root.can .tnode-panel { box-shadow: 0 0 0 3px var(--t-ok), 0 0 26px rgba(94, 207, 138, 0.6); }
.tnode.k-root.has .tnode-panel { box-shadow: 0 0 0 3px #fff, 0 0 22px rgba(246, 226, 160, 0.55); }
/* 奥義: ひし形・道の色の太字 */
.tnode.k-capstone .tnode-panel { width: 66px; height: 66px; --cut: 11px; transform: rotate(45deg); }
.tnode.k-capstone .tnode-panel img { transform: rotate(-45deg); width: 44px; height: 44px; }
@media (hover: hover) { .tnode.k-capstone:hover .tnode-panel { transform: rotate(45deg) scale(1.06); } }
.tnode.k-capstone .tnode-lv { margin-top: -2px; }
.tnode.k-capstone .tnode-name { font-weight: 700; color: var(--c); }

/* 新しく見えた節: 飛び出す。 根を取ったときは中心から */
.tnode.pop { animation: tree-popin 0.42s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes tree-popin { from { opacity: 0; transform: translate(-50%, -50%) scale(0.3); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.tnode.burst { animation: tree-burst 0.7s cubic-bezier(0.18, 1.3, 0.4, 1) both; }
@keyframes tree-burst {
  from { opacity: 0; transform: translate(calc(-50% + var(--fx)), calc(-50% + var(--fy))) scale(0.2); }
  60% { opacity: 1; }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.tree-shock {
  position: absolute; width: 80px; height: 80px; margin: -40px 0 0 -40px; border-radius: 50%;
  border: 3px solid var(--t-gold-hi);
  box-shadow: 0 0 24px var(--t-gold-hi), inset 0 0 24px rgba(246, 226, 160, 0.5);
  pointer-events: none; animation: tree-shock 1.4s ease-out both;
}
@keyframes tree-shock { from { transform: scale(0.4); opacity: 1; } to { transform: scale(9); opacity: 0; } }

/* ---- 通知 (= 買った・足りない) ---- */
.tree-notice {
  position: absolute; left: 50%; bottom: 58px;   /* SPEC-093: 上はマインちゃんと効果の札 */ transform: translateX(-50%); z-index: 4;
  max-width: calc(100% - 32px); padding: 6px 12px;
  background: rgba(12, 9, 18, 0.92); border: 1px solid var(--t-line); border-radius: var(--r-sm);
  font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none; animation: tree-popin-y 0.25s ease-out both;
}
.tree-notice.good { border-color: var(--t-ok); color: var(--t-ok); }
.tree-notice.bad { border-color: var(--t-ng); color: var(--t-ng); }
@keyframes tree-popin-y { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---- 下の欄 ---- */
.tree-sheet {
  position: relative; z-index: 2;
  background: rgba(12, 9, 18, 0.96); border-top: 1px solid var(--t-line);
  padding: 10px 14px calc(12px + var(--safe-b, 0px));
  max-height: 46dvh; overflow-y: auto;
}
/* ---- SPEC-094: 詳しい欄 (= Workshop の作り。 大きなアイコン・条件・変化・立体のボタン) ---- */
.tree-sheet.idle { padding-top: 8px; padding-bottom: calc(8px + var(--safe-b, 0px)); }
.dt-head { display: flex; align-items: center; gap: 12px; }
.dt-icon {
  flex: none; width: 60px; height: 60px; display: grid; place-items: center;
  border-radius: 12px; background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--c) 30%, #1c1727), #120e1a 75%);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 70%, transparent), 0 4px 12px rgba(0, 0, 0, 0.45);
  font-size: 26px; color: var(--t-ink3);
}
.dt-icon img { width: 48px; height: 48px; image-rendering: pixelated; }
.dt-icon.has { box-shadow: inset 0 0 0 2px #fff, 0 0 14px color-mix(in srgb, var(--c) 55%, transparent); }
.dt-icon.teaser { background: #15111d; box-shadow: inset 0 0 0 2px #3a3350; }
.dt-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.dt-tags { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; }
.route-tag { color: var(--c); border: 1px solid var(--c); border-radius: 4px; padding: 0 5px; }
.kind-tag { color: var(--t-ink2); border: 1px solid var(--t-line); border-radius: 4px; padding: 0 5px; }
.dt-name { font-size: 18px; font-weight: 700; line-height: 1.2; }
.dt-pips { display: flex; align-items: center; gap: 3px; }
.dt-pips i { width: 14px; height: 6px; border-radius: 2px; background: var(--t-raised); box-shadow: inset 0 0 0 1px var(--t-strong); }
.dt-pips i.on { background: linear-gradient(180deg, var(--t-gold-hi), var(--t-gold)); box-shadow: none; }
.dt-pips b { margin-left: 6px; font-size: 11px; font-weight: 600; color: var(--t-gold-hi); }
.sheet-x { align-self: flex-start; background: none; border: 0; color: var(--t-ink2); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 2px; }
.dt-desc { margin: 8px 0 6px; font-size: 13px; line-height: 1.6; }
.dt-conds { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: #f08a8a; }
.dt-conds li { display: flex; gap: 4px; align-items: baseline; }
.dt-conds li i { font-style: normal; font-weight: 800; }
.dt-conds li.met { color: var(--t-ink3); }
.dt-conds li.met i { color: var(--t-ok); }
.dt-changes {
  list-style: none; margin: 0 0 8px; padding: 6px 10px; border-radius: 8px;
  background: rgba(0, 0, 0, 0.35); display: flex; flex-direction: column; gap: 2px; font-size: 13px;
}
.dt-changes li { display: flex; justify-content: space-between; gap: 8px; padding-left: 8px; border-left: 3px solid var(--c); }
.dt-changes span { color: var(--t-ink2); }
.dt-changes b { font-weight: 500; color: #fff; white-space: nowrap; }
.dt-changes em { font-style: normal; font-weight: 700; color: var(--t-ok); }
.sheet-note { color: var(--t-ink2); font-size: 12px; margin: 2px 0; }
/* SPEC-157: 一括解放 (= ボタンと、 ゴールドダストも使うかの切り替え) */
.sheet-bulk { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--t-line); }
.sheet-check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--t-ink2); cursor: pointer; }
.sheet-check input { width: 16px; height: 16px; accent-color: var(--t-gold); margin: 0; }
.sheet-go {
  width: 100%; text-align: left;
  background: linear-gradient(180deg, rgba(94, 207, 138, 0.16), rgba(94, 207, 138, 0.06));
  border: 1px solid rgba(94, 207, 138, 0.45); color: var(--t-ok);
  border-radius: var(--r-sm); padding: 9px 12px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
}
.sheet-go:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45); }
/* ボタン: 立体 (= 下に影、 押すと沈む) のグラデーション */
.tree-btn {
  width: 100%; min-height: 50px; margin-top: 4px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border-radius: 10px; border: 2px solid var(--t-strong);
  background: linear-gradient(180deg, #3a3054, #261f38); color: var(--t-ink);
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 0 #0a0810;
  transition: transform 0.08s, filter 0.15s, box-shadow 0.08s;
}
.tree-btn:hover:not(:disabled) { filter: brightness(1.12); }
.tree-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #0a0810; }
.tree-btn:disabled { opacity: 0.5; cursor: not-allowed; filter: saturate(0.4); }
.tree-btn.gold { background: linear-gradient(180deg, #ffe69a, #f0b545 55%, #d68a22); border-color: #fff3c4; color: #3a1f06; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4); box-shadow: 0 3px 0 #6b3d0b, 0 0 16px rgba(240, 181, 69, 0.35); }
.tree-btn.gold:active:not(:disabled) { box-shadow: 0 1px 0 #6b3d0b; }
.tree-btn.green { background: linear-gradient(180deg, #8fe3a5, #4f9e5f 60%, #376f43); border-color: #c8f5d4; color: #0c2414; box-shadow: 0 3px 0 #18361f, 0 0 14px rgba(94, 207, 138, 0.3); }
.tree-btn.green:active:not(:disabled) { box-shadow: 0 1px 0 #18361f; }
.tree-btn.done { background: linear-gradient(180deg, #2b2342, #221b33); color: var(--t-gold-hi); opacity: 0.8; }
.tree-btn.sub { min-height: 36px; font-size: 13px; margin-top: 0; }
.tree-btn.danger { border-color: var(--t-ng); color: #fff; background: linear-gradient(180deg, #8a2a2a, #5a1717); box-shadow: 0 3px 0 #2a0909; }
.cost-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; font-size: 12px; font-weight: 700; }
.cost-chip { display: inline-flex; align-items: center; gap: 3px; background: rgba(0, 0, 0, 0.22); border-radius: 99px; padding: 1px 8px; }
.cost-chip img { width: 14px; height: 14px; image-rendering: pixelated; object-fit: contain; }
.tree-btn:not(.gold):not(.green) .cost-chip { background: rgba(0, 0, 0, 0.35); }
/* 木の左下: 縮める・広げる・中心へ */
.tree-tools { position: absolute; left: 10px; bottom: 10px; z-index: 3; display: flex; gap: 6px; }
.tree-tool {
  min-width: 38px; height: 38px; padding: 0 10px; border-radius: 10px;
  border: 1px solid var(--t-strong); background: linear-gradient(180deg, #3a3054, #241d35);
  color: var(--t-ink); font: inherit; font-size: 18px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 0 #0a0810;
}
.tree-tool.wide { font-size: 12px; }
.tree-tool:active { transform: translateY(2px); box-shadow: 0 1px 0 #0a0810; }
/* 効果の欄のいちばん下: 作り直す (= 小さく、 押すと確かめる) */
.stats-reset { margin-top: 12px; padding-top: 8px; border-top: 1px dashed var(--t-line); }
.reset-link { background: none; border: 0; padding: 2px 0; color: var(--t-ink3); font: inherit; font-size: 11px; text-decoration: underline; cursor: pointer; }
.reset-link:hover { color: var(--t-ng); }
.stats-reset.ask p { margin: 0 0 6px; font-size: 11px; color: var(--t-ink2); }
.reset-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
@media (min-width: 861px) { .tree-sheet { max-height: 34dvh; } }

/* ---- 入口: タイトルのボタンの数の札 / 結果の画面のボタン ---- */
.title-screen__tree { position: relative; clip-path: none; }   /* 数の札と NEW を角の切り抜きで欠かさない */
.tree-badge {
  position: absolute; top: -6px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 99px; background: var(--t-ok, #5ecf8a); color: #0a1a10;
  font-size: 10px; font-weight: 800; line-height: 1;
  box-shadow: 0 0 10px rgba(94, 207, 138, 0.6);
}
.result-tree-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  width: 100%; margin: 0.1rem 0 0.4rem;
}
.result-tree-btn img { width: 20px; height: 20px; image-rendering: pixelated; object-fit: contain; }

/* 動きを減らす: 飛び出す・流れる・脈打つを止める */
:root[data-reduce-fx] .tnode.pop,
:root[data-reduce-fx] .tnode.burst,
:root[data-reduce-fx] .tnode.can .tnode-panel,
:root[data-reduce-fx] .tree-links .link-flow,
:root[data-reduce-fx] .tree-links .link.grow,
:root[data-reduce-fx] .tree-shock,
:root[data-reduce-fx] .tree-notice { animation: none; }
:root[data-reduce-fx] .tree-world.glide { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .tnode.pop, .tnode.burst, .tnode.can .tnode-panel, .tree-links .link-flow, .tree-links .link.grow, .tree-shock, .tree-notice { animation: none; }
  .tree-world.glide { transition: none; }
}

/* ---- SPEC-090c: ヒーロー選択の 1 行 (= いま効いている恒久強化) ---- */
.hero-perks {
  margin: 0.15rem 0 0.1rem;
  padding: 0.25rem 0.6rem;
  font-size: 0.68rem;
  line-height: 1.4;
  letter-spacing: 0.03em;
  text-align: center;
  color: var(--node-gold-hi, #f6e2a0);
  background: rgba(196, 163, 90, 0.08);
  border: 1px solid rgba(196, 163, 90, 0.3);
  border-radius: var(--r-sm);
}

/* ---- SPEC-093: いまの効果の欄 (= 861px 以上は木の右の列。 狭い画面は右上の札で、 見出しを押すと開く) ---- */
.tree-stats {
  position: relative; z-index: 3; flex: none; width: 220px;
  display: flex; flex-direction: column; min-height: 0;
  background: rgba(12, 9, 18, 0.9); border-left: 1px solid var(--t-line);
}
.stats-head {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 8px 12px; background: none; border: 0; border-bottom: 1px solid var(--t-line);
  color: var(--t-gold-hi); font: inherit; font-size: 13px; text-align: left; cursor: default;
}
.stats-head b { font-weight: 700; flex: 1; }
.stats-head em { font-style: normal; font-size: 10px; color: var(--t-ink); background: var(--t-raised); border-radius: 99px; padding: 1px 7px; }
.stats-head i { display: none; font-style: normal; color: var(--t-ink2); }
.stats-body { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 12px 10px; }
.stats-note { margin: 0 0 6px; font-size: 10px; color: var(--t-ink3); }
.stats-none { margin: 4px 0; font-size: 12px; color: var(--t-ink2); }
.stats-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.stat-row {
  display: flex; align-items: baseline; gap: 6px; padding: 3px 6px; border-radius: 4px;
  font-size: 12px; border-left: 3px solid var(--c);
}
.stat-k { flex: 1; min-width: 0; color: var(--t-ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-v { color: #fff; font-weight: 600; white-space: nowrap; }
.stat-v b { color: var(--t-ok); }
.stat-row.chg { background: rgba(94, 207, 138, 0.12); }
.stat-row.chg .stat-k { color: var(--t-ink); }
.stats-flags { margin: 8px 0 0; font-size: 11px; line-height: 1.5; color: var(--t-gold-hi); }
@media (max-width: 860px) {
  .tree-stats {
    position: absolute; top: 8px; right: 8px; width: min(210px, 56vw); max-height: calc(100% - 16px);
    border: 1px solid var(--t-line); border-radius: var(--r-sm);
  }
  .stats-head { cursor: pointer; border-bottom: 0; padding: 6px 10px; }
  .stats-head i { display: inline; }
  .tree-stats.open .stats-head { border-bottom: 1px solid var(--t-line); }
  .tree-stats:not(.open) .stats-body { display: none; }
  .tree-stats:not(.open) { width: auto; }
  .stats-body { padding: 6px 10px 8px; }
}

/* ---- SPEC-093: 初回の案内 ---- */
/* 指し示す節: 金の輪が広がり、 上に「ここを 2 回！」が弾む */
.tnode.guide .tnode-panel::after {
  content: ""; position: absolute; inset: -2px; pointer-events: none;
  box-shadow: 0 0 0 3px var(--t-gold-hi); border-radius: inherit;
}
.tnode.guide::before {
  content: ""; position: absolute; left: 50%; top: 29px; width: 70px; height: 70px; margin: -35px 0 0 -35px;
  border-radius: 50%; border: 2px solid var(--t-gold-hi); pointer-events: none;
  animation: tree-guide-ring 1.3s ease-out infinite;
}
.tnode.k-root.guide::before { top: 38px; width: 92px; height: 92px; margin: -46px 0 0 -46px; }
.tnode-guide {
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  padding: 3px 9px; border-radius: 99px; white-space: nowrap; pointer-events: none;
  background: var(--t-gold-hi); color: #221a00; font-size: 11px; font-weight: 800;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  animation: tree-guide-bob 0.9s ease-in-out infinite;
}
.tnode-guide::after {
  content: ""; position: absolute; left: 50%; top: 100%; margin-left: -5px;
  border: 5px solid transparent; border-top-color: var(--t-gold-hi);
}
@keyframes tree-guide-ring { from { transform: scale(0.8); opacity: 0.9; } to { transform: scale(1.5); opacity: 0; } }
@keyframes tree-guide-bob { 50% { transform: translate(-50%, -5px); } }

/* 入口 (= タイトルと結果の画面): 脈打ち、 左上に「NEW」 */
.tree-nudge { animation: tree-nudge 1.2s ease-in-out infinite; position: relative; }
.tree-nudge::before {
  content: attr(data-new); position: absolute; top: -8px; left: -6px; z-index: 1;   /* タイトルのボタン (= 角を切らない) */
  padding: 1px 6px; border-radius: 4px; background: var(--node-gold-hi, #f6e2a0); color: #221a00;
  font-size: 9px; font-weight: 800; letter-spacing: 0.06em; line-height: 1.4;
}
/* 結果の画面のボタンは角を切っている (= はみ出すと欠ける) ので、 NEW はボタンの中の右上に */
.result-tree-btn.tree-nudge::before { top: 4px; left: auto; right: 10px; }
@keyframes tree-nudge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(246, 226, 160, 0.0); transform: scale(1); }
  50% { box-shadow: 0 0 0 4px rgba(246, 226, 160, 0.35), 0 0 18px rgba(246, 226, 160, 0.55); transform: scale(1.05); }
}
:root[data-reduce-fx] .tree-nudge, :root[data-reduce-fx] .tnode.guide::before, :root[data-reduce-fx] .tnode-guide { animation: none; }
@media (prefers-reduced-motion: reduce) { .tree-nudge, .tnode.guide::before, .tnode-guide { animation: none; } }

/* ---- SPEC-094: 広い画面の右の列 (= 上に詳しい欄、 下にいまの効果) ---- */
.tree-screen.wide .tree-side {
  position: relative; z-index: 3; flex: none; width: 340px; min-height: 0;   /* SPEC-135: Workshop と同じ 340px */
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(30, 24, 44, 0.96), rgba(14, 11, 20, 0.96));
  border-left: 1px solid var(--t-line);
}
.tree-screen.wide .tree-sheet {
  flex: none; max-height: 62%; overflow-y: auto; border-top: 0; border-bottom: 1px solid var(--t-line);
  background: none; padding: 14px 14px 14px;
}
.tree-screen.wide .tree-sheet.idle { padding: 12px 14px; }
.tree-screen.wide .tree-stats { flex: 1; width: auto; border-left: 0; background: none; }
.tree-screen.wide .dt-conds { flex-direction: column; }

/* SPEC-132: 戻るは木の右下 (= 縮める・広げる・中心へ と同じ高さ。 スマホで押しやすい) */
.tree-back2 {
  position: absolute; right: 10px; bottom: 10px; z-index: 3;
  display: inline-flex; align-items: center; gap: 6px;
  min-width: 96px; height: 44px; padding: 0 16px;
  font-size: 15px;
  border-color: var(--t-gold); color: var(--t-gold-hi);
}
.tree-back2 span:first-child { font-size: 12px; }
.tree-screen.wide .tree-back2 { right: 350px; }   /* 右の列 (340px) の手前 */

/* SPEC-134: ミニマップ (= 押す・なぞるとその場所へ)。 広い画面は左下のボタンの上、 狭い画面は右下の「戻る」の上に小さく */
.tree-minimap {
  position: absolute; left: 10px; bottom: 58px; z-index: 3;
  width: 150px; height: 110px;
  border: 1px solid var(--t-strong); border-radius: 8px;
  cursor: crosshair; touch-action: none;
}
.tree-screen:not(.wide) .tree-minimap { left: auto; right: 10px; bottom: 64px; width: 90px; height: 66px; }

/* SPEC-135: 狭い画面 (= 860px 以下) は上に木、 下に欄 (= 画面の 46% まで)。 詳しい欄を小さくして、 名前・効果・ボタンがスクロールなしで入るように */
@media (max-width: 860px) {
  .tree-sheet { max-height: 46dvh; padding: 8px 10px calc(10px + var(--safe-b, 0px)); }
  .tree-sheet .dt-icon { width: 44px; height: 44px; border-radius: 10px; }
  .tree-sheet .dt-icon img { width: 36px; height: 36px; }
  .tree-sheet .dt-name { font-size: 16px; }
  .tree-sheet .dt-desc { margin: 6px 0 4px; font-size: 13px; line-height: 1.45; }
  .tree-sheet .dt-conds { margin: 4px 0; font-size: 12px; }
  .tree-sheet .tree-btn { padding-top: 8px; padding-bottom: 8px; font-size: 15px; }
}

/* SPEC-146: 倒れたあとに開いたときの「もう一度挑む」 (= 戻るの上。 金色で目立たせる) */
.tree-retry {
  position: absolute; left: 10px; bottom: 64px; z-index: 6;   /* 狭い画面は左下のボタンの上 (= 右下はミニマップと戻る) */
  display: flex; gap: 6px; align-items: center; justify-content: center;
  min-width: 150px; height: 46px; padding: 0 16px;
  font-weight: 800; font-size: 15px; color: #2a1a05;
  background: linear-gradient(180deg, #ffe9a6, #f0b84b 55%, #c98a1c);
  border: 1.5px solid #fff2c4; border-radius: 10px;
  box-shadow: 0 0 18px rgba(255, 196, 64, 0.55), 0 4px 0 rgba(0, 0, 0, 0.35);
  animation: tree-retry-pulse 1.6s ease-in-out infinite;
}
.tree-screen.wide .tree-retry { left: auto; right: 350px; }
@keyframes tree-retry-pulse { 0%, 100% { box-shadow: 0 0 10px rgba(255, 196, 64, 0.4), 0 4px 0 rgba(0, 0, 0, 0.35); } 50% { box-shadow: 0 0 24px rgba(255, 196, 64, 0.85), 0 4px 0 rgba(0, 0, 0, 0.35); } }
:root[data-reduce-fx] .tree-retry { animation: none; }

/* SPEC-164: 根 (= サバイバーの覚醒) を取るまでは、 復活する・戻る・道・一括解放を押せない (= 根だけが光る) */
.tree-screen.gate .tree-retry, .tree-screen.gate .tree-back2, .tree-screen.gate .route-pip, .tree-screen.gate .sheet-bulk { opacity: 0.35; filter: grayscale(1); pointer-events: none; animation: none; }
