:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-muted: #f7f9fc;
  --text: #12213a;
  --text-muted: #5a6780;
  --border: #dbe3ef;
  --primary: #1463ff;
  --primary-hover: #0e50d4;
  --success: #168f5f;
  --warning: #b46f00;
  --danger: #c5382a;
  --shadow: 0 10px 30px rgba(20, 38, 76, 0.08);
}

html[data-theme='dark'] {
  --bg: #0f1523;
  --surface: #182236;
  --surface-muted: #212e46;
  --text: #edf4ff;
  --text-muted: #c3d0e7;
  --border: #31435f;
  --primary: #4d8dff;
  --primary-hover: #2f74ef;
  --success: #2dcf8f;
  --warning: #ffbf5e;
  --danger: #ff7468;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(circle at top right, rgba(20, 99, 255, 0.08), transparent 45%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.brand {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.6rem);
}

.app-main {
  min-height: calc(100vh - 100px);
  display: grid;
  place-items: center;
}

.card {
  width: min(100%, 720px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3vw, 2rem);
  animation: fadeUp 0.35s ease;
}

.card-title {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: clamp(1.25rem, 2.5vw, 1.8rem);
}

.card-subtitle {
  margin-top: 0;
  margin-bottom: 1.25rem;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.label {
  font-weight: 600;
}

.input {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  font-size: 1rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button {
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.button:focus-visible,
.option:focus-visible,
.input:focus-visible {
  outline: 3px solid rgba(20, 99, 255, 0.35);
  outline-offset: 2px;
}

.button:active {
  transform: translateY(1px);
}

.button-primary {
  background: var(--primary);
  color: #fff;
}

.button-primary:hover {
  background: var(--primary-hover);
}

.button-secondary {
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--border);
}

.button[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}

.meta-grid {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.progress-text {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #4cb4ff);
  transition: width 0.35s ease;
}

.question-text {
  margin: 0 0 1rem;
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
}

.options {
  display: grid;
  gap: 0.75rem;
  border: none;
  margin: 0;
  padding: 0;
}

.option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
  padding: 0.75rem;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.option:hover {
  border-color: var(--primary);
}

.option:has(input:checked) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface-muted));
}

.option-input {
  width: 18px;
  height: 18px;
}

.status-message {
  margin-top: 0.8rem;
  color: var(--warning);
  font-size: 0.92rem;
  min-height: 1.15rem;
}

.result-summary {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
}

.result-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
  width: fit-content;
}

.level-low {
  background: color-mix(in srgb, var(--danger) 20%, transparent);
  color: var(--danger);
}

.level-moderate {
  background: color-mix(in srgb, var(--warning) 24%, transparent);
  color: var(--warning);
}

.level-high {
  background: color-mix(in srgb, var(--success) 22%, transparent);
  color: var(--success);
}

.last-result {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.consent-dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 0;
  width: min(92vw, 520px);
}

.consent-dialog::backdrop {
  background: rgba(5, 12, 24, 0.55);
  backdrop-filter: blur(2px);
}

.consent-content {
  margin: 0;
  padding: 1.25rem;
}

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

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

@media (max-width: 640px) {
  .top-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .button-row {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .consent-content {
    padding: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
