:root {
  --bg: #07060a;
  --text: #f3efe9;
  --muted: rgba(243, 239, 233, 0.72);
  --ember: #e0732a;
  --candle: #f2b35a;
  /* Dimming applied to the photo and to the flame cutouts drawn over it */
  --photo-filter: brightness(0.62) saturate(0.95) contrast(1.05);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh; /* visible height on phones, so the content centres properly */
  display: grid;
  place-items: center;
  overflow-x: hidden; /* vertical scroll stays available as a safety net */
  -webkit-font-smoothing: antialiased;
}

/* ---------- Scene ---------- */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(90% 55% at 50% 105%, #4a2210 0%, #2a130a 30%, #140a08 55%, #07060a 80%),
    #07060a;
}

/* Photo stage: a 3:2 box sized to cover the viewport, so anything placed
   inside it in percentages stays locked to the same spot in the photo. */
.photo {
  --w: max(100vw, 150vh);
  --fx: 0.5;
  position: absolute;
  width: var(--w);
  height: calc(var(--w) / 1.5);
  left: calc((100vw - var(--w)) * var(--fx));
  top: calc((100vh - var(--w) / 1.5) * 0.6);
  animation: kenburns 48s ease-in-out infinite alternate;
  transform-origin: 50% 65%;
  will-change: transform;
}
/* On tall screens, shift the crop right so the taper candles stay in view */
@media (max-aspect-ratio: 1/1) {
  .photo { --fx: 0.62; }
}
@keyframes kenburns {
  from { transform: scale(1.06) translate(0, 0); }
  to   { transform: scale(1.17) translate(-1.5%, -1%); }
}

.photo-img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  filter: var(--photo-filter);
}

/* Candle flames. script.js cuts each flame out of the photo. Per flame:
   .cover  paints over the original flame with the background behind it,
   .fire   is the flame cutout itself, the only thing that moves,
   .glow   is a faint light hugging the flame. */
.flames {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.flame { position: absolute; }
.flame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: var(--photo-filter);
}
.flame .fire { will-change: transform, filter; }
.flame .glow {
  position: absolute;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 205, 140, 0.55) 0%,
    rgba(255, 150, 70, 0.18) 40%,
    transparent 70%);
  mix-blend-mode: screen;
  opacity: 0;
}

/* Steady warm wash over the lower part of the scene */
.flicker {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 45% at 50% 85%, rgba(255, 170, 80, 0.22), transparent 70%),
    radial-gradient(35% 30% at 15% 90%, rgba(255, 140, 60, 0.18), transparent 70%),
    radial-gradient(35% 30% at 85% 88%, rgba(255, 150, 60, 0.18), transparent 70%);
  mix-blend-mode: screen;
  opacity: 0.8;
}

/* Warm candle glows along the bottom */
.glow {
  position: absolute;
  bottom: -10vh;
  width: 60vw;
  height: 50vh;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.8;
  mix-blend-mode: screen;
  animation: breathe 6s ease-in-out infinite;
}
.glow-a { left: -10vw; background: radial-gradient(circle, rgba(224,115,42,0.75), transparent 65%); animation-delay: 0s; }
.glow-b { left: 30vw;  background: radial-gradient(circle, rgba(242,179,90,0.6), transparent 65%); animation-delay: -2s; }
.glow-c { right: -10vw; background: radial-gradient(circle, rgba(200,80,30,0.7), transparent 65%); animation-delay: -4s; }

@keyframes breathe {
  0%, 100% { opacity: 0.65; transform: scale(1); }
  50%      { opacity: 0.9; transform: scale(1.06); }
}

#embers {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, transparent 40%, rgba(7, 6, 10, 0.75) 100%),
    linear-gradient(to bottom, rgba(7,6,10,0.55), transparent 30%, transparent 70%, rgba(7,6,10,0.5));
}

/* ---------- Content ---------- */
.content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 32px 20px;
  width: 100%;
  max-width: 1100px;
}

h1 {
  margin: 0 0 18px;
  font-weight: 700;
  font-size: clamp(56px, 11vw, 150px);
  line-height: 1;
  letter-spacing: -0.03em;
  text-shadow: 0 2px 4px rgba(0,0,0,0.45), 0 4px 30px rgba(0,0,0,0.7);
}

.greeting {
  margin: 0 0 28px;
  font-weight: 500;
  font-size: clamp(20px, 3vw, 38px);
  letter-spacing: -0.01em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6), 0 2px 16px rgba(0,0,0,0.75);
}

.card {
  display: inline-block;
  min-width: min(100%, 560px);
  padding: clamp(28px, 4vw, 48px) clamp(32px, 6vw, 80px);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(10, 8, 12, 0.35);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  box-shadow: 0 30px 80px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.08);
}

.number {
  font-weight: 800;
  font-size: clamp(96px, 16vw, 200px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 6px 40px rgba(0,0,0,0.5);
}

.caption {
  margin-top: 14px;
  font-weight: 400;
  font-size: clamp(18px, 2.4vw, 30px);
  color: var(--text);
}

.divider {
  width: 56px;
  height: 1px;
  margin: 22px auto 18px;
  background: rgba(255,255,255,0.28);
}

.seconds {
  font-weight: 600;
  font-size: clamp(26px, 4vw, 46px);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

.seconds-caption {
  margin-top: 8px;
  font-size: clamp(12px, 1.3vw, 15px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Halloween day ---------- */
body.halloween .number { font-size: clamp(64px, 10vw, 120px); }
body.halloween .divider, body.halloween .seconds, body.halloween .seconds-caption { display: none; }

/* ---------- Short screens (phones held sideways) ----------
   Shrink the type and put the day count and seconds side by side. */
@media (max-height: 520px) {
  .content { padding: 12px 20px; }
  h1 { font-size: clamp(30px, 12vh, 56px); margin-bottom: 6px; }
  .greeting { font-size: clamp(14px, 5vh, 22px); margin-bottom: 10px; }

  .card {
    display: inline-grid;
    grid-template-columns: auto 1px auto;
    column-gap: clamp(18px, 4vw, 36px);
    align-items: center;
    min-width: 0;
    padding: 12px clamp(24px, 5vw, 48px) 14px;
  }
  .number { grid-column: 1; grid-row: 1; font-size: clamp(56px, 24vh, 110px); }
  .caption { grid-column: 1; grid-row: 2; margin-top: 4px; font-size: clamp(14px, 5vh, 20px); }
  .divider { grid-column: 2; grid-row: 1 / span 2; width: 1px; height: 70%; margin: 0; align-self: center; }
  .seconds { grid-column: 3; grid-row: 1; align-self: end; font-size: clamp(22px, 9vh, 40px); }
  .seconds-caption { grid-column: 3; grid-row: 2; align-self: start; margin-top: 6px; }

  body.halloween .card { display: inline-block; }
}

@media (prefers-reduced-motion: reduce) {
  .glow, .photo { animation: none; }
}
