/* ── RESET & BASE ── */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@300;400;500;600&family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0a0a0f;
  --surface:  #13131a;
  --card:     #1c1c26;
  --border:   #2a2a3a;
  --accent:   #e8ff47;
  --accent2:  #47d4ff;
  --accent3:  #ff6b6b;
  --text:     #f0f0f5;
  --muted:    #6b6b8a;
  --correct:  #4ade80;
  --wrong:    #ff6b6b;
  --radius:   16px;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body:    'DM Sans', 'Noto Sans KR', sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
}

/* ── SCREENS ── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ── LANDING ── */
#screen-landing {
  position: relative;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.landing-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, #1a1a2e 0%, transparent 70%),
              radial-gradient(ellipse 60% 40% at 80% 100%, #0d1f1a 0%, transparent 60%);
}

.grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(232,255,71,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232,255,71,0.04) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

.landing-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
  max-width: 560px;
}

.badge {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--accent);
  border: 1px solid rgba(232,255,71,0.3);
  padding: 6px 16px;
  border-radius: 100px;
  background: rgba(232,255,71,0.05);
}

.logo {
  font-family: var(--font-display);
  font-size: clamp(64px, 14vw, 100px);
  line-height: 0.9;
  text-align: center;
  letter-spacing: 2px;
  color: var(--text);
}
.logo span { color: var(--accent); }

.tagline {
  font-size: 15px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

/* Upload Zone */
.upload-zone {
  position: relative;
  width: 100%;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  background: var(--surface);
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(232,255,71,0.04);
}
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-icon { color: var(--muted); margin-bottom: 12px; }
.upload-zone:hover .upload-icon,
.upload-zone.drag-over .upload-icon { color: var(--accent); }
.upload-main { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.upload-sub { font-size: 13px; color: var(--muted); }

/* Word Stats */
.word-stats {
  display: flex;
  gap: 16px;
  width: 100%;
}
.stat-box {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-num {
  display: block;
  font-family: var(--font-display);
  font-size: 36px;
  color: var(--accent);
  letter-spacing: 1px;
}
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; display: block; }

/* Mode Select */
.mode-select { width: 100%; }
.mode-title {
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 500;
}
.mode-btns { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.mode-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  color: var(--text);
}
.mode-btn:hover { border-color: var(--accent2); background: rgba(71,212,255,0.04); }
.mode-btn.active {
  border-color: var(--accent);
  background: rgba(232,255,71,0.06);
}
.mode-lang {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 1px;
  color: var(--accent);
  min-width: 60px;
}
.mode-btn.active .mode-lang { color: var(--accent); }
.mode-desc { font-size: 13px; color: var(--muted); }

.btn-start {
  width: 100%;
  padding: 18px;
  background: var(--accent);
  color: #0a0a0f;
  border: none;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-start:hover { background: #f5ff70; transform: translateY(-2px); box-shadow: 0 8px 30px rgba(232,255,71,0.25); }

.hidden { display: none !important; }

/* ── QUIZ SCREEN ── */
#screen-quiz {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}
#screen-quiz.active { display: flex; }

.quiz-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.btn-back {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.btn-back:hover { color: var(--text); border-color: var(--text); }

.progress-wrap { flex: 1; }
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 100px;
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
  width: 0%;
}

.quiz-mode-badge {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--accent2);
  border: 1px solid rgba(71,212,255,0.3);
  padding: 5px 12px;
  border-radius: 100px;
  white-space: nowrap;
}

/* Flash Card */
.quiz-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px 24px;
  gap: 24px;
}

.card-wrap {
  perspective: 1200px;
  width: 100%;
  max-width: 480px;
}

.card {
  position: relative;
  width: 100%;
  height: 220px;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}
.card.flipped { transform: rotateY(180deg); }

.card-front, .card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
}
.card-back { transform: rotateY(180deg); }

.card.correct-flash { animation: flashCorrect 0.4s ease; }
.card.wrong-flash { animation: flashWrong 0.4s ease; }

@keyframes flashCorrect {
  0%, 100% { border-color: var(--border); }
  50% { border-color: var(--correct); box-shadow: 0 0 30px rgba(74,222,128,0.3); }
}
@keyframes flashWrong {
  0%, 100% { border-color: var(--border); }
  50% { border-color: var(--wrong); box-shadow: 0 0 30px rgba(255,107,107,0.3); }
}

.card-label {
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.card-word {
  font-family: var(--font-display);
  font-size: clamp(36px, 8vw, 56px);
  letter-spacing: 1px;
  color: var(--text);
  text-align: center;
  line-height: 1.1;
}
.card-hint {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.6;
}

/* Choice Grid */
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 480px;
}

.choice-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  line-height: 1.4;
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--accent2);
  background: rgba(71,212,255,0.06);
  transform: translateY(-2px);
}
.choice-btn.correct {
  border-color: var(--correct);
  background: rgba(74,222,128,0.1);
  color: var(--correct);
}
.choice-btn.wrong {
  border-color: var(--wrong);
  background: rgba(255,107,107,0.1);
  color: var(--wrong);
}
.choice-btn:disabled { cursor: default; }

