@import url("https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700;800&family=Kalam:wght@400;700&display=swap");

:root {
  --bg: #fff7ea;
  --bg-accent: #ffe0c1;
  --ink: #1d1c1a;
  --accent: #ff7a00;
  --accent-dark: #d65f00;
  --mint: #2bc7a8;
  --mint-dark: #169b7f;
  --berry: #ff4e78;
  --card: #ffffff;
  --shadow: 0 18px 45px rgba(45, 24, 8, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Baloo 2", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #fff3e4 0%, var(--bg) 50%, #ffe9d0 100%);
  overflow-x: hidden;
}

.app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  position: relative;
  z-index: 2;
}

.site-header {
  margin-bottom: 20px;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(255, 255, 255, 0.86);
  border-radius: 20px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.site-brand {
  font-weight: 800;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.site-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.site-nav a {
  text-decoration: none;
  font-weight: 700;
  color: var(--accent-dark);
  background: #fff7ef;
  border: 1px solid #ffd7b4;
  border-radius: 999px;
  padding: 7px 11px;
}

.site-nav a.site-brand {
  background: transparent;
  border: none;
  padding: 0;
}

.site-nav a:hover {
  background: var(--accent);
  color: #fff;
}

.hero {
  text-align: center;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 6px 18px;
  border-radius: 999px;
  background: var(--mint);
  color: white;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.hero h1 {
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  margin: 16px 0 8px;
}

.hero p {
  font-size: 1.1rem;
  margin: 0;
  width: 100%;
  text-align: center;
}

.hero-story {
  font-size: 1rem;
  opacity: 0.88;
  max-width: 780px;
  width: 100%;
  margin: 10px auto 0;
  text-align: center;
  white-space: pre-line;
}

.kakao-ad-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 20px auto 28px;
  overflow: hidden;
}

.kakao-ad-slot-middle {
  margin: 32px auto;
}

.kakao-ad-slot .kakao_ad_area,
.kakao-ad-slot iframe {
  border: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.panel {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr);
}

.controls {
  display: grid;
  gap: 16px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.control label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}

.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-weight: 700;
  cursor: pointer;
}

.inline-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--mint);
}

.control .small {
  margin: 8px 0 0;
}

.start-control {
  display: grid;
  gap: 8px;
}

.start-btn {
  width: 100%;
}

.tts-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.tts-controls .select {
  max-width: 320px;
}

.question-tts {
  text-align: center;
  font-weight: 700;
  color: #b25a00;
  min-height: 22px;
  margin-top: -6px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 2px solid transparent;
  padding: 8px 14px;
  border-radius: 999px;
  background: #ffe2c8;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s ease;
}

.chip.active {
  background: var(--accent);
  color: white;
  border-color: rgba(255, 255, 255, 0.5);
}

.toggle {
  display: inline-flex;
  flex-wrap: wrap;
  background: #fdf0e2;
  border-radius: 999px;
  padding: 4px;
}

.toggle-btn {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
}

.toggle-btn.active {
  background: var(--berry);
  color: white;
}

.range {
  display: flex;
  align-items: center;
  gap: 12px;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid #ffe2c8;
  background: #fff7ef;
  font-family: inherit;
  font-weight: 700;
}

.quiz {
  position: relative;
}

.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.hearts {
  display: flex;
  gap: 6px;
  font-size: 1.4rem;
}

.score {
  background: #fff1de;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
}

.card {
  background: var(--card);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.card-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  opacity: 0.7;
}

.question {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-family: "Baloo 2", "Segoe UI", sans-serif;
  text-align: center;
  margin: 20px 0;
}

