:root {
  --bg: #f4efe3;
  --bg-2: #e9e0cb;
  --card: #fffdf7;
  --ink: #23301f;
  --muted: #66705f;
  --line: #ddd3bd;
  --brand: #2f6b3a;
  --brand-ink: #ffffff;
  --brand-soft: #dcebd9;
  --venomous: #b8322a;
  --venomous-soft: #f8dcd8;
  --mild: #b9770e;
  --mild-soft: #f9ead0;
  --non: #2a7d46;
  --non-soft: #d8efdf;
  --good: #2a7d46;
  --good-soft: #dff2e4;
  --bad: #b8322a;
  --bad-soft: #f8dcd8;
  --shadow: 0 2px 10px rgba(40, 50, 30, .08);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161b14;
    --bg-2: #1e251b;
    --card: #222a1f;
    --ink: #eef1e8;
    --muted: #a4ad9c;
    --line: #36412f;
    --brand: #5fae6c;
    --brand-ink: #10160e;
    --brand-soft: #2a3d2b;
    --venomous: #ef6f62;
    --venomous-soft: #4a2420;
    --mild: #f0ae45;
    --mild-soft: #4a3718;
    --non: #63c784;
    --non-soft: #1f3f2a;
    --good: #63c784;
    --good-soft: #1f3f2a;
    --bad: #ef6f62;
    --bad-soft: #4a2420;
    --shadow: 0 2px 10px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Rubik", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(circle at 10% 0%, var(--bg-2) 0, transparent 40%),
                    radial-gradient(circle at 100% 100%, var(--bg-2) 0, transparent 40%);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--brand); }

.app { max-width: 760px; margin: 0 auto; padding: 16px 16px 32px; }
.screen { display: none; }
.screen.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.en { color: var(--muted); font-size: .85em; font-weight: 400; direction: ltr; unicode-bidi: isolate; }
.hidden-en .en-toggle { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 500;
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--bg-2); }
.btn.big { width: 100%; padding: 14px; font-size: 1.15rem; font-weight: 700; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 50%; width: 36px; height: 36px; flex: none; }

/* Start */
.hero { text-align: center; padding: 20px 0 8px; }
.logo { font-size: 64px; line-height: 1; animation: wiggle 3s ease-in-out infinite; display: inline-block; }
@keyframes wiggle { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
h1 { font-size: 2.4rem; font-weight: 800; margin: 8px 0 0; color: var(--brand); }
.subtitle { margin: 4px 0 0; font-size: 1.1rem; }
.subtitle .en { display: block; }

.cat-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0 16px; }
.cat-pill { border-radius: 14px; padding: 12px 10px; text-align: center; border: 1px solid var(--line); }
.cat-pill .ic { font-size: 1.6rem; display: block; }
.cat-pill b { display: block; }
.cat-pill small { display: block; color: var(--muted); font-size: .78rem; margin-top: 4px; line-height: 1.35; }
.cat-venomous { background: var(--venomous-soft); }
.cat-venomous b { color: var(--venomous); }
.cat-mild { background: var(--mild-soft); }
.cat-mild b { color: var(--mild); }
.cat-non { background: var(--non-soft); }
.cat-non b { color: var(--non); }

