:root {
  --primary: #00796b;
  --secondary: #f57c00;
  --bg: #f4fbf4;
  --card: #ffffff;
  --text: #333333;
}

body {
  font-family: 'Hiragino Maru Gothic ProN', 'Meiryo', sans-serif;
  background-color: #e8f5e9;
  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 8px 24px rgba(0,0,0,0.1);
  overflow: hidden;
  position: relative;
}

header {
  background: var(--primary);
  color: white;
  padding: 16px 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: 4px 12px; border-radius: 16px; font-weight: bold; }

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

.pool-container { max-height: 120px; overflow-y: auto; background: #fafafa; border: 2px solid #ddd; border-radius: 8px; margin-top: 8px; padding: 8px; }
.pool { display: flex; flex-wrap: wrap; gap: 6px; }

.groups { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; min-height: 80px; }
.group-box {
  background: #e0f2f1; border: 2px solid #80cbc4; border-radius: 8px; padding: 6px;
  display: flex; flex-wrap: wrap; gap: 4px; align-content: flex-start; justify-content: center;
  width: 80px; min-height: 60px;
}
.group-box.full { background: #b2dfdb; border-color: #00796b; }

.item {
  width: 24px; height: 24px; background: #ff5252; border-radius: 50%;
  box-shadow: inset -2px -2px 4px rgba(0,0,0,0.3), 0 2px 2px rgba(0,0,0,0.2);
  cursor: pointer; transition: transform 0.1s;
}
.item:hover { transform: scale(1.1); }
.item-slot { width: 24px; height: 24px; background: rgba(255,255,255,0.6); border-radius: 50%; }

/* Question Section */
.question-section { padding: 20px; }
.question-card { background: var(--card); border-radius: 12px; padding: 20px; 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 #e0f2f1; padding-bottom: 8px; }
.question-text { font-size: 22px; font-weight: bold; line-height: 1.8; margin-bottom: 20px; }
rt { font-size: 12px; color: #777; }

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

.answer-box { background: #f5f5f5; padding: 20px; border-radius: 12px; text-align: center; font-size: 26px; font-weight: bold; margin-bottom: 20px; }
.eq-display { display: inline-block; margin-right: 10px; }
input[type="text"] {
  width: 60px; height: 44px; font-size: 24px; text-align: center; font-weight: bold;
  border: 3px solid #ccc; border-radius: 8px; outline: none; transition: 0.2s;
}
input[type="text"]:focus { border-color: var(--secondary); background: #fff3e0; }

.action-buttons { display: flex; gap: 10px; }
.btn-hint { flex: 1; background: #ffb74d; color: #fff; border: none; border-radius: 8px; font-size: 18px; font-weight: bold; cursor: pointer; }
.btn-check, .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 #004d40; transition: 0.1s; }
.btn-check:active, .btn-next:active { transform: translateY(4px); box-shadow: 0 0 0 #004d40; }
.btn-next { background: #1976d2; box-shadow: 0 4px 0 #0d47a1; animation: pop 0.4s; }

.msg { margin-top: 20px; padding: 16px; 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: #d32f2f; 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; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(0.9); } 100% { transform: scale(1); } }