:root {
  --bg-1: #f4efe6;
  --bg-2: #d8e6ef;
  --ink: #1a2333;
  --muted: #4f5d73;
  --brand: #0a6c5a;
  --brand-soft: #ccefe2;
  --accent: #cc5a2e;
  --panel: rgba(255, 255, 255, 0.82);
  --border: rgba(26, 35, 51, 0.15);
  --shadow: 0 20px 45px rgba(30, 44, 59, 0.16);
  --shadow-lg: 0 25px 50px rgba(30, 44, 59, 0.2);
  --success: #08795f;
  --warning: #f8b84e;
  --info: #1f8cc9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(circle at 5% 20%, rgba(10, 108, 90, 0.16), transparent 35%),
    radial-gradient(circle at 90% 10%, rgba(204, 90, 46, 0.16), transparent 30%),
    linear-gradient(125deg, var(--bg-1), var(--bg-2));
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 280px;
  height: 280px;
  border-radius: 48% 52% 57% 43% / 41% 60% 40% 59%;
  z-index: -1;
  opacity: 0.38;
}

body::before {
  right: -80px;
  bottom: 18%;
  background: #f2c9b8;
  transform: rotate(8deg);
}

body::after {
  left: -100px;
  top: 30%;
  background: #b8d8cc;
}

h1,
h2,
h3 {
  font-family: "Fraunces", serif;
  margin-top: 0;
}

.app-shell {
  width: min(980px, 92vw);
  margin: 34px auto 60px;
  display: grid;
  gap: 22px;
}

footer {
  width: min(980px, 92vw);
  margin: 0 auto 36px;
  padding: 16px 20px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

footer small {
  color: var(--muted);
  font-weight: 600;
}

footer a {
  color: var(--ink);
  text-decoration: none;
}

footer > div:nth-child(2) {
  display: inline-flex;
  gap: 14px;
  align-items: center;
}

footer > div:nth-child(2) a,
.arrow-icon-wrapper a {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

footer > div:nth-child(2) a:hover,
.arrow-icon-wrapper a:hover {
  color: var(--brand);
  border-color: var(--brand);
  transform: translateY(-2px);
}

footer i {
  font-size: 1.25rem;
}

.hero {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.5));
  border: 2px solid var(--border);
  border-radius: 24px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
  animation: rise-in 0.6s ease;
}

.kicker {
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--brand);
  font-weight: 700;
  margin-bottom: 12px;
}

.hero h1 {
  font-size: clamp(1.9rem, 2.4vw, 2.7rem);
  line-height: 1.18;
  margin-bottom: 14px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-copy {
  margin: 0;
  line-height: 1.65;
  color: var(--muted);
  max-width: 66ch;
  font-size: 1.02rem;
}

.panel {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(7px);
  transition: all 0.3s ease;
}

.panel-title-wrap {
  margin-bottom: 20px;
}

.panel-title-wrap h2 {
  margin-bottom: 6px;
  font-size: 1.5rem;
}

.panel-title-wrap p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.category-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.category-btn {
  border: 2px solid var(--border);
  background: linear-gradient(150deg, #ffffff, #f4fbf8);
  box-shadow: inset 0 4px 0 var(--category-accent, var(--brand));
  border-radius: 18px;
  padding: 26px;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--category-accent, var(--brand)) 16%, white);
  color: var(--category-accent, var(--brand));
  font-size: 1.5rem;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--category-accent, var(--brand)) 24%, transparent);
}

.category-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.category-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.2), transparent 50%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.category-btn:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand);
  background: linear-gradient(150deg, #f8fffe, #e0f0ec);
}

.category-btn:hover::before {
  left: 100%;
}

.category-btn:hover::after {
  opacity: 1;
}

.category-btn:active {
  transform: translateY(-4px);
}

.category-btn h3 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--ink);
  font-weight: 700;
}

.category-btn p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  flex-grow: 1;
}

