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

:root {
  --bg: #f4f4f0;
  --card: #ffffff;
  --text: #2b2b2b;
  --muted: #8a8a84;
  --accent: #5b7cfa;
  --correct: #3eb878;
  --wrong: #e76a6a;
  --radius: 16px;
}

body {
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px 16px 40px;
}

.app {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

header {
  text-align: center;
  padding-top: 8px;
}

header h1 {
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.tagline {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.stats {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.stat {
  flex: 1;
  text-align: center;
}

.stat .label {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.stat .value {
  font-size: 1.05rem;
  font-weight: 700;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.question {
  font-size: 1.7rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
  min-height: 2.4em;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: keep-all;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.choice-btn {
  font-size: 1.2rem;
  font-weight: 600;
  font-family: inherit;
  padding: 16px 8px;
  border: 2px solid #e3e3dd;
  border-radius: 12px;
  background: #fafaf7;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
  touch-action: manipulation;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: #f0f3ff;
}

.choice-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.choice-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.choice-btn:disabled {
  cursor: default;
  opacity: 0.75;
}

/* 색 + 테두리 + 굵기로 정답/오답 표시 (색에만 의존하지 않음) */
.choice-btn.is-correct {
  border-color: var(--correct);
  border-width: 3px;
  background: #e8f7ef;
  color: #1e7a4d;
  opacity: 1;
}

.choice-btn.is-wrong {
  border-color: var(--wrong);
  border-width: 3px;
  border-style: dashed;
  background: #fdeeee;
  color: #b03a3a;
  opacity: 1;
}

.feedback {
  min-height: 1.6em;
  margin-top: 18px;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
}

.feedback-correct {
  color: var(--correct);
}

.feedback-wrong {
  color: var(--wrong);
}

.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.next-btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 28px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.next-btn:focus-visible,
.reset-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* 새총 피젯 */
.slingshot-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 10px 16px 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.slingshot-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.slingshot {
  position: relative;
  width: 200px;
  height: 130px;
  margin: 0 auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.slingshot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pouch {
  position: absolute;
  left: 100px;
  top: 56px;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  font-size: 24px;
  line-height: 1;
  cursor: grab;
  touch-action: none;
  padding: 0;
}

.pouch.grabbing {
  cursor: grabbing;
}

.pouch:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* 날아다니는 물건 레이어 */
#fly-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.fly {
  position: fixed;
  left: 0;
  top: 0;
  will-change: transform;
  line-height: 1;
}

.slingshot-result {
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  min-height: 1.4em;
}

.sling-top {
  list-style: none;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 0.78rem;
  color: var(--muted);
  min-height: 1.3em;
  padding: 4px 0 10px;
}

footer {
  text-align: center;
  margin-top: 8px;
}

.reset-btn {
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  padding: 6px 10px;
}

/* 정답 시 살짝 pop */
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.015); }
  100% { transform: scale(1); }
}

.card.pop {
  animation: pop 0.25s ease-out;
}

/* 오답 시 살짝 shake */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.card.shake {
  animation: shake 0.25s ease-in-out;
}

@media (max-width: 360px) {
  .question {
    font-size: 1.4rem;
  }

  .choice-btn {
    font-size: 1.05rem;
    padding: 14px 6px;
  }
}

[hidden] { display: none !important; }
.learning-controls { display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 10px; align-items: center; background: var(--card); padding: 16px; border-radius: var(--radius); }
.learning-controls select { width: 100%; min-height: 42px; font: inherit; border: 1px solid #ccc; border-radius: 8px; background: white; color: var(--text); padding: 6px; }
.auto-label, .control-hint { grid-column: 1 / -1; font-size: .8rem; line-height: 1.5; }
.auto-label { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.control-hint, .topic-label { color: #62625c; }
.topic-label { font-size: .78rem; margin-bottom: 16px; line-height: 1.5; }
.question { font-size: 1.35rem; overflow-wrap: anywhere; }
.diagram:empty { display: none; }
.diagram svg { width: 100%; max-height: 210px; margin-top: 12px; }
details { margin-top: 16px; line-height: 1.7; font-size: .95rem; }
summary { cursor: pointer; padding: 8px 0; color: #3856bc; }
details p { padding: 12px; background: #f2f5ff; border-radius: 8px; overflow-wrap: anywhere; }
select:focus-visible, summary:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
