/* ==========================================================================
   MuscleTree - Main Stylesheet (Web Root)
   ========================================================================== */

:root {
  --bg-dark: #0b0f19;
  --bg-card: #161e2e;
  --bg-card-hover: #1f293d;
  --primary: #10b981;
  --primary-glow: rgba(16, 185, 129, 0.4);
  --secondary: #3b82f6;
  --accent-gold: #f59e0b;
  --text-main: #f3f4f6;
  --text-sub: #9ca3af;
  --node-active-bg: linear-gradient(135deg, #059669, #10b981);
  --node-rest-bg: #1e293b;
  --node-locked-bg: #111827;
  --border-radius-lg: 20px;
  --border-radius-md: 12px;
  --font-heading: 'Outfit', 'Noto Sans JP', sans-serif;
  --font-body: 'Noto Sans JP', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 背景キャンバス & オーバーレイ */
#particleCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.glow-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.2), transparent 70%);
  opacity: 0;
  transition: opacity 0.5s ease;
}
.glow-overlay.active { opacity: 1; }

.rest-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  background: rgba(11, 15, 25, 0.7);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.5s ease;
}
.rest-overlay.active { opacity: 1; }

/* アプリコンテナ */
.app-container {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  max-height: 900px;
  background: linear-gradient(180deg, #0d1322 0%, #070a12 100%);
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  z-index: 10;
}

@media (min-width: 481px) {
  .app-container {
    height: 94vh;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
}

/* ==========================================================================
   Header & Category Tabs
   ========================================================================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(22, 30, 46, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.coach-avatar-mini {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle, #3b82f6, #1e40af);
  border: 2px solid var(--primary);
  overflow: hidden;
  box-shadow: 0 0 10px var(--primary-glow);
}
.coach-avatar-mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-stats {
  display: flex;
  gap: 6px;
}

.stat-badge, .streak-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 8px;
  border-radius: 16px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
}
.stat-icon { font-size: 0.8rem; }
.stat-value { color: #fff; }
.stat-unit { font-size: 0.7rem; color: var(--text-sub); }

/* デモツールバー & 横並びボタン群 */
.demo-toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
}

/* プロ相談ヘッダーボタン */
.pro-consult-btn {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: 1.5px solid #34d399;
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 0.72rem;
  font-weight: 800;
  font-family: var(--font-heading);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 0 10px var(--primary-glow);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  z-index: 10;
}

.pro-consult-btn.hidden {
  display: none !important;
}

/* キラーンと斜めの光沢線が駆け抜ける疑似要素 */
.pro-consult-btn::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -75%;
  width: 50%;
  height: 200%;
  background: linear-gradient(
    60deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.95) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: rotate(25deg);
  opacity: 0;
  pointer-events: none;
  z-index: 12;
}

/* 未タップ時 (.unread-pulse または .flash-glow)：カチカチ揺れ ＋ キラーン光沢を適用 */
.pro-consult-btn.unread-pulse,
.pro-consult-btn.flash-glow {
  animation: buttonShake 1.2s infinite ease-in-out !important;
  border-color: var(--accent-gold) !important;
  box-shadow: 0 0 15px rgba(52, 211, 153, 0.8), 0 0 25px rgba(245, 158, 11, 0.7) !important;
}

.pro-consult-btn.unread-pulse::after,
.pro-consult-btn.flash-glow::after {
  opacity: 1;
  animation: shineSweep 1.6s infinite cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* タップ後（通常状態）：静かな表示 */
.pro-consult-btn:not(.unread-pulse):not(.flash-glow) {
  animation: none !important;
  border-color: rgba(52, 211, 153, 0.4);
  box-shadow: none;
  opacity: 0.85;
}
.pro-consult-btn:not(.unread-pulse):not(.flash-glow)::after {
  opacity: 0;
  animation: none !important;
}

/* キラーンと光が通り抜けるキーフレーム */
@keyframes shineSweep {
  0% { left: -75%; }
  40%, 100% { left: 140%; }
}

/* カチカチと動くボタンのキーフレーム */
@keyframes buttonShake {
  0%, 100% { transform: scale(1) rotate(0deg); }
  10% { transform: scale(1.08) rotate(-4deg); }
  20% { transform: scale(1.08) rotate(4deg); }
  30% { transform: scale(1.08) rotate(-4deg); }
  40% { transform: scale(1.08) rotate(4deg); }
  50% { transform: scale(1.05) rotate(-2deg); }
  60% { transform: scale(1.05) rotate(2deg); }
  70% { transform: scale(1) rotate(0deg); }
}

.demo-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border: none;
  padding: 4px 8px;
  border-radius: 16px;
  font-size: 0.72rem;
  font-weight: 800;
  font-family: var(--font-heading);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  box-shadow: 0 3px 10px rgba(245, 158, 11, 0.3);
  transition: transform 0.2s ease;
  white-space: nowrap;
}
.demo-btn:active { transform: scale(0.95); }

