/* 10万匹ディフェンス — 夜の戦場（色はCSS変数のみ） */
:root { --accent: #b45309; --accent-ink: #ffffff; --accent-soft: #fdebd3; --field: #15170f; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --accent: #ffb02e; --accent-ink: #1d1206; --accent-soft: #3a2a12; }
}
:root[data-theme="dark"] { --accent: #ffb02e; --accent-ink: #1d1206; --accent-soft: #3a2a12; }

.hd-hero .mn-title { font-size: clamp(32px, 10vw, 46px); }
.hd-accent { color: var(--accent); font-size: 1.25em; }
.hd-daily-btn { flex-direction: column; gap: 0; min-height: 62px; }
.hd-daily-btn small { font-weight: 500; color: var(--text-sub); font-size: 13px; }
.hd-life { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.hd-life small { display: block; font-size: 12px; }
.hd-life b { font-size: 16px; }

/* 戦線 */
.hd-stages { display: grid; gap: 8px; }
.hd-stage { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; }
.hd-stage.is-next { border-color: var(--accent); }
.hd-stage.is-locked { opacity: .55; cursor: default; }
.hd-stage-no { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--field); color: #f4efe0; font-weight: 900; font-size: 18px; }
.hd-stage-main { flex: 1; min-width: 0; }
.hd-stage-main b, .hd-stage-main small { display: block; }
.hd-stage-main small { color: var(--text-sub); font-size: 13px; }
.hd-stars { color: var(--accent); letter-spacing: .05em; flex: none; }
.hd-gold-btn { justify-content: space-between; }
.hd-gold-btn span { color: var(--accent); }

/* 研究 */
.hd-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.hd-tab { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-weight: 700; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.hd-tab.is-on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.hd-tab i { font-style: normal; font-size: 11px; background: var(--bad); color: #fff; border-radius: 99px; min-width: 18px; padding: 0 5px; text-align: center; }
.hd-ups { display: grid; gap: 8px; }
.hd-up { display: flex; gap: 10px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.hd-up b, .hd-up small { display: block; }
.hd-up small { color: var(--text-sub); font-size: 13px; }
.hd-up.is-locked { opacity: .55; }
.hd-lv { font-size: 12px; color: var(--accent); font-weight: 700; }
.hd-up .mn-btn { min-width: 96px; flex: none; }
.hd-gold { color: var(--accent); font-size: 20px; }

/* 配置・戦闘 */
.hd-prep, .hd-battle { display: flex; flex-direction: column; gap: 8px; }
.hd-bar { display: flex; gap: 8px; align-items: center; }
.hd-bar b, .hd-bar small { display: block; line-height: 1.35; }
.hd-bar small { color: var(--text-sub); font-size: 12px; }
.hd-bar .mn-btn { min-height: 40px; padding: 6px 12px; }
.hd-cv-wrap { display: flex; justify-content: center; }
.hd-cv { display: block; border-radius: 10px; background: var(--field); touch-action: none; box-shadow: 0 0 0 1px var(--line), var(--shadow); cursor: crosshair; -webkit-user-select: none; user-select: none; }
.hd-hint { font-size: 12px; color: var(--text-sub); margin: 0; line-height: 1.5; min-height: 3em; }
.hd-pal { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
.hd-prep .hd-bar { min-height: 44px; }
.hd-pal-btn { position: relative; text-align: left; border: 2px solid var(--line); background: var(--surface); border-radius: 10px; padding: 4px 6px 4px 26px; cursor: pointer; line-height: 1.3; }
.hd-pal-btn i { position: absolute; left: 8px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 3px; background: var(--tc); box-shadow: 0 0 0 2px #0d0e0a; }
.hd-pal-btn b { display: block; font-size: 13px; }
.hd-pal-btn small { color: var(--text-sub); font-size: 12px; }
.hd-pal-btn.is-on { border-color: var(--accent); background: var(--accent-soft); }
.hd-actions { display: grid; grid-template-columns: 1fr .7fr 1.4fr; gap: 6px; }
.hd-actions .mn-btn { padding: 8px 6px; min-height: 52px; }
.hd-actions .hd-go { font-size: 18px; }
.hd-actions .is-on { border-color: var(--bad); color: var(--bad); }

.hd-hud { display: flex; gap: 8px; align-items: center; }
.hd-kill { flex: 1.1; min-width: 0; white-space: nowrap; }
.hd-kill b { font-size: 22px; color: var(--accent); font-variant-numeric: tabular-nums; }
.hd-kill small { font-size: 12px; color: var(--text-sub); }
.hd-kill small:first-child { margin-right: 4px; }
.hd-gate { flex: 1; min-width: 0; display: grid; grid-template-columns: auto 1fr; gap: 0 6px; align-items: center; }
.hd-gate small { font-size: 12px; color: var(--text-sub); }
.hd-gate small:last-child { grid-column: 2; text-align: right; line-height: 1.2; }
.hd-gate .mn-progress > i { background: var(--good); }
.hd-spd, .hd-pause { min-height: 40px; min-width: 44px; padding: 4px 8px; flex: none; }
.hd-abil { display: grid; grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)); gap: 6px; }
.hd-ab { position: relative; overflow: hidden; border: 2px solid var(--line); background: var(--surface); border-radius: 10px; min-height: 52px; padding: 4px 4px; cursor: pointer; line-height: 1.2; --cd: 0; }
.hd-ab::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--cd) * 100%); background: rgba(0, 0, 0, .18); pointer-events: none; }
.hd-ab b { display: block; font-size: 12px; position: relative; }
.hd-ab i { display: block; font-style: normal; font-size: 11px; color: var(--text-sub); position: relative; }
.hd-ab.is-on { border-color: var(--accent); background: var(--accent-soft); }
.hd-ab.is-wait b { opacity: .6; }

/* 結果 */
.hd-res-title { font-size: clamp(30px, 9vw, 40px); font-weight: 900; margin: 0; color: var(--bad); }
.hd-res-title.is-win { color: var(--accent); }
.hd-gain { margin: 10px 0 0; font-weight: 900; font-size: 20px; color: var(--accent); }
.hd-gain small { display: block; font-size: 12px; font-weight: 500; color: var(--text-sub); }
.hd-res-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.hd-badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 6px; }
.hd-share { background: #000; color: #fff; border-color: #000; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hd-share { background: #fff; color: #000; border-color: #fff; } }

/* オープニング */
.hd-op { position: relative; margin: -16px -16px 4px; overflow: hidden; background: var(--field); aspect-ratio: 16 / 10; }
.hd-op-media { display: block; width: 100% !important; height: 100% !important; object-fit: cover; }
.hd-op-shade { position: absolute; inset: auto 0 0 0; height: 30%; background: linear-gradient(to bottom, transparent, rgba(0,0,0,.45)); pointer-events: none; }
@media (min-width: 600px) { .hd-op { margin: 0 0 4px; border-radius: 14px; } }

/* 配置パネル */
.hd-panel { min-height: 50px; display: flex; align-items: center; }
.hd-panel .hd-hint { margin: 0; }
.hd-panel-row { display: flex; gap: 6px; align-items: center; width: 100%; padding: 6px 8px; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 12px; }
.hd-panel-row b, .hd-panel-row small { display: block; line-height: 1.3; }
.hd-panel-row small { font-size: 12px; color: var(--text-sub); }
.hd-panel-row .mn-btn { min-height: 40px; padding: 4px 10px; flex: none; }
.hd-rot { font-size: 20px; min-width: 44px; }
.hd-rm { color: var(--bad); }
.hd-pal-btn img { position: absolute; left: 4px; top: 50%; width: 24px; height: 24px; margin-top: -12px; }
.hd-pal-btn { padding-left: 32px; }
.hd-spd { min-width: 72px; font-size: 13px; }

/* 全画面 */
.hd-fs-btn { min-height: 40px; min-width: 44px; padding: 4px 8px; flex: none; }
body.hd-fs { background: #0b0d0a; color-scheme: dark; }
body.hd-fs .mn-header, body.hd-fs .mn-footer, body.hd-fs #about { display: none; }
body.hd-fs .mn-app { max-width: none; padding: 6px 8px 8px; }
body.hd-fs .hd-bar b, body.hd-fs .hd-kill small, body.hd-fs .hd-gate small, body.hd-fs .hd-hint, body.hd-fs .hd-bar small { color: #e9e4d4; }
body.hd-fs .hd-cv { box-shadow: none; }
body.hd-fs .hd-pal, body.hd-fs .hd-actions, body.hd-fs .hd-abil, body.hd-fs .hd-panel { max-width: 720px; width: 100%; margin-left: auto; margin-right: auto; }

/* 研究の盤（スフィア） */
.hd-tree .hd-bar { align-items: center; }
.hd-gold-box { text-align: right; line-height: 1.2; }
.hd-gold-box small { display: block; font-size: 11px; color: var(--text-sub); }
.hd-sg { position: relative; height: min(46vh, 560px); min-height: 300px; border-radius: 16px; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
  background: radial-gradient(ellipse at 50% 40%, #1b2140 0%, #0c0f1f 55%, #05060c 100%); box-shadow: inset 0 0 60px rgba(0,0,0,.6), 0 0 0 1px rgba(140,160,255,.15); }
body.hd-fs .hd-sg { height: calc(100vh - 290px); }
.hd-sg-svg { display: block; width: 100%; height: 100%; }
.hd-sg-link { stroke: rgba(120,140,190,.28); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 2 9; }
.hd-sg-link.is-web { stroke-width: 3; stroke: rgba(120,140,190,.16); }
.hd-sg-link.is-lit { stroke-dasharray: none; stroke-width: 6; filter: url(#hdGlow); opacity: .9; }
.hd-sg-node { cursor: pointer; transition: opacity .2s; outline: none; }
.hd-sg-node .hd-sg-halo { fill: transparent; stroke: transparent; stroke-width: 3; }
.hd-sg-node .hd-sg-ring-bg { fill: none; stroke: rgba(255,255,255,.12); stroke-width: 5; }
.hd-sg-node .hd-sg-ring { fill: none; stroke-width: 5; stroke-linecap: round; }
.hd-sg-node .hd-sg-lv { fill: #dfe6ff; font-size: 15px; font-weight: 800; paint-order: stroke; stroke: rgba(0,0,0,.7); stroke-width: 4px; }
.hd-sg-node .hd-sg-lock { font-size: 24px; display: none; }
.hd-sg-node.is-lock > :not(.hd-sg-lock):not(.hd-sg-halo) { filter: url(#hdGray); opacity: .35; }
.hd-sg-node.is-lock .hd-sg-lock { display: block; }
.hd-sg-node:not(.is-own):not(.is-lock) image { opacity: .55; }
.hd-sg-node.is-can .hd-sg-halo { stroke: rgba(255,226,140,.9); filter: url(#hdGlow); animation: hdPulse 1.6s ease-in-out infinite; }
.hd-sg-node.is-done .hd-sg-ring { stroke: #ffd36a !important; filter: url(#hdGlow); }
.hd-sg-node.is-sel .hd-sg-halo { stroke: #ffffff; stroke-width: 4; filter: url(#hdGlow); animation: hdPulse 1s ease-in-out infinite; }
@keyframes hdPulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.hd-sg-burst { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; pointer-events: none; opacity: 0; --c: #ffd27a; }
.hd-sg-burst.go { animation: hdBurst .7s ease-out; }
@keyframes hdBurst { 0% { opacity: 1; box-shadow: 0 0 0 0 var(--c), 0 0 30px 10px var(--c); } 100% { opacity: 0; box-shadow: 0 0 0 120px transparent, 0 0 80px 40px transparent; } }
.hd-sg-panel { min-height: 170px; }
.hd-sg-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px 8px; border-radius: 16px; background: linear-gradient(160deg, #161b33, #0d1020); color: #e9ecff; border: 1px solid rgba(140,160,255,.25); }
.hd-sg-card h3 { margin: 0 0 2px; font-size: 20px; color: #fff; }
.hd-sg-icon { width: 72px; height: 72px; border-radius: 50%; object-fit: contain; padding: 4px; background: #0b0d14; border: 3px solid #ffd27a; flex: none; box-shadow: 0 0 18px rgba(255,220,140,.25); }
.hd-sg-cat { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.hd-sg-lvrow { display: flex; gap: 8px; align-items: center; font-size: 13px; color: #b9c2ea; flex-wrap: wrap; }
.hd-sg-pips { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.hd-sg-pips i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.15); display: block; }
.hd-sg-desc { margin: 6px 0 4px; font-size: 14px; color: #d3d9f5; line-height: 1.6; }
.hd-sg-eff { margin: 0 0 8px; font-size: 14px; color: #b9c2ea; }
.hd-sg-eff b { color: #ffe08a; }
.hd-sg-buy { width: 100%; }
.hd-sg-nav { flex: none; align-self: center; width: 36px; height: 56px; border-radius: 10px; border: 1px solid rgba(140,160,255,.3); background: rgba(255,255,255,.05); color: #dfe6ff; font-size: 16px; cursor: pointer; }
.hd-sg-nav:hover { background: rgba(255,255,255,.12); }
@media (prefers-reduced-motion: reduce) { .hd-sg-node .hd-sg-halo { animation: none !important; } }

@media (max-width: 600px) {
  .hd-sg-icon { width: 54px; height: 54px; }
  .hd-sg-card { gap: 6px; padding: 10px 6px; }
  .hd-sg-card h3 { font-size: 18px; }
  .hd-sg-nav { width: 30px; height: 48px; }
  .hd-sg-desc { font-size: 13px; margin: 4px 0 2px; }
}
@media (max-width: 430px) {
  .hd-hud { gap: 6px; }
  .hd-kill b { font-size: 19px; }
  .hd-kill small:first-child { display: none; }
  .hd-gate > small:first-child { display: none; }
  .hd-gate { grid-template-columns: 1fr; }
  .hd-gate small:last-child { grid-column: 1; }
  .hd-spd { min-width: 60px; }
}

.hd-sg.is-drag { cursor: grabbing; }
.hd-sg-svg image { pointer-events: none; -webkit-user-drag: none; }

/* 研究の盤 v2 */
.hd-sg-link.is-open { stroke: rgba(200,215,255,.45); stroke-dasharray: none; stroke-width: 4; }
.hd-sg-link.is-tease { stroke: rgba(150,170,230,.28); stroke-dasharray: 3 8; stroke-width: 3; }
.hd-sg-link.is-all.is-tease, .hd-sg-link.is-all.is-open { stroke-dasharray: 10 4 2 4; }
.hd-sg-node image.is-dim { opacity: .7; }
.hd-sg-node.is-open .hd-sg-halo { stroke: rgba(200,215,255,.35); }
.hd-sg-node.is-can .hd-sg-halo { stroke: rgba(255,226,140,.95); filter: url(#hdGlow); animation: hdPulse 1.6s ease-in-out infinite; }
.hd-sg-node.is-own:not(.is-can) .hd-sg-halo { stroke: transparent; }
.hd-sg-node.is-sel .hd-sg-halo { stroke: #fff; stroke-width: 4; filter: url(#hdGlow); animation: hdPulse 1s ease-in-out infinite; }
.hd-sg-q { fill: rgba(200,215,255,.6); font-size: 26px; font-weight: 900; }
.hd-sg-cost { fill: #ffe08a; font-size: 14px; font-weight: 800; paint-order: stroke; stroke: rgba(0,0,0,.75); stroke-width: 4px; }
.hd-sg-check { fill: #2fbf71; stroke: #0b0d14; stroke-width: 2; }
.hd-sg-zoom { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.hd-sg-zoom button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid rgba(160,180,255,.35); background: rgba(12,15,31,.75); color: #e9ecff; font-size: 18px; font-weight: 800; cursor: pointer; }
.hd-sg-iconbox { position: relative; flex: none; }
.hd-sg-iconbadge { position: absolute; right: -4px; bottom: -4px; width: 32px; height: 32px; border-radius: 50%; background: #0b0d14; border: 2px solid; display: grid; place-items: center; }
.hd-sg-icon.is-q { display: grid; place-items: center; font-size: 30px; font-weight: 900; color: rgba(200,215,255,.6); background: #141827; border-style: dashed; }
.hd-sg-burst { margin: 0; transform: translate(-50%, -50%); }
/* 研究 v3：レベルの輪・必要レベル札 */
.hd-sg-ring-bg { fill: none; stroke: rgba(255,255,255,.12); stroke-width: 4; }
.hd-sg-ring { fill: none; stroke-width: 4; stroke-linecap: butt; }
.hd-sg-tick { stroke: #0b0d14; stroke-width: 2; }
.hd-sg-cost.is-max { fill: #ffd36a; }
.hd-sg-cost.is-can { fill: #8dffb0; }
.hd-sg-req rect { fill: #0b0d14; stroke: rgba(160,180,255,.45); stroke-width: 1.2; }
.hd-sg-req text { fill: #c9d2ff; font-size: 11px; font-weight: 800; }
.hd-sg-req.is-ok rect { stroke: #2fbf71; } .hd-sg-req.is-ok text { fill: #8dffb0; }
.hd-sg-node.is-max .hd-sg-ring { filter: drop-shadow(0 0 4px rgba(255,211,106,.8)); }
.hd-sg-lvrow { display: flex; align-items: center; gap: 8px; margin: 2px 0 6px; font-weight: 800; font-size: 13px; color: #e8ecff; }
.hd-sg-pips { display: inline-flex; gap: 3px; }
.hd-sg-pips i { width: 14px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.18); display: inline-block; }
/* 状態の色分け：緑＝強化できる／灰＝金貨不足／金＝完了 */
.hd-sg-node.is-can .hd-sg-halo { stroke: #3ddc84; stroke-width: 5; filter: url(#hdGlow); animation: hdPulse 1.3s ease-in-out infinite; }
.hd-sg-node.is-max .hd-sg-halo { stroke: #ffd36a; stroke-width: 4; filter: url(#hdGlow); animation: none; opacity: .9; }
.hd-sg-node.is-sel .hd-sg-halo { stroke: #fff; stroke-width: 4; }
.hd-sg-node.is-max .hd-sg-ring, .hd-sg-node.is-max .hd-sg-ring-bg { stroke: #ffd36a !important; }
.hd-sg-cost.is-can { fill: #5dff9e; }
.hd-sg-cost.is-max { fill: #ffd36a; }
.hd-sg-node.is-poor .hd-sg-cost { fill: #9aa3c7; }
.hd-sg-st circle { stroke: #0b0d14; stroke-width: 2.5; }
.hd-sg-st text { font-size: 13px; font-weight: 900; fill: #0b0d14; }
.hd-sg-st.is-can circle { fill: #3ddc84; } .hd-sg-st.is-max circle { fill: #ffd36a; }
.hd-sg-legend { position: absolute; left: 8px; bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px 9px; max-width: calc(100% - 16px); padding: 4px 8px; border-radius: 10px; background: rgba(12,15,31,.78); color: #dfe6ff; font-size: 11px; font-weight: 700; pointer-events: none; z-index: 2; }
.hd-sg-legend span { display: inline-flex; align-items: center; gap: 4px; }
.hd-sg-legend i { width: 15px; height: 15px; border-radius: 50%; display: inline-grid; place-items: center; font-style: normal; font-size: 9px; font-weight: 900; color: #0b0d14; }
.hd-sg-legend .is-can i { background: #3ddc84; box-shadow: 0 0 6px #3ddc84; }
.hd-sg-legend .is-poor i { background: #9aa3c7; }
.hd-sg-legend .is-max i { background: #ffd36a; }
.hd-sg-legend .is-q i { background: #141827; border: 1px dashed rgba(200,215,255,.6); color: rgba(200,215,255,.8); }
