*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --bg: #080a09;
  --paper: #fbfaf6;
  --paper-2: #efebe0;
  --lime: #c6f26a;
  --lime-soft: rgba(198, 242, 106, .14);
  --red: #ff7a6b;
  --ink: #12160f;
  --muted-dark: #7d867f;
}

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: #e9ece6;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(620px 440px at 14% 0%, rgba(198, 242, 106, .16), transparent 65%),
    radial-gradient(720px 520px at 92% 8%, rgba(92, 152, 255, .12), transparent 62%),
    radial-gradient(900px 620px at 50% 112%, rgba(198, 242, 106, .08), transparent 62%);
  filter: blur(24px);
}

.wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 22px 20px 34px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand { display: flex; flex-direction: column; gap: 3px; text-decoration: none; color: inherit; }
.logo { font-size: 23px; font-weight: 800; letter-spacing: -.045em; line-height: 1; }
.logo .dot { color: var(--lime); }
.brand .sub {
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: #8b948d;
  font-weight: 600;
}

.head-right { display: flex; align-items: center; gap: 9px; }

.seg {
  display: flex;
  padding: 3px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 999px;
}
.seg button {
  border: 0;
  background: transparent;
  color: #9aa39c;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 7px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s, color .18s;
}
.seg button:hover:not(.on) { color: #fff; }
.seg button.on { background: var(--lime); color: #12170c; }

.icon {
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .04);
  color: #c9d1ca;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background .18s, transform .12s;
}
.icon:hover { background: rgba(255, 255, 255, .1); }
.icon:active { transform: scale(.94); }

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 20px;
  padding: 5px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 17px;
  backdrop-filter: blur(8px);
}

