/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-brand: #1A3A6B;
  --color-cta: #FF6B35;
  --color-cta-hover: #e55a25;
  --color-type-a: #1A3A6B;
  --color-type-b: #E87D2B;
  --color-type-c: #2E8B57;
  --color-type-d: #C0392B;
  --color-text: #333333;
  --color-text-sub: #666666;
  --color-bg: #FFFFFF;
  --color-bg-light: #F8F9FA;
  --color-border: #E5E7EB;
  --radius: 12px;
  --radius-sm: 8px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== Screen System ===== */
.screen {
  display: none;
  min-height: 100vh;
  animation: fadeIn 0.3s ease;
}
.screen.active { display: block; }

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

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px;
}

/* ===== Header ===== */
.header {
  text-align: center;
  padding: 16px 0 8px;
}
.header-logo {
  height: 64px;
  width: auto;
}

/* ===== LANDING ===== */
.landing-hero {
  text-align: center;
  padding: 32px 0 24px;
}
.landing-title {
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--color-brand);
  margin-bottom: 12px;
}
.landing-sub {
  font-size: 0.9rem;
  color: var(--color-text-sub);
}

/* Type preview grid */
.type-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}
.type-preview-card {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.type-preview-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--type-color);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
}
.type-preview-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--type-color);
  margin-bottom: 4px;
}
.type-preview-blur {
  font-size: 0.75rem;
  color: var(--color-text-sub);
  filter: blur(3px);
  user-select: none;
}

/* Counter */
.counter-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--color-text-sub);
  margin-bottom: 20px;
}
.counter-box svg { color: var(--color-brand); flex-shrink: 0; }

/* CTA Button */
.btn-cta {
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--color-cta);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-family: inherit;
}
.btn-cta:active { transform: scale(0.98); }
.btn-cta:hover { background: var(--color-cta-hover); }
.btn-cta.disabled {
  background: #ccc;
  cursor: not-allowed;
}
.btn-cta.disabled:hover { background: #ccc; }

/* ===== GRADE ===== */
.grade-section { padding-top: 16px; }
.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
}
.section-sub {
  font-size: 0.875rem;
  color: var(--color-text-sub);
  text-align: center;
  margin-bottom: 24px;
}
.grade-group {
  margin-bottom: 16px;
}
.grade-group-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-sub);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.grade-buttons {
  display: flex;
  gap: 8px;
}
.grade-btn {
  flex: 1;
  padding: 12px 8px;
  background: var(--color-bg-light);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.grade-btn:hover { border-color: var(--color-brand); }
.grade-btn.selected {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: #fff;
  font-weight: 600;
}
.name-input-wrap {
  margin: 24px 0;
}
.name-input-wrap label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-sub);
  margin-bottom: 6px;
}
.name-input-wrap input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.name-input-wrap input:focus {
  border-color: var(--color-brand);
}

/* ===== QUIZ ===== */
.quiz-header {
  padding: 16px 0 8px;
}
.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar {
  height: 100%;
  background: var(--color-brand);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}
.progress-text {
  font-size: 0.8rem;
  color: var(--color-text-sub);
  text-align: right;
}

.quiz-body {
  padding: 24px 0;
}
.quiz-question {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 24px;
  min-height: 60px;
}

.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.choice-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 16px;
  background: var(--color-bg-light);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  font-family: inherit;
}
.choice-btn:hover {
  border-color: var(--color-brand);
  background: #f0f4f8;
}
.choice-btn.selected {
  border-color: var(--color-brand);
  background: #e8eff8;
}
.choice-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--color-brand);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 1px;
}
.choice-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--color-text);
  padding-top: 2px;
}

.btn-prev {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--color-text-sub);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 8px 0;
  font-family: inherit;
}
.btn-prev:hover { color: var(--color-text); }

/* ===== LOADING ===== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.loading-spinner {
  position: relative;
  width: 60px;
  height: 60px;
  margin-bottom: 24px;
}
.spinner-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 3px solid transparent;
  border-radius: 50%;
}
.spinner-ring:nth-child(1) {
  border-top-color: var(--color-type-a);
  animation: spin 1s linear infinite;
}
.spinner-ring:nth-child(2) {
  border-right-color: var(--color-type-b);
  animation: spin 1.2s linear infinite reverse;
}
.spinner-ring:nth-child(3) {
  border-bottom-color: var(--color-type-c);
  animation: spin 1.5s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-text {
  font-size: 1rem;
  color: var(--color-text-sub);
  text-align: center;
  transition: opacity 0.3s;
}

/* ===== RESULT ===== */
.result-banner {
  text-align: center;
  padding: 32px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  color: #fff;
}
.result-banner-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
}
.result-name-label {
  font-size: 0.95rem;
  opacity: 0.9;
  margin-bottom: 4px;
}
.result-type-name {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 6px;
}
.result-tagline {
  font-size: 0.95rem;
  opacity: 0.85;
}

