:root {
  --man-bg: #ffebee;   /* 薄いピンク */
  --man-txt: #e53935;
  --sen-bg: #ffffff;   /* 白 */
  --hyaku-bg: #e3f2fd; /* 薄い水色 */
  --ju-bg: #fffde7;    /* 薄い黄色 */
  --ichi-bg: #fce4ec;  /* 薄い赤紫 */
  --main-green: #4caf50;
}

body {
  font-family: 'Hiragino Maru Gothic ProN', 'Rounded Mplus 1c', sans-serif;
  background-color: #f5f5f5;
  color: #333;
  margin: 0;
  padding: 20px;
  display: flex;
  justify-content: center;
}

#app-container {
  width: 100%;
  max-width: 900px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-radius: 10px;
  overflow: hidden;
}

header {
  padding: 20px;
  border-bottom: 2px solid #ddd;
}

h1 {
  font-size: 24px;
  margin: 0;
  color: #2c3e50;
  display: flex;
  align-items: center;
  gap: 10px;
}

.unit-num {
  background: #fff;
  border: 3px solid var(--main-green);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--main-green);
}

.textbook-section {
  padding: 30px;
  border-bottom: 2px dashed #ccc;
}

.section-header.green-bg {
  background-color: #e8f5e9;
  border-radius: 5px 20px 20px 5px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 10px solid var(--main-green);
}

.section-header h2 { margin: 0; font-size: 20px; color: #2e7d32; }
.instruction { font-weight: bold; margin-top: 15px; }

/* 復習用の表 */
.review-tables { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 15px; }
.review-item { flex: 1; min-width: 300px; }
.tag.orange-tag { background: #ffcc80; padding: 5px 15px; display: inline-block; border-radius: 5px 5px 0 0; font-weight: bold; }
.dot-table { width: 100%; border-collapse: collapse; text-align: center; border: 2px solid #ffcc80; }
.dot-table th { background: #fff3e0; border: 1px solid #ffcc80; padding: 8px; }
.dot-table td { border: 1px solid #ffcc80; height: 60px; vertical-align: bottom; padding: 5px; }
.answer-row td { background: #ffe0b2; font-size: 20px; font-weight: bold; height: auto; padding: 10px; }

.dot.red {
  width: 12px; height: 12px; background: #e53935; border-radius: 50%;
  display: inline-block; margin: 2px;
}

/* 導入問題・クイズエリア */
.section-title { font-size: 20px; font-weight: bold; margin-bottom: 15px; display: flex; align-items: center; gap: 10px; }
.roman-num { background: #ff9800; color: #fff; padding: 2px 10px; border-radius: 5px; }
.green-text { color: var(--main-green); }
.question-box { border: 2px solid #ccc; padding: 15px; border-radius: 8px; margin-bottom: 20px; }
.main-q { font-size: 18px; font-weight: bold; border-bottom: 2px solid var(--main-green); display: inline-block; padding-bottom: 2px; }

.explanation-box { background: #fffde7; border-left: 5px solid #fbc02d; padding: 15px; margin-bottom: 20px; }
.highlight-yellow { background: linear-gradient(transparent 60%, #fff59d 60%); font-weight: bold; }

/* 入力欄とボタン */
.num-input { font-size: 18px; padding: 8px; width: 60px; text-align: center; border: 2px solid #90caf9; border-radius: 5px; }
.kanji-input { font-size: 18px; padding: 8px; width: 250px; border: 2px solid #90caf9; border-radius: 5px; margin-top: 5px; }
.small-input { width: 40px; }

.action-row { display: flex; gap: 15px; margin-top: 15px; }
button { font-family: inherit; cursor: pointer; border: none; border-radius: 5px; font-weight: bold; transition: 0.2s; }
button:active { transform: scale(0.95); }
.check-btn { background: #2196f3; color: white; padding: 10px 20px; font-size: 16px; box-shadow: 0 4px 0 #1565c0; }
.check-btn:active { box-shadow: 0 0 0; transform: translateY(4px); }
.hint-btn { background: #ff9800; color: white; padding: 10px 20px; font-size: 16px; box-shadow: 0 4px 0 #ef6c00; }
.hint-btn:active { box-shadow: 0 0 0; transform: translateY(4px); }

.hint-box { background: #e0f7fa; border: 2px dashed #00bcd4; padding: 15px; margin-top: 15px; border-radius: 5px; font-weight: bold; }
.hidden { display: none; }
.result-msg { font-size: 20px; font-weight: bold; margin-top: 15px; min-height: 30px; }

/* シミュレーター (位取り表) */
.simulator-container { border: 3px solid #ccc; border-radius: 10px; padding: 15px; background: #fafafa; }
.sim-header { display: flex; gap: 10px; justify-content: flex-end; margin-bottom: 10px; }
.small-btn { padding: 5px 10px; background: #9e9e9e; color: #fff; }
.clear-btn { background: #f44336; }

.place-value-chart { display: flex; border: 2px solid #999; }
.place-col { flex: 1; display: flex; flex-direction: column; border-right: 1px solid #999; }
.place-col:last-child { border-right: none; }

/* 背景色設定 */
.man-bg { background-color: var(--man-bg); }
.white-bg { background-color: var(--sen-bg); }
.hyaku-bg { background-color: var(--hyaku-bg); }
.ju-bg { background-color: var(--ju-bg); }
.ichi-bg { background-color: var(--ichi-bg); }

.place-name { text-align: center; padding: 10px 0; font-weight: bold; border-bottom: 1px solid #999; }
.man-text { color: var(--man-txt); }

.dot-display { height: 160px; display: flex; flex-direction: column-reverse; align-items: center; padding: 5px 0; gap: 4px; overflow: hidden; background: rgba(255,255,255,0.5); }
.sim-dot { width: 14px; height: 14px; background: #e53935; border-radius: 50%; box-shadow: 1px 1px 2px rgba(0,0,0,0.3); animation: pop 0.2s ease-out; }
@keyframes pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }

.btn-group { display: flex; border-top: 1px dotted #999; border-bottom: 1px solid #999; background: #fff; }
.ctrl-btn { flex: 1; padding: 10px 0; font-size: 20px; background: transparent; border-radius: 0; color: #333; }
.ctrl-btn:hover { background: #eee; }
.ctrl-btn.plus { border-right: 1px dotted #ccc; color: #1976d2; }
.ctrl-btn.minus { color: #d32f2f; }

.digit-display { text-align: center; font-size: 28px; font-weight: bold; padding: 10px 0; background: #fff; }

.sim-footer { text-align: center; font-size: 24px; font-weight: bold; margin-top: 15px; padding: 10px; background: #fff; border: 2px solid #ccc; border-radius: 5px; }

/* 練習問題エリア */
.practice-box { border: 2px solid #81c784; padding: 20px; border-radius: 8px; background: #f1f8e9; }
.practice-item { margin-bottom: 20px; border-bottom: 1px dashed #ccc; padding-bottom: 15px; }
.practice-item p { font-size: 18px; font-weight: bold; }