* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #120f1f;
  --card: #1d1930;
  --card-edge: #352b52;
  --ink: #f1e9e4;
  --muted: #a99cc4;
  --sun: #ff4d4d;
  --sun-deep: #d92638;
  --gold: #ffc24b;
  --teal: #35e0c8;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(circle 340px at 50% -60px, rgba(255, 77, 77, 0.28), transparent 70%),
    radial-gradient(circle 500px at 110% 30%, rgba(120, 60, 200, 0.15), transparent 70%),
    radial-gradient(circle 400px at -10% 70%, rgba(53, 224, 200, 0.08), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

/* ── Nagłówek ─────────────────────────────── */
header { padding: 0.7rem 0.8rem 0.6rem; text-align: center; position: relative; }

.brand {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, #fff 20%, var(--gold) 70%, var(--sun) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 28px rgba(255, 77, 77, 0.35);
}
.brand-sub {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  margin-top: 0.1rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  max-width: 520px;
  margin: 0 auto 0.7rem;
}

.header-actions { display: flex; gap: 0.4rem; }
.header-actions form { margin: 0; }

.action-btn {
  width: auto;
  margin: 0;
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-edge);
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}
.action-btn:hover { border-color: var(--sun); background: rgba(255, 77, 77, 0.12); }

.lang-switch { display: flex; gap: 0.25rem; }
.lang-flag {
  font-size: 1.3rem;
  text-decoration: none;
  padding: 0.15rem 0.3rem;
  border-radius: 8px;
  border: 2px solid transparent;
  filter: grayscale(0.7) opacity(0.6);
  transition: filter 0.15s;
}
.lang-flag:hover { filter: none; }
.lang-flag.active { border-color: var(--gold); filter: none; background: rgba(255, 194, 75, 0.12); }

.timer {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.28rem 1rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-edge);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 0.05em;
}
.timer.low { color: var(--sun); border-color: var(--sun-deep); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

.progress {
  margin: 0.8rem auto 0.3rem;
  max-width: 480px;
  height: 9px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--card-edge);
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--sun-deep), var(--sun) 55%, var(--gold));
  border-radius: 999px;
  transition: width 0.4s;
  box-shadow: 0 0 12px rgba(255, 77, 77, 0.6);
}
.progress-label { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.08em; }

/* ── Karty ────────────────────────────────── */
main { max-width: 520px; margin: 0 auto; padding: 1rem; }

.card {
  position: relative;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='84' height='42'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='0.045' stroke-width='1.4'%3E%3Ccircle cx='42' cy='42' r='40'/%3E%3Ccircle cx='42' cy='42' r='30'/%3E%3Ccircle cx='42' cy='42' r='20'/%3E%3Ccircle cx='42' cy='42' r='10'/%3E%3Ccircle cx='0' cy='42' r='40'/%3E%3Ccircle cx='0' cy='42' r='30'/%3E%3Ccircle cx='0' cy='42' r='20'/%3E%3Ccircle cx='84' cy='42' r='40'/%3E%3Ccircle cx='84' cy='42' r='30'/%3E%3Ccircle cx='84' cy='42' r='20'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0)),
    var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 18px;
  padding: 1.4rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  animation: card-in 0.45s ease both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.card:nth-of-type(2) { animation-delay: 0.08s; }
.card:nth-of-type(3) { animation-delay: 0.16s; }

/* ── Płatki sakury w tle ───────────────────── */
.sakura-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
main, header { position: relative; z-index: 1; }
.petal-bg {
  position: absolute;
  top: -24px;
  width: 12px;
  height: 12px;
  background: radial-gradient(circle at 35% 35%, #ffd7e6, #f5a9c6);
  border-radius: 70% 0 70% 0;
  opacity: 0.5;
  animation: petal-fall linear infinite;
}
@keyframes petal-fall {
  0%   { transform: translateY(-4vh) translateX(0) rotate(0deg); }
  25%  { transform: translateY(24vh) translateX(26px) rotate(140deg); }
  50%  { transform: translateY(50vh) translateX(-14px) rotate(280deg); }
  75%  { transform: translateY(76vh) translateX(22px) rotate(420deg); }
  100% { transform: translateY(106vh) translateX(-8px) rotate(560deg); }
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--sun) 30%, var(--gold) 70%, transparent);
  opacity: 0.8;
}

