:root {
  --primary: #00897b;
  --bg-color: #f4fbf9;
  --text-main: #333;
  --tape-color-a: #ffab91;
  --tape-color-user: #4fc3f7;
  --accent: #ffb300;
  --line-color: #555;
  --highlight: #ff4081;
}

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: 850px; 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 { font-size: 1.2rem; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.slider-group label { min-width: 280px; }
input[type="range"] { flex: 1; min-width: 200px; height: 30px; cursor: pointer; } /* タブレットで操作しやすいように太く */

/* テープ図（幅100% = 2m） */
.simulator-area, .quiz-section {
  background: white; padding: 40px 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-large { position: relative; width: 100%; padding-bottom: 10px; }
.practice-tape-block { position: relative; width: 100%; margin-top: 30px;}

.tape-labels-top { display: flex; justify-content: space-between; font-weight: bold; font-size: 1.2rem; margin-bottom: 5px; position: relative;}
.label-0 { position: absolute; left: 0; transform: translateX(-50%); }
.label-1 { position: absolute; left: 50%; transform: translateX(-50%); }
.label-2 { position: absolute; left: 100%; transform: translateX(-50%); }
.highlight-1m { color: var(--highlight); font-size: 1.4rem; }

.tape-name { font-weight: bold; margin-bottom: 5px; color: #555; }
.highlight-text { color: var(--tape-color-user); font-size: 1.4rem; }

/* テープのベース（枠と1m・2mの線） */
.tape-ruler-base, .tape-ruler-interactive {
  width: 100%; height: 50px; background-color: #fff; border: 2px solid #333;
  display: flex; position: relative; box-sizing: border-box;
}
/* 1mの区切り線（太線） */
.tape-ruler-base::after, .tape-ruler-interactive::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
  border-left: 3px solid #333; z-index: 5;
}
.highlight-1m-box::after { border-left: 4px solid var(--highlight); }

/* 固定テープ（㋐） */
.tape-diagram-fixed {
  position: absolute; top: 0; left: 0; height: 100%;
  background-color: var(--tape-color-a); opacity: 0.8; z-index: 1;
  width: 75%; /* 2mの3/4 = 1.5m, 全体の75% */
}
.tape-mark-fixed {
  position: absolute; top: 0; bottom: 0; border-left: 2px dashed #777; z-index: 2;
}

/* 操作するテープ */
.tape-diagram-fill {
  position: absolute; top: 0; left: 0; height: 100%;
  background-color: var(--tape-color-user); transition: width 0.3s ease-in-out; opacity: 0.8; z-index: 1;
}
.tape-mark-interactive {
  position: absolute; top: 0; bottom: 0; border-left: 1px dashed #999; z-index: 2;
}

/* 質問エリア */
.question-area { font-size: 1.2rem; }
.q-item { margin-bottom: 20px; }
.q-item p { font-weight: bold; margin: 0 0 10px 0;}
.q-inputs { display: flex; align-items: center; gap: 10px; }

.ans-box { text-align: right; margin-top: 15px; font-weight: bold; font-size: 1.2rem; display: flex; align-items: center; justify-content: flex-end; gap: 10px;}

/* 分数入力コンポーネント */
.fraction-input { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; gap: 4px;}
.fraction-input.small .num-input { width: 50px; height: 40px; font-size: 1.4rem;}
.fraction-line { width: 100%; height: 2px; background-color: var(--text-main); }
.num-input { width: 60px; height: 45px; font-size: 1.5rem; text-align: center; border: 2px solid #ccc; border-radius: 5px;}
.num-input:focus { border-color: var(--primary); outline: none; background-color: #e0f2f1; }

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

/* ボタン類 */
.action-btn {
  padding: 12px 30px; font-size: 1.3rem; font-weight: bold; background-color: #29b6f6; color: white;
  border: none; border-radius: 8px; cursor: pointer; box-shadow: 0 5px 0 #0288d1;
}
.action-btn:active { transform: translateY(5px); box-shadow: 0 0 0 #0288d1; }
.result-message { font-size: 1.3rem; font-weight: bold; margin-top: 10px; min-height: 26px;}
.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.15rem; line-height: 1.6; }