/* tree.css — 星図（スキルツリー）オーバーレイ。共通の変数・部品は style.css（docs/engine_api.md §8） */

.tree-root {
  position: absolute; inset: 0; overflow: hidden;
  background: #070820;
  opacity: 0; transition: opacity .25s ease-out;
  touch-action: none;
}
.tree-root.show { opacity: 1; }
.tree-root canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tree-bg { image-rendering: pixelated; }
.tree-fg { cursor: grab; touch-action: none; }
.tree-fg.pointing { cursor: pointer; }
.tree-fg.grabbing { cursor: grabbing; }
.tree-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 55%, transparent 55%, rgba(4, 3, 18, .55) 85%, rgba(3, 2, 14, .85) 100%),
    linear-gradient(180deg, rgba(5, 4, 20, .55), transparent 18%, transparent 80%, rgba(5, 4, 20, .6));
}

/* ------------------------------------------------------------------ ツールバー（下） */
.tree-toolbar {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 12px);
  display: flex; align-items: center; gap: 14px;
  padding: 6px 8px 6px 10px;
  background: linear-gradient(180deg, rgba(21, 26, 61, .9), rgba(11, 13, 36, .94));
  border: 2px solid rgba(255, 217, 138, .5);
  border-radius: 12px;
  box-shadow: 0 0 0 2px rgba(16, 7, 42, .85), 0 8px 24px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .08);
  white-space: nowrap;
  max-width: calc(100vw - 24px);
}
.tree-tb-title { display: flex; align-items: center; gap: 6px; padding-right: 4px; }
.tree-tb-title img { width: 28px; height: 28px; }
.tree-tb-titletext { display: flex; flex-direction: column; line-height: 1.1; }
.tree-tb-name { font-family: var(--font-dot); font-size: 16px; color: var(--honey); text-shadow: 0 0 8px rgba(255, 191, 94, .45); letter-spacing: .1em; }
.tree-tb-count { font-size: 11px; color: var(--muted); }
.tree-tb-mid { display: flex; gap: 6px; }
.tree-tb-btn { position: relative; gap: 4px; padding: 3px 10px 3px 6px; min-height: 36px; }
.tree-tb-btn img.icon { width: 22px; height: 22px; }
.tree-tb-next.has { border-color: var(--honey); box-shadow: 0 0 0 2px #10072a, 0 0 12px rgba(255, 191, 94, .45), inset 0 2px 0 rgba(255, 255, 255, .14); }
.tree-tb-badge {
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 2px;
  font-size: 11px; line-height: 18px; text-align: center; color: #2a1606;
  background: var(--amber); border-radius: 9px; box-shadow: 0 0 0 2px #10072a, 0 0 8px rgba(255, 191, 94, .7);
}
.tree-tb-moon { border-color: rgba(169, 214, 255, .7); }
.tree-tb-close { margin-left: 2px; }

/* 操作ヒント */
.tree-hint {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 74px);
  padding: 4px 14px; border-radius: 999px;
  font-size: 12px; color: var(--lavender); white-space: nowrap;
  background: rgba(11, 13, 36, .7); border: 1px solid rgba(183, 162, 255, .3);
  pointer-events: none !important;
  transition: opacity .8s;
}
.tree-hint.gone { opacity: 0; }

/* ------------------------------------------------------------------ 詳細カード */
.tree-card {
  position: absolute; left: 0; top: 0;
  width: 320px; max-width: calc(100vw - 24px);
  padding: 12px 14px 12px;
  overflow-y: auto; overflow-x: hidden;
  font-size: 13.5px; line-height: 1.55;
  transition: opacity .15s;
  will-change: transform;
  --accent: var(--lilac);
}
.has-frame .tree-card { padding: 12px 14px 16px; }
.tree-card::-webkit-scrollbar { width: 6px; }
.tree-card-close {
  position: absolute; top: 4px; right: 4px; z-index: 1;
  display: none; padding: 3px; line-height: 0;
  background: transparent; border: 0; border-radius: 6px; cursor: pointer;
}
.has-frame .tree-card-close { top: 10px; right: 10px; }
.tree-card-close img { width: 20px; height: 20px; }
.tree-card-close:hover { background: rgba(255, 255, 255, .08); }
.tree-card.pinned .tree-card-close, .tree-card.sheet .tree-card-close { display: block; }

