:root {
  --primary: #fb8c00; /* テーマカラーをオレンジ系に変更 */
  --bg-color: #fffdf7;
  --text-main: #333;
  --accent: #00897b;
  --tape-border: #757575;
  --tape-color: #ffcdd2; /* ピンク色 */
}

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: #00695c; color: white; box-shadow: 0 4px 0 #00695c; }

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; display: flex; align-items: center;
}

/* 分数・数式入力系のスタイル */
.fraction-input { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; gap: 4px;}
.fraction-input.small .num-input { width: 40px; height: 35px; font-size: 1.2rem;}
.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: 1.1em; line-height: 1.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: 1.5rem; }

/* 問題のバッジ（①、②、?など） */
.q-badge { 
  background-color: var(--primary); color: white; padding: 2px 8px; 
  border-radius: 4px; margin-right: 8px; font-size: 1rem; 
  vertical-align: middle; display: inline-block; font-weight: bold;
}
.q-badge.green { background-color: #81c784; }
.q-badge.dark-green { background-color: #2e7d32; border-radius: 50%; width: 20px; height: 20px; text-align: center; line-height: 20px; padding: 2px;}
.q-badge.triangle { 
  background: none; color: #d84315; border: 2px solid #d84315; 
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%); 
  padding: 8px 12px 2px; border-radius: 0; font-size: 0.9rem;
}

.q-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap;}
.q-row p { margin: 0; font-size: 1.1rem; font-weight: bold; }
.input-wrap { display: flex; align-items: center; gap: 5px; font-size: 1.1rem;}
.inline-flex { display: flex; align-items: center; flex-wrap: wrap; }

/* テープ図のスタイル */
.simulator-area, .quiz-section { 
  background: white; padding: 20px 30px; border-radius: 10px; 
  margin-bottom: 20px; border: 2px solid #e0e0e0;
}
.tape-container { position: relative; margin-bottom: 30px; }
.tape-label { text-align: center; margin-bottom: 5px; position: relative; }
.tape-label-text { display: inline-block; background: white; padding: 0 10px; position: relative; z-index: 1; font-weight: bold;}
.tape-label::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; border-top: 1px dashed #777; z-index: 0; }
.tape { display: flex; height: 35px; border: 2px solid var(--tape-border); background-color: white; }
.tape-part { flex: 1; border-right: 1px dashed var(--tape-border); }
.tape-part:last-child { border-right: none; }
.tape-part.colored { background-color: var(--tape-color); }
.box-pink { display: inline-block; width: 25px; height: 15px; background-color: var(--tape-color); border: 1px solid var(--tape-border); vertical-align: middle;}
.box-empty { display: inline-block; width: 20px; height: 15px; border: 1px solid var(--tape-border); vertical-align: middle;}

/* テープ下部の点線とカッコ */
.tape-measure { position: absolute; top: 100%; left: 0; width: 66.66%; margin-top: 5px;}
.measure-bracket { 
  border-bottom: 1px dashed #777; border-left: 1px dashed #777; border-right: 1px dashed #777; 
  height: 10px; position: relative; display: flex; justify-content: center; align-items: flex-end;
}
.measure-bracket span { background: white; padding: 0 5px; position: absolute; bottom: -12px; font-size: 0.9rem;}

/* インタラクティブなテープ（練習問題2） */
.tape.interactive .tape-part { cursor: pointer; transition: background-color 0.2s; }
.tape.interactive .tape-part:hover { background-color: #ffebee; }
.tape.interactive .tape-part.colored { background-color: var(--tape-color); }

/* 解説・まとめ・キャラクター */
.explanation-box { background: #fff8e1; border-left: 5px solid #ffca28; padding: 15px; font-size: 1.1rem; line-height: 1.8;}
.summary-box { background: #e8f5e9; border: 2px solid #81c784; border-radius: 8px; padding: 15px; font-size: 1.2rem; text-align: center; margin-top: 20px;}

.character-box {
  display: flex; align-items: flex-start; gap: 15px;
  background: white; padding: 15px; border-radius: 15px; border: 2px solid #ccc;
  position: relative; margin-top: 15px;
}
.character-box.right-align { flex-direction: row-reverse; text-align: right; border: none; background: transparent; padding: 0;}
.character-box.small-char { padding: 10px; border-color: #a5d6a7; background: #f1f8e9;}
.character-box.small-char .char-icon { width: 40px; height: 40px; }
.char-icon { width: 60px; height: 60px; }
.char-text { flex: 1; background: #fff; padding: 10px 15px; border-radius: 12px; border: 1px solid #e0e0e0; position: relative;}
.right-align .char-text { background: #e3f2fd; border-color: #90caf9;}
.char-text p { margin: 0; font-size: 1.1rem; line-height: 1.6; }
.point-label { 
  position: absolute; top: -12px; left: 10px; background: #2e7d32; color: white; 
  padding: 2px 10px; border-radius: 10px; font-size: 0.9rem; font-weight: bold;
}

/* 練習問題レイアウト */
.q-item-tape { display: flex; align-items: center; gap: 15px; margin-bottom: 40px; flex-wrap: wrap; }
.q-num { font-size: 1.2rem; font-weight: bold; width: 25px; text-align: center;}
.target-frac { width: 50px; text-align: center; font-weight: bold;}
.q-item-tape .tape-container { flex: 1; min-width: 250px; margin-bottom: 0;}
.q-inputs { font-size: 1.2rem; font-weight: bold;}

/* ボタン類 */
.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: 15px; min-height: 24px;}
.correct { color: #e91e63; }
.wrong { color: #1976d2; }