/* =========================================
   지적공무원 모의고사 - Global Styles
   ========================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0e1a;
  --surface: #111827;
  --surface2: #1a2235;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #4f8ef7;
  --accent2: #7c5cfc;
  --green: #22d3a0;
  --red: #f56565;
  --yellow: #f6c344;
  --text: #e8eaf0;
  --muted: #8a93aa;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Pretendard', 'Apple SD Gothic Neo', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Background Particles ---- */
.bg-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-particles span {
  position: absolute;
  border-radius: 50%;
  opacity: 0.06;
  animation: float 18s infinite ease-in-out;
}

.bg-particles span:nth-child(1) {
  width: 420px;
  height: 420px;
  background: #4f8ef7;
  top: -100px;
  left: -100px;
  animation-delay: 0s;
}

.bg-particles span:nth-child(2) {
  width: 300px;
  height: 300px;
  background: #7c5cfc;
  bottom: -80px;
  right: -80px;
  animation-delay: 3s;
}

.bg-particles span:nth-child(3) {
  width: 200px;
  height: 200px;
  background: #22d3a0;
  top: 50%;
  left: 60%;
  animation-delay: 6s;
}

.bg-particles span:nth-child(4) {
  width: 150px;
  height: 150px;
  background: #f6c344;
  top: 30%;
  right: 15%;
  animation-delay: 9s;
}

.bg-particles span:nth-child(5) {
  width: 250px;
  height: 250px;
  background: #4f8ef7;
  bottom: 20%;
  left: 5%;
  animation-delay: 12s;
}

.bg-particles span:nth-child(6) {
  width: 100px;
  height: 100px;
  background: #7c5cfc;
  top: 10%;
  left: 40%;
  animation-delay: 2s;
}

.bg-particles span:nth-child(7) {
  width: 180px;
  height: 180px;
  background: #22d3a0;
  bottom: 5%;
  right: 30%;
  animation-delay: 5s;
}

.bg-particles span:nth-child(8) {
  width: 80px;
  height: 80px;
  background: #f6c344;
  top: 70%;
  left: 20%;
  animation-delay: 8s;
}

.bg-particles span:nth-child(9) {
  width: 320px;
  height: 320px;
  background: #4f8ef7;
  top: 40%;
  left: -50px;
  animation-delay: 11s;
}

.bg-particles span:nth-child(10) {
  width: 260px;
  height: 260px;
  background: #7c5cfc;
  bottom: 40%;
  right: -60px;
  animation-delay: 14s;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-30px) scale(1.05);
  }
}

/* ---- App Shell ---- */
.app {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 16px 60px;
  min-height: 100vh;
}

/* ---- Screens ---- */
.screen {
  display: none;
  animation: fadeUp .45s cubic-bezier(.22, 1, .36, 1) both;
}

.screen.active {
  display: block;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================
   HOME SCREEN
   ========================================= */
.home-header {
  text-align: center;
  padding: 52px 0 40px;
}

.logo-badge {
  font-size: 56px;
  display: inline-block;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 20px rgba(79, 142, 247, 0.6));
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {

  0%,
  100% {
    filter: drop-shadow(0 0 20px rgba(79, 142, 247, 0.5));
  }

  50% {
    filter: drop-shadow(0 0 40px rgba(124, 92, 252, 0.8));
  }
}

.home-header h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  background: linear-gradient(135deg, #4f8ef7, #7c5cfc, #22d3a0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
}

.subtitle {
  margin-top: 10px;
  color: var(--muted);
  font-size: 1rem;
}

/* ---- Subject Cards ---- */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
}

@media (max-width: 580px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }
}

.subject-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
  position: relative;
  overflow: hidden;
}

.subject-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(79, 142, 247, 0.06), transparent);
  opacity: 0;
  transition: opacity .3s;
}

.subject-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(79, 142, 247, 0.2);
  border-color: rgba(79, 142, 247, 0.4);
}

.subject-card:hover::before {
  opacity: 1;
}

