:root {
  --primary: #00796b;
  --bg-color: #e0f2f1;
  --card-bg: #ffffff;
  --text-main: #333333;
  --c-dividend: #1976d2; /* 青：わられる数 */
  --c-divisor: #388e3c;  /* 緑：わる数 */
  --c-quotient: #d32f2f; /* 赤：答え */
  --c-remainder: #f57c00;/* オレンジ：あまり */
}

body {
  font-family: 'Hiragino Maru Gothic ProN', 'Meiryo', sans-serif;
  background-color: #b2dfdb;
  margin: 0;
  padding: 10px;
  display: flex;
  justify-content: center;
  color: var(--text-main);
}

#app {
  width: 100%;
  max-width: 800px;
  background: var(--bg-color);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  overflow: hidden;
  position: relative;
}

header {
  background: var(--primary);
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header h1 { margin: 0; font-size: 20px; }
.step-indicator { background: rgba(255,255,255,0.2); padding: 5px 15px; border-radius: 20px; font-weight: bold; }

/* ---------------- カラー定義 ---------------- */
.color-dividend { color: var(--c-dividend); font-weight: bold; }
.color-divisor { color: var(--c-divisor); font-weight: bold; }
.color-quotient { color: var(--c-quotient); font-weight: bold; }
.color-remainder { color: var(--c-remainder); font-weight: bold; }

input.input-dividend { border: 3px solid var(--c-dividend); }
input.input-divisor { border: 3px solid var(--c-divisor); }
input.input-q { border: 3px solid var(--c-quotient); }
input.input-r { border: 3px solid var(--c-remainder); }
input:focus { background: #fffde7; outline: none; }

/* ---------------- Visualizer ---------------- */
.visualizer { background: #ffffff; padding: 20px; border-bottom: 4px solid #80cbc4; }
.area-label { font-weight: bold; color: #555; display: flex; align-items: center; justify-content: space-between; }
.vis-controls { display: flex; gap: 8px; }
.btn-small { background: #eeeeee; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-family: inherit; font-weight: bold; transition: 0.2s;}
.btn-small:active { transform: scale(0.95); }
.btn-magic { background: #e8f5e9; color: #2e7d32; border: 1px solid #81c784; }

.pool { min-height: 50px; background: #fafafa; border: 2px dashed #ccc; border-radius: 10px; padding: 10px; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.groups { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; overflow-x: auto; padding-bottom: 10px;}

.person-box {
  background: #f1f8e9; border: 3px solid #aed581; border-radius: 12px;
  padding: 8px; flex: 1; min-width: 90px; min-height: 90px; display: flex; flex-direction: column; align-items: center; transition: 0.3s;
}
.person-box.active { background: #e8f5e9; border-color: var(--c-divisor); box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.person-icon { font-size: 24px; margin-bottom: 4px; }
.items-area { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; width: 100%; }

.item {
  width: 22px; height: 22px; background: #ffca28; border-radius: 4px; /* 色紙をイメージした四角 */
  box-shadow: inset -2px -2px 4px rgba(0,0,0,0.2), 0 2px 2px rgba(0,0,0,0.1);
  cursor: pointer; transition: transform 0.1s; border: 1px solid #ffb300;
}
.item:hover { transform: scale(1.1); }

/* ---------------- Lesson Flow ---------------- */
.lesson-flow { padding: 20px; }
.step-card { background: var(--card-bg); border-radius: 12px; padding: 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); animation: fadeIn 0.4s ease-out; }
.step-card h2 { color: var(--primary); margin-top: 0; border-bottom: 2px dashed #80cbc4; padding-bottom: 10px; font-size: 20px;}
.question-text { font-size: 18px; font-weight: bold; line-height: 1.6; }
rt { font-size: 11px; color: #666; }
.hint-text { color: #e65100; font-weight: bold; font-size: 15px; background: #fff3e0; padding: 10px; border-radius: 8px; display: inline-block; margin-top: 10px;}

.character-container { display: flex; gap: 15px; margin-bottom: 15px;}
.character-box { flex: 1; padding: 12px; border-radius: 8px; font-size: 16px; border: 2px solid transparent;}
.character-box.ami { background: #fce4ec; border-color: #f8bbd0; }
.character-box.riku { background: #e3f2fd; border-color: #90caf9; }

input[type="text"] {
  width: 50px; height: 40px; font-size: 20px; text-align: center; border-radius: 8px; font-family: inherit; font-weight: bold; margin: 0 5px;
}

.answer-box { background: #f5f5f5; padding: 15px; border-radius: 12px; text-align: center; font-size: 22px; font-weight: bold; margin: 15px 0; }
.formula-box { font-size: 20px; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 5px;}
.formula-box input { width: 60px; height: 45px; font-size: 24px;}

.formula-visual-link { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; background: #fffde7; padding: 15px; border-radius: 8px; border: 2px dashed #fff176; font-size: 18px; font-weight: bold; margin-bottom: 15px;}

.summary-box { background: #e8f5e9; border: 3px solid #81c784; padding: 20px; border-radius: 12px; text-align: center; font-size: 18px; font-weight: bold; margin-bottom: 20px;}
.highlight-formula { background: white; padding: 15px; border-radius: 8px; font-size: 24px; margin-top: 10px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);}

.practice-box { background: #fafafa; border: 2px solid #e0e0e0; padding: 15px; border-radius: 12px; margin-bottom: 20px; }
.practice-box h3 { margin-top: 0; color: #1565c0; }
.answer-row { margin-bottom: 15px; font-size: 20px; font-weight: bold; display: flex; align-items: center; flex-wrap: wrap;}
.answer-row .label { width: 120px; }
.answer-row input { margin-bottom: 5px; }

.btn-check { display: block; width: 100%; background: var(--primary); color: white; border: none; padding: 15px; font-size: 18px; font-weight: bold; border-radius: 8px; cursor: pointer; box-shadow: 0 4px 0 #004d40; transition: transform 0.1s; }
.btn-check:active { transform: translateY(4px); box-shadow: 0 0 0 #004d40; }

.msg { margin-top: 15px; padding: 15px; border-radius: 8px; font-weight: bold; font-size: 16px; line-height: 1.5; white-space: pre-wrap; }
.msg.error { background: #ffebee; color: #c62828; border-left: 5px solid #f44336; }
.msg.success { background: #e8f5e9; color: #2e7d32; border-left: 5px solid #4caf50; }
.msg.warning { background: #fff3e0; color: #e65100; border-left: 5px solid #ff9800; }

/* Clear Screen */
.clear-screen { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.95); display: flex; justify-content: center; align-items: center; text-align: center; z-index: 100; animation: fadeIn 0.5s; }
.clear-content { padding: 40px; }
.crown { font-size: 80px; animation: pop 1s infinite alternate; }
.clear-content h2 { color: #d32f2f; font-size: 32px; margin: 10px 0; }
.clear-content p { font-size: 18px; font-weight: bold; color: #333; line-height: 1.6; }

.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { 0% { transform: scale(0.9); } 100% { transform: scale(1); } }