:root {
  --bg: #f3eadb;
  --bg-2: #ebdfca;
  --card: #fbf6ec;
  --card-2: #f6eedf;
  --line: #e0d0b4;
  --ink: #3a2e24;
  --ink-2: #6f5f4e;
  --ink-3: #9c8b78;
  --green: #2f4f3a;
  --green-2: #4b7458;
  --red: #9e2b25;
  --red-2: #c0453d;
  --gold: #c8a24a;
  --gold-2: #e6cf8f;
  --adam: #2f4f3a;
  --julka: #9e2b25;
  --ok: #5b8c5a;
  --warn: #c9a13b;
  --bad: #b3aa9c;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 6px 18px -10px rgba(80, 55, 30, .35);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(200, 162, 74, .10) 0 120px, transparent 121px),
    radial-gradient(circle at 92% 30%, rgba(158, 43, 37, .06) 0 160px, transparent 161px),
    radial-gradient(rgba(111, 95, 78, .07) 1px, transparent 1.5px) 0 0 / 18px 18px,
    var(--bg);
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
a { color: var(--green); }
p { margin: 0 0 .8em; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- snow ---------- */
.snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.snow i {
  position: absolute; top: -20px; color: #fff; opacity: .9;
  text-shadow: 0 0 2px rgba(120, 100, 80, .35);
  animation: fall linear infinite;
}
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .snow { display: none; } }

/* ---------- layout ---------- */
.wrap { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }
header.top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 760px; margin: 0 auto; padding: 14px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--green); font-family: var(--serif); font-weight: 700; font-size: 1.1rem; }
.brand .star { color: var(--gold); font-size: 1.3rem; }
nav.links { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
nav.links a, nav.links button {
  font: inherit; font-size: .9rem; color: var(--ink-2); text-decoration: none; background: none; border: 0;
  padding: 6px 10px; border-radius: 999px; cursor: pointer;
}
nav.links a:hover, nav.links button:hover, nav.links a.active { background: var(--bg-2); color: var(--ink); }

.garland { height: 10px; margin: 0 auto 18px; max-width: 760px; position: relative; z-index: 1;
  background: radial-gradient(circle, var(--red) 0 3px, transparent 3.5px) 0 50% / 36px 10px repeat-x,
              radial-gradient(circle, var(--gold) 0 3px, transparent 3.5px) 12px 50% / 36px 10px repeat-x,
              radial-gradient(circle, var(--green-2) 0 3px, transparent 3.5px) 24px 50% / 36px 10px repeat-x; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card.tight { padding: 12px 14px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: 1rem;
  border: 0; border-radius: 999px; padding: 12px 22px; cursor: pointer;
  background: var(--red); color: #fff8ef; box-shadow: 0 3px 0 #6f1d19;
  transition: transform .06s, box-shadow .06s, background .15s;
  touch-action: manipulation;
}
.btn:hover { background: var(--red-2); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #6f1d19; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.green { background: var(--green); box-shadow: 0 3px 0 #1b3023; }
.btn.green:hover { background: var(--green-2); }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); box-shadow: none; }
.btn.ghost:hover { background: var(--card-2); }
.btn.block { width: 100%; }
.btn.small { padding: 8px 14px; font-size: .9rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.row > .grow { flex: 1 1 160px; }

input[type=text], input[type=password], input[type=number] {
  font: inherit; font-size: 1.05rem; color: var(--ink);
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fffdf8; outline: none;
}
input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200, 162, 74, .25); }
input[type=range] { width: 100%; accent-color: var(--red); }
label { display: block; font-weight: 700; font-size: .9rem; margin: 0 0 6px; color: var(--ink-2); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff8ef; padding: 10px 18px; border-radius: 999px;
  font-weight: 700; opacity: 0; transition: .2s; z-index: 50; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- score banner ---------- */
.scoreline {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  text-align: center;
}
.scoreline .who { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; }
.scoreline .num { font-family: var(--serif); font-size: clamp(2.2rem, 9vw, 3.2rem); font-weight: 700; line-height: 1; }
.scoreline .adam { color: var(--adam); }
.scoreline .julka { color: var(--julka); }
.scoreline .colon { font-family: var(--serif); font-size: 2rem; color: var(--ink-3); }
.lead-msg { text-align: center; margin-top: 8px; color: var(--ink-2); font-size: .95rem; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (min-width: 560px) { .cal { grid-template-columns: repeat(6, 1fr); } }
.tile {
  position: relative; aspect-ratio: 1 / 1.08; border-radius: 12px; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1.5px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform .12s;
}
.tile:hover { transform: translateY(-2px); }
.tile .n { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; line-height: 1; }
.tile .ico { font-size: 1.1rem; line-height: 1; }
.tile .st { font-size: .68rem; color: var(--ink-2); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.tile.locked { background: repeating-linear-gradient(135deg, var(--bg-2) 0 8px, var(--card-2) 8px 16px); color: var(--ink-3); box-shadow: none; cursor: default; }
.tile.locked:hover { transform: none; }
.tile.open { border-color: var(--gold); background: linear-gradient(180deg, #fffaf0, #f7ecd6); }
.tile.open .n { color: var(--red); }
.tile.today { outline: 3px solid var(--gold); outline-offset: 2px; }
.tile.won-adam { background: linear-gradient(180deg, #eef3ea, #dfe8d9); border-color: #b9ccb4; }
.tile.won-julka { background: linear-gradient(180deg, #f8ebe7, #f0d9d3); border-color: #e0b7b0; }
.tile.won-tie { background: linear-gradient(180deg, #f7f0dc, #efe2bf); border-color: var(--gold-2); }
.tile .badge {
  position: absolute; top: -6px; right: -6px; background: var(--gold); color: #fff;
  font-size: .65rem; font-weight: 800; border-radius: 999px; padding: 2px 6px; box-shadow: 0 2px 4px rgba(0,0,0,.15);
}
.tile .dot { position: absolute; top: 6px; left: 6px; width: 8px; height: 8px; border-radius: 50%; }
.tile .dot.mine { background: var(--ok); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--ink-2); margin-top: 12px; }

/* ---------- tables ---------- */
table.board { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.board th, table.board td { padding: 9px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.board th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
table.board tr.clickable { cursor: pointer; }
table.board tr.clickable:hover td { background: var(--card-2); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 800; }
.pill.adam { background: #dfe8d9; color: var(--adam); }
.pill.julka { background: #f0d9d3; color: var(--julka); }
.pill.tie { background: #efe2bf; color: #7a5f1f; }
.pill.wait { background: var(--bg-2); color: var(--ink-2); }

/* ---------- day page ---------- */
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.day-head .meta { color: var(--ink-2); font-size: .9rem; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--ink-2); }
.rules { background: var(--card-2); border-left: 4px solid var(--gold); padding: 12px 14px; border-radius: 10px; }
.partner-status { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--ink-2); }
.result-big { font-family: var(--serif); font-size: 2rem; font-weight: 700; }
.vs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .vs { grid-template-columns: 1fr; } }
.vs .side { border-radius: 12px; padding: 12px; border: 1.5px solid var(--line); background: #fffdf8; }
.vs .side.win { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200, 162, 74, .2); }
.vs .side h3 { display: flex; justify-content: space-between; align-items: center; }
.lines { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .8rem; white-space: pre-wrap; word-break: break-word; margin: 8px 0 0; color: var(--ink-2); line-height: 1.45; }
.winner-banner { text-align: center; padding: 14px; border-radius: 12px; background: linear-gradient(180deg, #fff6dc, #f3e2b2); border: 1.5px solid var(--gold-2); margin-bottom: 12px; }
.winner-banner .big { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; }

.progress { display: flex; gap: 4px; margin-bottom: 14px; }
.progress span { flex: 1; height: 6px; border-radius: 3px; background: var(--bg-2); }
.progress span.done { background: var(--green-2); }
.progress span.cur { background: var(--gold); }
.progress span.bad { background: var(--red-2); }

.big-q { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; margin-bottom: 14px; }
.feedback { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-weight: 700; }
.feedback.good { background: #e3eedd; color: #2e5a33; }
.feedback.bad { background: #f5dfda; color: #7f241f; }
.feedback.neutral { background: var(--card-2); color: var(--ink); }

/* ---------- słowle ---------- */
.wgrid { display: grid; gap: 6px; justify-content: center; margin: 4px auto 16px; }
.wrow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.wcell {
  width: min(15vw, 58px); height: min(15vw, 58px); border: 2px solid var(--line); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; background: #fffdf8;
  font-family: var(--serif); font-weight: 700; font-size: min(7vw, 1.8rem); text-transform: uppercase;
}
.wcell.filled { border-color: var(--ink-3); animation: pop .1s; }
.wcell.correct { background: var(--ok); border-color: var(--ok); color: #fff; }
.wcell.present { background: var(--warn); border-color: var(--warn); color: #fff; }
.wcell.absent { background: var(--bad); border-color: var(--bad); color: #fff; }
@keyframes pop { 50% { transform: scale(1.08); } }
.wrow.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.kb { display: flex; flex-direction: column; gap: 6px; user-select: none; }
.kb .kr { display: flex; gap: 5px; justify-content: center; }
.kb button {
  font: inherit; font-weight: 800; text-transform: uppercase; font-size: .95rem;
  flex: 1 1 0; max-width: 44px; min-width: 0; height: 50px; border-radius: 8px; border: 0; cursor: pointer;
  background: var(--bg-2); color: var(--ink); touch-action: manipulation; padding: 0;
}
.kb button.wide { max-width: 72px; flex: 1.6 1 0; font-size: .75rem; }
.kb button.correct { background: var(--ok); color: #fff; }
.kb button.present { background: var(--warn); color: #fff; }
.kb button.absent { background: var(--bad); color: #fff; opacity: .7; }
.kb .kr.pl button { background: #efe3cc; }
.kb .kr.pl button.correct { background: var(--ok); }
.kb .kr.pl button.present { background: var(--warn); }
.kb .kr.pl button.absent { background: var(--bad); }

/* ---------- powiązania ---------- */
.cgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.cword {
  font: inherit; font-weight: 800; font-size: clamp(.68rem, 2.9vw, .95rem); text-transform: uppercase;
  min-height: 64px; border-radius: 10px; border: 0; padding: 4px; cursor: pointer;
  background: var(--bg-2); color: var(--ink); word-break: break-word; hyphens: auto; touch-action: manipulation;
}
.cword.sel { background: var(--ink-2); color: #fff8ef; }
.cgroup { border-radius: 10px; padding: 10px; text-align: center; margin-bottom: 6px; }
.cgroup b { display: block; text-transform: uppercase; font-size: .85rem; letter-spacing: .03em; }
.cgroup span { font-size: .85rem; }
.cgroup.l0 { background: #f1dc8a; }
.cgroup.l1 { background: #b5d39a; }
.cgroup.l2 { background: #a9c6e3; }
.cgroup.l3 { background: #c9a9d8; }
.cgroup.unsolved { opacity: .65; }
.mistakes { display: flex; gap: 6px; align-items: center; justify-content: center; margin-bottom: 12px; font-size: .9rem; color: var(--ink-2); }
.mistakes i { width: 12px; height: 12px; border-radius: 50%; background: var(--ink-2); display: inline-block; }
.mistakes i.used { background: var(--line); }

/* ---------- familiada ---------- */
.fboard {
  background: #1f2a22; border-radius: 14px; padding: 12px; border: 4px solid var(--gold);
  box-shadow: inset 0 0 30px rgba(0,0,0,.5); margin-bottom: 14px;
}
.frow {
  display: grid; grid-template-columns: 28px 1fr 44px; gap: 8px; align-items: center;
  font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: #f7d76a; padding: 7px 8px;
  border-bottom: 1px dashed rgba(247, 215, 106, .2); text-transform: uppercase; font-size: .95rem;
}
.frow:last-child { border-bottom: 0; }
.frow .pts { text-align: right; }
.frow.hidden-ans .txt { color: rgba(247, 215, 106, .35); letter-spacing: .15em; }
.frow.missed .txt, .frow.missed .pts { color: #b9b2a0; }
.frow.just { animation: flash .6s; }
@keyframes flash { 0%, 100% { background: transparent; } 40% { background: rgba(247, 215, 106, .25); } }
.fsum { display: flex; justify-content: space-between; color: #f7d76a; font-family: ui-monospace, Consolas, monospace; font-weight: 800; padding: 8px 8px 0; border-top: 2px solid rgba(247, 215, 106, .4); margin-top: 4px; }
.xs { display: flex; gap: 8px; justify-content: center; margin: 0 0 12px; min-height: 40px; }
.xs b { font-size: 2rem; line-height: 1; color: var(--red); font-family: var(--sans); font-weight: 900; }
.xs b.off { color: var(--line); }
.guess-list { font-size: .85rem; color: var(--ink-2); margin-top: 8px; }

/* ---------- emoji / misc ---------- */
.emoji-big { font-size: clamp(2.4rem, 11vw, 3.6rem); text-align: center; letter-spacing: .06em; margin: 6px 0 4px; line-height: 1.3; }
.cat { text-align: center; text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; font-weight: 800; color: var(--ink-3); margin-bottom: 14px; }
.opts { display: grid; gap: 10px; }
.opt {
  font: inherit; text-align: left; font-weight: 700; padding: 14px 16px; border-radius: 12px; cursor: pointer;
  background: #fffdf8; border: 1.5px solid var(--line); color: var(--ink); touch-action: manipulation;
}
.opt:hover { border-color: var(--gold); }
.opt.correct { background: #e3eedd; border-color: var(--ok); }
.opt.wrong { background: #f5dfda; border-color: var(--red-2); }
.qtimer { height: 8px; border-radius: 4px; background: var(--bg-2); overflow: hidden; margin-bottom: 14px; }
.qtimer > div { height: 100%; background: var(--green-2); transition: width .25s linear; }
.qtimer.low > div { background: var(--red-2); }
.hl { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: stretch; margin-bottom: 14px; }
.hl .box { background: #fffdf8; border: 1.5px solid var(--line); border-radius: 12px; padding: 14px 10px; text-align: center; display: flex; flex-direction: column; justify-content: center; }
.hl .box .e { font-size: 2rem; }
.hl .box .name { font-weight: 800; }
.hl .box .val { font-family: var(--serif); font-size: 1.4rem; font-weight: 700; color: var(--green); }
.hl .box .val.q { color: var(--red); }
.hl .vsx { align-self: center; font-family: var(--serif); color: var(--ink-3); font-weight: 700; }
@media (max-width: 420px) { .hl { grid-template-columns: 1fr; } .hl .vsx { text-align: center; } }
.slider-val { font-family: var(--serif); font-size: 2rem; font-weight: 700; text-align: center; color: var(--red); margin: 4px 0; }
.hist { list-style: none; padding: 0; margin: 0; }
.hist li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.hist li:last-child { border-bottom: 0; }

/* ---------- login ---------- */
.login-card { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login-card form { text-align: left; display: grid; gap: 14px; margin-top: 14px; }
.who-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.who-pick button { font: inherit; font-weight: 800; padding: 14px; border-radius: 12px; border: 2px solid var(--line); background: #fffdf8; cursor: pointer; color: var(--ink); }
.who-pick button.sel.adam { border-color: var(--adam); background: #e8efe4; color: var(--adam); }
.who-pick button.sel.julka { border-color: var(--julka); background: #f6e3de; color: var(--julka); }
.error { color: var(--red); font-weight: 700; font-size: .9rem; min-height: 1.2em; }
