:root {
  --ink: #203247;
  --muted: #667487;
  --line: #e5e2dc;
  --paper: #fffefa;
  --cream: #fff8f2;
  --sky: #45aeef;
  --green: #45c58a;
  --violet: #8c72e8;
  --gold: #ffc857;
  --coral: #ff7d6e;
  --soft-blue: #edf8ff;
  font-family: "Zen Kaku Gothic New", sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
}

button { font: inherit; }

button:focus-visible {
  outline: 4px solid rgba(69, 174, 239, 0.3);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.app-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  padding: clamp(24px, 5vw, 64px) 20px;
  background:
    radial-gradient(circle at 12% 15%, rgba(255, 200, 87, 0.17) 0 3px, transparent 3.5px),
    radial-gradient(circle at 87% 31%, rgba(140, 114, 232, 0.12) 0 4px, transparent 4.5px),
    radial-gradient(circle at 76% 90%, rgba(69, 197, 138, 0.13) 0 3px, transparent 3.5px),
    linear-gradient(145deg, #fff8f2 0%, #fffef9 48%, #f2fbff 100%);
}

.background-shape {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(0.2px);
}

.shape-one {
  top: -85px;
  left: -72px;
  width: 220px;
  height: 220px;
  background: rgba(255, 200, 87, 0.2);
}

.shape-two {
  top: 28%;
  right: -96px;
  width: 240px;
  height: 240px;
  background: rgba(69, 174, 239, 0.13);
}

.shape-three {
  bottom: -110px;
  left: 8%;
  width: 260px;
  height: 260px;
  background: rgba(69, 197, 138, 0.12);
}

.quiz-frame {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
}

.app-header,
.screen {
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 30px;
  background: rgba(255, 254, 250, 0.96);
  box-shadow:
    0 18px 0 rgba(32, 50, 71, 0.025),
    0 20px 48px rgba(74, 93, 113, 0.12);
}

.app-header {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 5vw, 46px);
}

.app-header::before,
.app-header::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.app-header::before {
  top: -64px;
  right: -46px;
  width: 190px;
  height: 190px;
  border: 32px solid rgba(69, 197, 138, 0.13);
  border-radius: 50%;
}

.app-header::after {
  right: 118px;
  bottom: -27px;
  width: 82px;
  height: 54px;
  border-radius: 50% 50% 12px 12px;
  background: rgba(255, 125, 110, 0.1);
  transform: rotate(-12deg);
}

body[data-screen="quiz"] .app-header,
body[data-screen="result"] .app-header { display: none; }

html[data-embed="true"] {
  background: var(--cream);
}

html[data-embed="true"] body {
  min-height: 0;
}

html[data-embed="true"] .app-shell {
  min-height: auto;
  padding: 8px;
  overflow: visible;
  background: var(--cream);
}

html[data-embed="true"] .background-shape,
html[data-embed="true"] .app-header {
  display: none;
}

html[data-embed="true"] .screen {
  margin-top: 0;
  box-shadow: 0 10px 28px rgba(74, 93, 113, 0.09);
}

.eyebrow {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #218ac7;
  font: 800 0.78rem/1 "DM Sans", sans-serif;
  letter-spacing: 0.13em;
}

.eyebrow::before {
  content: "";
  width: 25px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
  transform: rotate(-4deg);
}

.page-title,
.section-title,
.course-name,
.question-text,
.result-rank-wrap strong {
  font-family: "Zen Maru Gothic", "Zen Kaku Gothic New", sans-serif;
}