.answers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.answer-btn {
  border: none;
  background: #fef6ef;
  padding: 14px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.answer-btn:hover {
  transform: translateY(-2px);
}

.answer-btn.correct {
  background: var(--mint);
  color: white;
}

.answer-btn.wrong {
  background: #ffe0e0;
  color: #b93232;
}

.feedback {
  text-align: center;
  font-size: 1.1rem;
  min-height: 28px;
  margin: 16px 0 8px;
  font-weight: 700;
}

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

button.primary,
button.ghost {
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: white;
}

button.primary:disabled {
  background: #ffd0a6;
  cursor: not-allowed;
}

button.ghost {
  background: transparent;
  border: 2px dashed var(--accent);
  color: var(--accent-dark);
}

.result {
  display: none;
  text-align: center;
  background: var(--card);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.result h2 {
  margin-top: 0;
}

.result .small {
  font-size: 0.95rem;
  opacity: 0.7;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
}

.review {
  margin-top: 20px;
  text-align: left;
}

.history {
  display: grid;
  gap: 20px;
}

.panel + .history {
  margin-top: 14px;
}

.content-stack {
  margin-top: 20px;
}

.legal-page {
  max-width: 860px;
}

.legal-topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
}

.legal-topbar label {
  font-weight: 700;
}

.legal-select {
  max-width: 220px;
}

.legal-stack {
  display: grid;
  gap: 16px;
}

.legal-card h2 {
  margin-top: 0;
  margin-bottom: 10px;
}

.legal-card h3 {
  margin: 16px 0 8px;
}

.legal-card p {
  margin: 0 0 10px;
}

.legal-card p:last-child {
  margin-bottom: 0;
}

.legal-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.legal-inline-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.legal-inline-links a {
  text-decoration: none;
  font-weight: 700;
  color: var(--accent-dark);
  background: #fff7ef;
  border: 1px solid #ffd7b4;
  border-radius: 999px;
  padding: 8px 12px;
}

.site-footer {
  margin-top: 20px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.site-footer-links {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.site-footer a {
  text-decoration: none;
  font-weight: 700;
  color: var(--accent-dark);
  background: #fff7ef;
  border: 1px solid #ffd7b4;
  border-radius: 999px;
  padding: 8px 12px;
}

.site-footer a:hover {
  background: var(--accent);
  color: #fff;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(255, 122, 0, 0.45);
  outline-offset: 2px;
}

.history-card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.history-card h3 {
  margin-top: 0;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.history-item {
  background: #fff7ef;
  padding: 12px 14px;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.history-item span {
  font-weight: 600;
  opacity: 0.8;
}

canvas#historyChart {
  width: 100%;
  height: 240px;
  margin-top: 12px;
  background: linear-gradient(180deg, #fff7ef 0%, #ffffff 100%);
  border-radius: 16px;
}

.hidden {
  display: none;
}

.ghost.small {
  padding: 6px 14px;
  font-size: 0.9rem;
}

.review-item {
  background: #fff7ef;
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 8px;
}

.bg-shape {
  position: fixed;
  border-radius: 50%;
  z-index: 1;
  filter: blur(0px);
  opacity: 0.6;
}

.shape-1 {
  width: 300px;
  height: 300px;
  background: #ffd2b3;
  top: -80px;
  left: -60px;
}

.shape-2 {
  width: 240px;
  height: 240px;
  background: #c8f3eb;
  bottom: -80px;
  right: -40px;
}

.shape-3 {
  width: 180px;
  height: 180px;
  background: #ffe5f0;
  top: 40%;
  right: 10%;
}

@media (max-width: 720px) {
  .kakao-ad-slot {
    margin: 16px auto 22px;
  }

  .kakao-ad-slot-middle {
    margin: 24px auto;
  }

  .site-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .site-nav-links {
    justify-content: flex-start;
  }

  .controls {
    padding: 18px;
  }

  .card,
  .result {
    padding: 20px;
  }

  .actions,
  .result-actions {
    flex-direction: column;
  }

  .legal-inline-links,
  .site-footer-links {
    justify-content: flex-start;
  }

  .legal-topbar {
    justify-content: flex-start;
  }
}

@keyframes pop {
  0% {
    transform: scale(0.95);
  }
  70% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.pop {
  animation: pop 0.35s ease;
}
