:root {
  --duo-green: #58cc02;
  --duo-green-dark: #46a302;
  --duo-green-soft: #e9ffd2;
  --duo-blue-soft: #e8f7ff;
  --duo-ink: #23343b;
  --duo-muted: #7a878d;
  --duo-line: #d8e0e5;
  --duo-bg: #f7fbf5;
  --duo-card: #ffffff;
  --duo-danger: #ff6b6b;
  --duo-yellow-soft: #fff6c9;
  --font-display: "Baloo 2", "Noto Sans KR", sans-serif;
  --font-body: "Noto Sans KR", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--duo-ink);
  background:
    linear-gradient(180deg, #f2ffe3 0%, #f7fbf5 18%, #f7fbf5 100%);
}

button,
input,
textarea {
  font: inherit;
}

h1,
h2,
p {
  margin: 0;
}

strong,
span {
  margin: 0;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 18px 16px 200px;
}

.topbar {
  display: grid;
  gap: 16px;
}

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

.brand-badge {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #70eb18 0%, var(--duo-green) 100%);
  color: white;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.14);
}

.eyebrow,
.question-kicker {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--duo-muted);
  font-weight: 800;
  margin-bottom: 2px;
}

h1,
h2,
.service-card span,
.pill,
.feedback,
.primary-button,
.ghost-button,
.choice-chip,
.word-chip {
  font-family: var(--font-display);
}

h1 {
  font-size: 1.9rem;
  line-height: 1;
}

.service-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.service-card {
  border: 2px solid var(--duo-line);
  border-radius: 22px;
  background: var(--duo-card);
  min-height: 72px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--duo-ink);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(35, 52, 59, 0.08);
}

.service-card.is-active {
  border-color: var(--duo-green);
  background: var(--duo-green-soft);
}

.service-avatar,
.coach-avatar {
  object-fit: cover;
}

.service-avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
}

.service-card span {
  font-size: 1.08rem;
  font-weight: 700;
}

.progress-card,
.coach-strip,
.quiz-card {
  background: var(--duo-card);
  border: 1px solid rgba(216, 224, 229, 0.95);
  border-radius: 26px;
}

.progress-card {
  padding: 14px 16px;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--duo-blue-soft);
  color: #1089ca;
  padding: 6px 12px;
  font-size: 0.95rem;
  font-weight: 700;
}

.progress-track {
  height: 16px;
  border-radius: 999px;
  background: #e7edf1;
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #84ef3a 0%, var(--duo-green) 100%);
  transition: width 200ms ease;
}

.coach-strip {
  margin-top: 16px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.coach-avatar {
  width: 64px;
  height: 64px;
  border-radius: 20px;
}

.coach-copy {
  min-width: 0;
}

.coach-copy strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}

.coach-copy p {
  color: var(--duo-muted);
  line-height: 1.45;
}

.quiz-card {
  margin-top: 16px;
  padding: 22px 16px;
  min-height: 56vh;
  margin-bottom: 20px;
}

.empty-state,
.quiz-stage {
  min-height: 100%;
}

.empty-state {
  display: grid;
  place-content: center;
  text-align: center;
  gap: 8px;
}

.empty-state p {
  color: var(--duo-muted);
}

.quiz-stage {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.question-header h2 {
  font-size: clamp(1.9rem, 7vw, 2.35rem);
  line-height: 1.08;
}

.song-meta {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--duo-yellow-soft);
  color: #7c6600;
  padding: 7px 12px;
  font-size: 0.92rem;
  font-weight: 700;
}

.question-body {
  display: grid;
  gap: 16px;
}

.line-preview,
.prompt-panel,
.answer-panel {
  border: 2px solid var(--duo-line);
  border-radius: 24px;
  padding: 16px;
  background: #fbfdff;
}

.line-preview {
  background: #fffdf1;
}

