/* ================= PATOFYZIOLOGIE — tmavý herní vzdělávací design ================= */

:root {
  color-scheme: dark;

  --bg:         #0B0F19;
  --bg-2:       #0F1523;
  --surface:    #131A2A;
  --surface-2:  #182238;
  --border:     #243049;
  --border-lit: #2F3E60;

  --text:       #E8EDF7;
  --text-dim:   #94A3B8;
  --text-faint: #64748B;

  --accent:     #06B6D4;
  --accent-2:   #8B5CF6;
  --gold:       #FBBF24;
  --green:      #10B981;
  --green-dim:  #064E3B;
  --red:        #F43F5E;
  --red-dim:    #4C0519;

  --radius:     16px;
  --radius-sm:  10px;
  --shadow:     0 8px 32px rgba(0,0,0,.45);
  --glow:       0 0 0 1px rgba(6,182,212,.25), 0 8px 32px rgba(6,182,212,.12);

  --ease-out:   cubic-bezier(.22,1,.36,1);
  --ease-back:  cubic-bezier(.34,1.56,.64,1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 600px at 15% -10%, rgba(139,92,246,.13), transparent 60%),
    radial-gradient(900px 500px at 90% 0%,   rgba(6,182,212,.11),  transparent 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.02em; }
button, input, select { font: inherit; }
a { color: var(--accent); }

/* ---------- boot ---------- */
.app-loading { display: grid; place-items: center; min-height: 100dvh; }
.boot { text-align: center; color: var(--text-dim); }
.boot-spin {
  width: 38px; height: 38px; margin: 0 auto 14px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.shell { max-width: 1080px; margin: 0 auto; padding: 0 20px 80px; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px;
  background: rgba(11,15,25,.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  font-weight: 700; letter-spacing: -.03em; font-size: 17px;
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  background: none; border: 0; color: var(--text); padding: 0;
}
.topbar .spacer { flex: 1; }

/* počítadla hvězdiček a životů */
.counters { display: flex; gap: 8px; }
.counter {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px;
}
.counter .ico { font-size: 15px; line-height: 1; }
#starCounter { color: var(--gold); }
#lifeCounter { color: var(--green); }
.counter.pop { animation: counterPop .42s var(--ease-back); }
@keyframes counterPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.28); }
  100% { transform: scale(1); }
}
.counter.drain { animation: counterDrain .5s ease; }
@keyframes counterDrain {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
}

.btn {
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid var(--border-lit);
  background: var(--surface-2); color: var(--text); cursor: pointer;
  transition: background .18s, border-color .18s, transform .12s;
}
.btn:hover:not(:disabled) { background: #1E2A45; border-color: var(--accent); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn-primary {
  border: 0; font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- přihlášení ---------- */
.login-wrap { display: grid; place-items: center; min-height: 100dvh; padding: 20px; }
.login-card {
  width: min(420px, 100%); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 34px; box-shadow: var(--shadow);
}
.login-card .logo { font-size: 40px; text-align: center; margin-bottom: 10px; }
.login-card h1 { text-align: center; font-size: 22px; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--text-dim); font-size: 13px; margin: 0 0 24px; }
label { display: block; font-size: 13px; color: var(--text-dim); margin: 0 0 6px; }
.field { margin-bottom: 16px; }
input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-lit); background: var(--bg-2); color: var(--text);
  transition: border-color .18s, box-shadow .18s;
}
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(6,182,212,.14);
}
.form-error {
  background: var(--red-dim); border: 1px solid #7F1D1D; color: #FCA5A5;
  padding: 10px 13px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px;
}

/* ---------- nástěnka ---------- */
.page-head { padding: 34px 0 22px; }
.page-head h1 { font-size: 30px; margin-bottom: 6px; }
.page-head p { color: var(--text-dim); margin: 0; }

.level-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 26px;
}
.level-bar .lvl-name { font-weight: 700; font-size: 16px; }
.level-bar .lvl-meta { color: var(--text-faint); font-size: 12px; }
.progress-track {
  flex: 1; min-width: 180px; height: 8px; border-radius: 99px;
  background: var(--bg-2); overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .7s var(--ease-out);
}