.q-count {
  display: inline-block;
  background: linear-gradient(135deg, var(--category-accent, var(--brand)), #1bb08f);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  width: fit-content;
  margin-top: auto;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.quiz-header h2 {
  margin: 0;
  font-size: 1.6rem;
}

.progress-wrap {
  margin: 18px 0 20px;
}

.progress-wrap p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(79, 93, 115, 0.15);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 10%;
  background: linear-gradient(90deg, var(--brand), #1bb08f, #08795f);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(10, 108, 90, 0.3);
}

.question-card {
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 26px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.question-card:hover {
  border-color: var(--brand);
  box-shadow: 0 8px 20px rgba(10, 108, 90, 0.1);
}

.question-card h3 {
  margin: 0 0 12px;
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--ink);
}

.question-type {
  margin: 8px 0 20px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: rgba(204, 90, 46, 0.1);
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
}

.answer-list {
  display: grid;
  gap: 12px;
}

.answer-item {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.answer-item:hover {
  border-color: var(--brand);
  background: rgba(10, 108, 90, 0.02);
  transform: translateX(4px);
}

.answer-item input {
  accent-color: var(--brand);
  cursor: pointer;
  width: 20px;
  height: 20px;
}

.answer-item input:checked {
  accent-color: var(--success);
}

.answer-item.correct {
  border-color: #08795f;
  background: rgba(8, 121, 95, 0.1);
  box-shadow: inset 0 0 0 2px #08795f;
}

.answer-item.correct input::after {
  content: "✓";
}

.answer-item.incorrect {
  border-color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
  box-shadow: inset 0 0 0 2px #e74c3c;
}

.answer-item.incorrect input {
  accent-color: #e74c3c;
}

.review-mode .answer-item {
  cursor: default;
}

.feedback-area {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: var(--surface-soft);
  margin-top: 16px;
}

.feedback-area.hidden {
  display: none;
}

.feedback-banner {
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
}

.feedback-banner.correct {
  background: rgba(8, 121, 95, 0.15);
  color: #08795f;
  border: 1px solid rgba(8, 121, 95, 0.3);
}

.feedback-banner.wrong {
  background: rgba(231, 76, 60, 0.15);
  color: #e74c3c;
  border: 1px solid rgba(231, 76, 60, 0.3);
}

.feedback-card {
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.feedback-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.feedback-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
}

.feedback-card ul {
  margin: 8px 0 0 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.93rem;
}

.drag-layout {
  display: grid;
  gap: 16px;
}

.drag-helper {
  margin: 0;
  padding: 12px 16px;
  background: rgba(31, 140, 201, 0.08);
  border: 1px solid rgba(31, 140, 201, 0.3);
  border-radius: 12px;
  color: var(--info);
  font-size: 0.9rem;
  font-weight: 500;
}

.drag-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 56px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  border: 2px dashed var(--border);
}

.draggable-chip {
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  background: linear-gradient(145deg, #fff, #f4fbf8);
  cursor: grab;
  user-select: none;
  transition: all 0.2s ease;
  font-weight: 600;
  font-size: 0.95rem;
}

.draggable-chip:hover {
  border-color: var(--brand);
  box-shadow: 0 4px 12px rgba(10, 108, 90, 0.15);
  transform: translateY(-2px);
}

.draggable-chip:active {
  cursor: grabbing;
}

.draggable-chip.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(10, 108, 90, 0.2);
}

.draggable-chip.correct-chip {
  border-color: #08795f;
  background: rgba(8, 121, 95, 0.15);
  box-shadow: 0 0 8px rgba(8, 121, 95, 0.3);
}

.draggable-chip.incorrect-chip {
  border-color: #e74c3c;
  background: rgba(231, 76, 60, 0.15);
  box-shadow: 0 0 8px rgba(231, 76, 60, 0.3);
}

.drop-grid {
  display: grid;
  gap: 12px;
}

.drop-zone {
  border: 3px dashed rgba(10, 108, 90, 0.3);
  border-radius: 14px;
  min-height: 60px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.8);
  transition: all 0.2s ease;
}

.drop-zone.over {
  background: var(--brand-soft);
  border-color: var(--brand);
  box-shadow: inset 0 0 10px rgba(10, 108, 90, 0.1);
}

.zone-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 700;
}

.quiz-actions {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.03em;
}

.primary-btn {
  background: linear-gradient(135deg, var(--brand), #1bb08f);
  color: #fff;
  box-shadow: 0 4px 15px rgba(10, 108, 90, 0.3);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(10, 108, 90, 0.4);
}

.primary-btn:active {
  transform: translateY(0);
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.secondary-btn {
  background: linear-gradient(135deg, #1f8cc9, #299fe8);
  color: #fff;
  box-shadow: 0 4px 15px rgba(31, 140, 201, 0.3);
}

.secondary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(31, 140, 201, 0.4);
}

.secondary-btn:active {
  transform: translateY(0);
}

.success-btn {
  background: linear-gradient(120deg, #08795f, #1fad8b);
  color: #fff;
  box-shadow: 0 4px 15px rgba(8, 121, 95, 0.3);
}

.success-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(8, 121, 95, 0.4);
}

.ghost-btn {
  background: #fff;
  border: 2px solid var(--border);
  color: var(--ink);
  transition: all 0.3s ease;
}

.ghost-btn:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}

.ghost-btn:active {
  transform: scale(0.98);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 24, 0.65);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
  backdrop-filter: blur(4px);
  animation: fade-in 0.3s ease;
}