.page-title {
  position: relative;
  margin: 13px 0 9px;
  font-size: clamp(1.8rem, 5vw, 2.15rem);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.page-title::after {
  content: "✦";
  display: inline-block;
  margin-left: 10px;
  color: var(--gold);
  font-size: 0.62em;
  vertical-align: top;
  transform: rotate(12deg);
}

.page-intro {
  position: relative;
  max-width: 610px;
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.quick-tags {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.quick-tags span {
  padding: 6px 11px;
  border: 1px solid rgba(69, 174, 239, 0.16);
  border-radius: 999px;
  color: #3e687f;
  background: #f1faff;
  font-size: 0.78rem;
  font-weight: 700;
}

.quick-tags span:nth-child(2) { background: #effbf5; border-color: rgba(69, 197, 138, 0.18); }
.quick-tags span:nth-child(3) { background: #fff8e6; border-color: rgba(255, 200, 87, 0.26); }

.screen {
  position: relative;
  margin-top: 22px;
  padding: clamp(22px, 4vw, 40px);
  animation: screen-in 170ms ease-out;
}

body[data-screen="quiz"] .screen,
body[data-screen="result"] .screen { margin-top: 0; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(7px) scale(0.995); }
  to { opacity: 1; transform: none; }
}

.section-title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1.35;
}

.section-lead {
  margin: 9px 0 26px;
  color: var(--muted);
  line-height: 1.75;
}

.course-select {
  overflow: hidden;
  background:
    radial-gradient(circle at 94% 6%, rgba(255, 200, 87, 0.22) 0 48px, transparent 49px),
    linear-gradient(145deg, rgba(255, 252, 246, 0.98), rgba(255, 255, 255, 0.98) 54%, rgba(239, 251, 245, 0.95));
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.course-card {
  position: relative;
  display: block;
  min-height: 205px;
  padding: 21px 21px 48px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 23px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(32, 50, 71, 0.045);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.course-card::after {
  content: "→";
  position: absolute;
  right: 18px;
  bottom: 16px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  font-weight: 900;
}

.course-card:hover {
  transform: translateY(-4px) rotate(-0.35deg);
  box-shadow: 0 12px 0 rgba(32, 50, 71, 0.055), 0 16px 28px rgba(74, 93, 113, 0.11);
}

.course-card:active { transform: translateY(-1px); }
.course-card.beginner { border-color: #a9e9ca; background: linear-gradient(145deg, #effcf5, #fffefa 76%); }
.course-card.intermediate { border-color: #adddf8; background: linear-gradient(145deg, #eff9ff, #fffefa 76%); }
.course-card.advanced { border-color: #cfc3f6; background: linear-gradient(145deg, #f6f2ff, #fffefa 76%); }
.course-card.all { border-color: #f2d78c; background: linear-gradient(145deg, #fff8e7, #fff6f3 50%, #f4f1ff); }

.course-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 5px 12px rgba(61, 77, 92, 0.08);
  font-size: 1.45rem;
  transform: rotate(4deg);
}

.course-copy { display: block; padding-right: 42px; }
.course-level,
.course-name,
.course-description { display: block; }
.course-level { margin-bottom: 7px; font: 800 0.75rem/1 "DM Sans", sans-serif; letter-spacing: 0.08rem; }
.beginner .course-level { color: #249865; }
.intermediate .course-level { color: #278dca; }
.advanced .course-level { color: #7459cf; }
.all .course-level { color: #b97a11; }
.course-name { margin-bottom: 8px; font-size: 1.2rem; font-weight: 900; }
.course-description { color: var(--muted); font-size: 0.88rem; line-height: 1.65; }

.course-count {
  position: absolute;
  left: 18px;
  bottom: 17px;
  padding: 5px 10px;
  border-radius: 999px;
  color: #3f6070;
  background: rgba(255, 255, 255, 0.83);
  font-size: 0.76rem;
  font-weight: 700;
}

.quiz-topline,
.score-line,
.question-meta,
.next-row,
.result-actions { display: flex; align-items: center; }
.quiz-topline { justify-content: space-between; gap: 14px; }
.course-pill { padding: 7px 14px; border-radius: 999px; color: #fff; font-size: 0.82rem; font-weight: 900; box-shadow: 0 4px 0 rgba(32, 50, 71, 0.08); }
.progress-copy { color: var(--muted); font-size: 0.9rem; font-weight: 700; }

.progress-track {
  height: 7px;
  margin: 18px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #ebeef0;
}

.progress-bar { height: 100%; width: 0; border-radius: inherit; transition: width 180ms ease; }

.progress-dots {
  display: grid;
  grid-template-columns: repeat(var(--dot-count, 10), minmax(5px, 1fr));
  gap: 5px;
}

.progress-dot {
  height: 6px;
  border-radius: 999px;
  background: #e3e7ea;
  transition: background 150ms ease, transform 150ms ease;
}

.progress-dot.is-done { background: var(--course-color, var(--sky)); opacity: 0.55; }
.progress-dot.is-current { background: var(--course-color, var(--sky)); transform: scaleY(1.55); }
.score-line { justify-content: flex-end; margin-top: 9px; color: #4c6777; font-size: 0.84rem; font-weight: 700; }
.score-line span { padding: 5px 10px; border-radius: 999px; background: #f4f6f7; }
.question-meta { gap: 8px; margin-top: 22px; }
.meta-tag { padding: 5px 10px; border: 1px solid #dee5e9; border-radius: 999px; color: #536b79; background: #fafbfb; font-size: 0.76rem; font-weight: 700; }
.question-text { margin: 15px 0 23px; font-size: clamp(1.24rem, 4vw, 1.58rem); font-weight: 900; line-height: 1.55; }
.question-text:focus { outline: none; }
.answers { display: grid; gap: 11px; }

.answer-button {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 58px;
  padding: 12px 44px 12px 16px;
  border: 2px solid #e1e6e8;
  border-radius: 17px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 4px 0 rgba(32, 50, 71, 0.045);
  text-align: left;
  line-height: 1.5;
  cursor: pointer;
  transition: border-color 130ms ease, background 130ms ease, transform 130ms ease, box-shadow 130ms ease;
}

.answer-button:hover:not(:disabled) {
  transform: translateX(4px);
  border-color: #8bcaef;
  background: #f5fbff;
  box-shadow: 0 5px 0 rgba(69, 174, 239, 0.13);
}

.answer-button:active:not(:disabled) { transform: translateX(2px) scale(0.995); }
.answer-button:disabled { cursor: default; opacity: 1; }
.answer-key { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 13px; color: #39708e; background: #edf8ff; font: 800 0.88rem/1 "DM Sans", sans-serif; }
.answer-button.is-correct { border-color: #73d6a8; background: #effbf5; }
.answer-button.is-correct .answer-key { color: #fff; background: var(--green); }
.answer-button.is-correct::after { content: "○"; position: absolute; right: 16px; color: #248a5e; font-size: 1.18rem; font-weight: 900; }
.answer-button.is-selected-wrong { border-color: #f1a19a; background: #fff3f1; }
.answer-button.is-selected-wrong .answer-key { color: #fff; background: var(--coral); }
.answer-button.is-selected-wrong::after { content: "×"; position: absolute; right: 16px; color: #c9564d; font-size: 1.22rem; font-weight: 900; }
.keyboard-hint { margin: 11px 2px 0; color: #84909b; font-size: 0.74rem; text-align: right; }

.feedback { margin-top: 17px; padding: 16px 18px; border: 2px solid; border-radius: 17px; }
.feedback.correct { border-color: #9be1bf; background: #effbf5; }
.feedback.wrong { border-color: #f3b4ae; background: #fff4f2; }
.feedback-result { margin: 0 0 5px; font-family: "Zen Maru Gothic", sans-serif; font-size: 1.02rem; font-weight: 900; }
.feedback.correct .feedback-result { color: #167a50; }
.feedback.wrong .feedback-result { color: #af4c44; }
.correct-answer { margin: 0 0 7px; font-weight: 700; }
.explanation { margin: 0; color: #49616f; line-height: 1.72; }
.next-row { justify-content: flex-end; margin-top: 17px; }

.action-button,
.secondary-button {
  min-height: 48px;
  padding: 11px 19px;
  border-radius: 15px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 130ms ease, box-shadow 130ms ease, background 130ms ease;
}

.action-button { border: 2px solid #278fcc; color: #fff; background: var(--sky); box-shadow: 0 6px 0 #2486bd; }
.action-button:hover { transform: translateY(-2px); background: #38a3e3; box-shadow: 0 8px 0 #2486bd; }
.action-button:active { transform: translateY(3px); box-shadow: 0 3px 0 #2486bd; }
.secondary-button { border: 2px solid #d7e1e5; color: #386174; background: #fff; box-shadow: 0 4px 0 rgba(32, 50, 71, 0.06); }
.secondary-button:hover { transform: translateY(-1px); background: #f6fafb; }

#result {
  overflow: hidden;
  border-color: rgba(255, 255, 255, 0.96);
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 200, 87, 0.23) 0 52px, transparent 53px),
    radial-gradient(circle at 95% 27%, rgba(69, 174, 239, 0.16) 0 72px, transparent 73px),
    linear-gradient(155deg, #fffdf7, #fff 55%, #f6f3ff);
}

.result-kicker { margin: 0 0 7px; color: #e56357; font: 800 0.78rem/1 "DM Sans", sans-serif; letter-spacing: 0.15em; }
.result-title { font-size: clamp(1.7rem, 5vw, 2.1rem); }
.result-title:focus { outline: none; }
.result-rank-wrap { margin: 4px auto 21px; text-align: center; }
.result-rank-wrap span { display: block; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.result-rank-wrap strong { display: block; margin-top: 4px; color: #6c50c8; font-size: clamp(2rem, 8vw, 3.5rem); font-weight: 900; line-height: 1.15; text-shadow: 3px 3px 0 rgba(255, 200, 87, 0.42); }
.result-summary { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 12px; align-items: stretch; }
.result-stat { display: grid; min-height: 116px; padding: 17px 10px; place-content: center; border: 2px solid #e3e6e8; border-radius: 19px; background: rgba(255, 255, 255, 0.86); box-shadow: 0 6px 0 rgba(32, 50, 71, 0.045); text-align: center; }
.result-score-stat { border-color: #f2d07d; background: #fff9e9; transform: rotate(-1deg); }
.result-stat strong,
.result-stat span { display: block; }
.result-stat strong { color: #278fcc; font: 800 clamp(1.35rem, 5vw, 1.9rem)/1.2 "DM Sans", sans-serif; }
.result-score-stat strong { color: #d68a18; font-size: clamp(1.6rem, 6vw, 2.25rem); }
.result-stat span { margin-top: 6px; color: var(--muted); font-size: 0.75rem; }
.result-message { margin-top: 21px; padding: 16px 18px; border: 2px solid #b8e0f7; border-radius: 17px; color: #276681; background: var(--soft-blue); font-family: "Zen Maru Gothic", sans-serif; font-size: 1.08rem; font-weight: 900; text-align: center; }
.result-note { color: var(--muted); line-height: 1.7; }
.result-actions { position: relative; z-index: 2; flex-wrap: wrap; gap: 11px; }
.perfect-message { width: 100%; padding: 10px 13px; border-radius: 13px; color: #14794f; background: #effbf5; font-weight: 700; text-align: center; }

#result.result-perfect .result-rank-wrap strong { color: #db8712; }
#result.result-high .result-rank-wrap strong { color: #7257d2; }
#result.result-mid .result-rank-wrap strong { color: #278fcc; }
#result.result-low .result-rank-wrap strong { color: #df665a; }

.result-confetti { position: absolute; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; }
.result-confetti i { --x: 10%; --delay: 0s; --duration: 2.2s; position: absolute; top: -20px; left: var(--x); width: 10px; height: 18px; border-radius: 3px; background: var(--gold); animation: confetti-fall var(--duration) var(--delay) ease-in-out both; }
.result-confetti i:nth-child(2) { --x: 18%; --delay: 0.18s; --duration: 2.5s; background: var(--sky); transform: rotate(28deg); }
.result-confetti i:nth-child(3) { --x: 28%; --delay: 0.04s; --duration: 2.1s; background: var(--coral); }
.result-confetti i:nth-child(4) { --x: 38%; --delay: 0.31s; --duration: 2.45s; background: var(--green); transform: rotate(55deg); }
.result-confetti i:nth-child(5) { --x: 47%; --delay: 0.13s; --duration: 2.3s; background: var(--violet); }
.result-confetti i:nth-child(6) { --x: 57%; --delay: 0.38s; --duration: 2.15s; background: var(--gold); }
.result-confetti i:nth-child(7) { --x: 66%; --delay: 0.06s; --duration: 2.4s; background: var(--sky); transform: rotate(34deg); }
.result-confetti i:nth-child(8) { --x: 74%; --delay: 0.26s; --duration: 2.2s; background: var(--coral); }
.result-confetti i:nth-child(9) { --x: 82%; --delay: 0.11s; --duration: 2.55s; background: var(--green); }
.result-confetti i:nth-child(10) { --x: 91%; --delay: 0.35s; --duration: 2.25s; background: var(--violet); transform: rotate(60deg); }
.result-confetti i:nth-child(11) { --x: 34%; --delay: 0.52s; --duration: 2.1s; background: var(--gold); }
.result-confetti i:nth-child(12) { --x: 70%; --delay: 0.48s; --duration: 2.35s; background: var(--coral); }

@keyframes confetti-fall {
  0% { opacity: 0; translate: 0 -15px; rotate: 0deg; }
  10% { opacity: 1; }
  100% { opacity: 0; translate: 28px 560px; rotate: 460deg; }
}

@media (max-width: 560px) {
  .app-shell { padding: 18px 13px 28px; }
  .app-header,
  .screen { border-radius: 23px; }
  .app-header { padding: 25px 22px; }
  .page-title { font-size: 1.52rem; letter-spacing: -0.045em; }
  .page-intro { font-size: 0.92rem; line-height: 1.7; }
  .quick-tags { gap: 6px; }
  .quick-tags span { padding: 5px 9px; font-size: 0.72rem; }
  .screen { padding: 22px 18px; }
  .section-title { font-size: 1.38rem; }
  .section-lead { margin-bottom: 21px; font-size: 0.9rem; line-height: 1.65; }
  .course-grid { grid-template-columns: 1fr; }
  .course-card { min-height: 176px; padding: 18px 18px 45px; }
  .course-icon { top: 14px; right: 14px; width: 44px; height: 44px; border-radius: 14px; font-size: 1.28rem; }
  .course-copy { padding-right: 38px; }
  .course-description { font-size: 0.84rem; }
  .course-count { left: 16px; bottom: 14px; }
  .question-text { margin-bottom: 18px; }
  .answer-button { grid-template-columns: 37px 1fr; min-height: 56px; padding: 10px 40px 10px 12px; border-radius: 15px; }
  .answer-key { width: 36px; height: 36px; border-radius: 12px; }
  .keyboard-hint { display: none; }
  .feedback { padding: 14px 15px; }
  .next-row { position: sticky; z-index: 5; bottom: 8px; margin: 16px -5px -5px; padding: 7px 5px 5px; background: linear-gradient(to bottom, transparent, rgba(255, 254, 250, 0.97) 24%); }
  .next-row .action-button { width: 100%; }
  .result-summary { grid-template-columns: 1fr 1fr; gap: 9px; }
  .result-score-stat { grid-column: 1 / -1; min-height: 98px; }
  .result-stat { min-height: 96px; padding: 14px 7px; }
  .result-actions > button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
