:root {
  --primary: #795548; /* 学習のしあげの茶色 */
  --bg-color: #fcf8f2;
  --text-main: #333;
  --water-color: #4fc3f7;
  --water-border: #0288d1;
  --beaker-border: #90caf9;
  --tape-pink: #f8bbd0;
  --tape-red: #ff8a80;
  --border-color: #555;
  --accent: #ff9800;
}

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; line-height: 1.5;
}
.q-badge {
  display: inline-block; background: #e0e0e0; color: #555; border: 1px solid #999;
  width: 1.5em; height: 1.5em; text-align: center; line-height: 1.5em; border-radius: 3px;
}

/* ================== 問題1：ビーカー ================== */
.simulator-area {
  display: flex; flex-wrap: wrap; justify-content: space-around; align-items: flex-end; gap: 10px;
  background: white; padding: 30px 10px; 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: 120px; display: flex; flex-direction: column; align-items: center;}
.beaker {
  width: 100%; height: 150px;
  border: 4px solid var(--beaker-border); border-top: none;
  border-radius: 0 0 8px 8px; 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-name { position: absolute; left: -40px; top: 50%; font-weight: bold; font-size: 1.3rem; transform: translateY(-50%);}
.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 4px 4px;
}
.marks {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; flex-direction: column;
}
.mark-segment { flex: 1; border-bottom: 1px dashed #999; box-sizing: border-box; }
.mark-segment:last-child { border-bottom: none; }

.choice-btn {
  width: 60px; height: 60px; font-size: 1.5rem; font-weight: bold;
  border-radius: 50%; border: 3px solid #ccc; background-color: #fff; color: #555;
  cursor: pointer; transition: all 0.2s; margin: 0 10px;
}
.choice-btn.selected {
  background-color: #e91e63; color: white; border-color: #c2185b;
}

/* ================== 問題2：テープ図 ================== */
.q-item-large { display: flex; align-items: center; gap: 10px; margin-bottom: 20px;}
.q-visual-wrap { flex: 1; min-width: 250px;}

.measure-line, .measure-line-double {
  width: 100%; text-align: center; border-bottom: 1px dashed #777;
  position: relative; margin-bottom: 10px; height: 20px; display: flex;
}
.measure-line::before, .measure-line::after { content:''; position: absolute; bottom: -5px; width: 1px; height: 10px; background: #777;}
.measure-line::before { left: 0; }
.measure-line::after { right: 0; }
.measure-line span { background: var(--bg-color); padding: 0 10px; position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); font-size: 0.9rem;}

.measure-line-double .m-part { flex: 1; position: relative; border-right: 1px dashed #777;}
.measure-line-double .m-part:last-child { border-right: none; }
.measure-line-double::before { content:''; position: absolute; bottom: -5px; left:0; width: 1px; height: 10px; background: #777;}
.measure-line-double::after { content:''; position: absolute; bottom: -5px; right:0; width: 1px; height: 10px; background: #777;}
.measure-line-double .m-part span { background: var(--bg-color); padding: 0 10px; position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); font-size: 0.9rem;}

.tape-container { width: 100%; height: 35px; background: #fff; border-radius: 4px; box-sizing: border-box; }
.tape { display: flex; height: 100%; box-sizing: border-box; border: 2px solid var(--border-color); border-radius: 4px; }
.tape-segment { flex: 1; border-right: 1px dashed var(--border-color); box-sizing: border-box; }
.tape-segment:last-child { border-right: none; }
.tape.pink .tape-segment.colored { background-color: var(--tape-pink); }
.tape.pink .tape-segment.colored-red { background-color: var(--tape-red); }

/* ================== 問題3：数直線 ================== */
.number-line {
  display: flex; width: 100%; box-sizing: border-box;
  border-top: 3px solid var(--text-main); position: relative; margin-top: 20px;
}
.tick-segment { flex: 1; position: relative; height: 15px; }
.tick-segment::after { content: ''; position: absolute; right: 0; top: 0; width: 2px; height: 15px; background: var(--text-main); }
.number-line::before { content: ''; position: absolute; left: 0; top: 0; width: 2px; height: 15px; background: var(--text-main); }
.tick-label { position: absolute; right: 0; top: 20px; transform: translateX(50%); font-weight: bold; font-size: 1.1rem; }
.tick-label-0 { position: absolute; left: 0; top: 20px; transform: translateX(-50%); font-weight: bold; font-size: 1.1rem; }

/* 記号 */
.kigou-label { position: absolute; right: 0; top: -35px; transform: translateX(50%); font-weight: bold; font-size: 1.2rem; }
.kigou-arrow { position: absolute; right: 0; top: -15px; transform: translateX(50%); font-size: 1rem; color: #555; }

.q-inputs-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 15px;}
.grid-item { display: flex; flex-direction: column; align-items: center; gap: 5px; background: #fff; padding: 15px; border-radius: 8px; border: 2px solid #e0e0e0;}
.q-label { font-size: 1.3rem; font-weight: bold; color: #d32f2f;}

/* ================== 問題4：計算 ================== */
.q-grid-calc { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.q-calc-item { background: #fff; padding: 15px; border-radius: 8px; border: 2px solid #e0e0e0; display: flex; align-items: center; gap: 10px;}
.q-num { font-size: 1.2rem; font-weight: bold; color: #777;}


/* 共通部品 */
.question-area { flex: 1; font-size: 1.2rem; background: #fff; padding: 20px; border-radius: 10px; border: 2px solid #e0e0e0;}
.text-center { text-align: center; }
.text-right { text-align: right; margin-top: 10px; }
.flex-center { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 1.3rem; flex-wrap: wrap;}

.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; }

.inline-frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; font-size: 0.9em; line-height: 1.1; font-weight: bold;}
.inline-frac .top { border-bottom: 2px solid currentColor; padding: 0 2px; }
.inline-frac .bottom { padding: 0 2px; }

.quiz-section { background: white; padding: 20px; border-radius: 10px; margin-bottom: 20px; border: 2px solid #e0e0e0;}

.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;}
.correct { color: #e91e63; }
.wrong { color: #1976d2; }