:root {
  --bg: #1a1210;
  --bg-2: #2a1c18;
  --paper: #f6ead7;
  --ink: #2b1a14;
  --muted: #cbb8a8;
  --accent: #c45c26;
  --accent-2: #e8a04a;
  --wrapped: #7a3b2e;
  --ok: #2f7d4a;
  --danger: #b33a3a;
  --radius: 18px;
  --font: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: radial-gradient(1200px 800px at 50% -10%, #3a241c, var(--bg));
  color: var(--paper);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1, h2 { font-weight: 650; letter-spacing: 0.02em; margin: 0; }
p { line-height: 1.5; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 1.1rem; flex: 1; text-align: center; padding-right: 48px; }
.back-link {
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
  min-width: 48px;
}

.landing {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 16px;
}
.splash {
  width: min(86vw, 420px);
  height: auto;
  border-radius: 28px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.tagline { color: var(--muted); margin: 0 0 8px; }

[hidden] { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.secondary { background: var(--paper); color: var(--ink); }
.btn.redeem {
  width: 100%;
  margin-top: 12px;
  padding: 18px;
  font-size: 1.15rem;
  background: linear-gradient(180deg, #ef7a3a, var(--accent));
  color: #fff;
}
.btn:disabled { opacity: 0.5; cursor: default; }

.status, .error, .redeemed-label { text-align: center; }
.status { color: var(--muted); }
.error { color: #ffb4b4; }
.redeemed-label {
  margin-top: 16px;
  font-weight: 700;
  color: var(--accent-2);
}

.calendar-wrap, .gift-wrap, .admin-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px 40px;
}

.page-calendar {
  background:
    radial-gradient(ellipse at 8% 22%, rgba(92, 115, 68, 0.28), transparent 34%),
    radial-gradient(ellipse at 95% 60%, rgba(92, 115, 68, 0.2), transparent 30%),
    radial-gradient(1200px 800px at 50% -10%, #3a241c, var(--bg));
}
.page-calendar .calendar-wrap {
  max-width: 720px;
  padding-top: 12px;
}
.calendar-trail {
  --map-paper: #d6c18a;
  --trail-gap: 24px;
  position: relative;
  display: grid;
  gap: var(--trail-gap);
  margin: 0;
  padding: 18px 12px 28px;
  list-style: none;
  overflow: hidden;
  border: 1px solid rgba(239, 220, 166, 0.45);
  border-radius: 28px 18px 30px 16px;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(255, 248, 214, 0.55), transparent 30%),
    repeating-linear-gradient(14deg, transparent 0 36px, rgba(116, 96, 52, 0.045) 37px 38px),
    var(--map-paper);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28), inset 0 0 28px rgba(104, 77, 34, 0.18);
}
.day-node {
  position: relative;
  z-index: 0;
  min-width: 0;
}
.trail-route {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  width: 100%;
  height: calc(150% + var(--trail-gap));
  overflow: visible;
  pointer-events: none;
}
.trail-route path {
  fill: none;
  stroke: rgba(157, 68, 42, 0.72);
  stroke-width: 1.2;
  stroke-dasharray: 1.2 2.2;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.day-node:last-child .trail-route { display: none; }
.day-stop {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 78%;
  min-height: 132px;
  padding: 10px;
  border: 1px solid rgba(93, 71, 36, 0.25);
  border-radius: 10px 18px 12px 16px;
  background: #f2e7c6;
  box-shadow: 0 5px 10px rgba(80, 57, 25, 0.2);
  color: #382b1d;
  text-decoration: none;
  transform: rotate(-0.8deg);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.day-node:nth-child(even) .day-stop {
  justify-self: end;
  border-radius: 16px 10px 18px 12px;
  transform: rotate(0.8deg);
}
.day-stop:focus-visible {
  outline: 3px solid #277d78;
  outline-offset: 3px;
}
.day-stop[href]:hover {
  box-shadow: 0 9px 16px rgba(80, 57, 25, 0.28);
  transform: translateY(-2px) rotate(0deg);
}
.day-stop img {
  display: block;
  width: 92px;
  height: 108px;
  object-fit: cover;
  border: 3px solid #fff9e9;
  border-radius: 7px;
  background: #cdbb8b;
}
.day-number {
  position: absolute;
  top: -8px;
  left: -8px;
  display: grid;
  width: 30px;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid #f2e7c6;
  border-radius: 50%;
  background: #a9432d;
  color: #fff5dc;
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: 0 2px 4px rgba(55, 35, 21, 0.25);
}
.day-copy { display: grid; gap: 6px; min-width: 0; }
.day-copy strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.day-copy small { color: #74633e; font-size: 0.75rem; }
.day-stop.locked { opacity: 0.82; }
.day-stop.today { outline: 3px solid #277d78; outline-offset: 2px; }

@media (max-width: 380px) {
  .calendar-trail { padding-inline: 8px; }
  .day-stop { grid-template-columns: 76px minmax(0, 1fr); gap: 9px; }
  .day-stop img { width: 76px; height: 100px; }
}

@media (min-width: 600px) {
  .calendar-trail { --trail-gap: 30px; padding: 24px 28px 36px; }
  .day-stop { grid-template-columns: 104px minmax(0, 1fr); min-height: 148px; width: 78%; gap: 16px; padding: 12px; }
  .day-stop img { width: 104px; height: 122px; }
  .day-copy strong { font-size: 1.15rem; }
}

.gift-card {
  background: var(--bg-2);
  border-radius: 24px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gift-image {
  width: 100%;
  border-radius: 18px;
  object-fit: cover;
  max-height: 52vh;
  background: #000;
}
.gift-card h2 { font-size: 1.6rem; }
.gift-card p { margin: 0; color: var(--muted); }

.login-box, .gift-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-2);
  padding: 16px;
  border-radius: 18px;
}
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
label.check { flex-direction: row; align-items: center; }
input, textarea {
  font: inherit;
  border-radius: 10px;
  border: 0;
  padding: 10px 12px;
  background: #3d2a24;
  color: var(--paper);
}
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.gift-list {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gift-list button {
  width: 100%;
  text-align: left;
  background: var(--bg-2);
  color: inherit;
  border: 0;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
}
.gift-list button.active { outline: 2px solid var(--accent-2); }

.confetti {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 20;
}
.confetti i {
  position: absolute;
  top: -12px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  animation: fall var(--t, 2.4s) linear forwards;
  background: var(--c, var(--accent));
}
@keyframes fall {
  to {
    transform: translate3d(var(--x, 0), 110vh, 0) rotate(720deg);
    opacity: 0.2;
  }
}

@media (min-width: 700px) {
  .calendar-grid { gap: 12px; }
  .day-cell { min-height: 120px; }
}