/* Result Popup */
.result-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: var(--card);
  border-radius: 20px;
  padding: 32px 48px;
  text-align: center;
  z-index: 100;
  animation: popIn 0.3s cubic-bezier(0.34,1.56,0.64,1) forwards;
  pointer-events: none;
  border: 1px solid var(--border);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
@keyframes popIn {
  to { transform: translate(-50%,-50%) scale(1); opacity: 1; }
  from { transform: translate(-50%,-50%) scale(0.8); opacity: 0; }
}
.result-icon { font-size: 48px; margin-bottom: 8px; }
.result-text { font-family: var(--font-display); font-size: 28px; letter-spacing: 1px; }

/* ── RESULT SCREEN ── */
#screen-result { display: none; flex-direction: column; }
#screen-result.active { display: flex; }

.result-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 20px 40px;
  gap: 24px;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
}

.result-trophy { font-size: 64px; }
.result-title {
  font-family: var(--font-display);
  font-size: 40px;
  letter-spacing: 2px;
  color: var(--accent);
}

.result-score-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 48px;
  text-align: center;
  width: 100%;
}
.result-big-score {
  font-family: var(--font-display);
  font-size: 80px;
  color: var(--accent);
  line-height: 1;
}
.result-score-label { font-size: 14px; color: var(--muted); margin-top: 6px; }

.result-stats {
  display: flex;
  gap: 12px;
  width: 100%;
}
.r-stat {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.r-stat--wrong .r-stat-num { color: var(--wrong); }
.r-stat-num {
  display: block;
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--correct);
}
.r-stat-label { font-size: 12px; color: var(--muted); display: block; margin-top: 4px; }

/* Wrong List */
.wrong-list-wrap {
  width: 100%;
  max-height: 280px;
  overflow-y: auto;
}
.wrong-title {
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.wrong-list { display: flex; flex-direction: column; gap: 6px; }
.wrong-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid rgba(255,107,107,0.2);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
}
.wrong-en { color: var(--text); font-weight: 500; }
.wrong-arrow { color: var(--muted); margin: 0 8px; }
.wrong-ko { color: var(--muted); }

.result-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}
.btn-retry, .btn-home {
  flex: 1;
  padding: 16px;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}
.btn-retry {
  background: var(--accent);
  color: #0a0a0f;
}
.btn-retry:hover { background: #f5ff70; transform: translateY(-2px); }
.btn-home {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-home:hover { border-color: var(--muted); transform: translateY(-2px); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Responsive */
@media (max-width: 400px) {
  .mode-btns { flex-direction: column; }
  .choice-grid { grid-template-columns: 1fr; }
}
