:root {
  --bg-0: #0b0d10;
  --bg-1: #0f1216;
  --bg-2: #151a21;
  --surface: rgba(22, 27, 34, 0.72);
  --surface-hi: rgba(30, 37, 46, 0.85);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e9eaec;
  --muted: #9aa3ad;
  --gold: #f3c969;
  --gold-deep: #c98f2b;
  --gold-glow: rgba(243, 201, 105, 0.35);
  --good: #66e2a3;
  --bad: #ff7a7a;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-lg: 0 30px 80px -30px rgba(0, 0, 0, 0.7), 0 4px 16px -4px rgba(0, 0, 0, 0.5);
  --shadow-ring: 0 0 0 1px var(--line) inset;
  --font-serif: "Fraunces", "Playfair Display", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 800px at 85% -10%, rgba(243, 201, 105, 0.08), transparent 60%),
              radial-gradient(1000px 700px at -10% 110%, rgba(120, 160, 255, 0.06), transparent 60%),
              var(--bg-0);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }

/* ========== Aurora background ========== */
.aurora {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.aurora .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
}
.aurora .blob-a {
  width: 520px; height: 520px;
  background: radial-gradient(circle, #d8a24a, transparent 60%);
  top: -140px; right: -120px;
  animation: float 18s ease-in-out infinite;
}
.aurora .blob-b {
  width: 460px; height: 460px;
  background: radial-gradient(circle, #2f4a82, transparent 60%);
  bottom: -160px; left: -120px;
  animation: float 22s ease-in-out infinite reverse;
}
.aurora .blob-c {
  width: 360px; height: 360px;
  background: radial-gradient(circle, #7a4bd1, transparent 60%);
  top: 40%; left: 40%;
  opacity: 0.25;
  animation: float 28s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translate(0,0) scale(1); }
  50% { transform: translate(30px, -40px) scale(1.08); }
}

/* ========== Top bar ========== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 18px 40px;
  background: linear-gradient(180deg, rgba(11, 13, 16, 0.85), rgba(11, 13, 16, 0.55));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(140deg, rgba(243, 201, 105, 0.18), rgba(243, 201, 105, 0.02));
  border: 1px solid rgba(243, 201, 105, 0.25);
  box-shadow: 0 0 28px -8px var(--gold-glow);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-top: 2px;
}

.nav {
  display: flex;
  gap: 4px;
  margin-left: 18px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}
.nav-link {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  transition: color .2s ease, background .2s ease;
}
.nav-link:hover { color: var(--text); }
.nav-link.active {
  color: var(--bg-0);
  background: linear-gradient(180deg, #f6d98a, #c98f2b);
  box-shadow: 0 2px 14px -4px var(--gold-glow);
}

.meta { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.streak {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}
.streak #meta-mastered { color: var(--gold); font-weight: 600; }

/* ========== Layout ========== */
main {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 48px 40px 96px;
}

.section-head {
  margin-bottom: 28px;
}
.section-head h2 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 32px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.section-head p {
  color: var(--muted);
  margin: 0;
  max-width: 640px;
}
.section-head em { color: var(--gold); font-style: normal; }

/* ========== Hero ========== */
.hero {
  position: relative;
  padding: 64px 56px 72px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background:
    radial-gradient(600px 260px at 85% 10%, rgba(243, 201, 105, 0.12), transparent 70%),
    linear-gradient(180deg, rgba(25, 30, 38, 0.85), rgba(15, 18, 22, 0.65));
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin-bottom: 56px;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 0.85 0 0 0 0 0.5 0 0 0 0.08 0'/></filter><rect width='140' height='140' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: overlay;
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; max-width: 780px; }
.eyebrow {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  padding: 6px 12px;
  border: 1px solid rgba(243, 201, 105, 0.35);
  border-radius: 999px;
  margin-bottom: 22px;
  background: rgba(243, 201, 105, 0.06);
}
.hero h1 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(38px, 5.5vw, 64px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
}
.hero h1 em {
  font-style: italic;
  background: linear-gradient(90deg, #f9d776, #c98f2b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  color: var(--muted);
  font-size: 17px;
  max-width: 620px;
  margin: 0 0 32px;
}
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 44px; }

.stat-row {
  display: flex;
  gap: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.stat { display: flex; flex-direction: column; }
.stat-n {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 500;
  color: var(--gold);
  line-height: 1;
}
.stat-l {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-top: 8px;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 22px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.005em;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
}
.btn-primary {
  background: linear-gradient(180deg, #f6d98a, #c98f2b);
  color: #1a120a;
  box-shadow: 0 10px 30px -10px var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 18px 40px -12px var(--gold-glow); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-strong);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ========== Word grid ========== */
.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.word-card {
  position: relative;
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(10px);
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
  cursor: pointer;
  overflow: hidden;
}
.word-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0;
  transition: opacity .3s ease;
}
.word-card:hover {
  transform: translateY(-2px);
  border-color: rgba(243, 201, 105, 0.3);
  background: var(--surface-hi);
}
.word-card:hover::before { opacity: 1; }
.word-card.mastered {
  border-color: rgba(102, 226, 163, 0.3);
}
.word-card.mastered::after {
  content: "✓";
  position: absolute;
  top: 14px;
  right: 16px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--good);
  color: #0b0d10;
  font-size: 12px;
  font-weight: 700;
}
.word-card-num {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
}
.word-card-word {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
  margin: 4px 0 6px;
  letter-spacing: -0.005em;
}
.word-card-pos {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.word-card-def {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.5;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .35s ease, opacity .3s ease, margin-top .3s ease;
}
.word-card.open .word-card-def {
  max-height: 240px;
  opacity: 1;
}

/* ========== Study / Flashcards ========== */
.study-frame {
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}
.arrow {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: 26px;
  color: var(--muted);
  display: grid; place-items: center;
  transition: color .2s ease, border-color .2s ease, transform .1s ease;
}
.arrow:hover { color: var(--gold); border-color: rgba(243, 201, 105, 0.4); }
.arrow:active { transform: scale(0.95); }

.flash-wrap { perspective: 1800px; min-height: 340px; }
.flash {
  position: relative;
  width: 100%;
  min-height: 340px;
  cursor: pointer;
}
.flash-inner {
  position: relative;
  width: 100%;
  min-height: 340px;
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.2, .8, .2, 1);
}
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 56px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background:
    radial-gradient(500px 200px at 80% 10%, rgba(243, 201, 105, 0.08), transparent 70%),
    linear-gradient(180deg, rgba(24, 29, 36, 0.9), rgba(16, 19, 24, 0.9));
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.flash-back { transform: rotateY(180deg); text-align: left; }
.flash-kicker {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 18px;
}
.flash-word {
  font-family: var(--font-serif);
  font-size: clamp(44px, 6vw, 72px);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  background: linear-gradient(180deg, #fff 20%, #a8a39a 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.flash-pos {
  font-style: italic;
  color: var(--muted);
  font-size: 16px;
}
.flash-hint {
  position: absolute;
  bottom: 28px;
  left: 0; right: 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.flash-def {
  font-family: var(--font-serif);
  font-size: 26px;
  line-height: 1.35;
  margin: 0 0 32px;
  font-weight: 400;
}
.flash-example {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.flash-example p {
  margin: 4px 0 0;
  color: var(--muted);
  font-style: italic;
  font-size: 15.5px;
  line-height: 1.6;
}

.study-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 28px;
}
.chip {
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  transition: all .2s ease;
}
.chip-learn:hover { color: #ffb36e; border-color: rgba(255, 179, 110, 0.4); background: rgba(255, 179, 110, 0.08); }
.chip-master:hover { color: var(--good); border-color: rgba(102, 226, 163, 0.4); background: rgba(102, 226, 163, 0.08); }
.chip.active-learn { color: #ffb36e; border-color: rgba(255, 179, 110, 0.5); background: rgba(255, 179, 110, 0.1); }
.chip.active-master { color: var(--good); border-color: rgba(102, 226, 163, 0.5); background: rgba(102, 226, 163, 0.12); }

/* ========== Progress ========== */
.progress { max-width: 480px; margin: 0 auto; text-align: center; }
.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-bottom: 10px;
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), #f9d776);
  border-radius: 999px;
  transition: width .4s ease;
}
.progress-label {
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.progress-label span { color: var(--gold); font-weight: 600; }

/* ========== Quiz ========== */
.quiz-card {
  padding: 40px 48px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(24, 29, 36, 0.9), rgba(16, 19, 24, 0.9));
  box-shadow: var(--shadow-lg);
  max-width: 760px;
  margin: 0 auto;
}
.quiz-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}
.quiz-head .quiz-score strong, .quiz-head .quiz-score span { color: var(--gold); font-weight: 600; }
.quiz-prompt {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  line-height: 1.4;
  margin: 0 0 32px;
  letter-spacing: -0.005em;
}
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quiz-option {
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
  font-size: 15.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all .2s ease;
}
.quiz-option:hover:not(:disabled) {
  border-color: rgba(243, 201, 105, 0.4);
  background: rgba(243, 201, 105, 0.05);
  transform: translateY(-1px);
}
.quiz-option .opt-key {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.quiz-option.correct {
  border-color: var(--good);
  background: rgba(102, 226, 163, 0.1);
  color: var(--good);
}
.quiz-option.correct .opt-key { background: var(--good); color: #0b0d10; }
.quiz-option.wrong {
  border-color: var(--bad);
  background: rgba(255, 122, 122, 0.08);
  color: var(--bad);
}
.quiz-option.wrong .opt-key { background: var(--bad); color: #0b0d10; }
.quiz-option:disabled { cursor: default; }

.quiz-foot {
  margin-top: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
}
.q-feedback { color: var(--muted); font-size: 14px; }
.q-feedback.good { color: var(--good); }
.q-feedback.bad { color: var(--bad); }

.quiz-result {
  text-align: center;
  padding: 60px 40px;
}
.quiz-result h3 {
  font-family: var(--font-serif);
  font-size: 48px;
  font-weight: 400;
  margin: 0 0 12px;
}
.quiz-result .score-ring {
  width: 160px; height: 160px;
  margin: 0 auto 28px;
  position: relative;
  display: grid; place-items: center;
}
.quiz-result .score-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.quiz-result .score-ring .score-num {
  font-family: var(--font-serif);
  font-size: 48px;
  font-weight: 500;
  color: var(--gold);
}
.quiz-result p { color: var(--muted); margin-bottom: 28px; }

/* ========== Match ========== */
.match-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  padding: 14px 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
  color: var(--muted);
}
.match-meta strong { color: var(--gold); font-weight: 600; }
.match-meta button { margin-left: auto; }

.match-board {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 16px;
}
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-tile {
  padding: 16px 20px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  text-align: left;
  font-size: 15px;
  line-height: 1.45;
  transition: all .2s ease;
  cursor: pointer;
}
.match-tile.word {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
}
.match-tile:hover:not(.done) {
  border-color: rgba(243, 201, 105, 0.4);
  transform: translateX(2px);
}
.match-tile.selected {
  border-color: var(--gold);
  background: rgba(243, 201, 105, 0.08);
  box-shadow: 0 0 0 3px rgba(243, 201, 105, 0.12);
}
.match-tile.done {
  opacity: 0.35;
  cursor: default;
  border-color: var(--line);
}
.match-tile.flash-ok { animation: flashOk .6s ease; }
.match-tile.flash-no { animation: flashNo .5s ease; }
@keyframes flashOk {
  0% { background: rgba(102, 226, 163, 0.25); border-color: var(--good); }
  100% { background: var(--surface); }
}
@keyframes flashNo {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); background: rgba(255, 122, 122, 0.15); }
  60% { transform: translateX(6px); }
}

.match-win {
  text-align: center;
  padding: 40px;
  margin-top: 24px;
  border-radius: 20px;
  border: 1px solid rgba(243, 201, 105, 0.3);
  background: radial-gradient(400px 200px at center, rgba(243, 201, 105, 0.1), transparent 70%), var(--surface);
}
.match-win h3 {
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 400;
  margin: 0 0 8px;
  color: var(--gold);
}

/* ========== Footer ========== */
.footer {
  position: relative;
  z-index: 1;
  padding: 32px 40px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  letter-spacing: 0.03em;
}

/* ========== Transitions between views ========== */
.fade-in { animation: fadeIn .45s cubic-bezier(.2, .8, .2, 1); }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== Responsive ========== */
@media (max-width: 900px) {
  .topbar { padding: 14px 20px; gap: 14px; flex-wrap: wrap; }
  .nav { order: 3; width: 100%; justify-content: center; }
  .meta { margin-left: auto; }
  main { padding: 32px 20px 80px; }
  .hero { padding: 44px 28px 52px; }
  .stat-row { gap: 28px; flex-wrap: wrap; }
  .quiz-card { padding: 28px 22px; }
  .quiz-options { grid-template-columns: 1fr; }
  .flash-face { padding: 36px 28px; }
  .match-board { grid-template-columns: 1fr; }
  .study-frame { grid-template-columns: 40px 1fr 40px; }
  .arrow { width: 40px; height: 40px; font-size: 20px; }
}