.module-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.module-card {
  position: relative; overflow: hidden; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; cursor: pointer; color: var(--text);
  transition: transform .22s var(--ease-out), border-color .22s, box-shadow .22s;
}
.module-card::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 3px;
  background: var(--mod-color, var(--accent));
}
.module-card:hover { transform: translateY(-4px); border-color: var(--mod-color, var(--accent)); box-shadow: var(--shadow); }
.module-card .ico { font-size: 30px; display: block; margin-bottom: 12px; }
.module-card h3 { font-size: 17px; margin-bottom: 6px; }
.module-card .meta { color: var(--text-faint); font-size: 12.5px; }
.module-card.is-master { background: linear-gradient(150deg, #1B1330, var(--surface)); }
.module-card .mini-track { height: 4px; border-radius: 99px; background: var(--bg-2); margin-top: 14px; overflow: hidden; }
.module-card .mini-fill { height: 100%; background: var(--mod-color, var(--accent)); border-radius: 99px; }
.badge-unpub {
  position: absolute; top: 14px; right: 14px; font-size: 10.5px; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 99px; background: var(--red-dim);
  border: 1px solid #7F1D1D; color: #FCA5A5;
}

/* ---------- výběr režimu ---------- */
.mode-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.mode-card {
  text-align: left; padding: 24px; border-radius: var(--radius); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: transform .22s var(--ease-out), border-color .22s, box-shadow .22s;
}
.mode-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.mode-card .tag { font-size: 22px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 8px; }
.mode-card p { color: var(--text-dim); font-size: 13.5px; margin: 0; }
.mode-hard:hover  { border-color: var(--red); }
.mode-hard .tag   { color: var(--red); }
.mode-jumbo:hover { border-color: var(--accent); }
.mode-jumbo .tag  { color: var(--accent); }
.mode-speed:hover { border-color: var(--gold); }
.mode-speed .tag  { color: var(--gold); }

/* ---------- kvíz ---------- */
.quiz { max-width: 760px; margin: 0 auto; padding-top: 26px; }
.quiz-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.chip {
  font-size: 12px; padding: 4px 11px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
}
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--gold); }
.timer.low { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.q-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
  animation: cardIn .34s var(--ease-out);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px); } }
.q-card.shake { animation: shake .42s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-9px); } 40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(3px); }
}
.q-topic { color: var(--text-faint); font-size: 12px; margin-bottom: 10px; }
.q-text { font-size: 19px; line-height: 1.45; margin-bottom: 22px; font-weight: 500; }

.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: flex-start; gap: 13px; width: 100%; text-align: left;
  padding: 15px 17px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1.5px solid var(--border); color: var(--text);
  cursor: pointer; transition: border-color .16s, background .16s, transform .12s;
}
.option:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-2); }
.option:disabled { cursor: default; }
.option .key {
  flex: 0 0 26px; height: 26px; display: grid; place-items: center;
  border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 700; color: var(--text-dim);
}
.option.correct {
  border-color: var(--green); background: var(--green-dim);
  animation: correctPop .42s var(--ease-back);
}
.option.correct .key { background: var(--green); border-color: var(--green); color: #04231A; }
@keyframes correctPop { 40% { transform: scale(1.025); } }
.option.wrong { border-color: var(--red); background: var(--red-dim); }
.option.wrong .key { background: var(--red); border-color: var(--red); color: #fff; }
.option.dim { opacity: .42; }

.explain {
  margin-top: 18px; padding: 15px 17px; border-radius: var(--radius-sm);
  background: var(--bg-2); border-left: 3px solid var(--accent);
  font-size: 14px; color: #CBD5E1; animation: cardIn .3s var(--ease-out);
}
.explain a { font-size: 13px; }
.quiz-foot { display: flex; gap: 12px; align-items: center; margin-top: 20px; }
.quiz-foot .spacer { flex: 1; }

/* ---------- animace hvězdiček a odměn ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 90; }
.fly-star {
  position: fixed; font-size: 24px; line-height: 1; pointer-events: none;
  will-change: transform, opacity; filter: drop-shadow(0 0 6px rgba(251,191,36,.75));
}
.fly-life {
  position: fixed; font-size: 22px; line-height: 1; pointer-events: none;
  will-change: transform, opacity;
}
.streak-burst {
  position: fixed; left: 50%; top: 34%; transform: translate(-50%,-50%);
  text-align: center; pointer-events: none; z-index: 95;
}
.streak-burst .label {
  font-size: clamp(30px, 8vw, 54px); font-weight: 900; letter-spacing: -.04em;
  background: linear-gradient(135deg, var(--gold), #F97316, var(--red));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 22px rgba(251,191,36,.45));
}
.streak-burst .bonus { font-size: 20px; font-weight: 700; color: var(--gold); margin-top: 2px; }
.particle {
  position: fixed; width: 7px; height: 7px; border-radius: 50%;
  pointer-events: none; will-change: transform, opacity;
}

/* ---------- souhrn ---------- */
.summary { max-width: 520px; margin: 40px auto; text-align: center; }
.summary .big { font-size: 60px; margin-bottom: 8px; }
.summary h2 { font-size: 26px; margin-bottom: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 24px 0; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
}
.stat .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--text-faint); font-size: 12px; margin-top: 2px; }