.tab {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: #a3aca4;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 13px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: background .18s, color .18s;
}
.tab .glyph { font-size: 12px; opacity: .65; }
.tab:hover:not(.on) { color: #fff; background: rgba(255, 255, 255, .06); }
.tab.on { background: #fff; color: #11150f; }

.progress { margin-left: auto; display: flex; align-items: center; gap: 9px; padding: 0 8px 0 4px; }
.ring {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: conic-gradient(var(--lime) calc(var(--p, 0) * 1%), rgba(255, 255, 255, .13) 0);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.ring span {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #0c0f0d;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 800;
  color: #dfe6da;
  font-variant-numeric: tabular-nums;
}
.progress-text { display: flex; flex-direction: column; line-height: 1.2; }
.progress-text strong { font-size: 12px; font-variant-numeric: tabular-nums; color: #eef1ea; }
.progress-text span { font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; color: #8b948d; font-weight: 700; }

/* ---------- stage ---------- */
.stage {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: center;
  padding-bottom: 8px;
}

.statusline {
  width: 100%;
  max-width: 460px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
  color: #8f9891;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

.mode { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }

/* ---------- deck ---------- */
.deck {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: clamp(370px, 52vh, 460px);
  perspective: 1600px;
  margin-top: 2px;
}

.ghost {
  position: absolute;
  inset: 0;
  border-radius: 26px;
  background: #161a16;
  border: 1px solid rgba(255, 255, 255, .06);
  transition: transform .35s ease, opacity .35s ease;
}
.ghost.g3 { transform: translateY(24px) scale(.9); opacity: .3; }
.ghost.g2 { transform: translateY(13px) scale(.95); opacity: .55; }
.ghost.g1 { transform: translateY(5px) scale(.98); opacity: .85; }

.card {
  position: absolute;
  inset: 0;
  border-radius: 26px;
  transform-style: preserve-3d;
  touch-action: none;
  cursor: grab;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 2;
  will-change: transform;
}
.card.dragging { cursor: grabbing; }
.card:focus-visible .face { outline: 2px solid var(--lime); outline-offset: 3px; }

.card .inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.3, .9, .25, 1);
}
.card.flipped .inner { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  border-radius: 26px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  padding: 26px 26px 22px;
  background: linear-gradient(158deg, var(--paper), var(--paper-2));
  color: var(--ink);
  box-shadow: 0 30px 60px -22px rgba(0, 0, 0, .85), inset 0 1px 0 #fff;
}
.face.back { transform: rotateY(180deg); background: linear-gradient(158deg, #f8f7f1, #e9e4d5); }

.tag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 800;
  color: #7c8478;
}
.tag::before { content: ""; width: 16px; height: 2px; border-radius: 2px; background: #c3c8ba; }

.face .word {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px 2px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  font-weight: 600;
  font-size: clamp(29px, 6.4vw, 46px);
  line-height: 1.14;
  letter-spacing: -.02em;
  overflow-wrap: break-word;
  hyphens: auto;
}
.face .word.long { font-size: clamp(20px, 4.5vw, 30px); }
.face .hintline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: #8b9184;
  font-weight: 500;
}

.face.back .word.small {
  flex: 0 0 auto;
  justify-content: flex-start;
  text-align: left;
  padding: 8px 0 2px;
  font-size: clamp(23px, 4.8vw, 32px);
  line-height: 1.18;
}
.face.back .word.small.long { font-size: clamp(19px, 4vw, 26px); }

.meta-line {
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: #8b9184;
  font-weight: 800;
}

.meaning {
  margin-top: 14px;
  padding-left: 12px;
  border-left: 2px solid #ccd3bf;
  font-size: 14px;
  line-height: 1.5;
  color: #3b4136;
}

.example {
  margin-top: auto;
  padding-top: 18px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  font-size: 15.5px;
  line-height: 1.55;
  color: #23281f;
}
.example mark {
  background: linear-gradient(transparent 52%, rgba(198, 242, 106, .7) 52%);
  color: inherit;
  padding: 0 2px;
  font-weight: 650;
}

.mark {
  position: absolute;
  top: 20px;
  z-index: 4;
  padding: 4px 10px;
  border: 2px solid currentColor;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s linear;
  background: rgba(255, 255, 255, .55);
  backdrop-filter: blur(3px);
}
.mark-right { right: 18px; color: #1f6a2c; transform: rotate(8deg); }
.mark-left { left: 18px; color: #9c3527; transform: rotate(-8deg); }

/* ---------- actions ---------- */
.actions { display: flex; gap: 9px; width: 100%; max-width: 440px; }

.btn {
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 12px;
  background: rgba(255, 255, 255, .06);
  color: #eef1ea;
  transition: transform .12s ease, background .18s, border-color .18s, filter .18s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.975); }
.btn .k { opacity: .5; font-size: 14px; }

.btn.no { flex: 1; color: #ffb4a8; border-color: rgba(255, 122, 107, .26); background: rgba(255, 122, 107, .08); }
.btn.no:hover { background: rgba(255, 122, 107, .16); }
.btn.yes { flex: 1; color: #dcffab; border-color: rgba(198, 242, 106, .3); background: rgba(198, 242, 106, .1); }
.btn.yes:hover { background: rgba(198, 242, 106, .18); }
.btn.mid {
  flex: 1.15;
  font-size: 12.5px;
  color: #c8d0c8;
  background: rgba(255, 255, 255, .05);
  border-color: rgba(255, 255, 255, .11);
}
.btn.mid:hover { background: rgba(255, 255, 255, .1); }

kbd {
  font-family: inherit;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .04em;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 5px;
  padding: 2px 5px;
  color: #aeb7ae;
}

.btn.primary {
  background: var(--lime);
  color: #101508;
  border: 0;
  padding: 14px 18px;
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: rgba(255, 255, 255, .14); color: #b7c0b7; }
.btn.ghost:hover { background: rgba(255, 255, 255, .05); }
.btn.wide { width: 100%; }

.hintline {
  margin: 0;
  max-width: 460px;
  text-align: center;
  font-size: 11px;
  line-height: 1.7;
  color: #7d867f;
}

/* ---------- quiz & typing ---------- */
.quizcard {
  width: 100%;
  max-width: 500px;
  padding: 26px;
  border-radius: 24px;
  background: linear-gradient(158deg, var(--paper), var(--paper-2));
  color: var(--ink);
  box-shadow: 0 30px 60px -25px rgba(0, 0, 0, .8), inset 0 1px 0 #fff;
}

.q-prompt {
  margin: 14px 0 6px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  font-weight: 600;
  font-size: clamp(25px, 5.4vw, 37px);
  line-height: 1.16;
  letter-spacing: -.02em;
  overflow-wrap: break-word;
  hyphens: auto;
}
.q-prompt.long { font-size: clamp(19px, 4.1vw, 27px); }
.q-sub { margin: 0 0 18px; font-size: 12.5px; color: #767e6f; }

.options { display: grid; gap: 8px; }
.option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 14.5px;
  font-weight: 550;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #dcd9cc;
  background: #fff;
  color: #1a1e17;
  cursor: pointer;
  transition: border-color .15s, transform .15s, background .15s;
}
.option .num {
  flex: 0 0 auto;
  min-width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 1px solid #e2dfd2;
  border-radius: 5px;
  font-size: 9.5px;
  font-weight: 800;
  color: #9aa292;
}
.option:hover:not(:disabled) { border-color: #12160f; transform: translateY(-1px); }
.option:disabled { cursor: default; opacity: .6; }
.option.correct { background: #e9fbcf; border-color: #7fbe3c; color: #1c3a10; opacity: 1; }
.option.correct .num { border-color: #7fbe3c; color: #3d7020; }
.option.wrong { background: #ffe9e4; border-color: #dd8779; color: #7c2a1c; opacity: 1; }
.option.wrong .num { border-color: #dd8779; color: #a8402c; }

.reveal { margin-top: 16px; padding-top: 14px; border-top: 1px solid #e0dccd; }
.reveal-word { font-weight: 750; font-size: 15.5px; letter-spacing: -.01em; }
.reveal .meaning { margin-top: 9px; border: 0; padding: 0; font-size: 13px; color: #5a6154; }
.reveal .example { margin-top: 10px; padding-top: 0; font-size: 14px; color: #3a4033; }
.reveal .btn { margin-top: 16px; }

.feedback { min-height: 20px; margin: 12px 0 0; font-size: 13px; font-weight: 650; line-height: 1.45; }
.feedback.ok { color: #3f7a1f; }
.feedback.bad { color: #a13a27; }

.type-row { display: flex; gap: 8px; margin-top: 4px; }
.type-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid #d9d6c8;
  background: #fff;
  color: #12160f;
  outline: none;
}
.type-row input::placeholder { color: #a8ae9d; }
.type-row input:focus { border-color: #12160f; box-shadow: 0 0 0 3px rgba(198, 242, 106, .45); }
.type-row .btn.primary { flex: 0 0 auto; border-radius: 12px; font-size: 13.5px; }

/* ---------- footer ---------- */
.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  font-size: 10.5px;
  color: #757e78;
  letter-spacing: .02em;
}
.foot-right { color: #5e665f; }

/* ---------- summary ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 8, 7, .72);
  backdrop-filter: blur(9px);
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }

.sheet {
  width: 100%;
  max-width: 400px;
  padding: 28px 26px 24px;
  border-radius: 26px;
  background: linear-gradient(158deg, var(--paper), #eee9dc);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 40px 80px -30px #000;
  animation: pop .28s cubic-bezier(.2, .9, .3, 1);
}
@keyframes pop { from { transform: translateY(14px) scale(.97); opacity: 0; } }

.sheet-emoji { font-size: 32px; line-height: 1; }
.sheet h2 { margin: 10px 0 8px; font-size: 22px; letter-spacing: -.025em; }
.sheet p { margin: 0 0 18px; font-size: 13.5px; line-height: 1.5; color: #6c7365; }

.sumgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.sumgrid > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 4px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #e3dfd2;
}
.sumgrid b { font-size: 20px; font-variant-numeric: tabular-nums; }
.sumgrid span {
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #8b9284;
}
.sheet .btn + .btn { margin-top: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .wrap { padding: 16px 14px 26px; }
  .brand .sub { display: none; }
  .tabs { flex-wrap: wrap; gap: 4px; }
  .tab { padding: 8px 11px; font-size: 12.5px; }
  .progress { margin-left: auto; padding-right: 4px; }
  .progress-text { display: none; }
  .deck { height: clamp(360px, 56vh, 430px); }
  .face { padding: 22px 20px 18px; }
  .btn.mid kbd { display: none; }
  .quizcard { padding: 20px; }
  .foot { justify-content: center; text-align: center; }
}

@media (max-width: 380px) {
  .seg button { padding: 7px 9px; font-size: 11px; }
  .tab .glyph { display: none; }
}

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