:root {
  --primary: #1976d2;
  --secondary: #ffb300;
  --bg-color: #e3f2fd;
  --card-bg: #ffffff;
  --text-main: #333333;
  --seed-color: #8d6e63;
}

body {
  font-family: 'Hiragino Maru Gothic ProN', 'Meiryo', sans-serif;
  background-color: #bbdefb;
  margin: 0;
  padding: 15px;
  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.15);
  overflow: hidden;
  position: relative;
}

header {
  background: var(--primary);
  color: white;
  padding: 15px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 { margin: 0; font-size: 22px; }
.step-indicator { background: rgba(255,255,255,0.2); padding: 5px 15px; border-radius: 20px; font-weight: bold; }

/* ---------------- Visualizer ---------------- */
.visualizer {
  background: #ffffff;
  padding: 20px 25px;
  border-bottom: 4px solid #90caf9;
}

.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: #fff3e0; color: #e65100; border: 1px solid #ffb74d; }

.pool {
  min-height: 60px; background: #fafafa; border: 2px dashed #ccc; border-radius: 10px;
  padding: 12px; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}

.groups {
  display: flex; justify-content: space-between; gap: 10px; margin-top: 10px;
}

.person-box {
  background: #f1f8e9; border: 3px solid #aed581; border-radius: 12px;
  padding: 10px; flex: 1; min-height: 100px; display: flex; flex-direction: column; align-items: center;
}
.person-icon { font-size: 24px; margin-bottom: 8px; }
.items-area { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; width: 100%; }

.item {
  width: 24px; height: 30px; background: var(--seed-color); border-radius: 50% 50% 40% 40%;
  box-shadow: inset -2px -2px 4px rgba(0,0,0,0.4), 0 2px 3px rgba(0,0,0,0.2);
  cursor: pointer; transition: transform 0.1s; position: relative;
}
.item::after { content: ''; position: absolute; top: 4px; left: 6px; width: 6px; height: 10px; background: rgba(255,255,255,0.3); border-radius: 50%; transform: rotate(20deg);}
.item:hover { transform: scale(1.1); }

/* ---------------- Lesson Flow ---------------- */
.lesson-flow { padding: 25px; }

.step-card {
  background: var(--card-bg); border-radius: 12px; padding: 25px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05); animation: fadeIn 0.5s ease-out;
}

.step-card h2 { color: var(--primary); margin-top: 0; border-bottom: 2px dashed #90caf9; padding-bottom: 10px; }
.question-text { font-size: 18px; font-weight: bold; line-height: 1.6; }
.hint-text { color: #f57c00; font-weight: bold; font-size: 15px; background: #fff3e0; padding: 10px; border-radius: 8px; display: inline-block;}
.notice-box { background: #e8f5e9; border-left: 5px solid #4caf50; padding: 12px; border-radius: 4px; font-weight: bold; margin-bottom: 20px;}

input[type="text"] {
  width: 60px; height: 40px; font-size: 20px; text-align: center;
  border: 2px solid #ccc; border-radius: 8px; outline: none; font-family: inherit; font-weight: bold;
}
input[type="text"]:focus { border-color: var(--secondary); background: #fff8e1; }
.input-short { width: 50px; }

.answer-box { background: #f5f5f5; padding: 20px; border-radius: 12px; text-align: center; font-size: 24px; font-weight: bold; margin: 20px 0; }
.final-answer { background: #e3f2fd; border: 2px solid #90caf9; }

.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 #1565c0; transition: transform 0.1s;
}
.btn-check:active { transform: translateY(4px); box-shadow: 0 0 0 #1565c0; }

/* Logic Box (Step 3) */
.logic-box { background: #fafafa; border: 2px solid #e0e0e0; border-radius: 8px; padding: 15px; font-size: 18px; font-weight: bold; margin-bottom: 20px;}
.logic-row { display: flex; align-items: center; gap: 10px; padding: 10px; border-bottom: 1px dashed #ccc; }
.logic-row:last-child { border-bottom: none; }
.logic-row label { width: 120px; }
.logic-row.highlight { background: #fff8e1; }
.logic-row.error-row { color: #d32f2f; }

.summary-box { background: #f1f8e9; border: 2px solid #8bc34a; padding: 20px; border-radius: 12px; font-size: 20px; font-weight: bold; line-height: 1.6; text-align: center; margin-bottom: 20px;}

.msg { margin-top: 20px; 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 1s; }
.clear-content { padding: 40px; }
.crown { font-size: 80px; animation: pop 1s infinite alternate; }
.clear-content h2 { color: #f57c00; font-size: 36px; margin: 10px 0; }
.clear-content p { font-size: 20px; 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); } }