/* ---------- teorie ---------- */
.theory { max-width: 760px; margin: 0 auto; padding-top: 26px; }
.theory-body { background: var(--surface); border: 1px solid var(--border);
               border-radius: var(--radius); padding: 30px; line-height: 1.75; }
.theory-body h2 { font-size: 20px; margin: 26px 0 10px; color: var(--accent); }
.theory-body h2:first-child { margin-top: 0; }
.theory-body h3 { font-size: 16px; margin: 20px 0 8px; }
.theory-body p { margin: 0 0 12px; }
.theory-body ul, .theory-body ol { margin: 0 0 14px; padding-left: 22px; }
.theory-body li { margin: 4px 0; }
.theory-body code { background: var(--bg-2); padding: 2px 6px; border-radius: 5px; font-size: 13px; }
.theory-body blockquote {
  margin: 14px 0; padding: 12px 16px; border-left: 3px solid var(--accent-2);
  background: var(--bg-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: #CBD5E1;
}
.theory-body table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px; }
.theory-body th, .theory-body td { padding: 9px 12px; border: 1px solid var(--border); text-align: left; }
.theory-body th { background: var(--surface-2); font-weight: 600; }
.table-scroll { overflow-x: auto; }
.src-flag {
  display: inline-block; font-size: 11px; padding: 3px 9px; border-radius: 99px;
  border: 1px solid var(--border); color: var(--text-faint); margin-bottom: 14px;
}
.src-external { border-color: #7C4A03; background: #2A1A05; color: #FCD34D; }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 6px; margin: 22px 0; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 16px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-dim); cursor: pointer; font-size: 14px;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; }
table.data th { color: var(--text-dim); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
table.data tr:hover td { background: var(--surface); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.panel h3 { font-size: 15px; margin-bottom: 14px; color: var(--text-dim); }
.settings-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.chart-box { position: relative; height: 260px; }
.muted { color: var(--text-faint); }
.empty { text-align: center; padding: 50px 20px; color: var(--text-faint); }

/* ---------- responzivita ---------- */
@media (max-width: 620px) {
  .shell { padding: 0 14px 60px; }
  .topbar { padding: 10px 12px; gap: 8px; row-gap: 8px; }
  .topbar .brand span.long { display: none; }
  /* Na úzkém displeji se ovládání zalomí pod počítadla, aby se nic neořízlo. */
  .topbar .spacer { flex: 1 0 auto; }
  .counters { order: 1; }
  .topbar .btn { order: 2; flex: 1 1 auto; min-width: 0; padding: 7px 10px; font-size: 13px; }
  .counter { padding: 6px 11px; font-size: 13px; }
  .q-card { padding: 20px; }
  .q-text { font-size: 17px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-head h1 { font-size: 24px; }
}

/* ---------- dostupnost ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .fly-star, .fly-life, .particle { display: none !important; }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
