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

  :root {
    --ink: #0f0e0d;
    --cream: #faf8f4;
    --warm: #f2ede4;
    --accent: #c8432a;
    --accent2: #e8a87c;
    --muted: #8a8070;
    --green: #4c8a6b;
    --card-bg: #ffffff;
    --border: rgba(15,14,13,0.1);
  }

  html, body {
    height: 100%;
    font-family: 'DM Sans', sans-serif;
    background: var(--cream);
    color: var(--ink);
    overflow: hidden;
  }
  button { font-family: 'DM Sans', sans-serif; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  }

  /* ── SCREENS ── */
  .screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.5s ease;
    transform: translateY(20px);
  }
  .screen.active { opacity: 1; pointer-events: all; transform: translateY(0); }
  .screen.exit { opacity: 0; transform: translateY(-20px); pointer-events: none; }

  /* ── LANDING ── */
  #landing { background: var(--cream); gap: 0; }

  .landing-bg { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
  .landing-bg::before {
    content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%;
    background: radial-gradient(circle, rgba(200,67,42,0.12) 0%, transparent 70%);
    top: -80px; right: -80px;
  }
  .landing-bg::after {
    content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%;
    background: radial-gradient(circle, rgba(232,168,124,0.15) 0%, transparent 70%);
    bottom: 60px; left: -60px;
  }

  .landing-inner {
    position: relative; z-index: 1; display: flex; flex-direction: column;
    align-items: center; text-align: center; width: 100%; max-width: 360px;
  }

  .logo-mark {
    width: 56px; height: 56px; border-radius: 16px; background: var(--ink);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 28px; animation: float 3s ease-in-out infinite;
  }
  .logo-mark svg { width: 28px; height: 28px; fill: var(--cream); }

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

  .landing-eyebrow {
    font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--accent); margin-bottom: 14px;
  }
  .landing-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(44px, 12vw, 64px); font-weight: 900; line-height: 1.0;
    letter-spacing: -0.02em; color: var(--ink); margin-bottom: 20px;
  }
  .landing-sub {
    font-size: 16px; font-weight: 300; color: var(--muted); line-height: 1.6;
    max-width: 280px; margin-bottom: 32px;
  }

  .landing-stats {
    display: flex; gap: 10px; margin-bottom: 32px;
  }
  .landing-stat {
    background: white; border: 1px solid var(--border); border-radius: 14px;
    padding: 10px 18px; text-align: center; min-width: 88px;
  }
  .landing-stat .n { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; }
  .landing-stat .l { font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

  .btn-start {
    width: 100%; max-width: 280px; height: 58px; border-radius: 16px;
    background: var(--ink); color: var(--cream);
    font-size: 16px; font-weight: 600; letter-spacing: 0.04em;
    border: none; cursor: pointer; position: relative; overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    box-shadow: 0 4px 24px rgba(15,14,13,0.18);
  }
  .btn-start::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, transparent 60%);
  }
  .btn-start:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(15,14,13,0.25); }
  .btn-start:active { transform: translateY(0); }

  .btn-bank-link {
    margin-top: 14px; background: none; border: 1.5px solid var(--border);
    color: var(--muted); width: 100%; max-width: 280px; height: 48px; border-radius: 14px;
    font-size: 14px; font-weight: 500; cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
  }
  .btn-bank-link:hover { border-color: var(--ink); color: var(--ink); }

  .landing-footer {
    position: absolute; bottom: 28px; left: 0; right: 0; text-align: center;
    font-size: 12px; color: var(--muted); letter-spacing: 0.04em; z-index: 1;
  }

  /* ── HEADERS (learn / quiz / bank) ── */
  .app-header {
    width: 100%; padding: 52px 28px 20px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
  }
  .back-btn {
    width: 38px; height: 38px; border-radius: 50%;
    border: 1.5px solid var(--border); background: white;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: transform 0.15s;
  }
  .back-btn:hover { transform: scale(1.08); }
  .back-btn svg { width: 16px; height: 16px; }

  .progress-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
  .progress-label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.08em; }
  .progress-dots { display: flex; gap: 6px; }
  .dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--border);
    transition: background 0.4s ease, transform 0.4s ease;
  }
  .dot.done { background: var(--accent); }
  .dot.active { background: var(--ink); transform: scale(1.3); }

  .streak-badge {
    min-width: 38px; height: 38px; padding: 0 10px; border-radius: 100px;
    background: var(--ink); color: var(--cream);
    font-size: 13px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; gap: 3px;
  }

  /* ── LEARN ── */
  #learn { justify-content: flex-start; padding: 0; background: var(--warm); }

  .card-stage {
    flex: 1; width: 100%; display: flex; align-items: center; justify-content: center;
    padding: 12px 24px; perspective: 1000px; overflow: hidden;
  }

  .vocab-card {
    width: 100%; max-width: 360px; background: var(--card-bg);
    border-radius: 28px; padding: 32px 32px 28px;
    box-shadow: 0 20px 60px rgba(15,14,13,0.12), 0 4px 16px rgba(15,14,13,0.06);
    position: relative; overflow: hidden;
    animation: cardIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }
  @keyframes cardIn {
    from { opacity: 0; transform: scale(0.88) translateY(24px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
  }
  @keyframes cardOut {
    from { opacity: 1; transform: scale(1) translateY(0); }
    to   { opacity: 0; transform: scale(0.9) translateY(-20px); }
  }
  .vocab-card.leaving { animation: cardOut 0.3s ease forwards; }

  .card-accent-line {
    position: absolute; top: 0; left: 32px; right: 32px; height: 3px;
    border-radius: 0 0 4px 4px;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
  }

  .card-top-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }

  .card-tag {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--accent); background: rgba(200,67,42,0.08);
    padding: 5px 12px; border-radius: 100px;
  }
  .card-tag.review { color: var(--green); background: rgba(76,138,107,0.1); }

  .card-icons { display: flex; gap: 8px; }
  .icon-btn {
    width: 36px; height: 36px; border-radius: 50%;
    border: 1.5px solid var(--border); background: white;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: transform 0.15s, border-color 0.2s;
  }
  .icon-btn:hover { transform: scale(1.1); }
  .icon-btn svg { width: 16px; height: 16px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .icon-btn.marked { border-color: var(--accent); background: rgba(200,67,42,0.08); }
  .icon-btn.marked svg { fill: var(--accent); stroke: var(--accent); }

  .card-word {
    font-family: 'Playfair Display', serif;
    font-size: clamp(36px, 10vw, 50px); font-weight: 700; line-height: 1.05;
    letter-spacing: -0.02em; color: var(--ink); margin-bottom: 6px;
  }
  .card-phonetic { font-size: 14px; color: var(--muted); margin-bottom: 22px; font-style: italic; }
  .card-divider { height: 1px; background: var(--border); margin-bottom: 18px; }

  .card-reveal-zone { position: relative; min-height: 150px; }
  .card-meaning-label {
    font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 8px;
  }
  .card-meaning { font-size: 17px; line-height: 1.5; color: var(--ink); margin-bottom: 20px; }
  .card-example {
    background: var(--warm); border-left: 3px solid var(--accent2);
    border-radius: 0 10px 10px 0; padding: 12px 16px;
    font-size: 14px; font-weight: 300; line-height: 1.6;
    color: #5a5040; font-style: italic;
  }
  .card-example strong { font-weight: 600; font-style: normal; color: var(--ink); }

  .card-cover {
    position: absolute; inset: -4px; background: var(--card-bg);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; cursor: pointer; transition: opacity 0.35s ease; z-index: 2;
  }
  .card-cover.hidden { opacity: 0; pointer-events: none; }
  .card-cover .hint-icon {
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--warm); display: flex; align-items: center; justify-content: center;
    font-size: 20px;
  }
  .card-cover .hint-text { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0.06em; }
  .card-cover .hint-sub { font-size: 12px; font-weight: 300; color: var(--muted); }

  .learn-footer { width: 100%; padding: 16px 24px 36px; flex-shrink: 0; }
  .btn-next {
    width: 100%; height: 58px; border-radius: 16px;
    background: var(--ink); color: var(--cream);
    font-size: 16px; font-weight: 600; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.2s;
    box-shadow: 0 4px 20px rgba(15,14,13,0.2);
  }
  .btn-next:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(15,14,13,0.28); }
  .btn-next:active { transform: translateY(0); }
  .btn-next svg { width: 18px; height: 18px; transition: transform 0.2s; }
  .btn-next:hover svg { transform: translateX(3px); }

  /* ── QUIZ ── */
  #quiz { justify-content: flex-start; padding: 0; background: var(--warm); }

  .quiz-stage { flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; padding: 12px 24px; overflow: hidden; }
  .quiz-card {
    width: 100%; max-width: 360px; background: var(--card-bg);
    border-radius: 28px; padding: 32px;
    box-shadow: 0 20px 60px rgba(15,14,13,0.12), 0 4px 16px rgba(15,14,13,0.06);
    position: relative; overflow: hidden;
    animation: cardIn 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
  }
  .quiz-card.leaving { animation: cardOut 0.3s ease forwards; }
  .quiz-q-label {
    font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 10px;
  }
  .quiz-q {
    font-family: 'Playfair Display', serif;
    font-size: 24px; font-weight: 700; line-height: 1.3; margin-bottom: 22px;
  }
  .quiz-q em { color: var(--accent); font-style: normal; }
  .quiz-opts { display: flex; flex-direction: column; gap: 10px; }
  .quiz-opt {
    width: 100%; text-align: left; padding: 14px 16px; border-radius: 14px;
    border: 1.5px solid var(--border); background: white;
    font-size: 14.5px; font-weight: 500; line-height: 1.4; color: var(--ink);
    cursor: pointer; transition: border-color 0.15s, background 0.15s, transform 0.15s;
    display: flex; gap: 10px; align-items: baseline;
  }
  .quiz-opt .key {
    font-size: 11px; font-weight: 700; color: var(--muted);
    border: 1px solid var(--border); border-radius: 6px;
    padding: 1px 6px; flex-shrink: 0;
  }
  .quiz-opt:hover { border-color: var(--ink); transform: translateY(-1px); }
  .quiz-opt.correct { border-color: var(--green); background: rgba(76,138,107,0.1); }
  .quiz-opt.wrong { border-color: var(--accent); background: rgba(200,67,42,0.08); }
  .quiz-opt:disabled { cursor: default; }

  /* ── RESULTS / DONE ── */
  #done, #results { background: var(--ink); color: var(--cream); gap: 0; }
  .done-bg { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
  .done-bg::before {
    content: ''; position: absolute; width: 500px; height: 500px; border-radius: 50%;
    background: radial-gradient(circle, rgba(200,67,42,0.25) 0%, transparent 65%);
    top: -120px; right: -120px;
  }
  .done-bg::after {
    content: ''; position: absolute; width: 350px; height: 350px; border-radius: 50%;
    background: radial-gradient(circle, rgba(232,168,124,0.15) 0%, transparent 65%);
    bottom: -60px; left: -80px;
  }
  .done-inner {
    position: relative; z-index: 1; display: flex; flex-direction: column;
    align-items: center; text-align: center; width: 100%; max-width: 340px;
  }
  .done-icon {
    width: 80px; height: 80px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.15);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 28px; font-size: 36px;
    animation: popIn 0.6s cubic-bezier(0.34,1.56,0.64,1) both 0.2s;
  }
  @keyframes popIn { from { opacity:0; transform: scale(0.5);} to { opacity:1; transform: scale(1);} }
  .done-eyebrow {
    font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--accent2); margin-bottom: 14px; animation: fadeUp 0.5s ease both 0.4s;
  }
  .done-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(28px, 8vw, 40px); font-weight: 900; line-height: 1.1;
    margin-bottom: 14px; animation: fadeUp 0.5s ease both 0.5s;
  }
  .done-sub {
    font-size: 15px; font-weight: 300; color: rgba(250,248,244,0.6); line-height: 1.6;
    margin-bottom: 28px; animation: fadeUp 0.5s ease both 0.6s;
  }
  @keyframes fadeUp { from { opacity:0; transform: translateY(12px);} to { opacity:1; transform: translateY(0);} }

  .done-stats-row {
    display: flex; gap: 10px; margin-bottom: 28px;
    animation: fadeUp 0.5s ease both 0.62s;
  }
  .done-stat {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px; padding: 10px 16px; min-width: 88px;
  }
  .done-stat .n { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; }
  .done-stat .l { font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(250,248,244,0.5); margin-top: 2px; }

  .done-words-row {
    display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
    margin-bottom: 32px; animation: fadeUp 0.5s ease both 0.65s;
  }
  .done-word-chip {
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 100px; padding: 6px 14px;
    font-size: 13px; font-weight: 500; color: rgba(250,248,244,0.8);
  }

  .btn-game {
    width: 100%; max-width: 280px; height: 58px; border-radius: 16px;
    background: var(--accent); color: white;
    font-size: 16px; font-weight: 600; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    box-shadow: 0 4px 24px rgba(200,67,42,0.4);
    transition: transform 0.18s, box-shadow 0.18s;
    animation: fadeUp 0.5s ease both 0.75s;
  }
  .btn-game:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(200,67,42,0.5); }
  .btn-ghost {
    margin-top: 14px; background: none;
    border: 1.5px solid rgba(255,255,255,0.18); color: rgba(250,248,244,0.65);
    width: 100%; max-width: 280px; height: 48px; border-radius: 14px;
    font-size: 14px; font-weight: 500; cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    animation: fadeUp 0.5s ease both 0.85s;
  }
  .btn-ghost:hover { border-color: rgba(255,255,255,0.35); color: var(--cream); }

  /* ── WORD BANK ── */
  #bank { justify-content: flex-start; padding: 0; background: var(--warm); }
  .bank-body { flex: 1; width: 100%; max-width: 420px; overflow-y: auto; padding: 0 24px 40px; }
  .bank-search {
    width: 100%; height: 48px; border-radius: 14px;
    border: 1.5px solid var(--border); background: white;
    padding: 0 16px; font-family: 'DM Sans', sans-serif; font-size: 14px;
    margin-bottom: 12px; outline: none; transition: border-color 0.2s;
  }
  .bank-search:focus { border-color: var(--ink); }
  .bank-filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
  .bank-filter {
    border: 1.5px solid var(--border); background: white; border-radius: 100px;
    padding: 6px 14px; font-size: 12px; font-weight: 600; color: var(--muted);
    cursor: pointer; transition: all 0.15s;
  }
  .bank-filter.on { background: var(--ink); color: var(--cream); border-color: var(--ink); }
  .bank-empty { text-align: center; color: var(--muted); font-size: 14px; font-weight: 300; padding: 48px 20px; line-height: 1.6; }
  .bank-item {
    background: white; border: 1px solid var(--border); border-radius: 18px;
    padding: 16px 18px; margin-bottom: 10px; cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
  }
  .bank-item:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(15,14,13,0.08); }
  .bank-item-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .bank-item-word { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 700; }
  .bank-item-badges { display: flex; gap: 6px; align-items: center; }
  .mini-badge {
    font-size: 9px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
    border-radius: 100px; padding: 3px 8px;
  }
  .mini-badge.struggling { color: var(--accent); background: rgba(200,67,42,0.1); }
  .mini-badge.mastered { color: var(--green); background: rgba(76,138,107,0.12); }
  .mini-badge.book { color: #a07818; background: rgba(240,208,128,0.28); }
  .bank-item-detail { display: none; margin-top: 12px; }
  .bank-item.open .bank-item-detail { display: block; }
  .bank-item-detail .card-meaning { font-size: 15px; margin-bottom: 12px; }
  .bank-item-detail .card-example { font-size: 13px; }
  .bank-item-actions { display: flex; gap: 8px; margin-top: 12px; }
  .bank-mini-btn {
    border: 1.5px solid var(--border); background: white; border-radius: 100px;
    padding: 6px 14px; font-size: 12px; font-weight: 600; color: var(--ink);
    cursor: pointer; transition: all 0.15s;
  }
  .bank-mini-btn:hover { border-color: var(--ink); }
  .bank-mini-btn.marked { border-color: var(--accent); color: var(--accent); background: rgba(200,67,42,0.06); }

  /* confetti */
  .confetti-wrap { position: fixed; inset: 0; pointer-events: none; z-index: 99; }
  .confetto { position: absolute; top: -12px; width: 8px; height: 8px; border-radius: 2px; animation: fall linear forwards; }
  @keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: 0; } }

  /* toast */
  .toast {
    position: fixed; bottom: 100px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--ink); color: var(--cream);
    padding: 10px 20px; border-radius: 100px;
    font-size: 13px; font-weight: 500; opacity: 0;
    transition: all 0.3s ease; pointer-events: none; z-index: 50; white-space: nowrap;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
