:root {
  --primary: #00897b;
  --bg-color: #f4fbf9;
  --text-main: #333;
  --water-color: #4fc3f7;
  --water-border: #0288d1;
  --beaker-border: #90caf9;
  --accent: #ffb300;
  --bunbo-color: #d84315;
  --bunshi-color: #1565c0;
}

body {
  margin: 0; padding: 0;
  font-family: 'Hiragino Maru Gothic ProN', 'Rounded M+ 1c', sans-serif;
  background-color: var(--bg-color); color: var(--text-main);
}

header {
  background-color: var(--primary); color: white;
  text-align: center; padding: 15px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
header h1 { margin: 0; font-size: 1.5rem; }
header p { margin: 5px 0 0 0; font-size: 1rem; }

.tabs { display: flex; justify-content: center; gap: 10px; margin: 20px; flex-wrap: wrap;}
.tab-btn {
  padding: 10px 20px; font-size: 1.1rem; font-weight: bold;
  border: 2px solid #ccc; border-radius: 8px; background-color: #fff; color: #555;
  cursor: pointer; box-shadow: 0 4px 0 #ccc; transition: all 0.1s;
}
.tab-btn:active { transform: translateY(4px); box-shadow: 0 0 0 #ccc; }
.tab-btn.active { background-color: var(--accent); border-color: #f57c00; color: white; box-shadow: 0 4px 0 #f57c00; }

main { max-width: 800px; margin: 0 auto; padding: 0 15px 40px; }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

h2 {
  font-size: 1.3rem; border-left: 5px solid var(--primary);
  padding-left: 10px; margin-top: 30px;
}
.instruction { background: #fff; padding: 15px; border-radius: 8px; border: 1px solid #ddd; margin-bottom: 20px;}
.instruction p { margin: 0; line-height: 1.5; font-size: 1.1rem;}

.control-panel {
  background: white; padding: 20px; border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05); margin-bottom: 20px; border: 2px solid #e0e0e0;
}
.slider-group { margin-bottom: 15px; font-size: 1.2rem; }
.slider-group:last-child { margin-bottom: 0; }
input[type="range"] { width: 100%; height: 20px; margin-top: 10px; cursor: pointer;}

/* ビーカーのスタイル */
.simulator-area, .terms-area {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 30px;
  background: white; padding: 30px 20px; border-radius: 10px;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.05); margin-bottom: 20px; border: 2px solid #e0e0e0;
}
.beaker-wrapper { position: relative; width: 140px; margin: 20px; }
.beaker-wrapper.small-beaker { width: 100px; }
.beaker {
  width: 100%; height: 180px;
  border: 4px solid var(--beaker-border); border-top: none;
  border-radius: 0 0 10px 10px; position: relative; background: #fafafa;
}
.beaker-label { position: absolute; left: -40px; font-weight: bold; font-size: 1.1rem;}
.beaker-label.top { top: -10px; border-bottom: 1px dashed #555; padding-bottom: 2px; width: 30px; text-align: right;}
.beaker-label.bottom { bottom: -5px; width: 30px; text-align: right;}

.water {
  position: absolute; bottom: 0; left: 0; width: 100%;
  background-color: var(--water-color); border-top: 2px solid var(--water-border);
  border-radius: 0 0 6px 6px; transition: height 0.3s ease-in-out;
}
.marks {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; flex-direction: column;
}
.mark-segment { flex: 1; border-bottom: 1px dashed #777; box-sizing: border-box; }
.mark-segment:last-child { border-bottom: none; }

/* 質問エリア・分数入力 */
.question-area { flex: 1; min-width: 250px; font-size: 1.2rem; }
.question-area p { margin: 0 0 10px 0; font-weight: bold;}
.fraction-input { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; gap: 4px;}
.fraction-input.small .num-input { width: 45px; height: 35px; font-size: 1.3rem;}
.fraction-line { width: 100%; height: 2px; background-color: var(--text-main); }
.num-input { width: 50px; height: 45px; font-size: 1.5rem; text-align: center; border: 2px solid #ccc; border-radius: 5px;}
.small-input { width: 40px; height: 35px; font-size: 1.2rem; }

/* 用語エリア（分母と分子） */
.fraction-terms { display: flex; flex-direction: column; align-items: center; gap: 10px;}
.term-box { text-align: center; background: #fff; padding: 10px 15px; border-radius: 8px; border: 2px solid #ccc; width: 220px;}
.term-box.bunshi { border-color: var(--bunshi-color); }
.term-box.bunbo { border-color: var(--bunbo-color); }
.term-name { font-size: 1.4rem; font-weight: bold; }
.term-box p { margin: 5px 0 0 0; font-size: 0.95rem;}
.arrow { font-size: 1.5rem; font-weight: bold; }
.arrow.down { color: var(--bunshi-color); margin-top: 5px;}
.arrow.up { color: var(--bunbo-color); margin-bottom: 5px;}

.fraction-display { display: inline-flex; flex-direction: column; align-items: center; font-size: 3rem; font-weight: bold; line-height: 1.1; margin: 10px 0;}
.fraction-display .fraction-line { height: 4px; background-color: #333; margin: 5px 0;}
.text-bunshi { color: var(--bunshi-color); }
.text-bunbo { color: var(--bunbo-color); }

/* クイズセクション */
.quiz-section { background: white; padding: 20px; border-radius: 10px; margin-bottom: 20px; border: 2px solid #e0e0e0;}
.quiz-section h3 { margin-top: 0; font-size: 1.2rem; line-height: 1.5; border-bottom: 2px dotted #ccc; padding-bottom: 10px;}
.q-item { display: flex; align-items: center; gap: 20px; margin-bottom: 25px; justify-content: center; flex-wrap: wrap;}
.q-target { width: 80px; text-align: center; }
.q-inputs { font-size: 1.2rem; font-weight: bold; display: flex; gap: 15px; align-items: center;}
.inline-frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; font-size: 1em; line-height: 1; font-weight: bold;}
.inline-frac .top { border-bottom: 2px solid currentColor; padding: 0 2px; }
.inline-frac .bottom { padding: 0 2px; }
.inline-frac.large { font-size: 2rem; }

/* ボタン類 */
.action-btn {
  padding: 10px 25px; font-size: 1.2rem; font-weight: bold; background-color: #29b6f6; color: white;
  border: none; border-radius: 8px; cursor: pointer; box-shadow: 0 4px 0 #0288d1;
}
.action-btn:active { transform: translateY(4px); box-shadow: 0 0 0 #0288d1; }
.result-message { font-size: 1.2rem; font-weight: bold; margin-top: 10px; min-height: 24px; text-align: right;}
.correct { color: #e91e63; }
.wrong { color: #1976d2; }

/* キャラクターふきだし */
.character-box {
  display: flex; align-items: flex-start; gap: 15px;
  background: white; padding: 15px; border-radius: 15px; border: 2px solid #a5d6a7;
  position: relative; margin-top: 20px;
}
.char-icon { width: 60px; height: 60px; }
.char-text { flex: 1; }
.char-text p { margin: 0; font-size: 1.1rem; line-height: 1.6; }