@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/lato-regular.woff2') format('woff2'),
       url('fonts/lato-regular.woff') format('woff');
}
@font-face {
  font-family: 'Lato';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/lato-bold.woff2') format('woff2'),
       url('fonts/lato-bold.woff') format('woff');
}

:root {
  --primary: #005fae;
  --primary-dark: #004696;
  --primary-light: #e6f0f8;
  --accent-red: #cc0000;
  --accent-red-light: #fbe9e9;
  --accent-green: #0a6b3e;
  --accent-green-light: #e7f3ec;
  --accent-gold: #d9a400;
  --text: #333333;
  --text-muted: #666666;
  --bg: #ffffff;
  --bg-light: #eef3f4;
  --border: #dde3e4;
  --radius: 14px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-light);
  color: var(--text);
  font-family: 'Lato', -apple-system, 'Segoe UI', Roboto, Arial, Helvetica, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

body {
  overscroll-behavior-y: none;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 24px rgba(0,0,0,0.06);
}

button { font-family: inherit; }

.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--primary);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .back-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topbar .title {
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.3px;
  flex: 1;
}
.topbar .logo-mini {
  height: 30px;
  width: auto;
  background: #fff;
  border-radius: 6px;
  padding: 2px 4px;
}

/* ---------- Password screen ---------- */
.pass-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 28px calc(28px + var(--safe-bottom));
  gap: 22px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  text-align: center;
}
.pass-screen .logo-wrap {
  background: #fff;
  border-radius: 22px;
  padding: 18px 22px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.pass-screen .logo-wrap img { width: 100px; display: block; }
.pass-screen h1 {
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-size: 22px;
  margin: 0;
  font-weight: 700;
}
.pass-screen p.sub { margin: -12px 0 0; opacity: 0.85; font-size: 15px; }
.pass-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 320px;
}
.pass-form input {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 18px;
  text-align: center;
  letter-spacing: 2px;
}
.pass-form input:focus { outline: 3px solid var(--accent-gold); }
.pass-form .error-msg {
  color: #fff;
  background: var(--accent-red);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 14px;
  font-weight: 700;
}
.pass-contact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: rgba(255,255,255,0.8);
}
.pass-contact-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
}
.pass-contact-links a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}
.pass-contact-links svg { width: 13px; height: 13px; flex-shrink: 0; }
@media (max-height: 700px) {
  .pass-screen { gap: 14px; padding-top: 18px; padding-bottom: 18px; }
  .pass-screen .logo-wrap { padding: 12px 16px; }
  .pass-screen .logo-wrap img { width: 76px; }
}
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Lato', Arial, sans-serif;
}
.btn-primary { background: #fff; color: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }

/* ---------- Menu screen ---------- */
.menu-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.menu-header {
  padding: calc(28px + var(--safe-top)) 24px 22px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.menu-header .logo-wrap {
  background: #fff;
  border-radius: 18px;
  padding: 10px 14px;
}
.menu-header .logo-wrap img { width: 64px; display: block; }
.menu-header h1 {
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-size: 20px;
  margin: 4px 0 0;
  font-weight: 700;
}
.menu-body {
  flex: 1;
  padding: 22px 20px calc(20px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.menu-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  border: none;
  background: var(--bg-light);
  border-radius: var(--radius);
  padding: 20px;
  text-align: left;
  cursor: pointer;
  border: 2px solid transparent;
}
.menu-card:active { border-color: var(--primary); }
.menu-card .icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  color: #fff;
}
.menu-card.c1 .icon { background: var(--primary); }
.menu-card.c2 .icon { background: var(--accent-green); }
.menu-card.c3 .icon { background: var(--accent-red); }
.menu-card.c4 .icon { background: var(--accent-gold); }
.menu-card .txt { flex: 1; }
.menu-card .txt .t1 {
  font-weight: 700;
  font-size: 17px;
  text-transform: uppercase;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
}
.menu-card .txt .t2 {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 3px;
}
.logout-link {
  display: block;
  margin: 4px auto 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 14px;
  text-decoration: underline;
}

/* ---------- Promo section ---------- */
.promo-section {
  margin-top: 6px;
  padding: 18px 16px;
  background: var(--bg-light);
  border-radius: var(--radius);
}
.promo-header {
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.3px;
  color: var(--primary);
  text-align: center;
  margin-bottom: 14px;
}
.promo-services {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.promo-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-decoration: none;
  color: var(--text);
}
.promo-card:active { background: var(--primary-light); }
.promo-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  box-sizing: border-box;
}
.promo-icon svg { width: 100%; height: 100%; }
.promo-label { font-size: 13.5px; font-weight: 700; flex: 1; line-height: 1.25; }
.promo-card .chev { color: var(--text-muted); font-size: 18px; flex-shrink: 0; }
.promo-contact {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: center;
  text-align: center;
}
.promo-owner { font-weight: 700; font-size: 14px; }
.promo-nip { font-size: 12px; color: var(--text-muted); margin-top: -5px; }
.promo-contact-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}
.promo-contact-row svg { width: 17px; height: 17px; flex-shrink: 0; }

