/* Modern CSS Reset & Core Styling */
:root {
  --bg-gradient: linear-gradient(135deg, #090d16 0%, #111827 50%, #1f1338 100%);
  --card-bg: rgba(30, 41, 59, 0.45);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --accent-primary: #8b5cf6;
  --accent-secondary: #6366f1;
  --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  --accent-glow: rgba(139, 92, 246, 0.3);
  
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.1);
  --color-success-border: rgba(16, 185, 129, 0.3);
  
  --color-error: #ef4444;
  --color-error-bg: rgba(239, 68, 68, 0.15);
  --color-error-border: rgba(239, 68, 68, 0.3);
  
  --font-sans: 'Noto Sans KR', sans-serif;
  --font-english: 'Outfit', sans-serif;
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Background Confetti Canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
}

/* Layout Elements */
.app-container {
  width: 100%;
  max-width: 600px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem;
}

/* Header styling */
.app-header {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.header-logo-img {
  height: 288px;
  max-width: 100%;
  object-fit: contain;
  filter: invert(1) brightness(1.2) drop-shadow(0 0 16px rgba(255, 255, 255, 0.25));
  mix-blend-mode: screen;
  transition: var(--transition-smooth);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Icon Buttons & Sound Toggle */
#sound-toggle-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  transition: var(--transition-smooth);
}

#sound-toggle-btn:hover {
  transform: translateY(-50%) scale(1.05);
}

#sound-toggle-btn:active {
  transform: translateY(-50%) scale(0.95);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.05);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* Main Content Area & Transitions */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-bottom: 2rem;
}

.quiz-screen {
  display: none;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.quiz-screen.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0);
}

/* CARD SYSTEM (Glassmorphism) */
.intro-card, .question-card, .result-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
}

/* Gimmicks on Intro Card */
.hero-image {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.glowing-orb {
  position: absolute;
  width: 90px;
  height: 90px;
  background: var(--accent-gradient);
  border-radius: 50%;
  filter: blur(20px);
  opacity: 0.5;
  animation: pulse 4s infinite alternate;
}

.hero-emoji {
  font-size: 3.5rem;
  z-index: 1;
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.5));
  animation: float 4s ease-in-out infinite;
}

@keyframes pulse {
  0% { transform: scale(0.85) rotate(0deg); opacity: 0.35; }
  100% { transform: scale(1.15) rotate(5deg); opacity: 0.6; }
}

.intro-card {
  text-align: center;
}

.intro-card h2 {
  font-size: 1.85rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 2rem;
}

/* Setup Group & Options Selection */
.setup-group {
  margin-bottom: 2rem;
  text-align: left;
}

.setup-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.quiz-options-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.selector-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.85rem 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: calc(var(--radius-md) - 4px);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.selector-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

.selector-btn.active {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* Primary/Secondary Buttons */
.primary-btn {
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  padding: 1.1rem 2rem;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  box-shadow: 0 4px 15px var(--accent-glow);
  transition: var(--transition-bounce);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--accent-glow);
}

.primary-btn:active {
  transform: translateY(1px);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 1rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  transition: var(--transition-smooth);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

/* QUIZ PLAY SCREEN STYLES */
.quiz-header {
  margin-bottom: 1.5rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

#score-tracker {
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.progress-bar-container {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  width: 0%;
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Question Sentence Box with Blank */
.sentence-box {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 1.25rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  text-align: center;
  min-height: 90px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.sentence-text {
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.8;
  word-break: keep-all;
}

/* Dynamic blank inside sentence */
.blank-space {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 80px;
  padding: 0 0.5rem;
  height: 34px;
  margin: 0 0.5rem;
  border-bottom: 3px solid var(--accent-primary);
  font-weight: 700;
  color: #fff;
  transition: var(--transition-smooth);
  vertical-align: middle;
  background: rgba(139, 92, 246, 0.05);
  border-radius: 4px 4px 0 0;
}

.blank-space.preview {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-secondary);
  background: rgba(139, 92, 246, 0.15);
}

.blank-space.correct {
  color: var(--color-success);
  border-bottom-color: var(--color-success);
  background: var(--color-success-bg);
}

.blank-space.incorrect {
  color: var(--color-error);
  border-bottom-color: var(--color-error);
  background: var(--color-error-bg);
}

/* Choices container and items */
.choices-container {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.choice-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  text-align: left;
  transition: var(--transition-bounce);
}

.choice-marker {
  font-family: var(--font-english);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: var(--transition-smooth);
}

.choice-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.15);
}

.choice-btn:hover:not(:disabled) .choice-marker {
  background: var(--accent-primary);
  color: #fff;
  border-color: transparent;
}

.choice-btn:active:not(:disabled) {
  transform: translateY(1px);
}

/* Choices States - Correct / Incorrect Selection */
.choice-btn.correct-choice {
  background: var(--color-success-bg) !important;
  border-color: var(--color-success) !important;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.15);
  color: #fff;
}