/* Result sections */
.result-section {
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
}
.result-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--color-text);
}
.result-section-title svg { color: var(--color-brand); flex-shrink: 0; }
.result-description {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--color-text);
}

/* Traits */
.trait-group { margin-bottom: 12px; }
.trait-group:last-child { margin-bottom: 0; }
.trait-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  padding: 3px 10px;
  border-radius: 4px;
  display: inline-block;
}
.trait-strength { background: #dcfce7; color: #166534; }
.trait-weakness { background: #fef3c7; color: #92400e; }
.trait-list {
  list-style: none;
  padding-left: 0;
}
.trait-list li {
  font-size: 0.9rem;
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
  color: var(--color-text);
}
.trait-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 11px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-sub);
}

/* Tip */
.tip-section { background: #fffbeb; border-color: #fcd34d; }
.tip-text {
  font-size: 0.9rem;
  line-height: 1.65;
  color: #78350f;
}

/* Mixed notice */
.mixed-notice {
  background: #eff6ff;
  border-color: #93c5fd;
}
.mixed-notice p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #1e40af;
}

/* Axis chart */
.axis-chart { padding: 4px 0; }
.axis-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.axis-label-left, .axis-label-right {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-sub);
  min-width: 28px;
  text-align: center;
}
.axis-bar-wrap {
  flex: 1;
  height: 12px;
  background: #e5e7eb;
  border-radius: 6px;
  position: relative;
  overflow: visible;
}
.axis-bar {
  height: 100%;
  border-radius: 6px;
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  width: 0%;
}
.axis-bar-focus { background: var(--color-brand); }
.axis-bar-visual { background: var(--color-type-c); }
.axis-marker {
  position: absolute;
  top: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--color-brand);
  transform: translateX(-50%);
  transition: left 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  left: 0%;
}
.axis-score-text {
  font-size: 0.8rem;
  color: var(--color-text-sub);
  text-align: center;
  margin-bottom: 16px;
}

/* Molip section */
.molip-section { background: #f0f7ff; border-color: #bfdbfe; }
.molip-message {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-text);
  margin-bottom: 16px;
}
.molip-buttons {
  display: flex;
  gap: 10px;
}
.btn-consult {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: var(--color-cta);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
  font-family: inherit;
}
.btn-consult:hover { background: var(--color-cta-hover); }
.btn-call {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 16px;
  background: #fff;
  color: var(--color-brand);
  border: 2px solid var(--color-brand);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
  font-family: inherit;
}
.btn-call:hover { background: #f0f4f8; }

/* Share */
.share-section { text-align: center; }
.share-sub {
  font-size: 0.85rem;
  color: var(--color-text-sub);
  margin-bottom: 14px;
}
.share-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.share-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.share-btn:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
}

/* Other types */
.other-types {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.other-type-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s;
}
.other-type-card:hover { border-color: var(--color-text-sub); }
.other-type-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
}
.other-type-info { flex: 1; }
.other-type-name {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.other-type-tagline {
  font-size: 0.8rem;
  color: var(--color-text-sub);
}

/* Result footer */
.result-footer {
  text-align: center;
  padding: 20px 0 40px;
}
.btn-retry {
  padding: 12px 32px;
  background: none;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--color-text-sub);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-retry:hover {
  border-color: var(--color-text-sub);
  color: var(--color-text);
}

/* Toast */
.toast {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  transition: bottom 0.3s ease;
  z-index: 1000;
  white-space: nowrap;
}
.toast.show { bottom: 32px; }

/* ===== Type detail modal ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
  padding: 20px;
}
.modal-content {
  background: #fff;
  border-radius: var(--radius);
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
}
.modal-close {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 16px;
  background: var(--color-bg-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--color-text);
}

/* ===== Mobile responsive ===== */
@media (max-width: 400px) {
  .container { padding: 16px; }
  .landing-title { font-size: 1.4rem; }
  .result-type-name { font-size: 1.5rem; }
  .molip-buttons { flex-direction: column; }
  .share-buttons { flex-direction: column; align-items: center; }
  .share-btn { width: 100%; justify-content: center; }
}