h1 { font-size: 1.3rem; margin-bottom: 0.6rem; letter-spacing: 0.01em; }
p.intro { color: var(--muted); margin-bottom: 1rem; line-height: 1.55; }

/* ── Quizy ────────────────────────────────── */
.question { margin-bottom: 1.2rem; }
.question .q-text { font-weight: 600; margin-bottom: 0.6rem; line-height: 1.4; }
.question.wrong .q-text { color: var(--sun); }

.q-image {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 0.6rem;
  border: 1px solid var(--card-edge);
}
.img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 180px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px dashed var(--card-edge);
  border-radius: 12px;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.choice {
  display: block;
  padding: 0.75rem 0.95rem;
  margin-bottom: 0.5rem;
  background: rgba(0, 0, 0, 0.28);
  border: 2px solid var(--card-edge);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.choice:hover { border-color: var(--gold); }
.choice:has(input:checked) {
  border-color: var(--sun);
  background: rgba(255, 77, 77, 0.12);
  transform: translateX(4px);
}
.choice input { margin-right: 0.6rem; accent-color: var(--sun); }

/* Tryb natychmiastowy: zielone = dobrze, niebieskie = pomyłka */
.choice.correct {
  border-color: #22c55e !important;
  background: rgba(34, 197, 94, 0.16) !important;
}
.choice.wrong-pick {
  border-color: #3b82f6 !important;
  background: rgba(59, 130, 246, 0.18) !important;
  opacity: 0.75;
}

input[type="text"] {
  width: 100%;
  padding: 0.75rem 0.95rem;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--card-edge);
  border-radius: 12px;
  color: var(--ink);
  font-size: 1rem;
}
input[type="text"]:focus { outline: none; border-color: var(--gold); }

/* ── Przyciski ────────────────────────────── */
button, .btn {
  display: inline-block;
  width: 100%;
  padding: 0.9rem;
  border: none;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--sun) 0%, var(--sun-deep) 100%);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  margin-top: 0.4rem;
  box-shadow: 0 6px 18px rgba(217, 38, 56, 0.35);
  transition: transform 0.1s, box-shadow 0.15s;
}
button:hover, .btn:hover { box-shadow: 0 8px 24px rgba(217, 38, 56, 0.5); }
button:active, .btn:active { transform: scale(0.98); }

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  border: 1px solid var(--card-edge);
  box-shadow: none;
}
.btn-secondary:hover { border-color: var(--gold); box-shadow: none; }

/* ── Komunikaty ───────────────────────────── */
.feedback { margin-top: 0.8rem; padding: 0.85rem; border-radius: 12px; display: none; line-height: 1.45; }
.feedback.error { display: block; background: rgba(217, 38, 56, 0.15); border: 1px solid rgba(217, 38, 56, 0.5); color: #ffb4bc; }
.feedback.ok { display: block; background: rgba(53, 224, 200, 0.1); border: 1px solid rgba(53, 224, 200, 0.4); color: #9ff3e6; }

.notice {
  margin-top: 0.9rem;
  padding: 0.85rem 0.95rem;
  background: rgba(255, 194, 75, 0.08);
  border: 1px solid rgba(255, 194, 75, 0.35);
  border-radius: 12px;
  color: #ffe3ae;
  line-height: 1.5;
  font-size: 0.95rem;
}
.ok-notice {
  background: rgba(53, 224, 200, 0.12) !important;
  border-color: var(--teal) !important;
  color: #9ff3e6 !important;
  font-weight: 700;
}

.coords {
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  padding: 0.85rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  margin: 0.8rem 0;
  letter-spacing: 0.04em;
  color: var(--gold);
}

#reader { border-radius: 12px; overflow: hidden; margin-top: 0.8rem; }

.yt-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  margin: 0.4rem 0 0.6rem;
  border: 1px solid var(--card-edge);
}
.yt-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ── Finał ────────────────────────────────── */
.finish { text-align: center; padding: 2rem 1rem; }
.finish .emoji { font-size: 4.5rem; filter: drop-shadow(0 0 22px rgba(255, 194, 75, 0.5)); }

.qr-tile { text-align: center; padding: 1rem; background: #fff; border-radius: 12px; margin-top: 0.8rem; }
.qr-tile canvas, .qr-tile img { margin: 0 auto; }
.qr-code-label { color: #12101d; font-weight: 700; margin-top: 0.5rem; font-family: monospace; }
