:root {
  --primary: #00897b;
  --bg-color: #f4fbf9;
  --text-main: #333;
  --tape-color-a: #ff7043;
  --tape-color-b: #42a5f5;
  --tape-bg: #ffe0b2;
  --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; line-height: 1.5;
}
.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 {
  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;
}
.tape-wrapper { margin-bottom: 30px; position: relative; padding-top: 20px;}
.tape-label { position: absolute; top: -5px; right: 0; font-weight: bold; font-size: 1.1rem; color: #555;}
.tape-label::before { content: ""; position: absolute; top: 20px; right: 0; bottom: -30px; border-right: 2px dashed #999; }
.tape-ruler {
  width: 100%; height: 40px; background-color: white; border: 2px solid #333;
  display: flex; position: relative; box-sizing: border-box;
}
.tape-diagram {
  height: 100%; background-color: var(--tape-color-a); transition: width 0.3s ease-in-out;
}
.tape-diagram.tape-b-color { background-color: var(--tape-color-b); }
.tape-name { font-weight: bold; margin-top: 5px; color: #555; }
.tape-mark { border-right: 1px dashed #777; height: 100%; box-sizing: border-box; }
.tape-mark:last-child { border-right: none; }

/* 数直線のスタイル */
.number-line-area {
  background: white; padding: 40px 20px 20px; border-radius: 10px;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.05); margin-bottom: 20px; border: 2px solid #e0e0e0;
}
.number-line-container {
  width: 100%; height: 60px; position: relative; border-bottom: 3px solid #333; margin-bottom: 40px;
}
.nl-tick {
  position: absolute; bottom: 0; width: 2px; height: 15px; background-color: #333; transform: translateX(-50%);
}
.nl-tick.main { height: 25px; width: 3px; }
.nl-label {
  position: absolute; top: 100%; left: 0; transform: translateX(-50%);
  margin-top: 8px; font-size: 1.2rem; font-weight: bold;
}
.fraction-inputs-row {
  display: flex; justify-content: center; gap: 15px; margin-top: 15px; flex-wrap: wrap;
}
.fraction-input-box {
  display: flex; flex-direction: column; align-items: center;
  border: 2px solid #ff4081; padding: 5px; border-radius: 8px; background: #fff;
}

/* 分数入力コンポーネント */
.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: 45px; height: 35px; font-size: 1.2rem; }

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

/* クイズセクション */
.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; padding-bottom: 10px;}
.q-item { display: flex; flex-direction: column; gap: 15px; margin-bottom: 20px; justify-content: center;}
.q-inputs { font-size: 1.2rem; font-weight: bold; display: flex; align-items: center; flex-wrap: wrap;}

/* ボタン類 */
.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; }

/* キャラクターふきだし */
.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; }