:root {
  --pine: #0e2a21;
  --pine-2: #15392d;
  --cream: #fbf6ec;
  --cream-2: #f3ead8;
  --ink: #2a2320;
  --muted: #6d6158;
  --gold: #c9a24a;
  --gold-2: #e8c46a;
  --berry: #a51f2d;
  --ok: #2e7d4f;
  --ok-bg: #e3f3e8;
  --bad: #c0392b;
  --bad-bg: #fbe5e2;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: hidden; }
button, a, input, .quote { -webkit-tap-highlight-color: transparent; }

body {
  min-height: 100vh;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 19px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--pine);
  overflow-x: hidden;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(201, 162, 74, .22), transparent 60%),
    radial-gradient(800px 500px at 100% 100%, rgba(165, 31, 45, .25), transparent 60%),
    linear-gradient(180deg, var(--pine-2), var(--pine));
}

#snow { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- nagłówek ---------- */
.hero { position: relative; z-index: 1; text-align: center; color: var(--cream); padding: 28px 16px 8px; }
.rings { width: 96px; height: 56px; color: var(--gold); filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.hero h1 {
  font-family: 'Mountains of Christmas', 'Cormorant Garamond', serif;
  font-size: clamp(40px, 8vw, 64px);
  margin: 4px 0 0;
  line-height: 1.05;
  color: var(--gold-2);
  text-shadow: 0 3px 0 rgba(0,0,0,.25), 0 0 24px rgba(232, 196, 106, .35);
}
.subtitle { font-family: 'Great Vibes', cursive; font-size: 28px; margin: 0; color: var(--cream-2); opacity: .9; }

.wrap { position: relative; z-index: 1; max-width: 980px; margin: 0 auto; padding: 12px 16px 40px; }

/* ---------- karta ---------- */
.card {
  position: relative;
  background: var(--cream);
  border-radius: var(--radius);
  padding: clamp(22px, 4vw, 40px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(201, 162, 74, .6);
  outline: 6px solid rgba(251, 246, 236, .08);
}
.card::before {
  content: "";
  position: absolute; inset: 10px;
  border: 1px solid rgba(201, 162, 74, .45);
  border-radius: calc(var(--radius) - 8px);
  pointer-events: none;
}
.card h2 {
  font-family: 'Mountains of Christmas', serif;
  color: var(--berry);
  font-size: clamp(30px, 5vw, 42px);
  margin: 0 0 6px;
  text-align: center;
  line-height: 1.1;
}
.card h3 { margin: 0 0 10px; font-size: 22px; color: var(--pine-2); letter-spacing: .04em; text-transform: uppercase; font-weight: 700; }
.lead { text-align: center; font-size: 22px; margin: 0 auto 12px; max-width: 640px; }
.hint { text-align: center; color: var(--muted); font-style: italic; margin: 0 0 22px; }

/* ---------- przyciski / pola ---------- */
.actions { display: flex; justify-content: center; margin-top: 22px; }
.btn {
  font: inherit; font-weight: 700; font-size: 20px;
  border: 0; cursor: pointer;
  padding: 12px 30px;
  border-radius: 999px;
  color: var(--cream);
  background: linear-gradient(180deg, #bf2a39, var(--berry));
  box-shadow: 0 6px 0 #6e121c, 0 10px 20px rgba(0,0,0,.2);
  transition: transform .1s, box-shadow .1s, filter .2s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #6e121c; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-gold { color: #3a2a06; background: linear-gradient(180deg, var(--gold-2), var(--gold)); box-shadow: 0 6px 0 #8a6a22, 0 10px 20px rgba(0,0,0,.2); }
.btn-gold:active { box-shadow: 0 2px 0 #8a6a22; }
.btn:focus-visible, input:focus-visible, .quote:focus-visible, .slot:focus-visible, .pool:focus-visible, .stepper button:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 2px;
}

input[type=text], input[type=password] {
  font: inherit; font-size: 20px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid #d9cbb0;
  background: #fff;
  color: var(--ink);
  transition: border-color .2s, background .2s;
}
input:focus { border-color: var(--gold); outline: none; }
input.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
input:disabled { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); font-weight: 700; }

.msg { min-height: 1.4em; margin: 10px 0 0; text-align: center; font-weight: 700; }
.msg:empty { min-height: 0; margin: 0; }
.msg-ok { color: var(--ok); }
.msg-wrong { color: var(--bad); }

/* ---------- logowanie ---------- */
.login { max-width: 460px; margin: 20px auto; text-align: center; }
.login form { display: grid; gap: 14px; margin-top: 18px; }
.login .btn { justify-self: center; }

/* ---------- nawigacja kroków ---------- */
.stepper {
  list-style: none; margin: 0 0 18px; padding: 0;
  display: flex; justify-content: center; gap: 6px; flex-wrap: wrap;
}
.stepper button {
  font: inherit; display: flex; align-items: center; gap: 8px;
  background: rgba(251, 246, 236, .08); color: var(--cream-2);
  border: 1px solid rgba(201, 162, 74, .35);
  border-radius: 999px; padding: 6px 14px 6px 6px; cursor: pointer;
}
.stepper button:disabled { opacity: .4; cursor: not-allowed; }
.stepper .dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 16px;
  background: rgba(251, 246, 236, .15);
}
.stepper .done .dot { background: var(--ok); color: #fff; }
.stepper .current .dot { background: var(--gold); color: #3a2a06; }
.stepper .viewing button { background: rgba(251, 246, 236, .2); border-color: var(--gold); }
.stepper .step-caption { display: none; }
@media (max-width: 700px) {
  .stepper .lbl { display: none; }
  .stepper button { padding: 4px; }
  .stepper .step-caption {
    display: block; flex-basis: 100%; text-align: center;
    color: var(--cream-2); font-size: 16px; margin-top: 6px; letter-spacing: .02em;
  }
}

/* ---------- zasady ---------- */
.rules { list-style: none; padding: 0; margin: 18px auto 0; max-width: 620px; display: grid; gap: 12px; }
.rules li {
  padding: 12px 16px 12px 48px; position: relative;
  background: var(--cream-2); border-radius: 12px;
}
.rules li::before {
  content: "❄"; position: absolute; left: 16px; top: 11px; color: var(--gold); font-size: 20px;
}

/* ---------- cytaty ---------- */
.board { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 24px; align-items: start; }
.board.is-locked { grid-template-columns: 1fr; }
@media (max-width: 760px) { .board { grid-template-columns: 1fr; } }

.pool-wrap { position: sticky; top: 12px; }
@media (max-width: 760px) { .pool-wrap { position: static; } }
.pool {
  display: grid; gap: 10px; min-height: 90px;
  padding: 12px; border-radius: 14px;
  background: repeating-linear-gradient(45deg, #f6eedd, #f6eedd 10px, #f1e6d0 10px, #f1e6d0 20px);
  border: 2px dashed #d9cbb0;
}
.pool:empty::after { content: "Wszystkie cytaty rozdane ✦"; color: var(--muted); font-style: italic; text-align: center; padding: 18px 0; }

.quote {
  background: #fff;
  border: 1px solid #e2d4b8;
  border-left: 4px solid var(--gold);
  border-radius: 10px;
  padding: 10px 14px;
  font-style: italic; font-size: 18px;
  box-shadow: 0 2px 6px rgba(60, 40, 10, .08);
  cursor: grab;
  touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: box-shadow .15s, transform .15s, opacity .15s;
}
.quote:hover { box-shadow: 0 6px 16px rgba(60, 40, 10, .15); }
.quote.selected { border-color: var(--berry); border-left-color: var(--berry); box-shadow: 0 0 0 3px rgba(165, 31, 45, .25); transform: scale(1.01); }
.quote.dragging { opacity: .35; }
.quote.locked { cursor: default; touch-action: auto; user-select: text; }
.quote.ghost {
  position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .3); opacity: .95; cursor: grabbing;
}

.authors { display: grid; gap: 12px; }
.author {
  border-radius: 14px; padding: 10px 12px 12px;
  background: var(--cream-2);
  border: 2px solid transparent;
  transition: background .25s, border-color .25s;
}
.author-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 8px; cursor: default; }
.author-name .name { font-weight: 700; font-size: 21px; color: var(--pine-2); }
.author-name .source { color: var(--muted); font-style: italic; font-size: 17px; }
.author-name .source::before { content: "· "; }
.has-selection .author { cursor: pointer; }
.has-selection .author:hover { border-color: var(--gold); }

.slot {
  min-height: 56px; border-radius: 10px;
  border: 2px dashed #d0c0a0; background: rgba(255,255,255,.5);
  display: grid; align-items: center; padding: 4px;
  transition: border-color .15s, background .15s;
}
.slot .slot-hint { color: #b3a487; font-style: italic; text-align: center; font-size: 16px; }
.slot .quote ~ .slot-hint, .slot:has(.quote) .slot-hint { display: none; }
.slot:has(.quote) { border-style: solid; border-color: transparent; background: transparent; padding: 0; }
.slot.over, .pool.over { border-color: var(--gold); background: #fff7e2; }

.author.ok { background: var(--ok-bg); border-color: var(--ok); }
.author.ok .quote { border-left-color: var(--ok); }
.author.wrong { background: var(--bad-bg); border-color: var(--bad); }
.author.wrong .quote { border-left-color: var(--bad); }
.author.wrong .slot { border-color: var(--bad); }

/* ---------- słuchanie ---------- */
.riddles { display: grid; gap: 14px; max-width: 640px; margin: 0 auto; }
.riddle { border-radius: 14px; padding: 16px 18px; background: var(--cream-2); border: 2px solid transparent; }
.riddle h3 { display: flex; align-items: center; gap: 8px; }
.riddle h3::before { content: "♪"; color: var(--berry); }
.riddle .row { display: flex; gap: 10px; align-items: center; }
.riddle .row input { flex: 1; min-width: 0; }
.riddle .btn { padding: 11px 22px; flex: none; }
.riddle.ok { background: var(--ok-bg); border-color: var(--ok); }
.riddle.ok .badge { color: var(--ok); font-weight: 700; white-space: nowrap; }
.riddle.active { background: #fff; border-color: var(--gold); box-shadow: 0 8px 24px rgba(201, 162, 74, .25); }
.riddle.locked { opacity: .6; }
.riddle.locked h3::before { content: "♪"; color: var(--muted); }
.locked-note { margin: 0; color: var(--muted); font-style: italic; }
@media (max-width: 560px) {
  .riddle .row { flex-wrap: wrap; }
  .riddle .btn { width: 100%; max-width: none; }
}

.shake { animation: shake .4s; }
@keyframes shake {
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

/* ---------- finał ---------- */
.final { text-align: center; max-width: 680px; margin: 0 auto; }
.final .gift { font-size: 84px; line-height: 1; animation: bob 2.4s ease-in-out infinite; }
.final-msg { font-size: clamp(24px, 4vw, 32px); font-weight: 600; margin: 14px auto; max-width: 560px; }
.signature { font-family: 'Great Vibes', cursive; font-size: 38px; color: var(--berry); margin: 10px 0 0; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-4deg); } }

/* ---------- konfetti ---------- */
.confetti {
  position: fixed; top: -40px; z-index: 999; pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translate(var(--drift), 110vh) rotate(540deg); opacity: .8; }
}

@media (prefers-reduced-motion: reduce) {
  .final .gift, .shake { animation: none; }
}

/* ---------- zagadka w osobnym kroku ---------- */
.riddle-task .riddle { max-width: 560px; margin: 0 auto; }
.instruction {
  max-width: 640px; margin: 18px auto 0; position: relative;
  padding: 22px 24px 16px;
  background: var(--cream-2);
  border: 1px solid rgba(201, 162, 74, .55);
  border-left: 5px solid var(--berry);
  border-radius: 12px;
}
.instruction-label {
  position: absolute; top: -13px; left: 18px;
  background: var(--berry); color: var(--cream);
  font-size: 15px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 12px; border-radius: 999px;
}
.instruction p { margin: 0 0 6px; font-size: 20px; }
.instruction .instruction-task { font-weight: 700; color: var(--pine-2); margin: 0; }
.answer-label {
  max-width: 560px; margin: 28px auto 10px !important;
  display: flex; align-items: center; gap: 12px;
  font-size: 18px !important; color: var(--muted) !important;
}
.answer-label::before, .answer-label::after { content: ""; flex: 1; height: 1px; background: rgba(201, 162, 74, .6); }

/* ---------- panel konta testowego ---------- */
.admin { position: relative; z-index: 5; max-width: 980px; margin: 12px auto 0; padding: 0 16px; }
.admin-box {
  background: rgba(10, 20, 16, .85); color: var(--cream-2);
  border: 1px dashed var(--gold); border-radius: 12px;
  padding: 10px 16px; font-size: 17px;
}
.admin-box summary { cursor: pointer; font-weight: 700; color: var(--gold-2); }
.admin-sub { font-weight: 500; color: var(--cream-2); opacity: .7; }
.admin-box h4 { margin: 12px 0 4px; font-size: 18px; }
.admin-box ul { margin: 0; padding-left: 20px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.admin-actions button, .admin-actions a {
  font: inherit; font-size: 16px; cursor: pointer; text-decoration: none;
  color: var(--cream); background: rgba(251, 246, 236, .1);
  border: 1px solid rgba(201, 162, 74, .6); border-radius: 999px; padding: 4px 14px;
}
.admin-actions .danger { background: var(--berry); border-color: var(--berry); }
.admin-actions a { margin-left: auto; }
.admin-msg { margin: 8px 0 0; color: var(--gold-2); }
.admin-msg:empty { display: none; }

/* ---------- telefon ---------- */
@media (pointer: coarse) {
  .quote { touch-action: pan-y; cursor: pointer; }
}
.quote.lifted { transform: scale(1.03); box-shadow: 0 12px 28px rgba(60, 40, 10, .3); border-left-color: var(--berry); }

.select-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 50; display: flex; align-items: center; gap: 10px;
  max-width: 640px; margin: 0 auto;
  padding: 10px 10px 10px 16px; border-radius: 16px;
  background: var(--berry); color: var(--cream);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
  transform: translateY(150%); transition: transform .2s ease;
}
.select-bar.show { transform: none; }
.select-bar-text { flex: 1; min-width: 0; display: grid; }
.select-bar-label { font-size: 14px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; opacity: .85; }
.select-bar-quote { font-style: italic; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-bar-cancel {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .18); color: var(--cream); font-size: 18px;
}
body.bar-open .wrap { padding-bottom: 110px; }

@media (max-width: 560px) {
  body { font-size: 18px; }
  .hero { padding: 18px 12px 4px; }
  .rings { width: 72px; height: 42px; }
  .subtitle { font-size: 24px; }
  .wrap { padding: 8px 10px 32px; }
  .card { padding: 22px 16px; border-radius: 16px; }
  .card::before { inset: 6px; }
  .lead { font-size: 19px; }
  .hint { font-size: 17px; margin-bottom: 16px; }
  .rules li { padding: 10px 12px 10px 40px; }
  .rules li::before { left: 12px; top: 9px; }
  .stepper { gap: 4px; margin-bottom: 12px; }
  .stepper .dot { width: 26px; height: 26px; font-size: 14px; }
  .pool { padding: 8px; gap: 8px; }
  .quote { font-size: 17px; padding: 10px 12px; }
  .author { padding: 10px; }
  .author-name .name { font-size: 19px; }
  .author-name .source { font-size: 15px; }
  .slot { min-height: 52px; }
  .instruction { padding: 20px 16px 14px; }
  .instruction p { font-size: 18px; }
  .riddle { padding: 12px; }
  .btn { width: 100%; max-width: 320px; padding: 14px 24px; }
  .admin { padding: 0 10px; margin-top: 8px; }
  .admin-actions a { margin-left: 0; }
  .final .gift { font-size: 68px; }
}
