:root {
  --primary: #e91e63;
  --bg-color: #fce4ec;
  --card-bg: #ffffff;
  --text-main: #333333;
}

body {
  font-family: 'Hiragino Maru Gothic ProN', 'Meiryo', sans-serif;
  background-color: #f8bbd0;
  margin: 0;
  padding: 10px;
  display: flex;
  justify-content: center;
  color: var(--text-main);
  transition: background-color 0.5s;
}
body.theme-tire { background-color: #bbdefb; }

#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;
  transition: background-color 0.5s;
}
#app.theme-tire { background: #e3f2fd; }

header {
  background: var(--primary);
  color: white;
  padding: 15px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.5s;
}
header.theme-tire { background: #1976d2; }
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; }

/* ---------------- Visualizer ---------------- */
.visualizer { background: #ffffff; padding: 20px; border-bottom: 4px solid #f48fb1; transition: border-color 0.5s;}
.visualizer.theme-tire { border-bottom-color: #90caf9; }

.area-label { font-weight: bold; color: #555; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;}
.vis-controls { display: flex; gap: 8px; }
.btn-small { background: #eeeeee; border: none; padding: 8px 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; }

.btn-add-box { background: #e3f2fd; color: #1565c0; border: 2px dashed #1e88e5; animation: pop 0.5s; font-size: 16px;}
.btn-add-box.theme-tire { background: #fff8e1; color: #f57c00; border-color: #ffca28; }

.pool-container { background: #fafafa; border: 2px dashed #ccc; border-radius: 10px; padding: 10px; margin-top: 10px;}
.pool-status { font-weight: bold; margin-bottom: 5px; color: #555; }
.pool-status strong { color: var(--primary); font-size: 1.2em; transition: color 0.5s;}
.pool-status strong.theme-tire { color: #1976d2; }
.pool { min-height: 45px; display: flex; flex-wrap: wrap; gap: 6px; }

.groups { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 15px; min-height: 100px;}

/* ケーキ用の箱デザイン */
.group-box.type-cake {
  background: #efebe9; border: 3px solid #8d6e63; border-radius: 4px;
  padding: 8px; width: 85px; min-height: 85px; display: flex; flex-wrap: wrap; gap: 4px; align-content: flex-start; justify-content: center;
  position: relative; transition: all 0.3s;
}
.group-box.type-cake::before { content: '📦'; position: absolute; top: -15px; left: -10px; font-size: 20px;}
.group-box.type-cake.full { background: #d7ccc8; border-color: #5d4037; }
.group-box.type-cake.new-box { animation: highlightBox 1s ease-out; border-color: #2196f3; background: #e3f2fd;}

/* タイヤ用の車デザイン */
.group-box.type-tire {
  background: #f5f5f5; border: 3px solid #9e9e9e; border-radius: 12px;
  padding: 8px; width: 85px; min-height: 85px; display: flex; flex-wrap: wrap; gap: 4px; align-content: center; justify-content: center;
  position: relative; transition: all 0.3s;
}
.group-box.type-tire::before { content: '🚙'; position: absolute; top: -15px; left: 30px; font-size: 24px; opacity: 0.3;}
.group-box.type-tire.full { background: #e3f2fd; border-color: #1976d2; }
.group-box.type-tire.full::before { opacity: 1; }

.item {
  width: 32px; height: 32px; border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1); cursor: pointer; transition: transform 0.1s;
  display: flex; justify-content: center; align-items: center; font-size: 22px;
}
.item.type-cake { background: #fff; }
.item.type-cake::after { content: '🍰'; }
.item.type-tire { background: #424242; border: 3px dashed #e0e0e0; }
.item.type-tire::after { content: '⚙️'; font-size: 18px;}
.item:hover { transform: scale(1.15); }

/* ---------------- Lesson Flow ---------------- */
.question-board { padding: 20px; }
.question-card { background: var(--card-bg); border-radius: 12px; padding: 25px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); animation: fadeIn 0.4s ease-out; }
.mission-title { color: var(--primary); margin-top: 0; border-bottom: 2px dashed #f48fb1; padding-bottom: 10px; }
.question-text { font-size: 18px; font-weight: bold; line-height: 1.6; }
rt { font-size: 11px; color: #666; }

.character-box { padding: 15px; border-radius: 10px; margin-bottom: 15px; font-size: 16px; border: 2px solid transparent; display: inline-block;}
.character-box.ami { background: #fce4ec; border-color: #f8bbd0; }

.action-prompt { background: #e3f2fd; border: 2px solid #64b5f6; padding: 15px; border-radius: 8px; font-weight: bold; font-size: 18px; color: #0d47a1; margin: 20px 0;}

input[type="text"] {
  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; margin: 0 5px;}

.answer-box { background: #f5f5f5; padding: 20px; border-radius: 12px; text-align: center; font-size: 22px; font-weight: bold; margin: 20px 0; }
.final-answer { background: #e8f5e9; border: 3px solid #4caf50; font-size: 24px;}

.action-buttons { display: flex; gap: 15px;}
.btn-primary { display: block; width: 100%; 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 #c2185b; transition: transform 0.1s; }
.btn-primary:active { transform: translateY(4px); box-shadow: 0 0 0 transparent !important; }

.msg { margin-top: 20px; padding: 15px; border-radius: 8px; font-weight: bold; font-size: 16px; line-height: 1.5; white-space: pre-wrap; animation: pop 0.3s;}
.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; }

.summary-box { background: #fff8e1; border: 2px dashed #ffc107; padding: 20px; border-radius: 12px;}

/* 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; }

.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { 0% { transform: scale(0.8); } 100% { transform: scale(1); } }
@keyframes highlightBox { 0% { transform: scale(1); } 50% { transform: scale(1.1); background: #bbdefb; } 100% { transform: scale(1); } }