.modal-card {
  width: min(580px, 100%);
  background: linear-gradient(160deg, #fff, #f4fbf8);
  border: 2px solid var(--border);
  border-radius: 24px;
  padding: 38px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-card h2 {
  margin: 0 0 16px;
  font-size: 1.8rem;
}

.modal-card.winner {
  border-color: var(--success);
  animation: pulse-border 1.2s ease infinite, pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.score-line {
  margin: 14px 0 8px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand);
}

.modal-card p {
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.6;
}

#score-feedback {
  margin: 16px 0 0 !important;
  font-size: 1.05rem;
  font-weight: 500;
}

.modal-actions {
  margin-top: 28px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

.review-all-list {
  display: grid;
  gap: 14px;
}

.review-card {
  padding: 20px;
}

.review-card h3 {
  margin-bottom: 10px;
}

.review-all-answers {
  margin-top: 8px;
}

.drag-zone-review {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.85);
  padding: 10px 12px;
}

.explanation {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.94rem;
}

.review-close-wrap {
  position: sticky;
  bottom: 0;
  margin-top: 16px;
  padding-top: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95) 50%);
}

.quiz-panel.review-all-mode .progress-wrap,
.quiz-panel.review-all-mode .quiz-actions {
  display: none;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes pulse-border {
  0% {
    box-shadow: 0 0 0 0 rgba(8, 121, 95, 0.7);
  }

  70% {
    box-shadow: 0 0 0 20px rgba(8, 121, 95, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(8, 121, 95, 0);
  }
}

.drag-helper {
  margin: 0;
  padding: 12px 16px;
  background: rgba(31, 140, 201, 0.08);
  border: 1px solid rgba(31, 140, 201, 0.3);
  border-radius: 12px;
  color: var(--info);
  font-size: 0.9rem;
  font-weight: 500;
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes glow {
  0% { box-shadow: 0 0 5px rgba(10, 108, 90, 0.3); }
  50% { box-shadow: 0 0 20px rgba(10, 108, 90, 0.6); }
  100% { box-shadow: 0 0 5px rgba(10, 108, 90, 0.3); }
}

.category-btn {
  animation: slide-up 0.4s ease-out;
}

@media (max-width: 700px) {
  .hero,
  .panel {
    padding: 24px;
  }

  footer {
    width: 94vw;
    justify-content: center;
    text-align: center;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .category-grid {
    grid-template-columns: 1fr;
  }

  .quiz-header {
    flex-direction: column;
    align-items: stretch;
  }

  .quiz-header h2 {
    font-size: 1.4rem;
  }

  .quiz-actions {
    justify-content: stretch;
    flex-direction: column;
  }

  .quiz-actions button {
    flex: 1;
    width: 100%;
  }

  .modal-card {
    padding: 28px;
  }

  .score-line {
    font-size: 1.3rem;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions button {
    width: 100%;
  }

  button {
    min-height: 44px;
  }

  .answer-item {
    min-height: 48px;
  }
}

@media (max-width: 480px) {
  .app-shell {
    width: 94vw;
    margin: 20px auto 40px;
    gap: 16px;
  }

  .hero,
  .panel {
    padding: 18px;
    border-radius: 16px;
  }

  .panel-title-wrap h2 {
    font-size: 1.25rem;
  }

  .category-btn {
    padding: 18px;
  }

  .question-card {
    padding: 16px;
  }

  .question-card h3 {
    font-size: 1.08rem;
    line-height: 1.4;
  }

  .answer-item {
    padding: 12px;
    align-items: flex-start;
    gap: 10px;
  }

  button {
    width: 100%;
    padding: 12px 14px;
    font-size: 0.92rem;
  }

  .review-card {
    padding: 14px;
  }
}

@media (hover: none) {
  .category-btn:hover,
  .answer-item:hover,
  .primary-btn:hover,
  .secondary-btn:hover,
  .success-btn:hover,
  .ghost-btn:hover {
    transform: none;
  }
}
