:root {
  --bg-1: #070a22;
  --bg-2: #1a1145;
  --bg-3: #3a1d5c;
  --gold: #f3d58a;
  --gold-soft: #e8c873;
  --ink: #f5ecff;
  --ink-dim: #c9bde6;
  --violet: #8a6bd6;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(243, 213, 138, 0.22);
  --radius: 18px;
  --serif: "Cormorant Garamond", Georgia, serif;
  --display: "Cinzel", "Times New Roman", serif;
}

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

html, body { margin: 0; }
html { background: var(--bg-1); }

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.5;
  overflow-x: hidden;
}
/* Fixed backdrop layer (background-attachment: fixed is unreliable on iOS). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(138, 107, 214, 0.35), transparent 60%),
    radial-gradient(900px 600px at -10% 30%, rgba(214, 107, 168, 0.18), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
}

/* ---------- starry sky ---------- */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.star {
  position: absolute;
  width: 2px; height: 2px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.7;
  animation: twinkle var(--d, 4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
.star.big { width: 3px; height: 3px; box-shadow: 0 0 6px 1px rgba(255, 240, 200, 0.7); }
@keyframes twinkle {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}
.shooting {
  position: absolute;
  width: 140px; height: 2px;
  background: linear-gradient(90deg, rgba(255,255,255,0.9), transparent);
  border-radius: 2px;
  transform: rotate(-25deg);
  opacity: 0;
  animation: shoot var(--d, 1.4s) ease-out forwards;
}
@keyframes shoot {
  0% { opacity: 0; translate: 0 0; }
  10% { opacity: 1; }
  100% { opacity: 0; translate: -420px 200px; }
}

main {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 16px 48px;
}

/* ---------- hero ---------- */
.hero { text-align: center; padding: 24px 0 8px; }
.greeting {
  font: inherit;
  font-style: italic;
  color: var(--ink-dim);
  margin: 0 0 4px;
  font-size: 1.15rem;
  background: none;
  border: 0;
  padding: 2px 8px;
  border-radius: 99px;
  cursor: pointer;
}
.greeting .edit { font-style: normal; font-size: 0.85em; margin-left: 6px; opacity: 0.45; transition: opacity 0.2s ease; }
.greeting:hover .edit, .greeting:focus-visible .edit { opacity: 1; }
.greeting:focus-visible { outline: 1px solid var(--card-border); }
h1 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: clamp(2.6rem, 10vw, 4.6rem);
  margin: 0;
  background: linear-gradient(180deg, #fff6d8, var(--gold) 60%, #b98d3a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(243, 213, 138, 0.25);
}
.subtitle {
  font-style: italic;
  font-size: clamp(1.15rem, 4.5vw, 1.45rem);
  color: var(--ink);
  margin: 2px 0 0;
}
.release-date {
  font-family: var(--display);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--gold-soft);
  margin: 6px 0 26px;
}

.countdown {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
}
.unit {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px 6px 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.unit span {
  display: block;
  font-family: var(--display);
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  line-height: 1.1;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.unit-days span { color: var(--gold); font-size: clamp(2.2rem, 9vw, 3.4rem); }
.unit small {
  display: block;
  font-family: var(--display);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-top: 4px;
}
.countdown-done {
  font-family: var(--display);
  font-size: clamp(1.4rem, 5vw, 2rem);
  color: var(--gold);
  margin: 10px 0;
}

.progress {
  max-width: 560px;
  height: 6px;
  margin: 22px auto 0;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--violet), var(--gold));
  border-radius: 99px;
  transition: width 1s ease;
}

/* ---------- calendar ---------- */
.calendar-section { margin-top: 44px; text-align: center; }
h2 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--gold);
  font-size: clamp(1.2rem, 4.5vw, 1.6rem);
  margin: 0 0 6px;
}
.hint { color: var(--ink-dim); margin: 0 auto 22px; max-width: 520px; font-style: italic; }

.calendar {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}
.calendar li { display: contents; }

.door {
  position: relative;
  aspect-ratio: 3 / 4;
  width: 100%;
  border: 1px solid var(--card-border);
  border-radius: 48px 48px 12px 12px; /* arched like a Velaris doorway */
  background:
    radial-gradient(circle at 50% 30%, rgba(243, 213, 138, 0.12), transparent 60%),
    linear-gradient(180deg, rgba(58, 36, 120, 0.85), rgba(20, 14, 56, 0.9));
  color: var(--ink);
  font-family: var(--display);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
.door:hover, .door:focus-visible { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4); outline: none; border-color: var(--gold); }
.door .num {
  display: block;
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}
.door .num-label {
  display: block;
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-top: 4px;
}
.door .date {
  position: absolute;
  bottom: 8px; left: 0; right: 0;
  font-family: var(--serif);
  font-size: 0.8rem;
  font-style: italic;
  color: var(--ink-dim);
}
.door .face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding-bottom: 14px;
}
.door .thumb { position: absolute; inset: 0; opacity: 0; transition: opacity 0.4s ease; }
.door .thumb svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.door.locked { cursor: default; filter: saturate(0.4); opacity: 0.55; }
.door.locked .num { color: var(--ink-dim); }
.door.locked::after {
  content: "🔒";
  position: absolute; top: 12px; left: 50%; translate: -50% 0;
  font-size: 0.75rem; opacity: 0.7;
}

.door.opened .thumb { opacity: 1; }
.door.opened .face {
  background: linear-gradient(180deg, transparent 35%, rgba(7, 10, 34, 0.85));
  justify-content: flex-end;
  padding-bottom: 26px;
}
.door.opened .num { font-size: 1.3rem; }
.door.opened .num-label { display: none; }

