:root {
  --bg: #fff7ea;
  --card: #ffffff;
  --pic-bg: #ffffff;
  --ink: #2b2b2b;
  --muted: #736b60;
  --line: #e8d8be;
  --soft: #f1e6d4;
  --accent: #d7141a;
  --accent-ink: #ffffff;
  /* Czech textbook gender colours (Czech Step by Step) */
  --g-f:  #d7141a;
  --g-ma: #11457e;
  --g-mi: #1f7ab8;
  --g-n:  #237a3c;
  --right: #237a3c; --right-soft: #dff3e3;
  --wrong: #c0392b; --wrong-soft: #fbe3df;
  --gold: #e0a100;
  --gold-ink: #8a5a00;
  --almost: #8f5600; --almost-soft: #fff0d6;
  --shadow: 0 6px 18px rgba(80, 50, 20, .12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1814;
    --card: #26221c;
    --pic-bg: #fdf8f0;   /* pictures are drawn for a light background */
    --ink: #eee7dc;
    --muted: #b0a695;
    --line: #3b352c;
    --soft: #332d25;
    --accent: #ff6f61;
    --accent-ink: #1b1814;
    --g-f:  #ff6b6b;
    --g-ma: #8fb4ec;
    --g-mi: #6cc0f5;
    --g-n:  #62d283;
    --right: #62d283; --right-soft: #1f3a27;
    --wrong: #ff7b6b; --wrong-soft: #45221d;
    --gold: #f5c542;
    --gold-ink: #f5c542;
    --almost: #f0b04a; --almost-soft: #3d2e14;
    --shadow: 0 6px 18px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Nunito", "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; touch-action: manipulation; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button:focus-visible, .button:focus-within, input:focus-visible { outline: 3px solid var(--g-mi); outline-offset: 2px; }
h1 { font-size: 1.5rem; margin: 0; }
.loading { text-align: center; padding-top: 28vh; color: var(--muted); font-weight: 700; }
.toast { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 30; width: max-content; max-width: calc(100% - 32px); background: var(--ink); color: var(--bg); font-weight: 800; padding: 10px 16px; border-radius: 14px; box-shadow: var(--shadow); animation: slidedown .25s ease; }
.banner { background: var(--almost-soft); color: var(--ink); border-bottom: 2px solid var(--almost); padding: 10px 16px; font-weight: 700; text-align: center; }

.screen { max-width: 560px; margin: 0 auto; padding: 12px 16px 28px; }
.screen.wide { max-width: 900px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.brand { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 1.35rem; font-weight: 800; }
.pills { display: flex; gap: 8px; }
.pill { background: var(--card); box-shadow: var(--shadow); border-radius: 999px; padding: 6px 12px; font-weight: 800; white-space: nowrap; }
.pill.streak:not(.lit) { filter: grayscale(1); opacity: .75; }
.icon-btn { border: none; background: var(--soft); border-radius: 999px; width: 44px; height: 44px; font-size: 1.2rem; cursor: pointer; flex: none; }

kbd { font: inherit; font-size: .7em; font-weight: 700; opacity: .6; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-right: 6px; }
@media (hover: none) { kbd { display: none; } }

button.primary {
  display: block; width: 100%; margin: 14px auto 0; border: none; border-radius: 16px;
  background: var(--accent); color: var(--accent-ink); font-size: 1.15rem; font-weight: 800; padding: 14px;
  cursor: pointer; box-shadow: 0 4px 0 rgba(0, 0, 0, .22);
}
button.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, .22); }
button.primary:disabled { opacity: .4; cursor: default; }
button.primary.done { background: var(--soft); color: var(--muted); box-shadow: none; opacity: 1; }
button.primary.big { font-size: 1.35rem; padding: 18px; }
button.secondary, .panel button, .button {
  display: block; width: 100%; margin: 10px auto 0; border: 2px solid var(--line); border-radius: 14px;
  background: var(--card); padding: 12px; font-weight: 800; cursor: pointer;
}
button.secondary.small { display: inline-block; width: auto; padding: 8px 14px; font-size: .9rem; margin: 0; }
.hint { text-align: center; color: var(--muted); font-weight: 600; min-height: 1.2em; margin: 10px 0 0; }

/* home */
.goal { position: relative; width: 180px; height: 180px; margin: 18px auto 8px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; stroke-linecap: round; }
.ring-bg { stroke: var(--soft); }
.ring-fg { stroke: var(--accent); stroke-dasharray: 0 999; transition: stroke-dasharray .6s ease; }
.goal.met .ring-fg { stroke: var(--gold); }
.goal-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.goal-text b { font-size: 2.6rem; line-height: 1; }
.goal-text span { font-weight: 700; color: var(--muted); }
.goal-text small { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.tiles, .sum-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.tile { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 6px; text-align: center; }
.tile b { display: block; font-size: 1.8rem; line-height: 1.1; }
.tile span { color: var(--muted); font-weight: 700; font-size: .8rem; }
.home-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.nav-btn { border: none; background: var(--card); box-shadow: var(--shadow); border-radius: 16px; padding: 14px 8px; font-weight: 800; cursor: pointer; }
.nav-btn small { display: block; color: var(--muted); font-weight: 700; }
.levelbar { height: 8px; background: var(--soft); border-radius: 99px; margin-top: 22px; overflow: hidden; }
.levelbar div { height: 100%; background: var(--gold); border-radius: 99px; width: 0; transition: width .6s ease; }
.xp-line { text-align: center; color: var(--muted); font-size: .85rem; font-weight: 700; margin: 6px 0 0; }

/* lesson */
.lesson-top { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.progress { flex: 1; height: 14px; background: var(--soft); border-radius: 99px; overflow: hidden; }
#progress-fg { height: 100%; width: 0; background: var(--right); border-radius: 99px; transition: width .3s ease; }
.combo { min-width: 4.5em; text-align: right; font-weight: 800; color: var(--gold-ink); white-space: nowrap; }
.combo:not(.on) .meter { visibility: hidden; }
.combo .meter { height: 4px; background: var(--soft); border-radius: 99px; margin-top: 2px; overflow: hidden; }
#combo-fg { height: 100%; width: 0; background: var(--gold); transition: width .25s ease; }
.combo.hot #combo-n { animation: pop .3s ease; }
.stage { padding-bottom: 8px; }
.prompt { font-size: 1.25rem; font-weight: 800; margin: 12px 0 10px; outline: none; }
.stage.masked text.ans { visibility: hidden; }
.prompt .target { font-size: 1.5em; color: var(--accent); display: inline-block; }

.card {
  background: var(--card); border-radius: 22px; box-shadow: var(--shadow);
  padding: 14px 14px 16px; text-align: center; border-top: 8px solid var(--line);
}
[data-gender="f"]  { --g: var(--g-f); }
[data-gender="ma"] { --g: var(--g-ma); }
[data-gender="mi"] { --g: var(--g-mi); }
[data-gender="n"]  { --g: var(--g-n); }
.card.revealed { border-top-color: var(--g); }
.pic { background: var(--pic-bg); border-radius: 14px; padding: 4px; }
.pic svg { display: block; width: 100%; max-width: 260px; max-height: 30vh; height: auto; aspect-ratio: 120 / 100; margin: 0 auto; }
.cs { font-size: 2.3rem; font-weight: 800; margin-top: 8px; line-height: 1.15; }
.card.revealed .cs { color: var(--g); }
.cs.small { font-size: 1.4rem; }
.cs .art { font-weight: 600; opacity: .7; font-size: .7em; }
.frame { font-size: 1.6rem; font-weight: 700; margin-top: 6px; }
.blank { display: inline-block; min-width: 3em; border-bottom: 3px solid var(--accent); color: var(--muted); }
.say { border: none; background: var(--soft); border-radius: 999px; width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; vertical-align: middle; }
.big-say { display: block; width: 88px; height: 88px; font-size: 2.4rem; margin: 10px auto 4px; }
.tip { color: var(--muted); font-size: .92rem; }
.en { font-size: 1.15rem; font-weight: 700; color: var(--muted); margin-top: 4px; }
.meta { margin-top: 8px; font-size: .9rem; color: var(--muted); }
.meta b { color: var(--ink); }
.gtag { display: inline-block; background: var(--g); color: #fff; vertical-align: middle; border-radius: 6px; padding: 0 6px; font-weight: 800; font-size: .85em; }
@media (prefers-color-scheme: dark) { .gtag { color: #1b1814; } }
.reveal { margin-top: 10px; font-size: 1.2rem; animation: pop .25s ease; }
.reveal b { color: var(--g); font-size: 1.3em; }

.options { display: grid; gap: 10px; margin-top: 14px; }
.options.words { grid-template-columns: 1fr 1fr; }
.options.pics { grid-template-columns: 1fr 1fr; }
.options.genders { grid-template-columns: 1fr 1fr; }
.opt {
  border: 2px solid var(--line); background: var(--card); border-radius: 16px; padding: 14px 8px;
  font-size: 1.25rem; font-weight: 800; cursor: pointer; box-shadow: 0 3px 0 var(--line);
  overflow-wrap: anywhere; min-height: 58px;
}
.opt:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.pic-opt { padding: 6px; background: var(--pic-bg); position: relative; }
.pic-opt svg { display: block; width: 100%; height: auto; aspect-ratio: 120 / 100; }
.pic-opt kbd { position: absolute; top: 6px; left: 8px; color: #2b2b2b; }
.gopt { color: var(--g); border-color: var(--g); display: flex; flex-direction: column; align-items: center; }
.gopt small { font-size: .75rem; color: var(--muted); font-weight: 700; }
.opt.right { background: var(--right-soft); border-color: var(--right); box-shadow: 0 3px 0 var(--right); animation: pop .25s ease; }
.opt.wrong { background: var(--wrong-soft); border-color: var(--wrong); box-shadow: 0 3px 0 var(--wrong); animation: shake .35s ease; }

.slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 16px 0 12px; min-height: 52px; }
.slot {
  width: 40px; height: 50px; border-bottom: 4px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 800; background: none; border-top: none; border-left: none; border-right: none; padding: 0;
}
.slot.next { border-bottom-color: var(--accent); }
.slot.full { cursor: pointer; border-bottom-color: var(--ink); }
.slot.gap { width: 16px; border-bottom: none; }
.slots.right .slot { color: var(--right); border-bottom-color: var(--right); }
.slots.wrong { animation: shake .35s ease; }
.slots.wrong .slot { color: var(--wrong); border-bottom-color: var(--wrong); }
.tileset { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ltile {
  width: 48px; height: 52px; border: 2px solid var(--line); background: var(--card); border-radius: 12px;
  font-size: 1.5rem; font-weight: 800; cursor: pointer; box-shadow: 0 3px 0 var(--line);
}
.ltile:disabled { opacity: .2; cursor: default; box-shadow: none; }
.spell-actions { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }
.typeform { display: flex; gap: 8px; margin-top: 14px; }
.typeform input { flex: 1; min-width: 0; font: inherit; font-size: 1.5rem; font-weight: 800; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--ink); }
.typeform input:focus { border-color: var(--g-mi); outline: none; }
.typeform .primary { width: auto; margin: 0; padding: 10px 18px; }
.accents { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; }
.accents button { width: 38px; height: 40px; border: 2px solid var(--line); background: var(--card); border-radius: 10px; font-size: 1.1rem; font-weight: 800; cursor: pointer; }

.feedback {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--wrong-soft); border-top: 3px solid var(--wrong);
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); animation: slideup .2s ease;
}
.feedback > * { max-width: 528px; margin-left: auto; margin-right: auto; }
.fb-card { display: flex; gap: 12px; align-items: center; }
.fb-card svg { width: 90px; height: 75px; flex: none; background: var(--pic-bg); border-radius: 10px; }
.fb-label { margin: 0; font-weight: 800; color: var(--wrong); }
.fb-cs { font-size: 1.6rem; color: var(--g); }
.fb-body p { margin: 8px 0 0; }
.feedback .primary { background: var(--wrong); color: var(--accent-ink); }
.feedback.almost { background: var(--almost-soft); border-top-color: var(--almost); }
.feedback.almost .fb-label { color: var(--almost); }
.feedback.almost .primary { background: var(--almost); }
body.fb-open #lesson { padding-bottom: 300px; }
.fb-card .say { width: 34px; height: 34px; font-size: .95rem; }

.xpfloat {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 6;
  font-weight: 800; font-size: 1.3rem; color: var(--gold-ink); pointer-events: none; animation: floatup 1s ease forwards;
}

/* summary */
#summary { text-align: center; }
#summary h1 { font-size: 2rem; margin: 28px 0 8px; }
.sum-note { font-weight: 700; line-height: 1.7; min-height: 1em; }
.sum-words { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0 12px; }
.chip { border-radius: 999px; padding: 4px 10px; font-weight: 800; background: var(--card); box-shadow: var(--shadow); color: var(--g); }
.chip.missed { outline: 2px solid var(--wrong); }
.chip.new::after { content: " ✨"; }
.sum-next { color: var(--muted); font-weight: 700; }
.quests { margin-top: 20px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 14px; }
.quests h2 { font-size: 1rem; margin: 0 0 6px; }
.quests ul { list-style: none; margin: 0; padding: 0; }
.quests li { display: grid; grid-template-columns: 1fr 70px 2.8em; align-items: center; gap: 8px; padding: 6px 0; font-weight: 700; font-size: .92rem; }
.quests li.done span:first-child { color: var(--muted); text-decoration: line-through; }
.quests small { color: var(--muted); text-align: right; }
.qbar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; display: block; }
.qbar i { display: block; height: 100%; background: var(--gold); }

/* album */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip-btn, .chips label { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; font-weight: 800; cursor: pointer; }
.chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-btn small, .chips small { font-weight: 700; opacity: .75; }
.atopic h2 { font-size: 1.1rem; margin: 20px 0 8px; }
.atopic h2 small { color: var(--muted); font-weight: 700; }
.agrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.sticker {
  background: var(--pic-bg); border: none; border-radius: 14px; padding: 6px 4px 4px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; cursor: pointer; border-top: 5px solid var(--g); color: #2b2b2b;
}
.sticker svg { width: 100%; height: auto; aspect-ratio: 120 / 100; }
.sticker span { font-weight: 800; font-size: .85rem; overflow-wrap: anywhere; }
.sticker.locked { cursor: default; border-top-color: transparent; background: var(--soft); box-shadow: none; }
.sticker.locked svg { filter: brightness(0); opacity: .12; }
@media (prefers-color-scheme: dark) { .sticker.locked svg { filter: brightness(0) invert(1); } }
.sticker.locked span { color: var(--muted); }
/* stars sit on the light picture background in both themes */
.stars { --on: #a86b00; --off: #d6cbb8; font-style: normal; letter-spacing: 1px; font-size: .8rem; color: var(--off); }
.stars.s1 { background: linear-gradient(90deg, var(--on) 33%, var(--off) 33%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stars.s2 { background: linear-gradient(90deg, var(--on) 66%, var(--off) 66%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stars.s3 { color: var(--on); }
.card .stars { --on: var(--gold-ink); --off: var(--line); }

/* settings */
.panel { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px; margin-top: 12px; }
.panel fieldset { border: none; padding: 0; margin: 0; }
.panel legend { font-weight: 800; padding: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; font-weight: 700; }
.row select { font: inherit; font-weight: 700; padding: 8px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); }
.row input[type=number] { width: 5.5em; font: inherit; padding: 8px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); }
.row input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--accent); }
.row.buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.row.buttons > * { margin: 0; padding: 10px 6px; font-size: .9rem; text-align: center; }
.panel .danger { color: var(--wrong); border-color: var(--wrong); }
.about { color: var(--muted); font-size: .85rem; line-height: 1.8; }
.about a { color: inherit; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 8; background: rgba(30, 20, 10, .5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { position: relative; width: 100%; max-width: 420px; }
.modal-box .close { position: absolute; top: -8px; right: -8px; z-index: 1; box-shadow: var(--shadow); }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; }

@keyframes pop { 0% { transform: scale(.94); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slidedown { from { transform: translate(-50%, 140%); } to { transform: translate(-50%, 0); } }
body.fb-open .toast { bottom: auto; top: calc(60px + env(safe-area-inset-top)); }
@keyframes floatup { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -40px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* summary extras */
.cat { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; }
.cat img { animation: bounce 1s ease 2; }
.bubble { position: relative; background: var(--card); box-shadow: var(--shadow); border-radius: 16px; padding: 8px 14px; font-weight: 800; font-size: 1.15rem; }
.bubble:empty { display: none; }
.bubble::before { content: ""; position: absolute; left: -8px; top: 50%; margin-top: -8px; border: 8px solid transparent; border-left: 0; border-right-color: var(--card); }
#summary h1 { margin-top: 10px; }
.sum-label { font-weight: 800; margin: 14px 0 6px; }
.sum-stickers { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.sticker.mini { width: 84px; animation: stickerin .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.sticker.mini span { font-size: .8rem; }
.type-note { min-height: 0; margin: 8px 0 0; font-weight: 700; color: var(--almost); text-align: center; }
.type-note:empty { display: none; }
@keyframes stickerin { from { opacity: 0; transform: scale(.3) rotate(-12deg); } to { opacity: 1; transform: none; } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-10px); } }

/* short screens (landscape phones, small phones, an open keyboard) */
@media (max-height: 620px) {
  .pic svg { max-height: 24vh; }
  .prompt { margin: 6px 0; font-size: 1.1rem; }
  .card { padding: 8px 10px 10px; }
  .cs { font-size: 1.8rem; }
  .options { gap: 8px; margin-top: 10px; }
  .opt { padding: 8px 6px; min-height: 48px; }
  .slots { margin: 8px 0; }
  .ltile { width: 42px; height: 46px; }
  .goal { width: 140px; height: 140px; margin: 8px auto 4px; }
}
@media (max-height: 620px) and (orientation: landscape) {
  .options.pics { grid-template-columns: repeat(4, 1fr); }
}
@media (max-height: 500px) and (orientation: landscape) {
  #lesson.screen { max-width: 900px; }
  .stage { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); column-gap: 16px; align-items: start; }
  .stage > .prompt { grid-column: 1 / -1; }
  .stage > .card, .stage > .big-say { grid-column: 1; grid-row: 2 / span 4; }
  .stage > :not(.prompt):not(.card):not(.big-say) { grid-column: 2; }
  .stage > .options.pics:not(.x) { grid-column: 1 / -1; grid-row: auto; }
  .pic svg { max-height: 40vh; }
  .feedback { max-height: 60vh; overflow: auto; }
}

.sleep { text-align: center; }
.sleep h2 { margin: 8px 0; }
.small-link { font-size: .9rem; }

.sum-note:empty { display: none; }
.typeform.cloze { align-items: center; flex-wrap: wrap; justify-content: center; }
.typeform.cloze .frame { margin: 0; font-size: 1.4rem; }
.typeform.cloze input { flex: 1 1 8em; }
