:root {
  --bg: #0b1626;
  --bg-2: #12223a;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.1);
  --text: #fff6e6;
  --muted: rgba(255, 246, 230, 0.62);
  --gold: #e8c15a;
  --red: #c8372d;
  --green: #2f8f5b;
  --wine: #7d2236;
  --pine: #1d5a43;
  --danger: #ff8a80;
  --ok: #8fdcae;
  --radius: 16px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(120% 80% at 50% 0%, #1a3152 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  overscroll-behavior-y: none;
}

h1,
h2,
h3 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 800;
  margin: 0 0 0.4em;
  line-height: 1.15;
}
h1 {
  font-size: 1.75rem;
}
h2 {
  font-size: 1.3rem;
}
h3 {
  font-size: 1.05rem;
  margin-top: 1.2em;
}
p {
  margin: 0 0 0.8em;
  line-height: 1.5;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 32px);
}

.loading {
  text-align: center;
  color: var(--muted);
  margin-top: 40vh;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.85rem;
}
.error {
  color: var(--danger);
}
.ok {
  color: var(--ok);
}

/* ---------- Sníh ---------- */
.snow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1.5px 1.5px at 120px 80px, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(2.5px 2.5px at 200px 160px, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1.5px 1.5px at 60px 220px, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(2px 2px at 260px 40px, rgba(255, 255, 255, 0.6), transparent);
  background-size: 300px 260px;
  animation: snow 18s linear infinite;
  opacity: 0.5;
}
@keyframes snow {
  to {
    background-position: 40px 260px;
  }
}

/* ---------- Hlavička ---------- */
.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.eyebrow {
  margin: 0 0 2px;
  color: var(--gold);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status {
  color: var(--muted);
  margin: 4px 0 16px;
}
.status strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(232, 193, 90, 0.12);
  border: 1px solid rgba(232, 193, 90, 0.3);
  font-size: 0.9rem;
  margin-bottom: 12px;
}
.banner.warn {
  background: rgba(255, 138, 128, 0.12);
  border-color: rgba(255, 138, 128, 0.35);
}
.banner span {
  flex: 1;
}

/* ---------- Mřížka okének ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.door {
  position: relative;
  aspect-ratio: 1 / 1.1;
  border: none;
  border-radius: 14px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 6px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, filter 0.2s ease, opacity 0.2s ease;
}
.door::before {
  /* vrstva se vzorem */
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.45;
}
.door:active {
  transform: scale(0.96);
}

