/* ---------- Fonty (SIL OFL, patrz fonts/LICENSE.txt) ---------- */
@font-face {
  font-family: 'Berkshire Swash';
  font-display: swap;
  src: url('/fonts/berkshire-swash-latin-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Berkshire Swash';
  font-display: swap;
  src: url('/fonts/berkshire-swash-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-weight: 200 1000;
  font-display: swap;
  src: url('/fonts/nunito-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Nunito';
  font-weight: 200 1000;
  font-display: swap;
  src: url('/fonts/nunito-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Podstawy ---------- */
:root {
  --pine-900: #06140f;
  --pine-800: #0b2a22;
  --pine-600: #14503c;
  --pine-500: #1b6b4f;
  --red-700: #9c1c24;
  --red-600: #c0262d;
  --red-500: #dc3a3f;
  --gold-500: #f2cd6b;
  --gold-600: #d9a93a;
  --gold-800: #8a6410;
  --cream: #fffaf0;
  --cream-dark: #f3e8d2;
  --ink: #2b211c;
  --ink-soft: #6b5d52;
  --script: 'Berkshire Swash', 'Brush Script MT', cursive;
  --sans: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(ellipse 90% 60% at 50% 0%, rgba(41, 122, 92, 0.55), transparent 70%),
    linear-gradient(var(--pine-800), var(--pine-900));
  background-attachment: fixed;
  background-color: var(--pine-900);
}

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

.scene {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  height: min(22vh, 200px);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Lampki ---------- */
.lights {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  overflow: hidden;
  pointer-events: none;
  z-index: 4;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='24'%3E%3Cpath d='M0 3 Q30 27 60 3' fill='none' stroke='%232f6b57' stroke-width='2'/%3E%3C/svg%3E")
    repeat-x;
}

.bulb {
  position: absolute;
  top: 14px;
  width: 10px;
  height: 15px;
  margin-left: -5px;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  background: var(--c);
  box-shadow: 0 0 12px 3px var(--c);
  animation: twinkle 2.6s ease-in-out infinite alternate;
}

.bulb::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 2px;
  width: 6px;
  height: 4px;
  border-radius: 2px 2px 0 0;
  background: #1d4a3b;
}

.bulb.b0 { --c: #ff5a5f; }
.bulb.b1 { --c: #ffd166; }
.bulb.b2 { --c: #6ee7a8; }
.bulb.b3 { --c: #7cc4ff; }
.bulb.b4 { --c: #ff9ff3; }

@keyframes twinkle {
  from { opacity: 1; }
  to { opacity: 0.45; }
}

/* ---------- Układ ---------- */
main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 64px 16px 170px;
}

.hero {
  text-align: center;
  margin-bottom: 22px;
}

.brand {
  display: inline-block;
  color: inherit;
  text-decoration: none;
}

.brand-star {
  display: block;
  font-size: 30px;
  line-height: 1;
  color: var(--gold-500);
  text-shadow: 0 0 18px rgba(242, 205, 107, 0.9);
  animation: twinkle 2s ease-in-out infinite alternate;
}

.brand h1 {
  margin: 6px 0 2px;
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(2.3rem, 10vw, 3.5rem);
  line-height: 1.1;
  color: var(--gold-500);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 0 30px rgba(242, 205, 107, 0.35);
}

.brand p {
  margin: 0;
  color: #d6e8df;
  font-size: 1.05rem;
}

.card {
  position: relative;
  margin-bottom: 20px;
  padding: 26px 22px;
  background: var(--cream);
  border-radius: 20px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.card::before {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1.5px solid rgba(217, 169, 58, 0.55);
  border-radius: 14px;
  pointer-events: none;
}

.card > *,
.card form > * {
  position: relative;
}

.center {
  text-align: center;
}

h2 {
  margin: 0 0 8px;
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(1.6rem, 6.5vw, 2rem);
  line-height: 1.2;
  color: var(--red-700);
  overflow-wrap: anywhere;
}

h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 24px 0 8px;
  font-size: 1.05rem;
  font-weight: 800;
}

.step {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--pine-600);
  color: #fff;
  font-size: 0.95rem;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pine-500);
  overflow-wrap: anywhere;
}

.lead {
  margin: 0 0 6px;
  color: var(--ink-soft);
}

.hint {
  margin: 8px 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.count {
  margin: 8px 0 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--pine-600);
}

.optional {
  font-weight: 500;
  color: var(--ink-soft);
}

.error {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fde4e1;
  color: #8f1620;
  font-weight: 700;
  font-size: 0.95rem;
}

.loading {
  text-align: center;
  color: #d6e8df;
  font-size: 1.1rem;
  padding: 40px 0;
}

footer {
  margin-top: 26px;
  text-align: center;
  font-family: var(--script);
  font-size: 1.4rem;
  color: var(--gold-500);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

/* ---------- Formularze i przyciski ---------- */
label {
  display: block;
  margin: 18px 0 6px;
  font-weight: 800;
}

input[type='text'] {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border: 2px solid var(--cream-dark);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input[type='text']::placeholder {
  color: #a3968a;
}

input[type='text']:focus-visible {
  outline: none;
  border-color: var(--pine-500);
  box-shadow: 0 0 0 3px rgba(27, 107, 79, 0.2);
}

input[readonly] {
  background: #f8f1e2;
  font-size: 0.92rem;
  text-overflow: ellipsis;
}

.row {
  display: flex;
  gap: 8px;
}

.row input {
  flex: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
.gift:focus-visible,
.pick:focus-visible,
summary:focus-visible,
.brand:focus-visible {
  outline: 3px solid var(--gold-600);
  outline-offset: 3px;
}

.btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.btn-red {
  background: linear-gradient(var(--red-500), var(--red-600));
  color: #fff;
  box-shadow: 0 4px 0 var(--red-700);
}

.btn-green {
  background: linear-gradient(var(--pine-500), var(--pine-600));
  color: #fff;
  box-shadow: 0 4px 0 #0d3829;
}

.btn-ghost {
  background: transparent;
  color: var(--pine-600);
  box-shadow: inset 0 0 0 2px var(--pine-600);
}

.btn-danger {
  background: transparent;
  color: var(--red-700);
  box-shadow: inset 0 0 0 2px var(--red-600);
}

.btn-big {
  width: 100%;
  min-height: 56px;
  margin-top: 22px;
  font-size: 1.08rem;
}

.btn-wide {
  width: 100%;
  margin-top: 10px;
}

/* ---------- Lista imion przy tworzeniu ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.chips:empty {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding-left: 14px;
  border-radius: 999px;
  background: #e3f1e9;
  color: #0f3f2f;
  font-weight: 700;
  animation: pop 0.2s ease-out;
}

.chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip button {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.chip button:hover {
  color: var(--red-600);
}

@keyframes pop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------- Pokoje organizatora ---------- */
.room-list,
.people,
.pick-grid {
  margin: 0;
  padding: 0;
  list-style: none;
}

.room-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px;
  border-top: 1px solid var(--cream-dark);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.room-list li:first-child a {
  border-top: 0;
}

.room-list a::after {
  content: '→';
  color: var(--red-600);
}

/* ---------- Panel organizatora ---------- */
.progress {
  height: 12px;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--cream-dark);
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: repeating-linear-gradient(
    -45deg,
    var(--red-600) 0 10px,
    #fff 10px 20px
  );
  transition: width 0.4s ease;
}

.people {
  margin-top: 12px;
}

.people li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 0;
  border-top: 1px solid var(--cream-dark);
}

.person-name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.badge {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge-done {
  background: #dff3e7;
  color: #0f5a3d;
}

.badge-wait {
  background: #f6ecd6;
  color: #7a5a12;
}

.link-btn {
  flex: none;
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--red-700);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}

#admin-edit {
  margin-top: 14px;
}

details.card summary {
  position: relative;
  font-weight: 800;
  cursor: pointer;
}

/* ---------- Wybór imienia ---------- */
.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 64px;
  padding: 8px 10px;
  border: 2px solid var(--pine-600);
  border-radius: 14px;
  background: #fff;
  color: var(--pine-600);
  font: inherit;
  font-size: 1.08rem;
  font-weight: 800;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.pick:hover:not([disabled]) {
  background: var(--pine-600);
  color: #fff;
  transform: translateY(-2px);
}

.pick[disabled] {
  border-color: var(--cream-dark);
  background: #f8f1e2;
  color: #9a8d80;
  cursor: not-allowed;
}

.pick small {
  font-size: 0.75rem;
  font-weight: 700;
}

/* ---------- Prezent ---------- */
.reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  padding: 10px 0;
  text-align: center;
}

.gift {
  position: relative;
  width: 180px;
  height: 180px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
  cursor: pointer;
  animation: wobble 2.8s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}

.gift-box {
  position: absolute;
  left: 16px;
  bottom: 0;
  width: 148px;
  height: 104px;
  border-radius: 0 0 12px 12px;
  background: linear-gradient(90deg, var(--red-700), var(--red-500) 45%, var(--red-600));
  box-shadow: 0 14px 22px -10px rgba(0, 0, 0, 0.5);
}

.gift-box::before,
.gift-lid::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 28px;
  height: 100%;
  margin-left: -14px;
  background: linear-gradient(90deg, var(--gold-600), var(--gold-500), var(--gold-600));
}

.gift-lid {
  position: absolute;
  left: 0;
  top: 42px;
  width: 180px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--red-600), #ea5257 45%, var(--red-500));
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.25);
  z-index: 1;
  transition: transform 0.6s cubic-bezier(0.3, 0.8, 0.4, 1), opacity 0.5s ease 0.15s;
}

.gift-bow {
  position: absolute;
  left: 50%;
  bottom: 100%;
}

.gift-bow::before,
.gift-bow::after {
  content: '';
  position: absolute;
  bottom: -4px;
  width: 50px;
  height: 36px;
  border: 10px solid var(--gold-500);
  box-shadow: inset 0 0 0 1px var(--gold-600), 0 0 0 1px var(--gold-600);
}

.gift-bow::before {
  right: -4px;
  border-radius: 60% 40% 10% 60%;
  transform: rotate(14deg);
}

.gift-bow::after {
  left: -4px;
  border-radius: 40% 60% 60% 10%;
  transform: rotate(-14deg);
}

.gift-cta {
  margin: 18px 0 0;
  font-weight: 800;
  color: var(--pine-600);
}

@keyframes wobble {
  0%, 60%, 100% { transform: rotate(0); }
  68% { transform: rotate(-5deg); }
  76% { transform: rotate(5deg); }
  84% { transform: rotate(-3deg); }
  92% { transform: rotate(2deg); }
}

.reveal[data-state='opening'] .gift {
  animation: none;
}

.reveal[data-state='opening'] .gift-lid {
  transform: translate(-30px, -110px) rotate(-24deg);
  opacity: 0;
}

.reveal[data-state='opening'] .gift-cta {
  visibility: hidden;
}

.reveal[data-state='open'] .gift,
.reveal[data-state='open'] .gift-cta {
  display: none;
}

.result {
  display: none;
}

.reveal[data-state='open'] .result {
  display: block;
  animation: reveal 0.6s cubic-bezier(0.2, 1.3, 0.4, 1);
}

@keyframes reveal {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.result-label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pine-500);
}

.result-name {
  margin: 6px 0 10px;
  font-family: var(--script);
  font-size: clamp(2.6rem, 13vw, 4rem);
  line-height: 1.1;
  color: var(--red-600);
  text-shadow: 0 2px 0 rgba(217, 169, 58, 0.5);
  overflow-wrap: anywhere;
}

.result-budget {
  display: inline-block;
  margin: 0 0 12px;
  padding: 6px 16px;
  border-radius: 999px;
  background: #f6ecd6;
  color: #6b4e0c;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.result-secret {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-weight: 700;
}

.big-emoji {
  margin: 0 0 6px;
  font-size: 3.4rem;
  line-height: 1;
}

.back-link {
  display: block;
  padding: 8px;
  text-align: center;
  color: #d6e8df;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

#view-missing .btn {
  margin-top: 16px;
}

/* ---------- Okno potwierdzenia i powiadomienia ---------- */
dialog {
  width: min(92vw, 420px);
  padding: 24px 22px;
  border: 0;
  border-radius: 20px;
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

dialog::backdrop {
  background: rgba(4, 16, 12, 0.72);
}

dialog h3 {
  display: block;
  margin: 0 0 8px;
  font-family: var(--script);
  font-weight: 400;
  font-size: 1.6rem;
  line-height: 1.2;
  color: var(--red-700);
  overflow-wrap: anywhere;
}

dialog p {
  margin: 0;
  color: var(--ink-soft);
}

.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.dialog-actions .btn {
  flex: 1;
  padding: 0 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 10;
  max-width: calc(100vw - 32px);
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--pine-600);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, 30px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 380px) {
  .card {
    padding: 22px 16px;
  }

  .btn {
    padding: 0 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
