@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@700;800&family=Noto+Sans+KR:wght@400;500;700&display=swap');

:root {
  --bg1: #a18cd1;
  --bg2: #fbc2eb;
  --card-bg: rgba(255, 255, 255, 0.18);
  --card-stroke: rgba(255, 255, 255, 0.35);
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #7c3aed;
  --accent-2: #06b6d4;
  --success: #22c55e;
  --danger: #ef4444;
  --shadow: 0 10px 30px rgba(0,0,0,0.12), 0 6px 12px rgba(0,0,0,0.08);
  --glass-blur: 10px;
}

/* Base reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Noto Sans KR', system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', Arial, 'Apple SD Gothic Neo', 'Malgun Gothic', '맑은 고딕', sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 100%);
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Floating background orbs */
body::before,
body::after {
  content: '';
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  z-index: 0;
  pointer-events: none;
}
body::before {
  top: -100px;
  left: -80px;
  background: radial-gradient(circle at 30% 30%, #ffffff, #fce7f3, transparent 70%);
  animation: floatA 12s ease-in-out infinite;
}
body::after {
  bottom: -120px;
  right: -120px;
  background: radial-gradient(circle at 70% 70%, #e9d5ff, #dbeafe, transparent 70%);
  animation: floatB 14s ease-in-out infinite;
}
@keyframes floatA { 0%,100%{transform:translate(0,0)}50%{transform:translate(18px,-10px)} }
@keyframes floatB { 0%,100%{transform:translate(0,0)}50%{transform:translate(-20px,15px)} }

.container {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 32px auto;
  padding: 20px;
}

/* Card styles */
.hidden { display: none; }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.68), rgba(255,255,255,0.5));
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--card-stroke);
  box-shadow: var(--shadow);
  border-radius: 18px;
  padding: 20px;
  animation: fadeInUp 420ms ease both;
}

/* Header */
h1, h2 { margin: 0 0 8px 0; line-height: 1.2; }
h1 {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 36px;
}
h2 { font-weight: 700; font-size: 20px; color: var(--text) }

#start-screen p {
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 15px;
}

/* Primary button */
.btn-primary {
  appearance: none;
  border: none;
  outline: none;
  padding: 12px 18px;
  font-weight: 800;
  border-radius: 12px;
  color: white;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 10px 20px rgba(124, 58, 237, 0.18), inset 0 -2px 0 rgba(255,255,255,0.12);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
.btn-primary:active { transform: translateY(0); box-shadow: 0 8px 16px rgba(124,58,237,0.14); }
.btn-primary:hover { transform: translateY(-3px); filter: brightness(1.02); }

/* Question area */
#question-container { margin-bottom: 12px; }
#question { font-size: 20px; font-weight: 800; margin-bottom: 12px; }

/* Choices grid - larger, touch friendly */
.choices-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.choice-btn {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--card-stroke);
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0.9));
  text-align: center;
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  box-shadow: 0 6px 10px rgba(0,0,0,0.06);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
  user-select: none;
  touch-action: manipulation;
  font-size: 15px;
}
.choice-btn:hover { transform: translateY(-3px); box-shadow: 0 12px 20px rgba(0,0,0,0.08); }
.choice-btn:active { transform: translateY(0); box-shadow: 0 6px 10px rgba(0,0,0,0.06); }
.choice-btn[disabled] { opacity: 0.6; transform: none; pointer-events: none; }

/* Visual feedback for selected choices */
.choice-btn.selected {
  background: linear-gradient(90deg, rgba(124,58,237,0.95), rgba(6,182,212,0.95));
  color: #fff;
  box-shadow: 0 14px 28px rgba(99,102,241,0.18);
}

/* Progress bar */
#progress-bar-container {
  margin-top: 12px;
  height: 12px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--card-stroke);
  border-radius: 999px;
  overflow: hidden;
}
#progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%); transition: width 220ms ease; }

/* Result card */
#result-display { display: grid; gap: 12px; }
.result-card {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0.85));
  border: 1px solid var(--card-stroke);
  box-shadow: var(--shadow);
}
.result-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.result-emoji { font-size: 40px; line-height: 1; }
.result-type-code { font-family: 'Montserrat', sans-serif; font-weight: 800; font-size: 22px; }
.result-type-name { color: var(--muted); font-weight: 700; font-size: 13px; }

/* Tag style */
.result-tags { display:flex; flex-wrap:wrap; gap:8px; margin:6px 0 2px; }
.tag {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 12px rgba(6,182,212,0.12);
}

/* Result grid */
.result-grid { display:grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.result-panel { padding: 12px; border-radius: 12px; background: rgba(255,255,255,0.95); border:1px solid var(--card-stroke); }

/* Confetti (lighter on mobile via JS) */
.confetti {
  position: fixed;
  top: -12px;
  width: 8px;
  height: 14px;
  opacity: 0.95;
  border-radius: 2px;
  transform: rotate(0deg);
  animation: confetti-fall 2200ms linear forwards, confetti-sway 1000ms ease-in-out infinite;
  z-index: 9999;
}

/* Accessibility helpers */
.choice-btn:focus { outline: 3px solid rgba(124,58,237,0.18); outline-offset: 3px; }

/* Animations */
@keyframes confetti-fall { to { transform: translateY(110vh) rotate(360deg); opacity: 1; } }
@keyframes confetti-sway { 0%{margin-left:0}50%{margin-left:10px}100%{margin-left:0} }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(6px); } to   { opacity: 1; transform: translateY(0); } }

