/* 滑車シミュレーター スタイルシート */

:root {
  --bg-main: #0f172a;
  --bg-side: rgba(30, 41, 59, 0.85);
  --accent: #fbbf24;
  --accent-blue: #38bdf8;
  --text: #f1f5f9;
  --text-dim: #cbd5e1;
  --text-secondary: #94a3b8;
  --glass: rgba(15, 23, 42, 0.65);
  --border: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(56, 189, 248, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', 'Outfit', 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  background-color: var(--bg-main);
  color: var(--text);
  overflow: hidden;
}

.app-container {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pinch-zoom;
}

.main-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
}

.app-title {
  position: absolute;
  top: 25px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 10px 20px rgba(0,0,0,0.3);
  z-index: 100;
  white-space: nowrap;
  pointer-events: none;
}



/* ポータルに戻るボタン */
#top-nav {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1000;
}

.portal-link-btn-mini {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.portal-link-btn-mini:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  transform: translateY(-2px);
}

/* Canvas */
canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* ヘッダー操作パネル (右側縦並びに変更) */
.header-controls {
  position: absolute;
  top: 45px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 1000;
  width: 350px;
  pointer-events: none;
}

.header-controls > * {
  pointer-events: auto;
}

@media (max-width: 768px) {
  body {
    overflow-y: auto; /* 縦スクロールを許可 */
  }

  .app-container {
    width: 100%;
    height: auto;
    overflow-y: auto;
    touch-action: auto;
  }

  .main-content {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    gap: 15px;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    overflow-y: visible;
  }

  .app-title {
    position: relative;
    top: 0;
    left: 0;
    transform: none;
    order: 1;
    font-size: 1.4rem;
    margin-bottom: 5px;
  }

  #top-nav {
    position: absolute;
    top: 15px;
    left: 15px;
  }

  /* 子要素を直接メインフレックスに配置するためdisplay: contentsにする */
  .header-controls {
    display: contents;
  }

  /* 1. 滑車のタイプ */
  #panel-type {
    order: 2;
    width: 100% !important;
    max-width: 480px;
    position: relative;
    margin-top: 40px; /* ナビやタイトルとの隙間 */
  }

  /* 2. クイズ問題エリア（滑車タイプの下に表示） */
  #quizContent {
    order: 3;
    width: 100% !important;
    max-width: 480px;
    position: relative;
  }

  /* 3. キャンバス (滑車の描画域) */
  canvas#simCanvas {
    position: relative;
    order: 4;
    width: 100% !important;
    height: 540px !important; /* 最も縦に長い「縦連結」滑車のおもりも完全に収まる高さに拡張 */
    max-width: 480px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.4);
    z-index: 1;
    touch-action: pan-y;
  }

  /* 4. おもりと滑車の設定 */
  #panel-config {
    order: 5;
    width: 100% !important;
    max-width: 480px;
    position: relative;
  }

  /* 5. ひもを引く動作 */
  #panel-pull {
    order: 6;
    width: 100% !important;
    max-width: 480px;
    position: relative;
  }


  .floating-panel {
    width: 100% !important;
    max-width: 100%;
  }
}



/* フローティングパネル共通 */
.floating-panel {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 320px;
}

.floating-panel:hover {
  border-color: rgba(255,255,255,0.15);
}

.panel-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.02em;
}

.control-group {
  margin-bottom: 8px;
}

.control-group:last-child {
  margin-bottom: 0;
}

.control-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.control-group label span {
  font-weight: 600;
}

/* スライダー */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-blue);
  cursor: pointer;
  transition: transform 0.1s;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

input[type="range"]#weightSlider::-webkit-slider-thumb {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

/* セレクトボックス */
select {
  width: 100%;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

select:focus {
  border-color: var(--accent-blue);
}

/* チェックボックス・トグル */
.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.checkbox-row input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent-blue);
  width: 16px;
  height: 16px;
}

.checkbox-row span {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.action-btn {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.4);
}

.quiz-content {
  /* パネル自体がクイズ問題エリアになったため、上部の区切り線・余白は不要 */
}

.quiz-question {
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 12px;
  color: var(--text);
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.option-btn {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  padding: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.option-btn:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--accent-blue);
  color: #fff;
}

.quiz-result {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.result-text {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.result-text.correct {
  color: #4ade80;
}

.result-text.incorrect {
  color: #f87171;
}

.result-explanation {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.hidden {
  display: none !important;
}

/* タブ切り替えUI */
.tab-header {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 2px;
  border-radius: 6px;
}

.tab-btn {
  flex: 1;
  padding: 6px 10px;
  font-size: 0.8rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  border: 1px solid var(--border);
}

.tab-content.hidden {
  display: none !important;
}

.tab-header.hidden {
  display: none !important;
}

/* ガイドツールチップ */
.guide-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 36px 10px 18px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: bold;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
  pointer-events: auto;
  max-width: 90vw;
  width: max-content;
  text-align: center;
  line-height: 1.4;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.guide-tooltip.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.tooltip-close-btn {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s ease;
}

.tooltip-close-btn:hover {
  color: #ef4444;
}

.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .guide-tooltip {
    border-radius: 12px;
    font-size: 0.8rem;
  }
  .mobile-only {
    display: inline;
  }
}