.line-label {
  display: block;
  margin-bottom: 8px;
  color: var(--duo-muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.lyric-line {
  font-size: clamp(1.18rem, 4.8vw, 1.55rem);
  font-weight: 700;
  line-height: 1.7;
}

.input-field {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  border: 2px solid var(--duo-line);
  border-radius: 18px;
  padding: 16px;
  background: white;
  font-size: 1rem;
  line-height: 1.6;
}

.input-field:focus {
  outline: none;
  border-color: var(--duo-green);
}

.choices-grid,
.word-bank,
.selected-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.choice-chip,
.word-chip {
  min-height: 50px;
  padding: 12px 15px;
  border-radius: 18px;
  border: 2px solid var(--duo-line);
  background: white;
  color: var(--duo-ink);
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 4px 0 rgba(35, 52, 59, 0.06);
  cursor: pointer;
}

.choice-chip.is-correct,
.word-chip.is-selected {
  border-color: var(--duo-green);
  background: #f4ffe9;
}

.choice-chip.is-wrong {
  border-color: var(--duo-danger);
  background: #fff0f0;
}

.answer-panel {
  display: grid;
  gap: 14px;
}

.assembled-line {
  min-height: 84px;
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border: 2px dashed var(--duo-line);
  border-radius: 18px;
  background: white;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.6;
}

.feedback {
  min-height: 30px;
  font-size: 1.05rem;
  font-weight: 700;
  display: none;
}

.feedback.success {
  color: var(--duo-green-dark);
}

.feedback.error {
  color: #de4c4c;
}

.question-actions,
.bottom-bar {
  display: grid;
  gap: 10px;
}

.question-actions {
  padding-bottom: 12px;
}

.primary-button,
.ghost-button,
.action-button {
  min-height: 54px;
  border-radius: 18px;
  padding: 14px 18px;
  border: 0;
  font-size: 1.02rem;
  font-weight: 800;
  cursor: pointer;
}

.primary-button,
.action-button {
  background: linear-gradient(180deg, #73ea1c 0%, var(--duo-green) 100%);
  color: white;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.13);
}

.ghost-button {
  background: white;
  color: var(--duo-ink);
  border: 2px solid var(--duo-line);
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(247, 251, 245, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(216, 224, 229, 0.95);
}

.celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.intro-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(247, 251, 245, 0.5);
  backdrop-filter: blur(4px);
  animation: intro-fade 950ms ease forwards;
}

.intro-card {
  position: relative;
  width: min(82vw, 320px);
  display: grid;
  justify-items: center;
  gap: 14px;
  animation: intro-pop 950ms cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

.intro-image {
  width: 140px;
  height: 140px;
  border-radius: 36px;
  object-fit: cover;
  border: 8px solid white;
  box-shadow: 0 20px 40px rgba(35, 52, 59, 0.16);
}

.intro-bubble {
  width: 100%;
  padding: 16px 18px;
  border-radius: 24px;
  background: white;
  border: 2px solid var(--duo-line);
  box-shadow: 0 16px 30px rgba(35, 52, 59, 0.1);
  text-align: center;
}

.intro-name {
  display: block;
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.intro-line {
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1.08;
}

.celebration-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(88, 204, 2, 0.18), rgba(88, 204, 2, 0) 58%);
  animation: celebration-fade 1300ms ease forwards;
}

.celebration-card {
  position: relative;
  width: min(88vw, 340px);
  min-height: 360px;
  padding: 28px 24px 22px;
  border-radius: 36px;
  background: linear-gradient(180deg, #ffffff 0%, #f3ffe5 100%);
  border: 3px solid #b8ea90;
  box-shadow: 0 30px 80px rgba(51, 92, 17, 0.22);
  display: grid;
  justify-items: center;
  align-content: start;
  overflow: hidden;
  animation: celebration-pop 1300ms cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

.celebration-card.is-fire {
  background: linear-gradient(180deg, #fffef7 0%, #efffd9 55%, #e0ffbc 100%);
  border-color: #86dd2f;
}

.celebration-card.is-gold {
  background: linear-gradient(180deg, #fffef4 0%, #fff4bf 50%, #ffe08e 100%);
  border-color: #ffcf4b;
}

.celebration-card.is-orange {
  background: linear-gradient(180deg, #fff7ef 0%, #ffdcae 52%, #ffbb75 100%);
  border-color: #ff9a31;
}

.celebration-card.is-legend {
  background: linear-gradient(180deg, #fff0ed 0%, #ffcabf 42%, #ff9b8e 100%);
  border-color: #ff5d43;
  box-shadow: 0 30px 90px rgba(255, 99, 71, 0.28);
}

.celebration-burst {
  position: absolute;
  border-radius: 999px;
  opacity: 0.8;
}

.celebration-burst-a {
  width: 120px;
  height: 120px;
  top: -30px;
  left: -22px;
  background: #d6ff9f;
}

.celebration-burst-b {
  width: 92px;
  height: 92px;
  top: 26px;
  right: -18px;
  background: #fff2a5;
}

.celebration-burst-c {
  width: 74px;
  height: 74px;
  bottom: 74px;
  right: 36px;
  background: #c4f7ff;
}

.celebration-ring {
  position: absolute;
  top: 28px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.95) 0%, rgba(233,255,210,0.9) 48%, rgba(233,255,210,0) 66%);
}

.celebration-image {
  position: relative;
  width: 164px;
  height: 164px;
  border-radius: 42px;
  object-fit: cover;
  border: 8px solid white;
  box-shadow: 0 18px 32px rgba(35, 52, 59, 0.16);
  margin-top: 16px;
  z-index: 1;
}

.celebration-copy {
  position: relative;
  margin-top: 18px;
  text-align: center;
  z-index: 1;
}

.celebration-kicker {
  display: block;
  color: var(--duo-green-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.celebration-title {
  display: block;
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 0.98;
}

.celebration-detail {
  margin-top: 10px;
  color: #54715d;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.45;
}

.celebration-streak {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 68px;
  height: 68px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #79ee21 0%, var(--duo-green) 100%);
  color: white;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.13);
  z-index: 1;
}

.result-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 24px;
  background: #ffffff;
  border: 1px solid rgba(216, 224, 229, 0.95);
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.result-panel.is-success {
  background: #ebffd7;
  border-color: #b9ec8c;
  box-shadow: 0 12px 24px rgba(88, 204, 2, 0.18);
  animation: success-pop 300ms ease;
}

.result-panel.is-error {
  background: #fff1f1;
  border-color: #ffc6c6;
  box-shadow: 0 12px 24px rgba(255, 107, 107, 0.12);
}

.result-panel.tier-lime.is-success {
  background: #efffd6;
  border-color: #bef181;
  box-shadow: 0 12px 24px rgba(126, 219, 42, 0.18);
}

.result-panel.tier-yellow.is-success {
  background: #fff8cb;
  border-color: #ffe17a;
  box-shadow: 0 12px 24px rgba(255, 211, 63, 0.18);
}

.result-panel.tier-orange.is-success {
  background: #ffe6c8;
  border-color: #ffb55e;
  box-shadow: 0 12px 24px rgba(255, 153, 51, 0.18);
}

.result-panel.tier-red.is-success {
  background: #ffd7d2;
  border-color: #ff7a67;
  box-shadow: 0 12px 24px rgba(255, 92, 67, 0.2);
}

.result-copy {
  min-width: 0;
}

.result-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--duo-muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-title {
  display: block;
  font-size: 1.15rem;
  line-height: 1.1;
  font-family: var(--font-display);
}

.result-detail {
  margin-top: 4px;
  color: #5d6b71;
  font-size: 0.95rem;
  line-height: 1.4;
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 72px;
  padding: 10px 12px;
  border-radius: 20px;
  background: linear-gradient(180deg, #7aee22 0%, var(--duo-green) 100%);
  color: white;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.13);
  animation: streak-bounce 340ms ease;
}

.streak-badge.tier-green {
  background: linear-gradient(180deg, #79ee21 0%, var(--duo-green) 100%);
}

.streak-badge.tier-lime {
  background: linear-gradient(180deg, #b9f43b 0%, #80d70f 100%);
}

.streak-badge.tier-yellow {
  background: linear-gradient(180deg, #ffe45a 0%, #ffbe1f 100%);
}

.streak-badge.tier-orange {
  background: linear-gradient(180deg, #ffb24a 0%, #ff7c21 100%);
}

.streak-badge.tier-red {
  background: linear-gradient(180deg, #ff7a67 0%, #ff4331 100%);
}

.primary-button.is-success {
  background: linear-gradient(180deg, #7aee22 0%, var(--duo-green) 100%);
}

.primary-button.is-success.tier-green {
  background: linear-gradient(180deg, #7aee22 0%, var(--duo-green) 100%);
}

.primary-button.is-success.tier-lime {
  background: linear-gradient(180deg, #b8f13b 0%, #82da0f 100%);
}

.primary-button.is-success.tier-yellow {
  background: linear-gradient(180deg, #ffe768 0%, #ffc928 100%);
  color: #5a4300;
  box-shadow: inset 0 -4px 0 rgba(122, 86, 0, 0.18);
}

.primary-button.is-success.tier-orange {
  background: linear-gradient(180deg, #ffb35a 0%, #ff8526 100%);
}

.primary-button.is-success.tier-red {
  background: linear-gradient(180deg, #ff7d6e 0%, #ff4735 100%);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, 0.13),
    0 0 0 4px rgba(255, 90, 59, 0.12);
}

.primary-button.is-error {
  background: linear-gradient(180deg, #ff8f8f 0%, #ff6b6b 100%);
}

@keyframes success-pop {
  0% {
    transform: scale(0.97);
  }
  60% {
    transform: scale(1.015);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes streak-bounce {
  0% {
    transform: scale(0.8) translateY(8px);
    opacity: 0;
  }
  60% {
    transform: scale(1.08) translateY(-2px);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes celebration-pop {
  0% {
    transform: translateY(28px) scale(0.78);
    opacity: 0;
  }
  18% {
    transform: translateY(-8px) scale(1.03);
    opacity: 1;
  }
  82% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-12px) scale(0.96);
    opacity: 0;
  }
}

@keyframes celebration-fade {
  0% {
    opacity: 0;
  }
  16% {
    opacity: 1;
  }
  82% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes intro-pop {
  0% {
    transform: translateY(18px) scale(0.88);
    opacity: 0;
  }
  18% {
    transform: translateY(-4px) scale(1.01);
    opacity: 1;
  }
  78% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-10px) scale(0.98);
    opacity: 0;
  }
}

@keyframes intro-fade {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (min-width: 760px) {
  .app-shell {
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 220px;
  }

  .question-actions {
    grid-template-columns: 1fr 1fr;
  }

  .bottom-bar {
    grid-template-columns: minmax(0, 1.5fr) 1fr 1fr;
    align-items: stretch;
  }
}