/* ---------- Browse (baza pytań) ---------- */
.search-wrap {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.search-input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-light);
}
.search-input:focus { outline: none; border-color: var(--primary); background: var(--bg); }
.browse-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin: -4px 0 2px;
}
.option-btn.static { cursor: default; }
.option-btn.static:active { background: var(--bg); }
.scroll-top-btn {
  position: fixed;
  right: max(18px, calc(50vw - 280px + 18px));
  bottom: calc(18px + var(--safe-bottom));
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}
.scroll-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* ---------- Confirm modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal-box {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 22px;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}
.modal-text {
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 18px;
}
.modal-actions {
  display: flex;
  gap: 10px;
}
.modal-actions .btn { flex: 1; }

/* ---------- Progress bar ---------- */
.progress-wrap {
  padding: 12px 16px 6px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 700;
}
.progress-meta .stat-ok { color: var(--accent-green); }
.progress-meta .stat-bad { color: var(--accent-red); }
.progress-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.25s ease;
}

/* ---------- Question screen ---------- */
.quiz-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  gap: 16px;
}
.question-card {
  background: var(--bg-light);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
}
.question-card .qtop {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.question-card .qnum {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  font-family: Arial, Helvetica, sans-serif;
}
.question-card .qtext {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}
.question-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.star-btn {
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  padding: 2px 4px;
  color: var(--border);
  flex-shrink: 0;
}
.star-btn.active { color: var(--accent-gold); }

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 2px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px 16px;
  font-size: 16px;
  color: var(--text);
  cursor: pointer;
  line-height: 1.3;
}
.option-btn:active { background: var(--bg-light); }
.option-btn .letter {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  font-size: 14px;
  color: var(--text-muted);
}
.option-btn.selected { border-color: var(--primary); background: var(--primary-light); }
.option-btn.selected .letter { background: var(--primary); color: #fff; }

.option-btn.correct { border-color: var(--accent-green); background: var(--accent-green-light); }
.option-btn.correct .letter { background: var(--accent-green); color: #fff; }
.option-btn.wrong { border-color: var(--accent-red); background: var(--accent-red-light); }
.option-btn.wrong .letter { background: var(--accent-red); color: #fff; }
.option-btn:disabled { cursor: default; }
.option-btn.dim { opacity: 0.55; }

.feedback-banner {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-weight: 700;
  text-align: center;
  font-size: 15px;
}
.feedback-banner.ok { background: var(--accent-green-light); color: var(--accent-green); }
.feedback-banner.bad { background: var(--accent-red-light); color: var(--accent-red); }

.quiz-actions {
  margin-top: auto;
  display: flex;
  gap: 10px;
}
.btn-outline {
  background: var(--bg);
  color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-block-primary { background: var(--primary); color: #fff; }
.btn-block-green { background: var(--accent-green); color: #fff; }
.btn-block-red { background: var(--accent-red); color: #fff; }

/* ---------- Exam mode: answers before result ---------- */
.exam-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.exam-nav .btn { flex: 1; }
.exam-nav .btn:disabled { opacity: 0.4; }

/* ---------- Result screen ---------- */
.result-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.result-hero {
  padding: calc(30px + var(--safe-top)) 24px 26px;
  text-align: center;
  color: #fff;
}
.result-hero.pass { background: linear-gradient(180deg, var(--accent-green) 0%, #084f2e 100%); }
.result-hero.fail { background: linear-gradient(180deg, var(--accent-red) 0%, #900000 100%); }
.result-hero .badge {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 26px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.result-hero .score {
  font-size: 46px;
  font-weight: 700;
  margin: 10px 0 4px;
}
.result-hero .pct { font-size: 16px; opacity: 0.9; }
.result-body {
  flex: 1;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.result-actions { display: flex; flex-direction: column; gap: 10px; }
.result-msg {
  border-radius: var(--radius);
  padding: 14px 16px;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  line-height: 1.4;
}
.result-msg-perfect {
  background: linear-gradient(135deg, var(--accent-gold) 0%, #f4c542 100%);
  color: #3a2b00;
  font-size: 18px;
}
.result-msg-pass { background: var(--accent-green-light); color: var(--accent-green); }
.result-msg-fail { background: var(--accent-red-light); color: var(--accent-red); }

/* ---------- Confetti ---------- */
.confetti-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 200;
}
.confetti-piece {
  position: absolute;
  top: -12px;
  border-radius: 1px;
  opacity: 0.95;
  transform: rotate(var(--rotate-start));
  animation-name: confetti-fall;
  animation-timing-function: cubic-bezier(0.4, 0.1, 0.6, 0.9);
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  0% {
    transform: translate3d(0, 0, 0) rotate(var(--rotate-start));
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--drift), 105vh, 0) rotate(calc(var(--rotate-start) + 420deg));
    opacity: 0.4;
  }
}
.wrong-list { display: flex; flex-direction: column; gap: 12px; }
.wrong-item {
  background: var(--bg-light);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.wrong-item .wq {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 15px;
}
.wrong-item .row { font-size: 14px; margin-bottom: 4px; display: flex; gap: 6px; }
.wrong-item .row .tag {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 5px;
  height: fit-content;
}
.wrong-item .row.your .tag { background: var(--accent-red-light); color: var(--accent-red); }
.wrong-item .row.correct .tag { background: var(--accent-green-light); color: var(--accent-green); }
.section-title {
  font-family: Arial, Helvetica, sans-serif;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-muted);
  margin: 4px 0 -2px;
}

/* ---------- Difficult list screen ---------- */
.list-screen { flex: 1; display: flex; flex-direction: column; }
.list-body { padding: 16px 16px calc(16px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 12px; flex: 1; }
.diff-item {
  background: var(--bg-light);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.diff-item .dq { font-weight: 700; margin-bottom: 8px; }
.diff-item .da {
  font-size: 14px;
  color: var(--accent-green);
  background: var(--accent-green-light);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 10px;
}
.diff-item .drow {
  display: flex;
  justify-content: flex-end;
}
.diff-item .remove-btn {
  border: none;
  background: var(--accent-red-light);
  color: var(--accent-red);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 30px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state .emoji { font-size: 46px; }

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 12px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

/* mode toggle */
.mode-toggle {
  display: flex;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin: 0 16px 4px;
  gap: 4px;
}
.mode-toggle button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-muted);
}
.mode-toggle button.active { background: var(--primary); color: #fff; }

.resume-banner {
  margin: 12px 16px 0;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}
.resume-banner button {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
}

@media (min-width: 600px) {
  html, body { background: #d5dee1; }
}
