* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-400: #60a5fa;
  --blue-50:  #eff6ff;
  --ink-900:  #0f172a;
  --ink-500:  #64748b;
  --ink-400:  #94a3b8;
  --ink-200:  #e2e8f0;
  --ink-100:  #f1f5f9;
  --green:    #16a34a;
  --red:      #dc2626;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif;
  background: #f8fafc;
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* background */
.bg-grid {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(to right, rgba(37, 99, 235, 0.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(37, 99, 235, 0.07) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 85%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 85%);
  pointer-events: none; z-index: 0;
}
.bg-glow {
  position: fixed; border-radius: 50%;
  filter: blur(80px); opacity: 0.55;
  pointer-events: none; z-index: 0;
}
.glow-1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, #bfdbfe 0%, transparent 70%);
  top: -160px; left: -120px;
}
.glow-2 {
  width: 620px; height: 620px;
  background: radial-gradient(circle, #dbeafe 0%, transparent 70%);
  bottom: -220px; right: -180px;
}

/* topbar */
.topbar {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 32px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 28px; height: 28px; object-fit: contain; }
.brand-name {
  font-weight: 700; font-size: 17px;
  color: var(--blue-600); letter-spacing: -0.2px;
}
.topbar .tag {
  font-size: 12px; font-weight: 600;
  color: var(--blue-600); background: var(--blue-50);
  border: 1px solid #dbeafe; padding: 5px 12px; border-radius: 999px;
}

/* stage */
.stage {
  position: relative; z-index: 2;
  min-height: calc(100vh - 68px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px 60px;
}
.hero { text-align: center; margin-bottom: 28px; }
.hero-title {
  font-size: 34px; font-weight: 700;
  color: var(--ink-900); letter-spacing: -0.6px; margin-bottom: 8px;
}
.hero-sub { color: var(--ink-500); font-size: 15px; }

/* card */
.card {
  width: 100%; max-width: 520px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--ink-200); border-radius: 18px;
  padding: 28px 28px 20px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 12px 40px -12px rgba(37,99,235,.18);
  animation: rise .4s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

#challenge-container {
  min-height: 170px;
  display: flex; align-items: center; justify-content: center;
}
.loading { color: var(--ink-500); font-size: 14px; }

/* challenge */
.challenge { width: 100%; }
.question {
  font-size: 16px; font-weight: 600; color: var(--ink-900);
  text-align: center; margin-bottom: 18px; line-height: 1.4;
}

/* sequence chips */
.sequence {
  display: flex; justify-content: center; gap: 10px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.sequence .chip {
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-50); border: 1px solid #dbeafe;
  border-radius: 10px; color: var(--blue-600);
  font-weight: 700; font-size: 16px;
}
.sequence .chip.q {
  color: var(--ink-400); background: #fff; border-style: dashed;
}

/* input */
.input-row { display: flex; gap: 8px; }
.input-row input {
  flex: 1; padding: 12px 14px;
  border: 1.5px solid var(--ink-200); background: #fff;
  border-radius: 10px; font-size: 15px; color: var(--ink-900);
  outline: none; transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.input-row input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px rgba(59,130,246,.12);
}

/* option grids */
.options-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.options-grid.rot-grid { grid-template-columns: repeat(4, 1fr); }

.option {
  aspect-ratio: 1; border: 1.5px solid var(--ink-200); background: #fff;
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform .12s, border-color .12s, background .12s;
  color: var(--blue-600); padding: 8px;
}
.option:hover { border-color: var(--blue-400); transform: translateY(-2px); }
.option.selected {
  border-color: var(--blue-500); background: var(--blue-50);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.option svg { width: 100%; height: 100%; fill: currentColor; }

/* color tiles */
.color-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.color-tile {
  aspect-ratio: 1; border-radius: 10px; cursor: pointer;
  border: 1.5px solid rgba(15,23,42,.06);
  transition: transform .12s;
}
.color-tile:hover { transform: translateY(-2px); }

/* slider */
.slider-wrap { padding: 26px 6px 6px; }
.slider-track {
  position: relative; height: 8px;
  background: var(--ink-100); border-radius: 999px;
}
.slider-target {
  position: absolute; top: -16px; transform: translateX(-50%);
  color: var(--blue-600); font-size: 20px; font-weight: 700;
  line-height: 1; pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(37,99,235,.3));
}
input[type="range"].slider-input {
  position: absolute; inset: -8px 0 auto 0; width: 100%; height: 24px;
  -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer;
}
input[type="range"].slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--blue-600); border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.4); cursor: grab;
}
input[type="range"].slider-input::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--blue-600); border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.4); cursor: grab;
}
.slider-value {
  text-align: center; margin-top: 16px;
  font-size: 13px; color: var(--ink-500);
  font-variant-numeric: tabular-nums;
}

/* buttons */
.btn-primary {
  width: 100%; margin-top: 20px; padding: 13px 16px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
  color: #fff; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .15s, box-shadow .15s, opacity .15s;
  font-family: inherit;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -8px rgba(37,99,235,.6);
}
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.card-footer {
  display: flex; justify-content: center;
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--ink-100);
}
.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent; border: none; color: var(--ink-500);
  font-size: 13px; font-weight: 500; cursor: pointer;
  padding: 6px 10px; border-radius: 8px;
  transition: color .15s, background .15s; font-family: inherit;
}
.btn-ghost:hover { color: var(--blue-600); background: var(--blue-50); }

/* message */
.message {
  display: none; margin-top: 14px; padding: 10px 14px;
  border-radius: 10px; font-size: 13.5px;
  text-align: center; font-weight: 500;
}
.message.error {
  display: block; background: #fef2f2; color: var(--red);
  border: 1px solid #fecaca;
}

/* success */
.success { text-align: center; padding: 16px 6px 4px; animation: pop .45s ease both; }
@keyframes pop {
  0%   { transform: scale(.85); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}
.success-icon {
  width: 66px; height: 66px; margin: 0 auto 18px; border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 30px -8px rgba(22,163,74,.6);
}
.success-icon svg { width: 32px; height: 32px; stroke: #fff; stroke-width: 3; fill: none; }
.success h2 { font-size: 20px; color: var(--ink-900); margin-bottom: 6px; }
.success p  { color: var(--ink-500); font-size: 14px; }
.success .note {
  margin-top: 14px; font-size: 12.5px; color: var(--ink-500);
}
.progress-bar {
  margin: 18px auto 0; width: 60%; height: 4px;
  background: var(--ink-100); border-radius: 999px; overflow: hidden;
}
.progress-bar > div {
  height: 100%; width: 0%; background: var(--blue-500);
  border-radius: 999px; transition: width 1.6s linear;
}

/* footnote */
.footnote { margin-top: 22px; font-size: 12.5px; color: var(--ink-500); }
.footnote strong { color: var(--blue-600); }

/* mobile */
@media (max-width: 520px) {
  .topbar { padding: 16px 20px; }
  .hero-title { font-size: 26px; }
  .card { padding: 22px 20px 16px; border-radius: 16px; }
  .options-grid.rot-grid { grid-template-columns: repeat(2, 1fr); }
}