:root {
  --yellow: #FFD93D;
  --coral: #FF6B6B;
  --mint: #6BCB77;
  --blue: #4D96FF;
  --purple: #C77DFF;
  --bg: #fef9f0;
  --card: #ffffff;
  --text: #2d2d2d;
  --sub: #888;
  --border: #e0d6c8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  margin: 16px auto;
  max-width: 600px;
  border: 1px dashed #d8cdb9;
  border-radius: 12px;
  background: #fffdf8;
}
.ad-label {
  font-size: 12px;
  letter-spacing: 0.05em;
  color: #bbb;
}

/* 도구 간 이동 네비게이션 */
.tool-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 600px;
  margin: 16px auto 0;
  padding: 0 16px;
}
.tool-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid #ccc;
  color: #888;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.15s;
}
.tool-nav-item:hover {
  border-color: #666;
  color: #444;
}
.tool-nav-item.active {
  border-color: #222;
  color: #222;
}

.tools_header {
  background: linear-gradient(135deg, #6BCB77 0%, #4D96FF 100%);
  padding: 36px 20px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.tools_header::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
}
.tools_header h1 {
  font-family: 'Gaegu', cursive;
  font-size: 2.4rem;
  color: #fff;
  text-shadow: 2px 3px 0 rgba(0,0,0,0.12);
  position: relative; z-index: 1;
}
.tools_header p {
  color: rgba(255,255,255,0.92);
  font-size: 0.95rem;
  margin-top: 6px;
  position: relative; z-index: 1;
}

.game-main {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
}

.panel {
  background: var(--card);
  border-radius: 24px;
  padding: 28px 22px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.07);
  border: 2px solid var(--border);
  text-align: center;
}

.panel h2 {
  font-family: 'Gaegu', cursive;
  font-size: 1.5rem;
  margin-bottom: 20px;
  color: #444;
}

/* 난이도 선택 */
.level-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.level-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: #fafafa;
  font-family: 'Gaegu', cursive;
  font-size: 1.3rem;
  font-weight: 700;
  color: #444;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  width: 100%;
}
.level-btn:hover {
  border-color: var(--mint);
  background: #f0fff4;
  transform: translateY(-2px);
}

/* 게임 진행 화면 */
.level-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--sub);
  font-weight: 700;
}
.btn-change {
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  color: #888;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.75rem;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer;
}
.btn-change:hover {
  background: #e5e5e5;
}

.game-status {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--sub);
  font-weight: 700;
  margin-bottom: 20px;
}

.question {
  font-family: 'Gaegu', cursive;
  font-size: 2.6rem;
  font-weight: 700;
  color: #2a6db5;
  margin-bottom: 24px;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.choice-btn {
  padding: 20px 10px;
  border: 2.5px solid var(--border);
  border-radius: 16px;
  background: #fafafa;
  font-family: 'Gaegu', cursive;
  font-size: 1.6rem;
  font-weight: 700;
  color: #444;
  cursor: pointer;
  transition: all 0.15s;
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--blue);
  transform: translateY(-2px);
}
.choice-btn:disabled {
  cursor: default;
}
.choice-btn.correct {
  background: linear-gradient(135deg, #6BCB77, #4D96FF);
  border-color: transparent;
  color: #fff;
}
.choice-btn.wrong {
  background: #ffe5e5;
  border-color: var(--coral);
  color: var(--coral);
}

/* 정답 설명 */
.explain {
  border-top: 2px dashed var(--border);
  padding-top: 20px;
  margin-top: 10px;
}
.explain-array {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  overflow-x: auto;
  margin-bottom: 12px;
}
.explain-array .dot-row {
  display: flex;
  gap: 5px;
}
.explain-array .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--mint);
  flex: 0 0 auto;
}

/* 두 자리 수 곱셈용 가르기(분배법칙) 시각화 */
.breakdown {
  width: 100%;
}
.breakdown-bar {
  display: flex;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}
.breakdown-bar .seg {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  padding: 2px;
}
.breakdown-bar .seg-a { background: var(--blue); }
.breakdown-bar .seg-b { background: var(--coral); }
.breakdown-formula {
  font-family: 'Gaegu', cursive;
  font-size: 1.05rem;
  color: #444;
  word-break: keep-all;
}
.explain-text {
  font-family: 'Gaegu', cursive;
  font-size: 1.2rem;
  color: #444;
  margin-bottom: 18px;
}

.btn-next {
  background: linear-gradient(135deg, #6BCB77, #4D96FF);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 24px;
  font-family: 'Gaegu', cursive;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(77,150,255,0.3);
}
.btn-next:hover { transform: translateY(-2px); }

/* 결과 화면 */
.result-score {
  font-family: 'Gaegu', cursive;
  font-size: 3rem;
  font-weight: 700;
  color: #2a6db5;
  margin: 10px 0;
}
.result-message {
  font-size: 1rem;
  color: #555;
  margin-bottom: 24px;
}
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.btn-visualize {
  background: linear-gradient(135deg, #6BCB77, #4D96FF);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  font-family: 'Gaegu', cursive;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(77,150,255,0.3);
}
.btn-reset {
  background: #f0f0f0;
  border: 2px solid #e0e0e0;
  color: #888;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: 'Noto Sans KR', sans-serif;
}
.btn-next-level {
  background: linear-gradient(135deg, #FF9A3C, #C77DFF);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  font-family: 'Gaegu', cursive;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(199,125,255,0.3);
}
.btn-next-level:hover { transform: translateY(-2px); }

.tools_footer {
  text-align: center;
  padding: 40px 20px 20px;
  font-size: 0.8rem;
  color: #bbb;
}

@media (max-width: 420px) {
  .tools_header h1 { font-size: 2rem; }
  .question { font-size: 2.1rem; }
  .choice-btn { font-size: 1.35rem; padding: 16px 8px; }
}
