:root {
  --paper: #EEF0F7;
  --ink: #23246B;
  --muted: #5B5E8C;
  --rule: #CDD1E6;
  --highlight: #FFE45C;
  --on-highlight: #23246B;
  --pen: #C8203A;
  --field: #FFFFFF;
  --display: 'Gloock', 'Iowan Old Style', Georgia, serif;
  --text: 'Figtree', -apple-system, system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #191A3D;
    --ink: #ECEDF8;
    --muted: #A3A6CC;
    --rule: #34366B;
    --highlight: #FFE45C;
    --on-highlight: #191A3D;
    --pen: #FF6B7D;
    --field: #242550;
  }
}
:root[data-theme="dark"] {
  --paper: #191A3D; --ink: #ECEDF8; --muted: #A3A6CC; --rule: #34366B;
  --highlight: #FFE45C; --on-highlight: #191A3D; --pen: #FF6B7D; --field: #242550;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.5 var(--text);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--highlight); outline-offset: 2px; border-radius: 4px; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 20px calc(env(safe-area-inset-bottom) + 24px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.bar { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.date { margin: 0; color: var(--muted); font-weight: 500; }
.icon-btn {
  width: 44px; height: 44px; margin-right: -10px;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 50%; color: var(--muted); cursor: pointer;
}

.install {
  margin: 4px 0 8px;
  padding: 12px 14px;
  border-left: 3px solid var(--highlight);
  background: color-mix(in srgb, var(--highlight) 18%, transparent);
  font-size: 15px;
}
.install p { margin: 0; }
.share-glyph svg { vertical-align: -2px; }

main { flex: 1; }
.status { color: var(--muted); margin-top: 30vh; text-align: center; }
.status button { margin-top: 12px; }

/* ---------- the word ---------- */
.word {
  font: 400 clamp(48px, 15vw, 84px)/0.98 var(--display);
  letter-spacing: -0.01em;
  margin: 28px 0 10px;
  overflow-wrap: anywhere;
}
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; margin: 0; color: var(--muted); }
.pos { font-style: italic; }
.speak {
  width: 40px; height: 40px; margin-left: -8px;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 50%; color: var(--muted); cursor: pointer;
}

.question { font: 700 15px/1.3 var(--text); color: var(--muted); margin: 40px 0 6px; }

/* Options sit on ruled lines, like a notebook page */
.options { list-style: none; margin: 0; padding: 0; counter-reset: opt; }
.options li { border-bottom: 1px solid var(--rule); }
.options li:first-child { border-top: 1px solid var(--rule); }
.opt {
  counter-increment: opt;
  display: grid; grid-template-columns: 28px 1fr; align-items: baseline;
  width: 100%; min-height: 60px; padding: 15px 0;
  background: none; border: 0; text-align: left; cursor: pointer;
  font-size: 18px; line-height: 1.4;
}
.opt::before { content: counter(opt, lower-alpha); color: var(--muted); font-weight: 500; }
.opt:active:not(:disabled) { background: color-mix(in srgb, var(--rule) 45%, transparent); }
.opt:disabled { cursor: default; }
.opt .t {
  padding: 1px 2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  background-repeat: no-repeat;
  background-size: 0% 100%;
  transition: background-size 0.55s cubic-bezier(.6, .1, .2, 1), color 0.2s;
}
/* Correct answer: swept with a highlighter */
.opt.is-right .t {
  background-image: linear-gradient(100deg, transparent 0 0.2em, var(--highlight) 0.4em calc(100% - 0.3em), transparent);
  background-size: 100% 100%;
  color: var(--on-highlight);
}
.opt.is-right::before { content: '✓'; color: var(--ink); }
/* Wrong pick: struck through in red pen */
.opt.is-wrong .t {
  text-decoration: line-through 2px var(--pen);
  color: var(--muted);
}
.opt.is-wrong::before { content: '✕'; color: var(--pen); }
.opt.is-dim { opacity: 0.7; }

/* ---------- result ---------- */
.result { margin-top: 36px; animation: rise 0.4s 0.35s both ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.verdict { font: 400 30px/1.15 var(--display); margin: 0 0 4px; }
.verdict-sub { margin: 0 0 32px; color: var(--muted); }

.translation { margin: 0 0 32px; }
.translation .lang { color: var(--muted); font-size: 15px; margin: 0; }
.translation .tword { font: 400 40px/1.1 var(--display); margin: 2px 0 6px; overflow-wrap: anywhere; }
.translation .alts { color: var(--muted); margin: 0 0 10px; }
.translation .tmeaning, .translation .texample, .translation .tnote { margin: 0 0 6px; }
.translation .texample { font-style: italic; }
.translation .tnote { color: var(--muted); font-size: 15px; }
.translation.loading { color: var(--muted); }

.detail { margin: 0 0 24px; }
.detail h3 { font: 700 15px/1.3 var(--text); color: var(--muted); margin: 0 0 4px; }
.detail p { margin: 0; }
.detail ul { margin: 0; padding: 0; list-style: none; }
.detail li { font-style: italic; margin-bottom: 6px; padding-left: 14px; border-left: 2px solid var(--rule); }
.detail mark { background: none; color: inherit; font-weight: 700; font-style: normal; }
.tip { padding: 14px 16px; background: var(--field); border-radius: 12px; }

.stats { color: var(--muted); font-size: 15px; text-align: center; padding-top: 32px; min-height: 1.5em; }

/* ---------- buttons ---------- */
.primary {
  display: block; width: 100%; min-height: 50px; padding: 12px 16px;
  background: var(--ink); color: var(--paper);
  border: 0; border-radius: 12px; font-weight: 700; cursor: pointer;
}
.primary.secondary { background: none; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.primary:disabled { opacity: 0.45; }
.text-btn { background: none; border: 0; padding: 10px 0; font-weight: 700; color: var(--ink); cursor: pointer; }

/* ---------- settings sheet ---------- */
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh;
  margin: auto auto 0; padding: 0;
  border: 0; border-radius: 20px 20px 0 0;
  background: var(--paper); color: var(--ink);
}
.sheet::backdrop { background: rgb(10 10 40 / 0.45); }
.sheet[open] { animation: sheet-up 0.28s ease-out; }
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet-body { padding: 8px 20px calc(env(safe-area-inset-bottom) + 24px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font: 400 28px/1.2 var(--display); margin: 12px 0; }
.welcome { margin: 0 0 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 24px; }
.field > span { font-weight: 700; }
.field small { color: var(--muted); font-size: 14px; line-height: 1.4; }
.field select, .field input {
  appearance: none; -webkit-appearance: none;
  width: 100%; min-height: 50px; padding: 12px 14px;
  font: 400 17px var(--text); color: var(--ink);
  background: var(--field); border: 1px solid var(--rule); border-radius: 12px;
}
.field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(-45deg, transparent 50%, var(--muted) 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px; background-repeat: no-repeat;
}

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