.tree-card-head { display: flex; align-items: center; gap: 10px; padding-right: 34px; }
.tree-card-icon {
  flex: none; width: 56px; height: 56px; display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #26306a, #0e1238 70%);
  box-shadow: 0 0 0 2px #10072a, 0 0 0 4px var(--accent), 0 0 0 6px #10072a, 0 0 18px color-mix(in srgb, var(--accent) 55%, transparent);
}
.tree-card-icon img { width: 48px; height: 48px; }
.tree-card-icon.fog { background: radial-gradient(circle, #4a4a8a, #23234f); box-shadow: 0 0 0 2px #10072a, 0 0 0 4px #6b6aa8, 0 0 0 6px #10072a; }
.tree-card-icon.fog span { font-family: var(--font-dot); font-size: 26px; color: #d8ccff; opacity: .8; }
.tree-card.keystone .tree-card-icon { border-radius: 10px; transform: rotate(45deg); }
.tree-card.keystone .tree-card-icon img { transform: rotate(-45deg); }
.tree-card-title { flex: 1 1 auto; min-width: 0; }
.tree-card-branch { font-family: var(--font-dot); font-size: 11px; color: var(--accent); letter-spacing: .08em; opacity: .95; }
.tree-card-name {
  font-family: var(--font-dot); font-size: 18px; line-height: 1.25; color: var(--cream);
  text-shadow: 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent), 0 2px 0 #10072a;
  overflow-wrap: anywhere;
}
.tree-card-lv { flex: none; font-size: 18px; color: var(--honey); text-align: right; line-height: 1; white-space: nowrap; }
.tree-card-lv .lvlabel { font-size: 11px; color: var(--muted); }
.tree-card-lv .lvmax { font-size: 12px; color: var(--muted); }
.tree-card[data-status="maxed"] .tree-card-lv { color: var(--gold); text-shadow: 0 0 8px rgba(253, 200, 66, .6); }

.tree-card-pips { display: flex; flex-wrap: wrap; gap: 3px; margin: 8px 0 2px 66px; }
.tree-card-pips .pip {
  width: 8px; height: 8px; transform: rotate(45deg);
  background: #2a2c58; box-shadow: 0 0 0 1px #10072a;
}
.tree-card-pips .pip.on { background: color-mix(in srgb, var(--accent) 70%, white); box-shadow: 0 0 0 1px #10072a, 0 0 6px var(--accent); }
.tree-card-bar { flex: 1; height: 6px; background: #12143a; border: 1px solid rgba(255, 217, 138, .3); border-radius: 2px; overflow: hidden; }
.tree-card-bar .fill { height: 100%; background: var(--accent); box-shadow: 0 0 6px var(--accent); }

.tree-card-desc { margin: 8px 0 6px; color: var(--lavender); font-size: 13px; line-height: 1.6; }
.tree-card-sec { margin-top: 8px; font-family: var(--font-dot); font-size: 11px; color: var(--muted); letter-spacing: .1em; }
.tree-card-sec::before { content: '✦ '; color: var(--accent); }
.tree-card-effects { list-style: none; margin: 3px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.tree-eff {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 4px 8px; border-radius: 6px;
  background: rgba(255, 255, 255, .045); border-left: 3px solid var(--accent);
}
.tree-eff-label { color: var(--text); }
.tree-eff-val { display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap; margin-left: auto; }
.tree-eff-cur { color: var(--muted); }
.tree-eff-arrow { color: var(--accent); font-size: 12px; }
.tree-eff-next { color: var(--good); text-shadow: 0 0 8px rgba(158, 240, 200, .35); font-size: 15px; }
.tree-eff.unlock { align-items: center; justify-content: flex-start; color: var(--honey); border-left-color: var(--honey); }
.tree-eff.unlock img { width: 16px; height: 16px; flex: none; }
.tree-eff.maxed { border-left-color: var(--gold); color: #ffe9a0; }

.tree-card-req {
  display: flex; align-items: center; gap: 6px; margin-top: 8px; padding: 5px 8px;
  font-size: 12px; color: var(--muted); background: rgba(10, 10, 30, .4); border-radius: 6px; border: 1px dashed rgba(183, 162, 255, .3);
}
.tree-card-req img { width: 16px; height: 16px; flex: none; opacity: .8; }

.tree-card-group {
  margin-top: 8px; padding: 6px 8px; border-radius: 6px;
  background: rgba(253, 200, 66, .05); border: 1px solid rgba(253, 200, 66, .22);
}
.tree-card-group.done { background: rgba(253, 200, 66, .12); border-color: rgba(253, 200, 66, .6); box-shadow: 0 0 12px rgba(253, 200, 66, .18) inset; }
.tree-grp-head { display: flex; align-items: center; gap: 6px; }
.tree-grp-head img { width: 18px; height: 18px; flex: none; }
.tree-grp-name { font-family: var(--font-dot); font-size: 13px; color: var(--honey); }
.tree-grp-dots { display: inline-flex; gap: 3px; margin-left: auto; }
.tree-grp-dots .gdot { width: 7px; height: 7px; transform: rotate(45deg); background: #3a3456; box-shadow: 0 0 0 1px #10072a; }
.tree-grp-dots .gdot.on { background: var(--gold); box-shadow: 0 0 0 1px #10072a, 0 0 5px var(--gold); }
.tree-grp-count { font-size: 12px; color: var(--muted); }
.tree-card-group.done .tree-grp-count { color: var(--gold); }
.tree-grp-bonus { margin-top: 2px; font-size: 12px; color: #ffe9a0; }
.tree-grp-desc { margin-top: 2px; font-size: 12px; color: var(--lavender); opacity: .85; }

.tree-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px;
  border-top: 2px solid transparent;
  border-image: linear-gradient(90deg, transparent, rgba(255, 217, 138, .45), transparent) 1;
}
.tree-card-cost { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.tree-cost { display: inline-flex; align-items: center; gap: 4px; font-size: 16px; }
.tree-cost img { width: 18px; height: 18px; }
.tree-cost.lack { text-shadow: 0 0 8px rgba(255, 138, 154, .35); }
.tree-buy { min-width: 128px; min-height: 42px; margin-left: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.tree-buy:disabled { cursor: not-allowed; }
.tree-card-hint { margin-top: 4px; text-align: center; font-size: 11px; color: var(--muted); }
.tree-card-maxed {
  display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 10px; padding: 6px;
  font-family: var(--font-dot); font-size: 13px; color: var(--gold);
  background: rgba(253, 200, 66, .08); border-radius: 6px;
}
.tree-card-maxed img { width: 18px; height: 18px; }

.tree-card[data-status="locked"] .tree-card-icon img { filter: brightness(.55) saturate(.6); }
.tree-card[data-status="maxed"] .tree-card-icon { box-shadow: 0 0 0 2px #10072a, 0 0 0 4px var(--gold), 0 0 0 6px #10072a, 0 0 22px rgba(253, 200, 66, .6); }
.tree-card.moonnode .tree-card-icon { background: radial-gradient(circle at 40% 35%, #2b4a7e, #0e1838 70%); }

/* 購入の気持ちよさ */
.tree-card.tree-pop .tree-card-icon { animation: treeIconPop .45s cubic-bezier(.2, 1.6, .4, 1); }
.tree-card.tree-pop .tree-card-lv { animation: treeLvPop .5s ease-out; }
@keyframes treeIconPop { 0% { transform: scale(1); } 35% { transform: scale(1.18); filter: brightness(1.6); } 100% { transform: scale(1); } }
.tree-card.keystone.tree-pop .tree-card-icon { animation: none; }
@keyframes treeLvPop { 0% { transform: scale(1); } 30% { transform: scale(1.35); color: #fff; } 100% { transform: scale(1); } }
.tree-card.tree-shake { animation: treeShake .32s ease-out; }
@keyframes treeShake {
  0%, 100% { translate: 0 0; } 20% { translate: -5px 0; } 40% { translate: 4px 0; } 60% { translate: -3px 0; } 80% { translate: 2px 0; }
}

/* ------------------------------------------------------------------ スマホ縦 */
@media (max-width: 600px), (orientation: portrait) and (max-width: 820px) {
  .tree-toolbar {
    left: 0; right: 0; bottom: 0; transform: none; max-width: none;
    gap: 4px; justify-content: space-between;
    padding: 6px calc(var(--safe-right) + 6px) calc(var(--safe-bottom) + 6px) calc(var(--safe-left) + 6px);
    border-radius: 14px 14px 0 0; border-bottom: 0;
  }
  .tree-tb-title { display: none; }
  .tree-tb-mid { flex: 1 1 auto; gap: 4px; }
  .tree-tb-btn { flex: 1 1 0; flex-direction: column; gap: 0; padding: 4px 2px; min-height: 52px; min-width: 0; }
  .tree-tb-mid .tree-tb-btn { flex: 1 1 0; }
  .tree-tb-close { flex: 0 0 64px; }
  .tree-tb-label { font-size: 11px; }
  .tree-tb-badge { position: absolute; top: 2px; right: 6px; }
  .tree-hint { bottom: calc(var(--safe-bottom) + 76px); font-size: 11px; white-space: normal; text-align: center; width: max-content; max-width: calc(100vw - 32px); }

  .tree-card.sheet {
    left: 8px; right: 8px; top: auto; width: auto; max-width: none;
    transform: none !important;
    animation: treeSheetIn .22s ease-out;
  }
  .tree-card-name { font-size: 17px; }
  .tree-buy { flex: 1 1 auto; }
}
@keyframes treeSheetIn { from { translate: 0 20px; opacity: 0; } to { translate: 0 0; opacity: 1; } }

/* 見出し：系統タグとレベルを1行に、名前は全幅 */
.tree-card-tagrow { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tree-card-tagrow .tree-card-lv { font-size: 16px; }
.tree-card-tagrow .tree-card-lv:empty { display: none; }

/* ------------------------------------------------------------------ 小星座の完成・月の環の帯（上） */
.tree-banner {
  position: absolute; left: 50%; top: calc(var(--safe-top) + 118px);
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 300px; max-width: calc(100vw - 24px);
  padding: 10px 34px 12px;
  text-align: center; pointer-events: none !important;
  background:
    radial-gradient(120% 140% at 50% 0%, rgba(253, 200, 66, .22), transparent 60%),
    linear-gradient(180deg, rgba(36, 26, 70, .92), rgba(16, 12, 42, .94));
  border: 2px solid rgba(253, 200, 66, .75);
  border-radius: 14px;
  box-shadow: 0 0 0 2px #10072a, 0 0 28px rgba(253, 200, 66, .35), 0 12px 30px rgba(0, 0, 0, .5);
  opacity: 0;
}
.tree-banner::before, .tree-banner::after {
  content: '✦'; position: absolute; top: 50%; translate: 0 -50%;
  color: var(--gold); font-size: 16px; text-shadow: 0 0 8px rgba(253, 200, 66, .9);
}
.tree-banner::before { left: 12px; }
.tree-banner::after { right: 12px; }
/* left:50% の絶対配置は幅が画面の半分で折り返すので、中身の幅にする（名前が「ほ／か」のように割れないように） */
.tree-banner { width: max-content; }
.tree-banner.show { animation: treeBanner 3.4s cubic-bezier(.2, .9, .25, 1) both; }
@keyframes treeBanner {
  0% { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(.92); }
  10% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.03); }
  16% { transform: translateX(-50%) scale(1); }
  86% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-6px); }
}
.tree-banner-sub { display: flex; align-items: center; gap: 6px; font-family: var(--font-dot); font-size: 12px; letter-spacing: .12em; color: #ffe9a0; }
.tree-banner-sub img { width: 32px; height: 32px; margin: -6px 0; }
.tree-banner-name {
  font-family: var(--font-dot); font-size: 26px; line-height: 1.25; color: #fff3c4; letter-spacing: .12em;
  text-shadow: 0 0 14px rgba(253, 200, 66, .85), 0 2px 0 #3a2408;
}
.tree-banner-bonus { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--good); }
.tree-banner-bonus img { width: 16px; height: 16px; }
.tree-banner[data-kind="moon"] { border-color: rgba(169, 214, 255, .8); background: radial-gradient(120% 140% at 50% 0%, rgba(150, 200, 255, .25), transparent 60%), linear-gradient(180deg, rgba(24, 34, 78, .93), rgba(10, 14, 40, .95)); box-shadow: 0 0 0 2px #10072a, 0 0 28px rgba(150, 200, 255, .4), 0 12px 30px rgba(0, 0, 0, .5); }
.tree-banner[data-kind="moon"] .tree-banner-name { color: #e6f2ff; text-shadow: 0 0 14px rgba(150, 200, 255, .9), 0 2px 0 #0a1430; }
.tree-banner[data-kind="moon"]::before, .tree-banner[data-kind="moon"]::after { color: #cfe6ff; text-shadow: 0 0 8px rgba(150, 200, 255, .9); }

/* ズームボタン（右下） */
.tree-zoom {
  position: absolute; right: calc(var(--safe-right) + 14px); bottom: calc(var(--safe-bottom) + 16px);
  display: flex; flex-direction: column; gap: 6px;
}
.tree-zoom-btn { width: 40px; height: 40px; min-height: 0; padding: 0; justify-content: center; font-family: var(--font-dot); font-size: 22px; line-height: 1; }

/* たりない量 */
.tree-card-lack {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; padding: 4px 8px;
  font-size: 12px; color: var(--muted); background: rgba(255, 138, 154, .07); border-radius: 6px;
}
.tree-lack-label { color: #ffb3bf; }
.tree-lack-part { display: inline-flex; align-items: center; gap: 3px; color: #ffd0d8; font-size: 13px; }
.tree-lack-part img { width: 16px; height: 16px; }
.tree-lack-eta { margin-left: auto; color: var(--lavender); }
.tree-buy.holding { filter: brightness(1.12); box-shadow: 0 0 0 2px #3a1d06, 0 0 18px rgba(255, 191, 94, .9); }
.tree-buy-count { margin-left: 8px; font-size: 15px; }

@media (max-width: 600px), (orientation: portrait) and (max-width: 820px) {
  .tree-zoom { display: none; }
  .tree-banner { top: calc(var(--safe-top) + 150px); min-width: 0; width: calc(100vw - 32px); padding: 8px 28px 10px; }
  .tree-banner-name { font-size: 19px; letter-spacing: .06em; }
  .tree-banner-bonus { font-size: 12px; }
}
