* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #8e8e93;
  --primary: #4a6cf7;
  --primary-light: #e8ecff;
  --border: #d1d1d6;
  --green: #34c759;
  --yellow: #f0c800;
  --orange: #ff9500;
  --red: #ff3b30;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior: none;
}

.screen {
  display: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  scrollbar-width: none;
}

.screen::-webkit-scrollbar {
  display: none;
}

.screen.scrollable {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.page {
  min-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.page::-webkit-scrollbar {
  display: none;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ─── START SCREEN ─── */

.start-content {
  flex: 1;
  padding: 40px 24px calc(24px + var(--safe-bottom));
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  overflow-x: hidden;
}

h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-top: 4px;
}

.instructions {
  margin-top: 24px;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.instructions p + p {
  margin-top: 10px;
}

.scale-legend {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--radius);
  font-size: 14px;
}

.scale-row {
  padding: 3px 0;
}

.scale-num {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  margin-right: 8px;
}

.form-fields {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-fields input {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  max-width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

.form-fields input:focus {
  border-color: var(--primary);
}

.start-buttons {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── BUTTONS ─── */

.btn {
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-align: center;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-secondary {
  background: var(--primary-light);
  color: var(--primary);
}

.btn-nav {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
  font-size: 15px;
  padding: 12px 20px;
}

.btn-link {
  background: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  text-decoration: underline;
  padding: 8px;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  text-decoration: none;
}

a.btn {
  text-decoration: none;
  display: block;
}

/* ─── QUESTION SCREEN ─── */

.question-header {
  flex-shrink: 0;
  padding: 12px 20px 0;
}

.progress-bar-container {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

#progress-label {
  font-variant-numeric: tabular-nums;
}

.question-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 24px 16px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.question-number {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 12px;
}

.question-text {
  font-size: 20px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: -0.2px;
}

.answer-section {
  flex-shrink: 0;
  padding: 0 24px calc(16px + var(--safe-bottom));
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.answer-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding: 0 4px;
}

.answer-buttons {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.answer-btn {
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
}

.answer-btn:active {
  transform: scale(0.92);
}

.answer-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.nav-buttons {
  display: flex;
  gap: 10px;
}

.nav-buttons .btn {
  flex: 1;
}

#btn-prev:disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ─── RESULTS SCREEN ─── */

.results-content {
  flex: 1;
  padding: 12px 12px calc(12px + var(--safe-bottom));
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.results-content h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.results-meta {
  font-size: 11px;
  color: var(--text-secondary);
}

.results-answered {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.result-card {
  padding: 3px 0;
}

.result-name {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.result-severity {
  font-size: 10px;
  font-weight: 500;
  flex-shrink: 0;
  white-space: nowrap;
}

.result-bar {
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  margin-top: 2px;
  overflow: hidden;
}

.result-bar-fill {
  height: 100%;
  border-radius: 1px;
}

.severity-low .result-bar-fill { background: var(--green); }
.severity-medium .result-bar-fill { background: var(--yellow); }
.severity-high .result-bar-fill { background: var(--orange); }
.severity-veryHigh .result-bar-fill { background: var(--red); }

.severity-low .result-severity { color: #1a8a3a; }
.severity-medium .result-severity { color: #9a7b00; }
.severity-high .result-severity { color: #c77800; }
.severity-veryHigh .result-severity { color: #cc2222; }

.results-footer {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ─── SECTION TITLES ─── */

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin-top: 28px;
  margin-bottom: 4px;
}

.section-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* ─── PARENTAL PATTERNS ─── */

.pattern-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  border-left: 4px solid var(--border);
}

.pattern-card.pattern-pronounced {
  border-left-color: var(--orange);
}

.pattern-card.pattern-normal {
  border-left-color: var(--green);
}

.pattern-badge {
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.pattern-badge-pronounced {
  background: #fff3e0;
  color: #c77800;
}

.pattern-badge-normal {
  background: #e8faed;
  color: #1a8a3a;
}

.pattern-fill-pronounced {
  background: var(--orange);
}

.pattern-fill-normal {
  background: var(--green);
}

/* ─── INFO PAGES ─── */

.info-links {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-info-link {
  font-size: 14px;
  padding: 12px 16px;
  text-align: left;
}

.info-content {
  flex: 1;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

.info-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.info-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.info-intro {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.info-content h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 24px 0 12px;
}

/* Schema comparison table */

.schema-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -20px;
  padding: 0 20px;
}

.schema-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.5;
}

.schema-table th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
  position: sticky;
  top: 0;
}

.schema-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.schema-table tbody tr:nth-child(odd) {
  background: var(--card);
}

.schema-table tbody tr:nth-child(even) {
  background: var(--bg);
}

/* YPI key cards */

.ypi-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
}

.ypi-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.ypi-items {
  font-size: 13px;
  color: var(--text-secondary);
}

.ypi-note {
  font-style: italic;
  font-size: 12px;
}

.ypi-instructions {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.ypi-instructions p + p {
  margin-top: 10px;
}

.ypi-instructions strong {
  color: var(--text);
}

@media (min-width: 600px) {
  .question-text {
    font-size: 24px;
  }

  .answer-btn {
    min-height: 60px;
    font-size: 20px;
  }
}