.door.today { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(243, 213, 138, 0.35), 0 0 30px rgba(243, 213, 138, 0.35); }
.door.today:not(.opened) { animation: glow 2.4s ease-in-out infinite; }
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(243, 213, 138, 0.3), 0 0 18px rgba(243, 213, 138, 0.25); }
  50% { box-shadow: 0 0 0 3px rgba(243, 213, 138, 0.6), 0 0 38px rgba(243, 213, 138, 0.55); }
}
.door.today .badge {
  position: absolute; top: 10px; left: 50%; translate: -50% 0;
  font-family: var(--display);
  font-size: 0.5rem;
  letter-spacing: 0.2em;
  background: var(--gold);
  color: #1a1145;
  padding: 2px 7px;
  border-radius: 99px;
  z-index: 2;
}
.door.release { grid-column: 1 / -1; aspect-ratio: auto; height: 150px; border-radius: 80px 80px 18px 18px; }
.door.release .num { font-size: 1.5rem; letter-spacing: 0.1em; }

.shake { animation: shake 0.45s ease; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ---------- dialog ---------- */
.door-dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--card-border);
  border-radius: 24px;
  background: linear-gradient(180deg, #17103f, #0c0a28);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  overflow: auto;
}
.door-dialog::backdrop { background: rgba(4, 4, 18, 0.7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.door-dialog[open] { animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: none; } }
.door-dialog article { padding: 0 0 22px; position: relative; }
.close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(7, 10, 34, 0.6);
  color: #fff;
  font-size: 1.5rem; line-height: 1;
  cursor: pointer;
}
.art { margin: 0; }
.art svg { display: block; width: 100%; height: auto; }
.art-caption {
  text-align: center;
  font-style: italic;
  color: var(--ink-dim);
  margin: 8px 16px 0;
  font-size: 0.95rem;
}
.door-dialog h3 {
  font-family: var(--display);
  text-align: center;
  color: var(--gold);
  letter-spacing: 0.08em;
  margin: 14px 16px 0;
  font-size: 1.3rem;
}
.days-left {
  text-align: center;
  font-family: var(--display);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 4px 16px 16px;
}
.card {
  margin: 12px 16px 0;
  padding: 14px 18px 16px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}
.label {
  font-family: var(--display);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}
.card p { margin: 6px 0 0; }
.card h4 { font-family: var(--display); font-weight: 600; margin: 6px 0 0; font-size: 1.02rem; letter-spacing: 0.03em; }
blockquote {
  margin: 8px 0 0;
  font-size: 1.35rem;
  font-style: italic;
  line-height: 1.35;
}
cite { display: block; margin-top: 8px; color: var(--ink-dim); font-size: 0.9rem; }
cite::before { content: "— "; }

.vote { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.vote button {
  flex: 1 1 auto;
  font-family: var(--serif);
  font-size: 0.95rem;
  padding: 7px 10px;
  border-radius: 99px;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.vote button[aria-pressed="true"] { background: rgba(243, 213, 138, 0.18); border-color: var(--gold); color: #fff; }

/* ---------- name & gift dialogs ---------- */
.name-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 28px 22px 22px;
  border: 1px solid var(--card-border);
  border-radius: 24px;
  background: linear-gradient(180deg, #1d1450, #0c0a28);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.name-dialog::backdrop { background: rgba(4, 4, 18, 0.75); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.name-dialog[open] { animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
.name-dialog h3 { font-family: var(--display); color: var(--gold); font-weight: 600; letter-spacing: 0.05em; margin: 6px 0 4px; font-size: 1.3rem; }
.eyebrow { font-family: var(--display); font-size: 0.66rem; letter-spacing: 0.24em; text-transform: uppercase; color: var(--ink-dim); margin: 0; }
.muted { color: var(--ink-dim); font-style: italic; margin: 0 0 4px; }
.name-dialog input {
  width: 100%;
  margin-top: 14px;
  padding: 12px 16px;
  font: inherit;
  font-size: 1.15rem;
  text-align: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  outline: none;
}
.name-dialog input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(243, 213, 138, 0.18); }
.name-dialog input[readonly] { font-size: 0.85rem; color: var(--ink-dim); }
.actions { display: flex; gap: 10px; margin-top: 18px; }
.actions button {
  flex: 1;
  font-family: var(--display);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  padding: 12px 10px;
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
}
.primary { background: linear-gradient(180deg, #f7e2a6, var(--gold-soft)); color: #1a1145; border: 0; font-weight: 700; }
.ghost { background: transparent; color: var(--ink-dim); border: 1px solid var(--card-border); }
.link-btn {
  font: inherit;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--gold-soft);
  background: none;
  border: 0;
  padding: 4px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(243, 213, 138, 0.35);
  text-underline-offset: 4px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
  translate: -50% 20px;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 16px;
  background: rgba(23, 16, 63, 0.95);
  border: 1px solid var(--card-border);
  color: var(--ink);
  font-style: italic;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, translate 0.3s ease;
  z-index: 10;
}
.toast.show { opacity: 1; translate: -50% 0; }

footer { text-align: center; margin-top: 48px; color: var(--ink-dim); font-style: italic; }
footer .small { font-size: 0.8rem; opacity: 0.7; }

@media (max-width: 420px) {
  body { font-size: 18px; }
  .countdown { gap: 6px; }
  .calendar { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .door { border-radius: 36px 36px 10px 10px; }
  .door .num { font-size: 1.5rem; }
  .door .date { font-size: 0.68rem; }
}

@media (prefers-reduced-motion: reduce) {
  .star, .shooting, .door.today, .door-dialog[open], .name-dialog[open] { animation: none !important; }
}
