/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  color: #1D1D1F;
  background: #FFFFFF;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Layout ===== */
.container { max-width: 640px; margin: 0 auto; padding: 0 24px; }

/* ===== Screens ===== */
.screen {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
  padding: 60px 0 40px;
}
.screen.active { display: flex; }

/* ===== Typography ===== */
.title-large { font-size: 2.125rem; font-weight: 700; letter-spacing: -0.5px; line-height: 1.1; }
.title-1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.3px; line-height: 1.15; }
.title-2 { font-size: 1.375rem; font-weight: 700; line-height: 1.2; }
.body-text { font-size: 1.0625rem; line-height: 1.47; }
.secondary-text { font-size: 1.0625rem; line-height: 1.47; color: #86868B; }
.caption { font-size: 0.75rem; line-height: 1.33; color: #86868B; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 1.0625rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: all 0.2s ease;
  border-radius: 980px;
  padding: 12px 24px;
  min-height: 44px;
  min-width: 44px;
  user-select: none;
  -webkit-user-select: none;
}
.btn-primary { background: #0071E3; color: #FFFFFF; }
.btn-primary:hover { background: #0077ED; }
.btn-primary:active { background: #006EDB; }
.btn-secondary { background: transparent; color: #0071E3; }
.btn-secondary:hover { background: rgba(0,113,227,0.04); }
.btn-link {
  background: none; border: none; color: #0071E3;
  font-family: inherit; font-size: 1.0625rem; cursor: pointer;
  padding: 8px 0; transition: opacity 0.2s ease;
}
.btn-link:hover { opacity: 0.7; }

/* ===== Welcome ===== */
#welcome { justify-content: center; align-items: center; text-align: center; }
.welcome-icon { width: 64px; height: 64px; margin-bottom: 24px; }
.welcome-title { margin-bottom: 8px; }
.welcome-subtitle { color: #86868B; font-size: 1.0625rem; margin-bottom: 40px; max-width: 480px; }
.welcome-actions { display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ===== Share / QR ===== */
#share { align-items: center; padding-top: 80px; }
.share-title { margin-bottom: 8px; text-align: center; }
.share-desc { color: #86868B; text-align: center; margin-bottom: 32px; }
.share-tip { margin-bottom: 12px; text-align: center; }
.url-input-group { display: flex; width: 100%; max-width: 480px; gap: 8px; margin-bottom: 32px; }
.url-input {
  flex: 1; height: 44px; padding: 0 16px;
  border: 1px solid #D2D2D7; border-radius: 10px;
  font-family: inherit; font-size: 0.9375rem; color: #1D1D1F;
  background: #FFFFFF; outline: none; transition: border-color 0.2s ease;
}
.url-input:focus { border-color: #0071E3; }
.url-input::placeholder { color: #AEAEB2; }
.qr-display {
  padding: 32px; background: #FFFFFF; border-radius: 16px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.08); margin-bottom: 24px;
  display: flex; justify-content: center; align-items: center;
  width: 100%; max-width: 360px;
}
.qr-display svg { display: block; width: 200px; height: 200px; }
.qr-panel { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.qr-feedback { font-size: 0.9375rem; line-height: 1.5; text-align: center; }
.qr-feedback.is-error { color: #B42318; }
.qr-url-label { font-size: 0.875rem; color: #86868B; }
.qr-url { color: #0071E3; word-break: break-all; text-align: center; text-decoration: none; }
.qr-url:hover { text-decoration: underline; }

/* ===== Instructions ===== */
#instructions { justify-content: center; }
.instructions-content { max-width: 520px; margin: 0 auto; }
.instructions-title { margin-bottom: 24px; }
.instructions-list { list-style: none; margin-bottom: 40px; }
.instructions-list li {
  padding: 12px 0; border-bottom: 1px solid #F5F5F7;
  font-size: 1.0625rem; display: flex; gap: 12px;
}
.instructions-list .num { color: #86868B; font-variant-numeric: tabular-nums; min-width: 24px; }

/* ===== Test ===== */
#test { padding-top: 0; }
.test-header {
  position: sticky; top: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  z-index: 10; padding: 16px 0 12px;
}
.progress-track {
  width: 100%; height: 3px; background: #F5F5F7;
  border-radius: 1.5px; overflow: hidden; margin-bottom: 12px;
}
.progress-fill {
  height: 100%; background: #0071E3;
  border-radius: 1.5px; transition: width 0.3s ease;
}
.test-meta { display: flex; justify-content: space-between; align-items: center; }
.question-counter { font-size: 0.9375rem; color: #86868B; font-variant-numeric: tabular-nums; }
.set-indicator {
  font-size: 0.8125rem; color: #86868B; background: #F5F5F7;
  padding: 4px 10px; border-radius: 6px;
}
.question-content { padding: 24px 0; animation: fadeIn 0.3s ease; }
.question-prompt { text-align: center; margin-bottom: 6px; }
.question-subtle { text-align: center; margin-bottom: 24px; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Matrix */
.matrix-wrapper { display: flex; justify-content: center; margin-bottom: 32px; }
.matrix-grid {
  display: grid; gap: 2px; background: #D2D2D7;
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.matrix-grid.dim-2 { grid-template-columns: repeat(2, 1fr); width: 240px; }
.matrix-grid.dim-3 { grid-template-columns: repeat(3, 1fr); width: 300px; }
.matrix-cell {
  background: #FFFFFF; display: flex; align-items: center;
  justify-content: center; aspect-ratio: 1; padding: 8px;
}
.matrix-cell svg { width: 100%; height: 100%; }
.matrix-cell.missing { background: #F5F5F7; position: relative; }
.matrix-cell.missing::after {
  content: '?'; font-size: 1.5rem; font-weight: 600; color: #AEAEB2;
}

/* Options */
.options-label { font-size: 0.9375rem; color: #86868B; margin-bottom: 12px; text-align: center; }
.options-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; max-width: 360px; margin: 0 auto;
}
.option-cell {
  background: #FFFFFF; border: 2px solid #E8E8ED;
  border-radius: 12px; display: flex; align-items: center;
  justify-content: center; aspect-ratio: 1; padding: 10px;
  cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}
.option-cell:hover { border-color: #AEAEB2; }
.option-cell.selected { border-color: #0071E3; box-shadow: 0 0 0 1px #0071E3; }
.option-cell svg { width: 100%; height: 100%; }
.option-index {
  position: absolute; top: 4px; left: 8px;
  font-size: 0.6875rem; color: #AEAEB2; font-weight: 500;
}

/* Nav */
.test-nav { display: flex; justify-content: flex-end; padding: 20px 0; }
.btn-next { min-width: 120px; }
.btn-next:disabled { background: #D2D2D7; color: #FFFFFF; cursor: not-allowed; }

/* ===== Results ===== */
#results { align-items: center; justify-content: center; text-align: center; }
.results-card {
  background: #FFFFFF; border-radius: 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  padding: 40px 32px; max-width: 400px; width: 100%; margin-bottom: 24px;
}
.results-label {
  font-size: 0.8125rem; color: #86868B;
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px;
}
.score-number {
  font-size: 4.5rem; font-weight: 700;
  letter-spacing: -2px; line-height: 1; margin-bottom: 4px;
}
.score-unit { font-size: 1.0625rem; color: #86868B; margin-bottom: 24px; }
.results-divider { height: 1px; background: #F5F5F7; margin: 0 -8px; }
.results-stats { display: flex; justify-content: center; gap: 32px; padding: 20px 0; }
.stat-value { font-size: 1.375rem; font-weight: 600; margin-bottom: 2px; }
.stat-label { font-size: 0.8125rem; color: #86868B; }
.results-interpretation {
  font-size: 1.0625rem; color: #636366;
  max-width: 400px; margin-bottom: 16px; line-height: 1.5;
}
.results-note { font-size: 0.875rem; color: #86868B; margin-top: 12px; }
.results-sets { width: 100%; max-width: 400px; margin-bottom: 32px; }
.set-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid #F5F5F7; font-size: 0.9375rem;
}
.set-name { color: #86868B; }
.set-val { font-weight: 500; font-variant-numeric: tabular-nums; }
.results-actions { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.time-display { font-size: 0.875rem; color: #AEAEB2; margin-top: 16px; }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .title-large { font-size: 1.75rem; }
  .matrix-grid.dim-3 { width: 252px; }
  .matrix-grid.dim-2 { width: 200px; }
  .url-input-group { flex-direction: column; }
  .options-grid { max-width: 300px; gap: 8px; }
  .results-card { padding: 32px 24px; }
  .score-number { font-size: 3.5rem; }
  .results-stats { gap: 24px; }
}

/* ===== Utility ===== */
.hidden { display: none !important; }