.setup { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.label { font-weight: 500; }
.seg { display: inline-flex; background: var(--bg-2); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 6px 16px; }
.seg button.on { background: var(--card); box-shadow: var(--shadow); font-weight: 700; color: var(--brand); }
.best { text-align: center; color: var(--muted); margin: 0; min-height: 1em; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.slider { width: 46px; height: 26px; border-radius: 26px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.slider::after { content: ""; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::after { transform: translateX(-20px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Quiz */
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress { flex: 1; height: 10px; background: var(--bg-2); border-radius: 10px; overflow: hidden; }
.bar { height: 100%; width: 0; background: var(--brand); border-radius: 10px; transition: width .3s; }
.stats { display: flex; gap: 10px; align-items: center; font-size: .95rem; white-space: nowrap; }
.streak { color: var(--mild); font-weight: 700; }

.question-card { padding: 0; overflow: hidden; }
.question-card > *:not(figure) { margin-left: 20px; margin-right: 20px; }
.q-image { margin: 0; position: relative; background: var(--bg-2); }
.q-image img { display: block; width: 100%; height: 300px; object-fit: cover; }
.q-image figcaption { position: absolute; bottom: 6px; left: 8px; font-size: .72rem; background: rgba(0,0,0,.5); border-radius: 6px; padding: 1px 6px; }
.q-image figcaption a { color: #fff; text-decoration: none; }
.q-type { display: inline-block; margin-top: 16px; font-size: .8rem; color: var(--muted); }
.q-text { font-size: 1.35rem; margin-top: 16px; margin-bottom: 4px; }
.q-text-en { margin-top: 0; text-align: left; }
.options { display: grid; gap: 10px; margin-top: 16px; margin-bottom: 20px; }
.options.three { grid-template-columns: repeat(3, 1fr); }
.opt {
  text-align: right;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex; gap: 10px; align-items: flex-start;
  transition: border-color .15s, background .15s;
}
.opt:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.opt .num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--bg-2); display: grid; place-items: center; font-size: .85rem; font-weight: 700; }
.opt .txt { flex: 1; }
.opt .txt .en { display: block; text-align: left; }
.opt:disabled { cursor: default; }
.opt.correct { border-color: var(--good); background: var(--good-soft); }
.opt.correct .num { background: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .num { background: var(--bad); color: #fff; }
.opt.dim { opacity: .55; }
.opt.cat { flex-direction: column; align-items: center; text-align: center; }
.opt.cat .ic { font-size: 1.6rem; }
.opt.cat .num { display: none; }
.opt.cat .txt .en { text-align: center; }

.feedback { border-top: 1px solid var(--line); padding: 18px 0 20px; animation: fade .25s ease; }
.fb-head { font-size: 1.4rem; font-weight: 800; }
.fb-head.good { color: var(--good); }
.fb-head.bad { color: var(--bad); }
.fb-answer { font-weight: 500; margin: 6px 0; }
.fb-explain { margin: 8px 0 12px; }
.badge { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: .85rem; font-weight: 700; }
.badge.venomous { background: var(--venomous-soft); color: var(--venomous); }
.badge.mild { background: var(--mild-soft); color: var(--mild); }
.badge.non { background: var(--non-soft); color: var(--non); }
.fb-links { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.fb-links a { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-2); border-radius: 10px; padding: 6px 12px; text-decoration: none; font-weight: 500; }
.fb-links a:hover { background: var(--brand-soft); }
.vocab { background: var(--bg-2); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.vocab h3 { margin: 0 0 8px; font-size: 1rem; }

.vocab-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.vocab-list li { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.vocab-list .he { font-weight: 500; }
.vocab-list .arrow { color: var(--muted); }
.vocab-list .w-en { direction: ltr; flex: 1; text-align: left; color: var(--brand); font-weight: 500; }
.say { background: none; border: 0; padding: 2px; font-size: 1rem; opacity: .7; }
.say:hover { opacity: 1; }
.glossary { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 12px; }

/* Result */
.result-card { text-align: center; }
.result-emoji { font-size: 64px; }
.result-card h2 { margin: 6px 0; }
.result-score { font-size: 1.2rem; margin: 0 0 16px; }
.review { padding-right: 20px; margin: 0; }
.review li { margin-bottom: 8px; }
.review .mark { font-weight: 700; }
.review .ok { color: var(--good); }
.review .no { color: var(--bad); }
.review small { color: var(--muted); display: block; }

/* Pages */
.page-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-top h2 { margin: 0; }
.search { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; }
.filter { margin-bottom: 14px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.g-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; text-align: right; padding: 0; box-shadow: var(--shadow); }
.g-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.g-card .g-body { padding: 10px 12px; }
.g-card b { display: block; }
.g-card .sci { font-style: italic; color: var(--muted); font-size: .8rem; direction: ltr; display: block; text-align: left; }

.snake-dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: 560px; width: calc(100% - 32px); background: var(--card); color: var(--ink); }
.snake-dialog::backdrop { background: rgba(0,0,0,.5); }
.snake-dialog img { width: 100%; max-height: 320px; object-fit: cover; display: block; }
.snake-dialog #dialog-body > div { padding: 16px 20px 0; }
.snake-dialog form { padding: 12px 20px 20px; }
.snake-dialog h2 { margin: 0; }

.foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 24px; }

@media (max-width: 560px) {
  h1 { font-size: 2rem; }
  .cat-legend small { display: none; }
  .q-image img { height: 220px; }
  .q-text { font-size: 1.15rem; }
  .options.three { grid-template-columns: 1fr; }
  .opt.cat { flex-direction: row; text-align: right; }
  .opt.cat .txt .en { text-align: left; }
  .stats { font-size: .85rem; gap: 6px; }
}
