/* =====================================================================
   Opakování Pythonu — styl
   Paleta: chladné světlé pozadí, pythoní modrá + zlatá, tmavý panel kódu
   ===================================================================== */

:root {
  --bg: #f2f5fa;
  --card: #ffffff;
  --ink: #14233c;
  --ink-soft: #5a6a85;
  --blue: #2e6db4;
  --blue-dark: #1f4f87;
  --gold: #ffc93c;
  --green: #2e9e6b;
  --green-soft: #e3f4ec;
  --red: #d85454;
  --red-soft: #fbe9e9;
  --line: #dde4ee;
  --code-bg: #14233c;
  --code-ink: #e8eefb;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(20, 35, 60, .08);
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% -10%, rgba(46, 109, 180, .10), transparent 45%),
    radial-gradient(circle at 95% 110%, rgba(255, 201, 60, .14), transparent 40%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
  min-height: 100vh;
}

.hidden { display: none !important; }
.screen { min-height: 100vh; }

h1, h2, h3 { font-family: var(--font-display); }

/* ---------- tlačítka ---------- */
.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .95rem;
  border: none;
  border-radius: 10px;
  padding: .65rem 1.2rem;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 14px rgba(46, 109, 180, .35);
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
}
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-big { font-size: 1.1rem; padding: .85rem 1.8rem; }
.btn:focus-visible, input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- úvod ---------- */
#screen-start {
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.start-card {
  background: var(--card);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
  padding: 2.5rem 2.5rem 2.2rem;
  max-width: 540px;
  width: 100%;
  text-align: center;
  border-top: 6px solid var(--gold);
}
.start-snake {
  font-size: 3rem;
  animation: wiggle 3s ease-in-out infinite;
  display: inline-block;
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}
.start-card h1 { font-size: 2.2rem; margin: .4rem 0 .2rem; }
.accent { color: var(--blue); }
.start-sub {
  font-family: var(--font-mono);
  color: var(--ink-soft);
  font-size: .85rem;
  margin: 0 0 1.2rem;
}
.start-info {
  text-align: left;
  font-size: .95rem;
  background: var(--bg);
  border-radius: 10px;
  padding: .9rem 1.1rem;
  color: var(--ink);
}
.inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .8rem;
  margin: 1.2rem 0;
  text-align: left;
}
.inputs label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .85rem;
}
.inputs input {
  display: block;
  width: 100%;
  margin-top: .3rem;
  padding: .6rem .8rem;
  font-size: 1rem;
  font-family: var(--font-body);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.inputs input:focus { border-color: var(--blue); }

/* ---------- horní lišta + hadí progress ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(242, 245, 250, .92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .65rem 1rem;
}
.who {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .85rem;
  white-space: nowrap;
  color: var(--ink-soft);
}
.snaketrack-wrap { position: relative; flex: 1; height: 22px; }
.snaketrack {
  display: flex;
  gap: 3px;
  height: 10px;
  margin-top: 6px;
}
.seg {
  flex: 1;
  background: var(--line);
  border-radius: 5px;
  position: relative;
  transition: background .25s ease;
}
.seg.correct { background: var(--green); }
.seg.wrong   { background: var(--red); }
.seg.current {
  background: repeating-linear-gradient(45deg, var(--gold), var(--gold) 4px, #ffe9a8 4px, #ffe9a8 8px);
}
.seg.hinted::after {
  content: "";
  position: absolute;
  top: -6px; left: 50%;
  width: 5px; height: 5px;
  margin-left: -2.5px;
  border-radius: 50%;
  background: var(--gold);
}
.snakehead {
  position: absolute;
  top: -3px;
  font-size: 1.1rem;
  transform: translateX(-50%) scaleX(-1);
  transition: left .4s cubic-bezier(.5, 1.4, .6, 1);
  pointer-events: none;
}
.timer {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: .9rem;
  padding: .25rem .6rem;
  border-radius: 8px;
  background: var(--card);
  border: 1.5px solid var(--line);
  min-width: 64px;
  text-align: center;
}
.timer.low { border-color: var(--gold); background: #fff7e0; }

/* ---------- otázka ---------- */
.quiz-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}
.q-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.8rem 2rem 1.5rem;
  animation: slidein .3s ease;
}
@keyframes slidein {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.q-meta {
  display: flex;
  align-items: center;
  gap: .7rem;
  font-family: var(--font-mono);
  font-size: .75rem;
  margin-bottom: .8rem;
}
.q-topic {
  background: var(--blue);
  color: #fff;
  padding: .15rem .6rem;
  border-radius: 999px;
  font-weight: 700;
}
.q-counter { color: var(--ink-soft); }
.q-streak { margin-left: auto; font-weight: 700; color: var(--green); }
.q-text { font-size: 1.25rem; margin: 0 0 1rem; }
.q-code {
  background: var(--code-bg);
  color: var(--code-ink);
  font-family: var(--font-mono);
  font-size: .95rem;
  border-radius: 10px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  border-left: 5px solid var(--gold);
  margin: 0 0 1rem;
}
.q-note {
  font-size: .85rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: -.4rem 0 1rem;
}

/* odpovědi */
.q-answer { display: grid; gap: .6rem; margin-bottom: 1rem; }
.opt {
  display: flex;
  align-items: center;
  gap: .8rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: .7rem 1rem;
  cursor: pointer;
  background: #fff;
  font-size: 1rem;
  text-align: left;
  font-family: var(--font-body);
  transition: border-color .12s ease, background .12s ease;
}
.opt:hover { border-color: var(--blue); }
.opt .opt-key {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: .8rem;
  background: var(--bg);
  border-radius: 6px;
  padding: .15rem .5rem;
  color: var(--ink-soft);
}
.opt.selected { border-color: var(--blue); background: #eef4fc; }
.opt.right { border-color: var(--green); background: var(--green-soft); }
.opt.bad   { border-color: var(--red); background: var(--red-soft); }
.opt:disabled { cursor: default; opacity: .85; }
.opt code, .q-text code {
  font-family: var(--font-mono);
  background: var(--bg);
  padding: .05rem .35rem;
  border-radius: 5px;
  font-size: .9em;
}

.text-answer {
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: .7rem 1rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  width: 100%;
}
.text-answer:focus { border-color: var(--blue); outline: none; }
.text-answer.right { border-color: var(--green); background: var(--green-soft); }
.text-answer.bad   { border-color: var(--red); background: var(--red-soft); }

/* interaktivní editor kódu (opravy chyb) */
.editor {
  display: flex;
  background: var(--code-bg);
  border-radius: 10px;
  border: 2px solid var(--code-bg);
  border-left: 5px solid var(--gold);
  overflow: hidden;
}
.editor:focus-within { box-shadow: 0 0 0 3px rgba(46, 109, 180, .3); }
.editor.right { border-color: var(--green); border-left-color: var(--green); }
.editor.bad   { border-color: var(--red); border-left-color: var(--red); }
.editor-gutter {
  font-family: var(--font-mono);
  font-size: .95rem;
  line-height: 1.55;
  color: rgba(232, 238, 251, .35);
  background: rgba(255, 255, 255, .05);
  padding: 1rem .7rem 1rem .9rem;
  text-align: right;
  white-space: pre;
  user-select: none;
}
.editor-area {
  flex: 1;
  background: transparent;
  color: var(--code-ink);
  caret-color: var(--gold);
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: .95rem;
  line-height: 1.55;
  padding: 1rem 1.2rem 1rem .9rem;
  white-space: pre;
  overflow-x: auto;
}
.editor-area:disabled { opacity: .9; }
.btn-small {
  font-size: .78rem;
  padding: .35rem .8rem;
  justify-self: start;
}

/* nápověda + zpětná vazba */
.q-hint {
  background: #fff7e0;
  border: 1.5px solid var(--gold);
  border-radius: 10px;
  padding: .7rem 1rem;
  font-size: .95rem;
  margin-bottom: 1rem;
}
.q-feedback {
  border-radius: 10px;
  padding: .8rem 1.1rem;
  font-size: .95rem;
  margin-bottom: 1rem;
  animation: slidein .25s ease;
}
.q-feedback.ok  { background: var(--green-soft); border: 1.5px solid var(--green); }
.q-feedback.err { background: var(--red-soft); border: 1.5px solid var(--red); }
.q-feedback b { font-family: var(--font-display); }

.q-actions {
  display: flex;
  align-items: center;
  gap: .8rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}
.spacer { flex: 1; }
.hint-cost { font-weight: 400; font-size: .75rem; opacity: .8; }

/* ---------- výsledky ---------- */
#screen-end { display: grid; place-items: center; padding: 2rem 1rem; }
.end-card {
  background: var(--card);
  border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow);
  padding: 2.5rem;
  max-width: 560px;
  width: 100%;
  text-align: center;
  border-top: 6px solid var(--blue);
}
.end-emoji { font-size: 3rem; }
.end-card h1 { margin: .3rem 0 .5rem; }
.end-score { margin: 0 0 .5rem; }
.end-points {
  font-family: var(--font-display);
  font-size: 3.4rem;
  font-weight: 700;
  color: var(--blue);
}
.end-max { color: var(--ink-soft); font-family: var(--font-mono); }
.end-msg { font-size: 1.05rem; margin: 0 0 1.3rem; }
.end-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .6rem;
  margin-bottom: 1.3rem;
}
.stat {
  background: var(--bg);
  border-radius: 10px;
  padding: .6rem .3rem;
}
.stat b { display: block; font-family: var(--font-display); font-size: 1.3rem; }
.stat span { font-size: .72rem; color: var(--ink-soft); font-family: var(--font-mono); }
.end-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin-bottom: 1.2rem;
}
.dot {
  width: 22px; height: 22px;
  border-radius: 6px;
  font-size: .65rem;
  font-family: var(--font-mono);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
}
.dot.ok { background: var(--green); }
.dot.err { background: var(--red); }
.dot.skip { background: var(--line); color: var(--ink-soft); }
.end-sent { font-family: var(--font-mono); font-size: .85rem; color: var(--ink-soft); }
.end-sent.ok { color: var(--green); font-weight: 700; }
.end-sent.err { color: var(--red); font-weight: 700; }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 35, 60, .45);
  display: grid;
  place-items: center;
  z-index: 50;
}
.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.6rem 1.8rem;
  max-width: 420px;
  width: calc(100% - 2rem);
  box-shadow: var(--shadow);
}
.modal-box h3 { margin: 0 0 .4rem; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .7rem;
  margin-top: 1.2rem;
}

/* ---------- responzivita + přístupnost ---------- */
@media (max-width: 560px) {
  .inputs { grid-template-columns: 1fr; }
  .who { display: none; }
  .q-card { padding: 1.3rem 1.1rem; }
  .end-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