.demo-btn-reset {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  padding: 4px 8px;
  border-radius: 16px;
  font-size: 0.72rem;
  font-weight: 800;
  font-family: var(--font-heading);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.demo-btn-reset:hover {
  background: rgba(239, 68, 68, 0.35);
  color: #fff;
}
.demo-btn-reset:active { transform: scale(0.95); }

.modal-primary-btn.danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* 4部位切替タブバー */
.category-nav {
  display: flex;
  background: rgba(15, 23, 42, 0.9);
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  gap: 6px;
  z-index: 20;
}

.tab-btn {
  flex: 1;
  padding: 8px 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  color: var(--text-sub);
  font-size: 0.8rem;
  font-weight: 800;
  font-family: var(--font-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.25s ease;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(5, 150, 105, 0.4));
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 12px var(--primary-glow);
}

/* ==========================================================================
   Branching Skill Tree Main Area
   ========================================================================== */
.tree-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 12px 140px; /* 下部ボタンに被らないよう十分な余白を設定 */
  position: relative;
  scroll-behavior: smooth;
}

.tree-nodes-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column-reverse; /* スタートノードを下、上位ノードを上に配置 */
  gap: 44px;
  align-items: center;
}

.tree-svg-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.tree-connector-path {
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 4;
  fill: none;
  stroke-dasharray: 6 4;
  transition: stroke 0.4s ease, stroke-width 0.4s ease, filter 0.4s ease;
}

.tree-connector-path.active {
  stroke: #10b981;
  stroke-width: 5;
  stroke-dasharray: none;
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.8));
}

.tree-level-row {
  display: flex;
  justify-content: space-around;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 5;
}

/* スキルノードカード */
.tree-node {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 3px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.5);
}

.tree-node.selected {
  transform: scale(1.12);
  border-color: #fff !important;
  box-shadow: 0 0 25px rgba(255, 255, 255, 0.7) !important;
}

.tree-node.status-active {
  background: var(--node-active-bg);
  border-color: #34d399;
  box-shadow: 0 0 18px var(--primary-glow);
}

.tree-node.status-rest {
  background: var(--node-rest-bg);
  border-color: #64748b;
  opacity: 0.85;
}

.tree-node.status-locked {
  background: var(--node-locked-bg);
  border-color: rgba(255, 255, 255, 0.05);
  opacity: 0.45;
  filter: grayscale(1);
}

.tree-node.status-paywall {
  background: linear-gradient(135deg, #78350f, #b45309);
  border-color: var(--accent-gold);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}

.node-icon { font-size: 1.6rem; line-height: 1; margin-bottom: 2px; }
.node-title {
  font-size: 0.6rem;
  font-weight: 800;
  text-align: center;
  color: #fff;
  padding: 0 4px;
  line-height: 1.15;
}

.node-badge {
  position: absolute;
  bottom: -6px;
  background: rgba(0, 0, 0, 0.85);
  color: var(--primary);
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid var(--primary);
  white-space: nowrap;
}

.tree-node.status-rest .node-badge {
  color: #94a3b8;
  border-color: #64748b;
}

.rest-zzz {
  position: absolute;
  top: -8px;
  right: -4px;
  font-size: 0.95rem;
  animation: zzzFloat 2s infinite ease-in-out;
}
@keyframes zzzFloat {
  0% { transform: translate(0, 0) scale(0.8); opacity: 0.5; }
  50% { transform: translate(4px, -6px) scale(1.1); opacity: 1; }
  100% { transform: translate(8px, -12px) scale(0.8); opacity: 0; }
}

/* ==========================================================================
   Footer Section
   ========================================================================== */
.app-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 10px 16px 16px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 25;
}

.selected-node-banner {
  background: rgba(30, 41, 59, 0.9);
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid rgba(16, 185, 129, 0.4);
  align-self: center;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  max-width: 90%;
  transition: all 0.25s ease;
}

.selected-node-banner::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: rgba(30, 41, 59, 0.9) transparent transparent transparent;
}

.banner-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}

.banner-title {
  font-size: 0.78rem;
  font-weight: 800;
  color: #fff;
}

.banner-sub {
  font-size: 0.7rem;
  color: var(--primary);
  font-weight: 700;
}

.action-btn {
  width: 100%;
  height: 52px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  border-radius: var(--border-radius-lg);
  font-size: 1.05rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 8px 20px var(--primary-glow);
  transition: all 0.2s ease;
}
.action-btn:hover:not(:disabled) { transform: translateY(-2px); }
.action-btn:disabled {
  background: #334155;
  color: #64748b;
  box-shadow: none;
  cursor: not-allowed;
}

/* ==========================================================================
   Full Body Coach Screen-wide Overlay (画面全体のダイナミックトレーナー演出)
   ========================================================================== */
.full-coach-slide-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 10, 18, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  z-index: 45;
  pointer-events: auto;
  transition: transform 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.35s ease;
  transform: translateX(0);
  opacity: 1;
}

