:root {
  --primary: #3f51b5;
  --secondary: #ff9800;
  --bg: #e8eaf6;
  --card: #ffffff;
  --text: #333333;
  --c-quo: #e91e63;
  --c-rem: #ff9800;
}

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

#app {
  width: 100%;
  max-width: 800px;
  background: var(--bg);
  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 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 12px; border-radius: 16px; font-weight: bold; }

/* Visualizer */
.visualizer { background: #fff; padding: 20px; border-bottom: 4px solid #7986cb; }
.area-label { font-weight: bold; color: #555; display: flex; justify-content: space-between; align-items: center; }
.vis-controls { display: flex; gap: 8px; }
.btn-small { background: #eee; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: bold; font-family: inherit; transition: 0.2s;}
.btn-small:active { transform: scale(0.95); }
.btn-magic { background: #fff3e0; color: #e65100; border: 1px solid #ffb74d; }

.pool-container { background: #fafafa; border: 2px dashed #ccc; border-radius: 8px; margin-top: 10px; padding: 10px; }
.pool-status { font-weight: bold; margin-bottom: 5px; color: #555; }
.pool-status strong { color: var(--primary); font-size: 1.2em; }
.pool { display: flex; flex-wrap: wrap; gap: 4px; max-height: 80px; overflow-y: auto;}

.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; margin-top: 10px; min-height: 80px;}
.group-box {
  background: #e8eaf6; border: 2px solid #9fa8da; border-radius: 8px; padding: 6px;
  display: flex; flex-wrap: wrap; gap: 3px; align-content: flex-start; justify-content: center; min-height: 60px;
}
.group-box.full { background: #c5cae9; border-color: #5c6bc0; }

.item {
  width: 16px; height: 16px; background: #ffeb3b; border: 1px solid #fbc02d; border-radius: 50%;
  box-shadow: 1px 1px 2px rgba(0,0,0,0.1); cursor: pointer; transition: transform 0.1s;
  display: flex; justify-content: center; align-items: center; font-size: 10px;
}
.item:hover { transform: scale(1.2); }

/* Question Board */
.question-board { padding: 20px; }
.question-card { background: var(--card); border-radius: 12px; padding: 25px; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.question-card h2 { margin-top: 0; color: var(--primary); font-size: 20px; border-bottom: 2px solid #e8eaf6; padding-bottom: 8px; }
.question-text { font-size: 20px; font-weight: bold; line-height: 1.8; margin-bottom: 15px; }
.question-text .quote { background: #fce4ec; padding: 10px; border-radius: 8px; display: block; margin-top: 10px; border-left: 5px solid #f06292;}
rt { font-size: 11px; color: #777; }

.hint-area { background: #fff8e1; border: 2px dashed #ffc107; padding: 12px; border-radius: 8px; margin-bottom: 20px; font-size: 16px; font-weight: bold; color: #555; animation: fadeIn 0.3s;}

.input-section { margin-bottom: 20px; animation: fadeIn 0.4s;}
.answer-box { background: #f5f5f5; padding: 15px; border-radius: 8px; font-size: 22px; font-weight: bold; display: flex; align-items: center; flex-wrap: wrap; gap: 5px; justify-content: center;}
.eq-left { margin-right: 10px; color: #333; }

input[type="text"] {
  width: 50px; height: 40px; font-size: 20px; text-align: center; font-weight: bold; font-family: inherit;
  border: 3px solid #ccc; border-radius: 8px; outline: none; transition: 0.2s; margin: 0 4px;
}
input[type="text"]:focus { background: #fffde7; border-color: var(--secondary);}
input.input-quotient { border-color: var(--c-quo); }
input.input-remainder { border-color: var(--c-rem); }

/* Shiho's Section */
.judgment-box { text-align: center; background: #fff3e0; padding: 15px; border-radius: 8px; border: 2px solid #ffb74d;}
.judgment-box p { font-size: 18px; font-weight: bold; margin: 0;}
.btn-judge { flex: 1; padding: 12px; font-size: 18px; font-weight: bold; border: none; border-radius: 8px; cursor: pointer; color: white; transition: 0.1s; }
.btn-judge:active { transform: translateY(3px); }
.btn-circle { background: #f44336; box-shadow: 0 4px 0 #c62828; }
.btn-cross { background: #4caf50; box-shadow: 0 4px 0 #2e7d32; }

.reason-box { background: #e8f5e9; padding: 15px; border-radius: 8px; border: 2px dashed #4caf50; text-align: center;}
.reason-box p { font-weight: bold; margin-top: 0; color: #2e7d32;}
select { font-size: 16px; padding: 8px; font-weight: bold; border: 2px solid #4caf50; border-radius: 8px; width: 100%; font-family: inherit;}

/* Actions */
.action-buttons { display: flex; gap: 15px; }
.btn-hint { flex: 1; background: #ffb74d; color: white; border: none; border-radius: 8px; font-size: 18px; font-weight: bold; cursor: pointer; box-shadow: 0 4px 0 #f57c00;}
.btn-hint:active { transform: translateY(4px); box-shadow: 0 0 0 #f57c00; }
.btn-primary, .btn-next { flex: 2; background: var(--primary); color: white; border: none; padding: 16px; font-size: 20px; font-weight: bold; border-radius: 8px; cursor: pointer; box-shadow: 0 4px 0 #283593; transition: 0.1s; width: 100%;}
.btn-primary:active, .btn-next:active { transform: translateY(4px); box-shadow: 0 0 0 #283593; }
.btn-next { background: #f57c00; box-shadow: 0 4px 0 #e65100; animation: pop 0.4s; }

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

/* 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: var(--primary); font-size: 36px; 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; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(0.9); } 100% { transform: scale(1); } }