:root {
  --bg: #fff8ef;
  --bg-2: #fff1dc;
  --card: #ffffff;
  --ink: #2d2a32;
  --ink-2: #5d5866;
  --line: #eadfce;
  --accent: #4d96ff;
  --accent-soft: #e5efff;
  --ok: #2fb35a;
  --ok-soft: #dcf6e4;
  --bad: #e5484d;
  --bad-soft: #fde2e2;
  --warn: #f4a100;
  --warn-soft: #fff3d1;
  --shadow: 0 2px 0 rgba(45, 42, 50, .08), 0 8px 24px rgba(45, 42, 50, .06);
  --radius: 20px;
  --font-body: 'Noto Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Comfortaa', 'Noto Sans', system-ui, sans-serif;
  --sim-bg: #f4f9ff;
  --sim-ink: #2d2a32;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1a22; --bg-2: #23212c; --card: #2a2833; --ink: #f3eff8; --ink-2: #bcb5c9; --line: #3c3947;
    --accent-soft: #2f3550; --ok-soft: #1f3a2a; --bad-soft: #452428; --warn-soft: #43381c;
    --shadow: 0 2px 0 rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); --sim-bg: #22283a; --sim-ink: #f3eff8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1a22; --bg-2: #23212c; --card: #2a2833; --ink: #f3eff8; --ink-2: #bcb5c9; --line: #3c3947;
  --accent-soft: #2f3550; --ok-soft: #1f3a2a; --bad-soft: #452428; --warn-soft: #43381c;
  --shadow: 0 2px 0 rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); --sim-bg: #22283a; --sim-ink: #f3eff8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-body); color: var(--ink); background: var(--bg);
  background-image: radial-gradient(circle at 12% 8%, var(--bg-2) 0 120px, transparent 121px),
    radial-gradient(circle at 92% 30%, var(--bg-2) 0 80px, transparent 81px);
  background-attachment: fixed;
  font-size: 17px; line-height: 1.55; min-height: 100vh; overflow-x: hidden;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }

/* ---------- Κεφαλίδα ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.brand-logo { font-size: 1.5rem; }
.topbar-title { flex: 1; font-family: var(--font-head); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1rem; }
.spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; min-width: 42px; height: 42px; border-radius: 14px; border: 0;
  background: var(--card); box-shadow: var(--shadow); text-decoration: none; font-size: 1.15rem; cursor: pointer;
}
.install-btn { display: none; }
body.can-install .install-btn { display: inline-grid; }

.page { max-width: 780px; margin: 0 auto; padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); }

/* ---------- Αρχική ---------- */
.hero {
  display: grid; grid-template-columns: 110px 1fr; gap: 14px; align-items: center;
  background: var(--card); border-radius: 28px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.hero h1 { font-size: 1.35rem; }
.hero p { margin: 0 0 10px; color: var(--ink-2); }
.mascot svg { width: 110px; height: 110px; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
@media (max-width: 440px) { .hero { grid-template-columns: 1fr; text-align: center; } .mascot { margin: 0 auto; } }
.total { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: .95rem; }
.bar { flex: 1; height: 14px; border-radius: 99px; background: var(--line); overflow: hidden; display: block; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, #ffd93d, #ff9f45); border-radius: inherit; transition: width .6s; }
.bar.small { height: 8px; margin-top: 8px; width: 100%; }
.bar.small > span { background: var(--accent); }

.continue {
  display: flex; align-items: center; gap: 12px; text-decoration: none; background: var(--card); border-radius: 18px;
  padding: 12px 16px; box-shadow: var(--shadow); border-left: 6px solid var(--accent); margin-bottom: 18px;
}
.continue small { display: block; color: var(--ink-2); }
.continue-ic { font-size: 1.8rem; }
.continue .go { margin-left: auto; font-size: 1.3rem; color: var(--accent); }
.section-title { font-size: 1.2rem; margin: 8px 4px 12px; }

.chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; }
.chapter-card {
  position: relative; display: flex; flex-direction: column; text-decoration: none; padding: 16px 14px 14px; border-radius: 22px;
  background: var(--card); box-shadow: 0 4px 0 var(--accent), var(--shadow); border: 2px solid var(--accent);
  transition: transform .15s; overflow: hidden; min-height: 150px;
}
.chapter-card::before { content: ''; position: absolute; right: -30px; top: -30px; width: 100px; height: 100px; border-radius: 50%; background: var(--accent-soft); z-index: 0; }
.chapter-card > * { position: relative; }
.chapter-card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent); }
@media (hover: hover) { .chapter-card:hover { transform: translateY(-3px) rotate(-.5deg); } }
.ch-emoji { font-size: 2.2rem; line-height: 1; margin-bottom: 8px; }
.ch-num { font-size: .78rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .03em; }
.ch-title { font-family: var(--font-head); font-weight: 700; font-size: 1.08rem; line-height: 1.2; margin: 2px 0 4px; }
.ch-meta { font-size: .82rem; color: var(--ink-2); margin-top: auto; }