.full-coach-slide-overlay.hidden {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.slide-coach-body {
  height: 92vh;
  max-height: 800px;
  position: absolute;
  right: -20px;
  bottom: 0;
  filter: drop-shadow(-12px 10px 25px rgba(0, 0, 0, 0.8));
  pointer-events: none;
}

.slide-coach-body img {
  height: 100%;
  width: auto;
  object-fit: contain;
}

.slide-speech-bubble {
  position: absolute;
  top: 20%;
  left: 16px;
  right: 120px;
  background: rgba(22, 30, 46, 0.95);
  border: 2px solid var(--primary);
  border-radius: 24px;
  padding: 18px 20px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  pointer-events: auto;
  animation: bubblePop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.slide-speech-bubble::after {
  content: '';
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 10px 0 10px 14px;
  border-style: solid;
  border-color: transparent transparent transparent var(--primary);
}

.bubble-speaker {
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 6px;
}

.bubble-content {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.4;
}

/* ==========================================================================
   Door Unlock Modal (新スキル解放の扉が開く演出)
   ========================================================================== */
.door-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 8, 15, 0.92);
  backdrop-filter: blur(10px);
  z-index: 60;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1200px;
  transition: opacity 0.4s ease;
}
.door-modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.door-container {
  position: relative;
  width: 320px;
  height: 420px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 観音開きドア */
.door {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border: 3px solid var(--accent-gold);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  transition: transform 1.2s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 10;
}

.door-left {
  left: 0;
  border-radius: 16px 0 0 16px;
  transform-origin: left center;
}
.door-right {
  right: 0;
  border-radius: 0 16px 16px 0;
  transform-origin: right center;
}

.door-panel {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 1px dashed rgba(245, 158, 11, 0.4);
}

.door-knob {
  width: 16px;
  height: 36px;
  background: linear-gradient(180deg, #f59e0b, #b45309);
  border-radius: 8px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.door-left .door-knob { right: 8px; }
.door-right .door-knob { left: 8px; }

.door-emblem {
  font-size: 2.5rem;
  color: var(--accent-gold);
  text-shadow: 0 0 15px rgba(245, 158, 11, 0.6);
}

/* 扉が開いた状態のアニメーションクラス */
.door-container.open .door-left {
  transform: rotateY(-115deg);
}
.door-container.open .door-right {
  transform: rotateY(115deg);
}

/* 扉の奥に浮き出るカード */
.unlocked-skill-reveal {
  position: absolute;
  width: 260px;
  background: var(--bg-card);
  border: 2px solid var(--primary);
  border-radius: var(--border-radius-lg);
  padding: 24px 16px;
  text-align: center;
  box-shadow: 0 0 35px var(--primary-glow);
  opacity: 0;
  transform: scale(0.6);
  transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.3s;
  z-index: 5;
}

.door-container.open .unlocked-skill-reveal {
  opacity: 1;
  transform: scale(1);
}

.reveal-badge {
  font-size: 0.7rem;
  font-weight: 900;
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.15);
  padding: 4px 10px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 12px;
}

.reveal-icon { font-size: 3.2rem; margin-bottom: 8px; }
.reveal-title { font-size: 1.1rem; font-weight: 900; color: #fff; margin-bottom: 6px; }
.reveal-desc { font-size: 0.8rem; color: var(--text-sub); margin-bottom: 18px; }

/* モーダル汎用 */
.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 10, 18, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 50;
  transition: opacity 0.3s ease;
}
.modal-backdrop.hidden { opacity: 0; pointer-events: none; }

.modal-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-lg);
  padding: 24px 20px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}
.modal-card.hidden { display: none; }

.modal-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 12px;
}
.modal-badge.warning { background: rgba(245, 158, 11, 0.15); color: var(--accent-gold); }
.modal-badge.success { background: rgba(59, 130, 246, 0.15); color: var(--secondary); }

.modal-title { font-size: 1.2rem; font-weight: 900; line-height: 1.3; margin-bottom: 8px; color: #fff; }
.modal-desc { font-size: 0.85rem; color: var(--text-sub); margin-bottom: 20px; line-height: 1.4; }

.coach-select-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.coach-select-card {
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-md);
  padding: 10px 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.coach-select-card.selected {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.1);
  box-shadow: 0 0 15px var(--primary-glow);
}

.coach-img-frame {
  width: 60px;
  height: 60px;
  margin: 0 auto 6px;
  border-radius: 50%;
  overflow: hidden;
  background: #111827;
}
.coach-img-frame img { width: 100%; height: 100%; object-fit: cover; }

.coach-card-title { font-size: 0.75rem; font-weight: 800; color: #fff; }
.coach-card-style { font-size: 0.65rem; color: var(--text-sub); }

.modal-action-group { display: flex; flex-direction: column; gap: 10px; }

.modal-primary-btn {
  width: 100%;
  height: 48px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--border-radius-md);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.modal-primary-btn.gold { background: linear-gradient(135deg, #f59e0b, #d97706); }
.modal-primary-btn:disabled { background: #374151; color: #9ca3af; cursor: not-allowed; }

.modal-secondary-btn {
  background: transparent;
  color: var(--text-sub);
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 8px;
}