/* Pastelové barvy */
.door:not(.opened) {
  color: #3d2a33;
}
.tone-0 {
  background: linear-gradient(160deg, #f6d3d1, #e7aeb0); /* růžová */
}
.tone-1 {
  background: linear-gradient(160deg, #d6e6cf, #b2cda8); /* šalvějová */
}
.tone-2 {
  background: linear-gradient(160deg, #d6e4f0, #b0c8de); /* ledově modrá */
}
.tone-3 {
  background: linear-gradient(160deg, #f6ebc8, #e6d199); /* máslová */
}

/* Vzory místo pruhu (bílé, jemné) */
.pat-0::before {
  /* puntíky */
  background: radial-gradient(white 1.6px, transparent 2px) 0 0 / 14px 14px,
    radial-gradient(white 1.6px, transparent 2px) 7px 7px / 14px 14px;
}
.pat-1::before {
  /* vločky */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg stroke='white' stroke-width='1.5' stroke-linecap='round' fill='none'%3E%3Cpath d='M16 10v12M10.8 13l10.4 6M10.8 19l10.4-6'/%3E%3C/g%3E%3C/svg%3E")
    0 0 / 32px 32px;
}
.pat-2::before {
  /* hvězdičky */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M14 8l1.4 3.4 3.6.3-2.8 2.3.9 3.5L14 15.6l-3.1 1.9.9-3.5-2.8-2.3 3.6-.3z' fill='white'/%3E%3C/svg%3E")
    0 0 / 28px 28px;
}
.pat-3::before {
  /* proužky */
  background: repeating-linear-gradient(135deg, white 0 4px, transparent 4px 13px);
}

/* 24. prosinec – šampaňská se zlatým rámečkem a hvězdou */
.door.special {
  background: linear-gradient(160deg, #fbefd6, #edd3a1);
}
.special::before {
  inset: 5px;
  border: 1.5px solid #c9a24a;
  border-radius: 10px;
  opacity: 0.9;
}
.special::after {
  content: '';
  position: absolute;
  top: 13%;
  left: 50%;
  width: 16px;
  height: 16px;
  transform: translateX(-50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m12 2 2.9 6.6 7.1.6-5.4 4.7 1.6 7L12 17.3 5.8 21l1.6-7L2 9.2l7.1-.6z' fill='%23c9a24a'/%3E%3C/svg%3E")
    center / contain no-repeat;
  pointer-events: none;
}
.door.special .num {
  margin-top: 10px;
}

.door .num {
  position: relative;
  font-family: Fraunces, Georgia, serif;
  font-weight: 800;
  font-size: clamp(1.4rem, 7vw, 2rem);
}
.door.opened .num {
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.door .badge {
  position: absolute;
  top: 6px;
  right: 6px;
  opacity: 0.7;
  display: inline-flex;
}
.door.locked {
  opacity: 0.55;
  filter: saturate(0.8);
}
.door.unlocked:not(.opened) {
  box-shadow: inset 0 0 0 2px var(--gold), 0 0 18px rgba(232, 193, 90, 0.35);
}
.door.opened {
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.door.opened::before,
.door.opened::after {
  opacity: 0;
}
.door.opened .num {
  color: var(--muted);
}
.door.found .num {
  color: var(--gold);
}
.found-badge {
  color: var(--gold);
}
.door.today {
  animation: glow 2.4s ease-in-out infinite;
}
@keyframes glow {
  50% {
    box-shadow: inset 0 0 0 2px var(--gold), 0 0 28px rgba(232, 193, 90, 0.6);
  }
}
.door.shake {
  animation: shake 0.4s;
}
@keyframes shake {
  20%,
  60% {
    transform: translateX(-4px);
  }
  40%,
  80% {
    transform: translateX(4px);
  }
}

.footer {
  text-align: center;
  margin-top: 18px;
}

/* ---------- Tlačítka a formuláře ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #2a1d00;
}
.btn.ghost {
  background: transparent;
}
.btn.small {
  padding: 8px 12px;
  font-size: 0.85rem;
}
.btn.wide {
  width: 100%;
}
.btn:active {
  transform: scale(0.98);
}
.link {
  background: none;
  border: none;
  color: var(--gold);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.icon-btn {
  appearance: none;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

input,
textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* zabrání zoomu na iOS */
  color: var(--text);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
}
textarea {
  resize: vertical;
}
input:focus,
textarea:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 12px;
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.row input {
  flex: 1;
  min-width: 140px;
  width: auto;
}
.grow {
  flex: 1;
  min-width: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  backdrop-filter: blur(6px);
}
.center {
  text-align: center;
}
.gate {
  margin-top: 12vh;
}
.gate-emoji {
  font-size: 3rem;
  margin-bottom: 8px;
}

/* ---------- Modál ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(3, 8, 16, 0.6);
  display: grid;
  place-items: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.modal-backdrop.open {
  opacity: 1;
}
.modal {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #17294a, #0f1d33);
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: 28px 22px 22px;
  transform: scale(0.9) rotateX(12deg);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal-backdrop.open .modal {
  transform: none;
}
.modal-backdrop.sheet {
  place-items: end center;
  padding: 0;
}
.modal.sheet {
  border-radius: 22px 22px 0 0;
  padding-bottom: calc(env(safe-area-inset-bottom) + 22px);
  transform: translateY(40px);
}
.modal .close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
}

.hint {
  display: grid;
  gap: 12px;
}
.hint-day {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--gold);
  font-family: Fraunces, Georgia, serif;
}
.hint-day span {
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1;
}
.hint-day small {
  font-size: 1.1rem;
}
.hint-title {
  margin: 0;
}
.hint-body {
  white-space: pre-wrap;
  font-size: 1.05rem;
  margin: 0;
}
.hint-img {
  width: 100%;
  border-radius: 12px;
}

.steps {
  padding-left: 1.2em;
  line-height: 1.7;
  margin: 0 0 0.8em;
}
.inline-icon {
  display: inline-flex;
  vertical-align: -3px;
  color: #4ea0ff;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  transform: translate(-50%, 20px);
  z-index: 100;
  max-width: calc(100% - 32px);
  background: #fff6e6;
  color: #1b1b1b;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Konfety ---------- */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 120;
  overflow: hidden;
}
.confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to {
    top: 105vh;
    transform: rotate(720deg);
  }
}

/* ---------- Administrace ---------- */
.user-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--card-border);
}
.user-row p {
  margin: 2px 0 0;
}
.invite-link {
  flex-basis: 100%;
  font-size: 13px;
  padding: 8px 10px;
  color: var(--muted);
}
.hint-edit {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.15);
}
.hint-edit summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  cursor: pointer;
  list-style: none;
}
.hint-edit summary::-webkit-details-marker {
  display: none;
}
.hint-edit[open] {
  padding-bottom: 12px;
}
.day-chip {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--red);
  font-weight: 700;
  flex-shrink: 0;
}
.pill {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok {
  color: var(--ok);
  background: rgba(143, 220, 174, 0.12);
}

@media (prefers-reduced-motion: reduce) {
  .snow,
  .door.today {
    animation: none;
  }
}