/* Responsive adjustments */
@media (max-width: 920px) {
  .container { max-width: 760px; padding: 16px; margin: 20px auto; }
  h1 { font-size: 32px; }
  .choice-btn { font-size: 15px; padding: 13px 14px; }
}
@media (max-width: 720px) {
  .container { margin: 16px 12px; padding: 12px; }
  h1 { font-size: 26px; }
  #start-screen, #test-screen, #result-screen { padding: 16px; border-radius: 14px; }
  .choices-grid { grid-template-columns: 1fr; gap: 10px; }
  .choice-btn { font-size: 17px; padding: 16px 14px; border-radius: 14px; }
  .result-grid { grid-template-columns: 1fr; }
  .result-emoji { font-size: 36px; }
  #progress-bar-container { height: 10px; }
  .tag { font-size: 11px; padding: 6px 8px; }
}

/* Small phone */
@media (max-width: 420px) {
  h1 { font-size: 22px; }
  .choice-btn { font-size: 16px; padding: 14px; }
  .result-emoji { font-size: 34px; }
}

/* Additional polish & hero/start-screen styles */
.start-hero {
  display: flex;
  align-items: center;
  gap: 14px;
}
.start-hero .hero-emoji {
  font-size: 56px;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(124,58,237,0.12), rgba(6,182,212,0.08));
  box-shadow: 0 8px 18px rgba(99,102,241,0.08);
}
.lead {
  font-size: 15px;
  color: var(--muted);
}

/* Feature badges */
.start-features .feature {
  font-size: 14px;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.86));
  padding: 8px 12px;
  border-radius: 10px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.06);
}

/* Button / primary (subtle hover) */
.btn-primary {
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease, opacity 160ms ease;
  will-change: transform;
}
.btn-primary:active {
  transform: translateY(1px) scale(0.995);
}
.btn-primary:focus {
  box-shadow: 0 6px 20px rgba(124,58,237,0.18), 0 0 0 6px rgba(124,58,237,0.06);
}

/* Retry / secondary button styling */
#retry-btn,
.btn-secondary {
  appearance: none;
  border: none;
  outline: none;
  padding: 10px 16px;
  font-weight: 800;
  border-radius: 12px;
  color: var(--accent);
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0.9));
  border: 2px solid rgba(124,58,237,0.12);
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(124,58,237,0.06);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

/* Make the retry button stand out on hover */
#retry-btn:hover,
.btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(124,58,237,0.12);
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border-color: transparent;
}

/* Focus styles for accessibility */
#retry-btn:focus,
.btn-secondary:focus {
  box-shadow: 0 8px 26px rgba(124,58,237,0.14), 0 0 0 6px rgba(124,58,237,0.06);
}

/* Small adjustments on mobile */
@media (max-width: 720px) {
  #retry-btn,
  .btn-secondary {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    border-radius: 14px;
  }
}

/* Question and choice card polish */
#test-screen {
  padding-top: 8px;
}
#question {
  font-size: 20px;
  margin-bottom: 12px;
}
.choices-grid {
  gap: 14px;
}
.choice-btn {
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 6px 12px rgba(0,0,0,0.04);
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}
.choice-btn:hover:not([disabled]) {
  transform: translateY(-4px);
  box-shadow: 0 16px 30px rgba(0,0,0,0.08);
}
.choice-btn.selected {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(99,102,241,0.12);
}

/* Result card flourish */
.result-card {
  overflow: visible;
  padding: 22px;
  position: relative;
}
.result-card::before {
  content: '';
  position: absolute;
  left: -20px;
  top: -20px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle at 30% 30%, rgba(124,58,237,0.12), transparent 40%);
  filter: blur(18px);
  z-index: 0;
  pointer-events: none;
}
.result-header { position: relative; z-index: 1; }
.result-desc { z-index: 1; position: relative; }

/* Make tags more playful */
.tag {
  font-weight: 800;
  letter-spacing: -0.01em;
  transform: translateY(0);
  transition: transform 160ms ease;
}
.tag:hover {
  transform: translateY(-4px) scale(1.03);
}

/* Confetti tuning for accessibility: prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .confetti { display: none !important; }
  .choice-btn, .btn-primary, .result-card { transition: none !important; animation: none !important; }
}

/* Small layout tweaks for narrow devices */
@media (max-width: 420px) {
  .start-hero { gap: 10px; flex-direction: row; align-items: center; }
  .start-hero .hero-emoji { font-size: 44px; width: 56px; height: 56px; }
  .lead { font-size: 13px; }
  .start-features .feature { padding: 8px 10px; font-size: 13px; }
}
