:root {
  color-scheme: light dark;
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #1c2b24;
  --muted: #5f6b64;
  --line: #e8e2d8;
  --pine: #17392c;
  --on-pine: #f6f1e7;
  --on-pine-muted: #c3cfc6;
  --berry: #a32f38;
  --berry-text: #a32f38;
  --gold: #d9ae55;
  --gold-text: #7d5c14;
  --gold-soft: #f8efd9;
  --mine-soft: #f1f4ef;
  --snow: rgb(23 57 44 / 0.1);
  --serif: "Fraunces", Georgia, serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a16;
    --surface: #16241e;
    --ink: #edf1ec;
    --muted: #a0ada5;
    --line: #27372f;
    --pine: #1b4233;
    --berry-text: #ec8a90;
    --gold-text: #e3bf73;
    --gold-soft: #2b2a1b;
    --mine-soft: #1b2c25;
    --snow: rgb(246 241 231 / 0.09);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* delikatny śnieg na górze strony, gaśnie w dół */
body::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 300px;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(circle, var(--snow) 1.5px, transparent 2px),
    radial-gradient(circle, var(--snow) 1px, transparent 1.5px);
  background-size: 70px 70px, 43px 43px;
  background-position: 0 0, 22px 31px;
  mask-image: linear-gradient(to bottom, #000, transparent);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 640px;
  min-height: 64px;
  margin: 0 auto;
  padding: 12px 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

main {
  display: grid;
  gap: 16px;
  max-width: 640px;
  margin: 0 auto;
  padding: 4px 16px calc(48px + env(safe-area-inset-bottom));
}

h1, h2, .receiver {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

h1 { font-size: clamp(1.75rem, 6.5vw, 2.25rem); }
h2 { font-size: 1.5rem; }
p { margin: 0; }

.muted { color: var(--muted); }
.small-text { font-size: 0.875rem; }

.card {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.lead { margin-top: 8px; color: var(--muted); }
.hint { margin-top: 12px; font-size: 0.875rem; color: var(--muted); }

.error {
  padding: 12px 16px;
  color: var(--berry-text);
  background: var(--surface);
  border: 1px solid currentColor;
  border-radius: 12px;
}

/* formularz */
label {
  display: block;
  margin: 20px 0 6px;
  font-weight: 500;
}

input, textarea {
  width: 100%;
  padding: 12px 14px;
  /* 16px, żeby iOS nie przybliżał strony przy pisaniu */
  font: inherit;
  font-size: 1rem;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

input {
  min-height: 48px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

input::placeholder { letter-spacing: 0.06em; }
textarea { display: block; resize: vertical; field-sizing: content; min-height: 84px; }
input::placeholder, textarea::placeholder { color: var(--muted); }

:is(input, textarea, button, summary):focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* przyciski */
button {
  min-height: 48px;
  padding: 0 20px;
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { cursor: default; opacity: 0.5; }

.primary { color: #fff; background: var(--berry); }
.small { min-height: 40px; padding: 0 16px; }
.light { color: var(--pine); background: var(--on-pine); }

.ghost {
  min-height: 40px;
  padding: 0 12px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
}

#login-form .primary { width: 100%; margin-top: 12px; }

/* karta losowania */
.hero {
  position: relative;
  overflow: hidden;
  padding: 28px 20px 20px;
  color: var(--on-pine);
  background: var(--pine);
  border-radius: 20px;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgb(246 241 231 / 0.16) 1.5px, transparent 2px),
    radial-gradient(circle, rgb(246 241 231 / 0.1) 1px, transparent 1.5px);
  background-size: 64px 64px, 37px 37px;
  background-position: 8px 10px, 26px 30px;
}

.hero > * { position: relative; }
.hero p:not(.eyebrow, .receiver) { margin-top: 8px; color: var(--on-pine-muted); }
.hero button { width: 100%; margin-top: 20px; }

.eyebrow {
  margin-bottom: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gold);
}

.receiver {
  font-size: clamp(2.5rem, 12vw, 3.5rem);
  animation: reveal 0.5s ease-out;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
  .receiver { animation: none; }
  button { transition: none; }
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.chips li {
  padding: 4px 12px;
  font-size: 0.875rem;
  border: 1px solid rgb(246 241 231 / 0.3);
  border-radius: 999px;
}

/* instrukcja */
details.card { padding: 0; }

summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 20px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
  border-radius: 16px;
}

summary::-webkit-details-marker { display: none; }

summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border: solid var(--muted);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  transition: transform 0.15s;
}

details[open] summary::after { transform: rotate(-135deg); }

.steps {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0 20px 20px;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding-left: 40px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--on-pine);
  background: var(--pine);
  border-radius: 50%;
}

.steps strong { font-weight: 600; }

/* tabela uwag */
#notes { margin-top: 12px; }
#notes > .muted { margin-top: 4px; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
}

.section-head .muted { font-size: 0.875rem; }

.table-wrap {
  margin-top: 12px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

th, td {
  padding: 14px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  padding-block: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

th:first-child { width: 36%; }
tbody tr { border-top: 1px solid var(--line); }
tr.is-target { background: var(--gold-soft); }
tr.is-mine { background: var(--mine-soft); }

.person { display: block; font-weight: 600; overflow-wrap: anywhere; }
.note { white-space: pre-wrap; overflow-wrap: anywhere; }

.badge {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--on-pine);
  background: var(--pine);
  border-radius: 999px;
}

.badge.gold { color: #33260a; background: var(--gold); }

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.status::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
}

.status.done::before {
  background: var(--gold);
  border-color: var(--gold);
}

.editor-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

@media (min-width: 600px) {
  .card { padding: 24px; }
  details.card { padding: 0; }
  summary { padding: 0 24px; }
  .steps { padding: 0 24px 24px; }
  .hero { padding: 36px 32px 28px; }
  .hero button { width: auto; }
  #login-form .primary { width: auto; }
  th, td { padding-inline: 16px; }
}