#card-it:hover {
  box-shadow: 0 16px 48px rgba(124, 92, 252, 0.2);
  border-color: rgba(124, 92, 252, 0.4);
}

#card-it::before {
  background: linear-gradient(135deg, rgba(124, 92, 252, 0.06), transparent);
}

.card-icon {
  font-size: 2.8rem;
  flex-shrink: 0;
}

.card-content {
  flex: 1;
}

.card-content h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.card-content p {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 12px;
}

.card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.card-arrow {
  font-size: 1.4rem;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform .2s;
}

.subject-card:hover .card-arrow {
  transform: translateX(4px);
  color: var(--accent);
}

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.badge-hard {
  background: rgba(245, 101, 101, 0.15);
  color: #f56565;
}

.badge-mid {
  background: rgba(246, 195, 68, 0.15);
  color: #f6c344;
}

.badge-easy {
  background: rgba(34, 211, 160, 0.15);
  color: #22d3a0;
}

/* ---- Stats Panel ---- */
.stats-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 32px;
}

.stats-panel h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.stat-item {
  background: var(--surface2);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.stat-subject {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-score {
  font-size: 1.5rem;
  font-weight: 800;
}

.stat-count {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.stat-empty {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 20px;
  width: 100%;
}

.home-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* =========================================
   EXAM SCREEN
   ========================================= */
.exam-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.btn-back {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background .2s;
  font-family: inherit;
  flex-shrink: 0;
}

.btn-back:hover {
  background: var(--surface2);
}

.exam-title-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-weight: 700;
  font-size: 1rem;
}

.exam-progress-text {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
}

.timer-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: background .3s, color .3s;
}

.timer-warn {
  background: rgba(245, 101, 101, 0.15) !important;
  color: #f56565 !important;
  border-color: rgba(245, 101, 101, 0.4) !important;
}

.timer-icon {
  font-size: 1rem;
}

.progress-bar-wrap {
  width: 100%;
  height: 5px;
  background: var(--surface2);
  border-radius: 99px;
  margin-bottom: 24px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
  transition: width .5s cubic-bezier(.22, 1, .36, 1);
}

/* ---- Question Card ---- */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px 24px;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
  min-height: 340px;
}

.q-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.q-number {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.q-difficulty {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}

.diff-상 {
  background: rgba(245, 101, 101, 0.15);
  color: #f56565;
}

.diff-중 {
  background: rgba(246, 195, 68, 0.15);
  color: #f6c344;
}

.diff-하 {
  background: rgba(34, 211, 160, 0.15);
  color: #22d3a0;
}

.q-text {
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.75;
  margin-bottom: 28px;
  color: var(--text);
}

.choices-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choice-item {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all .2s ease;
  position: relative;
  overflow: hidden;
}

.choice-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: transparent;
  border-radius: 4px 0 0 4px;
  transition: background .2s;
}

.choice-item:hover {
  border-color: var(--accent);
  background: rgba(79, 142, 247, 0.08);
}

.choice-item:hover::before {
  background: var(--accent);
}

.choice-item.selected {
  border-color: var(--accent);
  background: rgba(79, 142, 247, 0.12);
}

.choice-item.selected::before {
  background: var(--accent);
}

/* 채점 후 */
.choice-item.correct {
  border-color: var(--green);
  background: rgba(34, 211, 160, 0.1);
  pointer-events: none;
}

.choice-item.correct::before {
  background: var(--green);
}

.choice-item.wrong {
  border-color: var(--red);
  background: rgba(245, 101, 101, 0.1);
  pointer-events: none;
}

.choice-item.wrong::before {
  background: var(--red);
}

.choice-item.answered {
  pointer-events: none;
}

/* ---- Navigation ---- */
.exam-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.btn-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 22px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all .2s;
  font-family: inherit;
}

.btn-nav:hover {
  background: var(--surface2);
  border-color: var(--accent);
}

.btn-nav:disabled {
  opacity: 0.3;
  pointer-events: none;
}

