@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&display=swap");

:root {
  color-scheme: light;
  --bg: #f3f0e9;
  --panel: #ffffff;
  --ink: #1d1a16;
  --muted: #615a52;
  --accent: #f5a524;
  --accent-dark: #d78000;
  --line: #e0d8ce;
  --shadow: 0 20px 40px rgba(29, 26, 22, 0.08);
  --radius: 18px;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, #fffaf0 0%, #f1eadf 55%, #e9e1d4 100%);
  color: var(--ink);
}

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

.site-header {
  padding: 24px 6vw 0;
}

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

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f8c15c, #ef7b00);
  color: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
  letter-spacing: 1px;
}

.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 16px;
}

.brand h1 {
  margin: 0;
  font-size: 1.8rem;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
}

.header-text {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.6);
  padding: 10px 16px;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(29, 26, 22, 0.12);
  backdrop-filter: blur(6px);
  text-align: center;
}

.quiz-logo-wrap {
  margin: 14px 6vw 0;
  display: flex;
  justify-content: center;
}

.quiz-logo-wrap img {
  max-width: min(240px, 70vw);
  max-height: 120px;
  object-fit: contain;
  border-radius: 12px;
}

.page {
  display: grid;
  gap: 24px;
  padding: 24px 6vw 48px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel h2 {
  margin-top: 0;
  font-size: 1.2rem;
}

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

.form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 20px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.95rem;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

input[type="number"],
input[type="text"],
textarea,
select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 0.95rem;
  background: #fff;
}

textarea {
  resize: vertical;
}

.mode-toggle,
.actions,
.api-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.actions {
  margin-top: 10px;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(29, 26, 22, 0.12);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1d1608;
}

.btn.outline {
  background: transparent;
}

.btn.small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.hint {
  color: var(--muted);
  margin-top: 0;
}

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

.question-card {
  border: 1px dashed var(--line);
  padding: 16px;
  border-radius: 14px;
  background: #fcfaf7;
}

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

.question-card h3 {
  margin: 0;
  font-size: 1rem;
}

.options-grid {
  display: grid;
  gap: 8px;
}

.option-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

.quiz-panel {
  grid-column: 1 / -1;
}

.quiz-stage {
  min-height: 160px;
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.quiz-body {
  position: relative;
  min-height: 100vh;
  background: none;
}

.quiz-body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--quiz-bg),
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.25), transparent 55%),
    radial-gradient(circle at 80% 30%, rgba(255, 255, 255, 0.2), transparent 60%);
  background-size: 320% 320%, 220% 220%, 260% 260%;
  background-position: 0% 50%, 20% 30%, 80% 20%;
  animation: waveShift 18s ease-in-out infinite;
  z-index: -1;
}

.bg-picker {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.bg-picker label {
  font-weight: 600;
}

.bg-picker select {
  min-width: 180px;
}

.quiz-body.bg-sunrise {
  --quiz-bg: linear-gradient(120deg, #ffd6a1, #f28f3b, #f9d976, #fbc2eb);
}

.quiz-body.bg-ocean {
  --quiz-bg: linear-gradient(120deg, #71c9ce, #277da1, #2a9d8f, #bde0fe);
}

.quiz-body.bg-ember {
  --quiz-bg: linear-gradient(120deg, #f94144, #f3722c, #f8961e, #f9844a);
}

.quiz-body.bg-forest {
  --quiz-bg: linear-gradient(120deg, #2a9d8f, #264653, #1b4332, #52b788);
}

.quiz-body.bg-lagoon {
  --quiz-bg: linear-gradient(120deg, #80ffdb, #64dfdf, #48bfe3, #5e60ce);
}

.quiz-body.bg-coral {
  --quiz-bg: linear-gradient(120deg, #ff9a8b, #ff6a88, #ff99ac, #ffd3a5);
}

.quiz-body.bg-mint {
  --quiz-bg: linear-gradient(120deg, #c0fdfb, #a8f0c6, #7bdff2, #b8f2e6);
}

.quiz-body.bg-sand {
  --quiz-bg: linear-gradient(120deg, #f2e9e4, #c9ada7, #f4a261, #e9c46a);
}

.quiz-body.bg-orchid {
  --quiz-bg: linear-gradient(120deg, #9d4edd, #7b2cbf, #c77dff, #f7b2f4);
}

.quiz-body.bg-night {
  --quiz-bg: linear-gradient(120deg, #1d1f33, #2c3e50, #3d5a80, #0f2027);
}

.quiz-stage.stage-enter .quiz-question,
.quiz-stage.stage-enter .hint {
  animation: fadeUp 0.4s ease both;
}

.option-animate {
  animation: optionIn 0.4s ease both;
}

.quiz-question {
  font-size: 1.1rem;
  font-weight: 600;
}

.quiz-options {
  display: grid;
  gap: 10px;
}

.quiz-option {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.quiz-option.correct {
  border-color: #ef7b00;
  background: #fff0d6;
}

.answer-reveal {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: #fff7e1;
  border: 1px solid #f0c782;
  font-weight: 600;
}

.timer {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff6da;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #f1d290;
}

.timer strong.counting {
  animation: tick 1s ease-in-out infinite;
}

.code-block {
  background: #1a1712;
  color: #f8f4ea;
  padding: 16px;
  border-radius: 12px;
  max-height: 240px;
  overflow: auto;
  font-size: 0.85rem;
}

.empty-state {
  color: var(--muted);
  margin: 0;
}

.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(19, 17, 15, 0.45);
  backdrop-filter: blur(4px);
  z-index: 6;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(560px, 90vw);
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.finish-overlay.hidden {
  display: none;
}

.finish-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(19, 17, 15, 0.35);
  backdrop-filter: blur(3px);
  z-index: 5;
}

.finish-text {
  font-family: "Comic Sans MS", "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: clamp(3rem, 8vw, 6rem);
  color: #fff;
  text-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  padding: 24px 48px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.15);
  animation: finishPop 0.6s ease;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 123, 0, 0.5);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(239, 123, 0, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 123, 0, 0);
  }
}

@keyframes tick {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes fadeUp {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes optionIn {
  0% {
    opacity: 0;
    transform: translateX(-10px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes finishPop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes waveShift {
  0% {
    background-position: 0% 50%, 20% 30%, 80% 20%;
  }
  50% {
    background-position: 100% 50%, 80% 70%, 20% 80%;
  }
  100% {
    background-position: 0% 50%, 20% 30%, 80% 20%;
  }
}

@media (max-width: 720px) {
  .site-header {
    padding: 16px 6vw 0;
  }

  .panel {
    padding: 18px;
  }

  .brand {
    width: 100%;
  }

  .header-text {
    width: 100%;
  }
}