/* ---------- Κεφάλαιο ---------- */
.ch-hero { text-align: center; padding: 18px 8px 8px; }
.ch-hero-emoji { font-size: 3.5rem; display: block; animation: bob 3s ease-in-out infinite; }
.ch-hero p { color: var(--ink-2); max-width: 560px; margin: 0 auto; }
.lesson-list { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 10px; }
.lesson-item {
  display: flex; align-items: center; gap: 12px; text-decoration: none; background: var(--card); padding: 12px 14px;
  border-radius: 18px; box-shadow: var(--shadow); border: 2px solid transparent;
}
.lesson-item:hover { border-color: var(--accent); }
.lesson-item.done { border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.l-num { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; font-family: var(--font-head); }
.l-body { flex: 1; min-width: 0; }
.l-title { display: block; font-weight: 700; }
.l-sub { display: block; font-size: .85rem; color: var(--ink-2); }
.stars { white-space: nowrap; font-size: 1.1rem; letter-spacing: 1px; }
.star { color: var(--line); }
.star.on { color: #ffc93c; text-shadow: 0 1px 0 #e0a100; }
.stars.big { display: block; font-size: 2rem; text-align: center; margin: 4px 0 10px; }
.ch-done { text-align: center; font-weight: 700; }

/* ---------- Μάθημα ---------- */
.lesson-hero { padding: 8px 2px 4px; }
.lesson-hero h1 { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.l-emoji { font-size: 2rem; }
.chip { display: inline-block; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.hook {
  display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: center; margin: 12px 0 4px;
  background: var(--warn-soft); border-radius: 18px; padding: 10px 14px; border: 2px dashed var(--warn);
}
.hook p { margin: 0; font-weight: 600; }
.hook-mascot svg { width: 56px; height: 56px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 14px 0; }
.card-title { font-size: 1.15rem; display: flex; gap: 8px; align-items: center; }
.card-title .ic { font-size: 1.4rem; }
.prose p { margin: 0 0 .7em; }
.prose p:last-child { margin-bottom: 0; }
.prose ul { padding-left: 1.2em; margin: .3em 0 .7em; }
.prose li { margin: .2em 0; }
.term { background: var(--accent-soft); color: inherit; padding: 0 .3em; border-radius: 6px; font-weight: 700; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.learn { border-top: 5px solid var(--accent); }
.learn-art { margin: 4px auto 10px; text-align: center; }
.learn-art svg { width: 100%; max-height: 260px; }
.fact { background: var(--warn-soft); border: 2px solid color-mix(in srgb, var(--warn) 45%, transparent); box-shadow: none; }
.fact-badge { font-weight: 800; font-family: var(--font-head); margin-bottom: 4px; }
.glance { background: var(--accent-soft); box-shadow: none; }
.glance-list { margin: 0; padding-left: 1.2em; }
.glance-list li { margin: .35em 0; }
.glossary dt { font-weight: 800; color: var(--accent); margin-top: 8px; }
.glossary dd { margin: 0 0 0 0; }

.sim-head { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; margin-bottom: 4px; }
.chip-lab { background: #e1f5ff; color: #0077b6; }
.chip-exp { background: #ffe8d6; color: #c2410c; }
.chip-fill { background: #efe4ff; color: #7a3fd1; }
.chip-game { background: #dcf6e4; color: #1d7a3d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip-lab, :root:not([data-theme="light"]) .chip-exp, :root:not([data-theme="light"]) .chip-fill, :root:not([data-theme="light"]) .chip-game { background: rgba(255,255,255,.1); color: var(--ink); } }
.sim { border: 3px solid #bde3ff; }
.sim-how { color: var(--ink-2); margin: 0 0 8px; font-size: .95rem; }
.sim-body { display: grid; gap: 12px; }
.sim-svg { width: 100%; height: auto; background: var(--sim-bg); border-radius: 16px; display: block; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.sim-svg text { font-family: var(--font-body); }
.sim-svg text:not([fill]) { fill: var(--sim-ink); }
.sim-note { background: var(--accent-soft); border-radius: 14px; padding: 10px 12px; font-size: .95rem; min-height: 2.6em; }
.sim-note.ok { background: var(--ok-soft); }
.sim-note.bad { background: var(--bad-soft); }
.sim-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.readout { display: flex; flex-wrap: wrap; gap: 8px; }
.readout .pill { background: var(--bg-2); border-radius: 12px; padding: 6px 10px; font-weight: 700; font-size: .92rem; }

.exp { border: 3px dashed #ffc79c; }
.exp-q { font-weight: 700; margin: 4px 0 8px; }
.materials { background: var(--bg-2); border-radius: 14px; padding: 10px 12px; }
.mat-list { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 6px 0 0; }
.mat-list li { background: var(--card); border-radius: 99px; padding: 2px 10px; font-size: .9rem; border: 1px solid var(--line); }
.steps { padding-left: 1.3em; }
.steps li { margin: .4em 0; }
.safety { background: var(--bad-soft); border-radius: 12px; padding: 8px 12px; font-size: .92rem; }
.reveal-body { margin-top: 10px; background: var(--ok-soft); border-radius: 14px; padding: 10px 12px; }

/* ---------- Κουμπιά ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 10px 18px;
  border-radius: 16px; border: 0; cursor: pointer; font-weight: 800; text-decoration: none; font-size: 1rem;
  background: var(--card); box-shadow: 0 3px 0 var(--line); border: 2px solid var(--line); transition: transform .08s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 70%, #000); }
.btn-primary:active { box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 70%, #000); }
.btn-soft { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.btn-danger { background: var(--bad); color: #fff; border-color: var(--bad); box-shadow: 0 3px 0 #9b1c20; }
.btn-big { width: 100%; font-size: 1.1rem; min-height: 56px; }
.btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn { border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 12px; cursor: pointer; font-weight: 700; font-size: .92rem; min-height: 42px; }
.seg-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.slider { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; font-weight: 700; font-size: .95rem; }
.slider-label { grid-column: 1; }
.slider-val { grid-column: 2; background: var(--bg-2); border-radius: 10px; padding: 2px 8px; min-width: 3.5em; text-align: center; }
.slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); height: 34px; }

/* ---------- Συμπλήρωση ---------- */
.fill { border: 3px solid #e2d1ff; }
.hint { color: var(--ink-2); font-size: .9rem; margin: 0 0 8px; }
.fill-text { font-size: 1.05rem; line-height: 2.2; }
.blank {
  display: inline-block; min-width: 72px; border: 0; border-bottom: 3px solid #b983ff; background: color-mix(in srgb, #b983ff 18%, var(--card));
  border-radius: 8px 8px 0 0; padding: 0 8px; margin: 0 2px; font-weight: 800; cursor: pointer; line-height: 1.6; color: var(--ink);
}
.blank.ok { background: var(--ok-soft); border-color: var(--ok); cursor: default; }
.blank.bad { background: var(--bad-soft); border-color: var(--bad); }
.bank { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.word { border: 2px solid #b983ff; background: var(--card); color: var(--ink); border-radius: 12px; padding: 6px 12px; font-weight: 700; cursor: pointer; min-height: 42px; }
.word:disabled { opacity: .3; }
.fill-msg { margin-top: 10px; font-weight: 700; min-height: 1.4em; }
.fill-msg.ok { color: var(--ok); }
.fill-msg.bad { color: var(--bad); }

/* ---------- Ταξινόμηση ---------- */
.sort { border: 3px solid #bdecc9; }
.sort-pool { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; min-height: 10px; }
.sort-item { border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 8px 12px; font-weight: 700; cursor: pointer; min-height: 44px; box-shadow: 0 3px 0 var(--line); }
.sort-item.picked { border-color: var(--accent); background: var(--accent); color: #fff; transform: translateY(-3px); box-shadow: 0 6px 12px rgba(0,0,0,.15); }
.bins { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.bin { border: 3px dashed var(--line); background: var(--bg-2); border-radius: 18px; padding: 10px; min-height: 110px; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.bin-name { font-family: var(--font-head); font-weight: 800; }
.bin-list { display: flex; flex-wrap: wrap; gap: 5px; }
.sorted { background: var(--ok-soft); color: var(--ink); border-radius: 10px; padding: 2px 8px; font-size: .88rem; font-weight: 700; }
.bin-0 { border-color: #9ccbff; } .bin-1 { border-color: #ffb3a7; } .bin-2 { border-color: #b8e6a8; } .bin-3 { border-color: #e3c1ff; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Κουίζ ---------- */
.quiz-card { border: 3px solid var(--accent); text-align: center; }
.quiz { text-align: left; margin-top: 12px; }
.quiz-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 8px; flex-wrap: wrap; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.dot.cur { outline: 3px solid var(--accent); outline-offset: 1px; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }
.quiz-count { text-align: center; color: var(--ink-2); font-size: .88rem; margin: 0; }
.quiz-q { font-size: 1.15rem; margin: 8px 0 12px; font-family: var(--font-body); font-weight: 800; }
.quiz-opts { display: grid; gap: 8px; }
.quiz-opts.tf { grid-template-columns: 1fr 1fr; }
.opt { text-align: left; border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 14px; font-weight: 700; cursor: pointer; min-height: 50px; box-shadow: 0 3px 0 var(--line); }
.quiz-opts.tf .opt { text-align: center; }
.opt:not(:disabled):hover { border-color: var(--accent); }
.opt.ok { background: var(--ok-soft); border-color: var(--ok); box-shadow: 0 3px 0 var(--ok); }
.opt.bad { background: var(--bad-soft); border-color: var(--bad); box-shadow: 0 3px 0 var(--bad); }
.opt:disabled { cursor: default; }
.quiz-fb { margin: 12px 0; border-radius: 14px; padding: 0; }
.quiz-fb.ok, .quiz-fb.bad { padding: 10px 12px; }
.quiz-fb.ok { background: var(--ok-soft); } .quiz-fb.bad { background: var(--bad-soft); }
.quiz .btn-primary { width: 100%; }
.quiz-end { text-align: center; }
.big-stars { font-size: 3rem; letter-spacing: 6px; }
.big-stars .star.on { animation: pop .5s both; }
.big-stars .star.on:nth-child(2) { animation-delay: .15s; } .big-stars .star.on:nth-child(3) { animation-delay: .3s; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.3); } }
.quiz-score { font-size: 1.4rem; font-weight: 800; margin: 0; }
.new-best { font-weight: 800; color: var(--warn); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 100; }

/* ---------- Εργαλεία προσομοιώσεων ---------- */
.draggable { cursor: grab; }
.tap { cursor: pointer; }
.glow { filter: drop-shadow(0 0 6px #ffd93d); }
.pulse { animation: pulse 1.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.tbl th { background: var(--bg-2); }
.tbl tr.hl td { background: var(--accent-soft); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

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

/* ---------- Drag and drop ---------- */
.draggable-item { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
.draggable-item.pressing { transform: scale(.94); transition: transform .3s; }
.drag-ghost {
  position: fixed; z-index: 300; pointer-events: none; margin: 0; opacity: .95;
  transform: scale(1.08) rotate(-3deg); box-shadow: 0 10px 24px rgba(0,0,0,.25) !important;
}
.drag-origin { opacity: .3; }
body.dragging, body.dragging * { cursor: grabbing !important; -webkit-user-select: none; user-select: none; }
.drop-ready { outline: 3px dashed color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.drop-hover { outline: 3px solid var(--accent) !important; background: var(--accent-soft) !important; transform: scale(1.04); }
.blank.selected { border-bottom-color: var(--accent); background: var(--accent-soft); animation: pulse 1.2s ease-in-out infinite; }
.pan-hit.drop-ready { outline: none; }
.pan-hit.drop-ready + .pan-shape, .pan-hit.drop-hover + .pan-shape { stroke: var(--accent); stroke-width: 4; }
.pan-hit.drop-hover { transform: none; fill: rgba(77,150,255,.15) !important; }
.swatch { display: inline-block; width: 16px; height: 12px; border-radius: 3px; border: 1.5px solid #6d4c41; vertical-align: middle; }
/* Τα σχέδια να μην πιάνουν όλη την οθόνη του κινητού, ώστε να φαίνονται και τα κουμπιά τους */
.sim-svg { max-height: 58vh; }