.choice-btn.correct-choice .choice-marker {
  background: var(--color-success) !important;
  color: #fff !important;
  border-color: transparent !important;
}

.choice-btn.incorrect-choice {
  background: var(--color-error-bg) !important;
  border-color: var(--color-error) !important;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.15);
  color: #fff;
}

.choice-btn.incorrect-choice .choice-marker {
  background: var(--color-error) !important;
  color: #fff !important;
  border-color: transparent !important;
}

.choice-btn:disabled {
  cursor: default;
  opacity: 0.6;
}

/* Shake Animation for Wrong Answers */
.shake-card {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%, 45%, 75% { transform: translateX(-8px); }
  30%, 60%, 90% { transform: translateX(8px); }
}

/* Instant Feedback Panel Styling */
.feedback-panel {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.feedback-panel.show {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.feedback-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.15rem;
}

.feedback-icon {
  font-size: 1.25rem;
}

.feedback-panel.correct-feedback .feedback-status {
  color: var(--color-success);
}

.feedback-panel.incorrect-feedback .feedback-status {
  color: var(--color-error);
}

.explanation-container {
  display: none;
  background: rgba(15, 23, 42, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  border-left: 4px solid var(--accent-primary);
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

.explanation-container.show {
  display: block;
}

.feedback-panel.correct-feedback .explanation-container {
  border-left-color: var(--color-success);
}

.feedback-panel.incorrect-feedback .explanation-container {
  border-left-color: var(--color-error);
}

#feedback-explanation {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.feedback-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.25rem;
}

/* RESULTS SCREEN STYLES */
.result-card {
  text-align: center;
}

.result-card h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
}

.score-circle-container {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.score-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.03);
  stroke-width: 8;
}

.score-ring-fill {
  fill: none;
  stroke: var(--accent-primary); /* fallback */
  stroke: url(#scoreGradient);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-text {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#score-percentage {
  font-family: var(--font-english);
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}

#score-fraction {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 0.2rem;
}

.result-badge {
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.75rem;
}

.result-message {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 2rem;
  padding: 0 1rem;
}

.result-actions {
  margin-bottom: 2.5rem;
}

/* Detailed Review / Mistakes Note section */
.review-section {
  text-align: left;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 2rem;
}

.review-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  color: #fff;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Review List Scrollbar Customization */
.review-list::-webkit-scrollbar {
  width: 6px;
}
.review-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}
.review-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
.review-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.review-item {
  background: rgba(15, 23, 42, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: relative;
  transition: var(--transition-smooth);
}

.review-item.correct-item {
  border-left: 4px solid var(--color-success);
}

.review-item.incorrect-item {
  border-left: 4px solid var(--color-error);
}

.review-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.review-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.review-item.correct-item .review-badge {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.review-item.incorrect-item .review-badge {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.review-num {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.review-sentence {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.review-sentence span {
  font-weight: 800;
}

.review-sentence .review-correct {
  color: var(--color-success);
  border-bottom: 2px solid var(--color-success);
}

.review-sentence .review-incorrect {
  color: var(--color-error);
  text-decoration: line-through;
}

.review-explanation {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.04);
}

/* Footer elements */
.app-footer {
  text-align: center;
  padding: 1rem 0;
}

.app-footer p {
  color: rgba(255, 255, 255, 0.2);
  font-size: 0.8rem;
}

/* Responsive Media Queries */
@media (max-width: 480px) {
  .app-container {
    padding: 1rem;
  }
  
  .intro-card, .question-card, .result-card {
    padding: 1.25rem 1rem;
    border-radius: var(--radius-md);
  }
  
  .intro-card h2 {
    font-size: 1.5rem;
  }
  
  .sentence-text {
    font-size: 1.1rem;
  }
  
  .choice-btn {
    padding: 1rem 1.25rem;
    font-size: 1rem;
  }
  
  .score-circle-container {
    width: 120px;
    height: 120px;
  }
  
  #score-percentage {
    font-size: 1.75rem;
  }
  
  .header-logo-img {
    height: 156px;
    max-width: 90%;
  }
}