.dot-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 320px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all .2s;
}

.dot.answered {
  background: var(--accent);
  border-color: var(--accent);
}

.dot.current {
  background: var(--accent2);
  border-color: var(--accent2);
  transform: scale(1.3);
}

.submit-wrap {
  text-align: center;
}

.btn-submit {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  color: #fff;
  border-radius: 12px;
  padding: 14px 48px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(79, 142, 247, 0.35);
  transition: transform .2s, box-shadow .2s;
  font-family: inherit;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(79, 142, 247, 0.45);
}

/* =========================================
   RESULT SCREEN
   ========================================= */
.result-header {
  text-align: center;
  padding: 40px 0 20px;
}

.result-emoji {
  font-size: 4rem;
  margin-bottom: 12px;
}

.result-header h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 6px;
}

#result-subject-label {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Score Ring */
.score-ring-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 24px auto 24px;
}

.score-ring {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.ring-bg {
  fill: none;
  stroke: var(--surface2);
  stroke-width: 10;
}

.ring-fill {
  fill: none;
  stroke: url(#ring-grad);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 314;
  stroke-dashoffset: 314;
  transition: stroke-dashoffset 1.2s cubic-bezier(.22, 1, .36, 1);
}

.score-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: row;
  gap: 2px;
}

#score-num {
  font-size: 2.8rem;
  font-weight: 800;
}

.score-denom {
  font-size: 1.1rem;
  color: var(--muted);
  align-self: flex-end;
  padding-bottom: 8px;
}

/* Result Stats */
.result-stats {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.rstat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  text-align: center;
  min-width: 110px;
}

.rstat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.rstat-val {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Review Section */
.review-section {
  margin-bottom: 32px;
}

.review-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.review-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
  border-left: 4px solid var(--border);
}

.review-item.review-correct {
  border-left-color: var(--green);
}

.review-item.review-wrong {
  border-left-color: var(--red);
}

.review-qnum {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.review-qtext {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 10px;
  line-height: 1.6;
}

.review-answer-wrap {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.review-answer-wrap span {
  font-weight: 600;
}

.ans-correct {
  color: var(--green);
}

.ans-wrong {
  color: var(--red);
}

.review-explanation {
  font-size: 0.83rem;
  color: var(--muted);
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px 14px;
  line-height: 1.6;
}

/* Result Buttons */
.result-buttons {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  padding-bottom: 20px;
}

.btn-retry,
.btn-home-result {
  border-radius: 12px;
  padding: 13px 36px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  font-family: inherit;
}

.btn-retry {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  color: #fff;
  box-shadow: 0 6px 20px rgba(79, 142, 247, 0.3);
}

.btn-retry:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(79, 142, 247, 0.4);
}

.btn-home-result {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-home-result:hover {
  background: var(--surface2);
  border-color: var(--accent);
}

/* SVG gradient for ring */
svg defs {
  display: block;
}

/* =========================================
   ROUND SELECTION SCREEN
   ========================================= */
.round-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  padding: 24px 0;
}

.round-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: all .25s ease;
  position: relative;
  overflow: hidden;
}

.round-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 12px 32px rgba(79, 142, 247, 0.2);
}

.round-card.done {
  border-color: var(--green);
}

.round-card.done:hover {
  box-shadow: 0 12px 32px rgba(34, 211, 160, 0.2);
}

/* 동그라미 번호 */
.round-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--surface2);
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 1.4rem;
  font-weight: 800;
  transition: all .25s;
}

.round-card:hover .round-circle {
  border-color: var(--accent);
  background: rgba(79, 142, 247, 0.12);
  color: var(--accent);
}

.round-card.done .round-circle {
  border-color: var(--green);
  background: rgba(34, 211, 160, 0.12);
  color: var(--green);
}

.round-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.round-date {
  font-size: 0.73rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.round-score {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--green);
}

.round-badge-new {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(34, 211, 160, 0.2);
  color: var(--green);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}