:root {
  font-family: "Space Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
  --bg: #040811;
  --panel: rgba(12, 18, 32, 0.94);
  --panel-2: rgba(12, 24, 40, 0.86);
  --accent: #7de0ff;
  --accent-2: #ff8fa3;
  --accent-3: #7cffc7;
  --text: #f6f8ff;
  --muted: #c4d2ea;
  --border: rgba(255, 255, 255, 0.14);
  --shadow: 0 26px 64px rgba(0, 0, 0, 0.55);
  --ribbon: linear-gradient(120deg, #f56f81, #f24f66 50%, #f78d9c);
  --ribbon-alt: linear-gradient(120deg, #7cffc7, #59e2ac 50%, #9ef3da);
  --ribbon-gold: #ffd28a;
  --snow: rgba(255, 255, 255, 0.85);
  --glass: rgba(255, 255, 255, 0.06);
  --card-noise:
    radial-gradient(1px 1px at 22% 28%, rgba(255,255,255,0.08), transparent 55%),
    radial-gradient(1px 1px at 66% 62%, rgba(124,255,214,0.07), transparent 55%),
    radial-gradient(1.2px 1.2px at 78% 20%, rgba(255,143,163,0.07), transparent 55%);
}

body.theme-deep-space,
body.theme-sunset,
body.theme-r0icemas {
  --bg: #040811;
  --panel: rgba(12, 18, 32, 0.94);
  --panel-2: rgba(12, 24, 40, 0.86);
  --accent: #7de0ff;
  --accent-2: #ff8fa3;
  --accent-3: #7cffc7;
  --text: #f6f8ff;
  --muted: #c4d2ea;
  --border: rgba(255, 255, 255, 0.14);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: transparent;
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 12px 14px;
  position: relative;
  z-index: 2;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 44px);
  letter-spacing: 0.3px;
}
.lead {
  color: var(--muted);
  margin: 6px 0 0 0;
  line-height: 1.5;
}

.advent-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin: 12px 0 24px;
}
.theme-switch { display: none; }

.theme-switch {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.theme-dot {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 6px 10px;
  background: rgba(255,255,255,0.03);
  color: var(--text);
}
.theme-dot .label { font-weight: 600; }
.theme-dot.is-active { border-color: var(--accent-2); box-shadow: 0 0 0 1px rgba(255,255,255,0.08); }

.section {
  margin: 0 0 16px 0;
}
.advent-join-card {
  background: linear-gradient(150deg, rgba(20,28,52,0.95), rgba(12,22,40,0.88));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 16px 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  max-width: 640px;
}
.advent-join-card h2 { margin: 0 0 8px 0; }
.advent-join-card p { margin: 0 0 8px 0; color: var(--muted); }
.advent-join-card ol { padding-left: 20px; margin: 8px 0 6px 0; color: var(--text); }
.advent-join-card code {
  background: rgba(255,255,255,0.06);
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
}
.muted { color: var(--muted); }
.small { font-size: 0.92rem; }

.grid {
  position: relative;
  display: block;
  min-height: 520px;
  margin-top: 4px;
  isolation: isolate;
}

#gift-pile-zone {
  position: absolute;
  right: clamp(-120px, -7vw, 20px);
  bottom: clamp(-170px, -7vh, -50px);
  width: clamp(240px, 34vw, 420px);
  height: clamp(220px, 38vh, 420px);
  pointer-events: none; /* allow clicks to pass to children; children set to auto */
  z-index: 6;
}
#gift-pile-zone::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6%;
  width: 78%;
  height: 16%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.35), transparent 65%);
  filter: blur(12px);
  opacity: 0.9;
  pointer-events: none;
}

.door {
  position: absolute;
  padding: 16px 14px 16px;
  background: linear-gradient(160deg, var(--door-bg1, rgba(28,42,72,0.94)), var(--door-bg2, rgba(10,18,36,0.9)));
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.2s ease, filter 0.2s ease;
}
.door::before,
.door::after {
  content: "";
  position: absolute;
  background: var(--ribbon);
  opacity: 0.92;
}
.door::before {
  width: 16px;
  inset: -14% auto -14% 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 18px rgba(0,0,0,0.2);
}
.door::after {
  height: 12px;
  inset: 50% -14% auto -14%;
  transform: translateY(-50%);
  background: var(--ribbon-alt);
  box-shadow: 0 0 18px rgba(0,0,0,0.2);
}
.door .bow {
  position: absolute;
  top: 12px;
  left: 50%;
  width: 22px;
  height: 22px;
  background: var(--ribbon-gold);
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 16px rgba(255,210,138,0.6);
  z-index: 2;
}
.door .bow::before,
.door .bow::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 8px;
  background: var(--ribbon);
  top: 50%;
  border-radius: 10px 10px 2px 2px;
}
.door .bow::before { left: -10px; transform: translate(-50%, -50%) rotate(-14deg); }
.door .bow::after { right: -10px; transform: translate(50%, -50%) rotate(14deg); }
.door .shine {
  position: absolute;
  inset: 0;
  background: radial-gradient(80% 80% at 30% 24%, rgba(255,255,255,0.12), transparent 60%),
              linear-gradient(110deg, rgba(255,255,255,0.12), rgba(255,255,255,0.02) 40%, transparent 60%);
  opacity: 0.7;
  pointer-events: none;
}

.door,
.door * {
  pointer-events: auto;
}
.door .door-topper {
  position: relative;
  padding: 8px 10px 6px;
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 10px;
}
.door .tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  font-weight: 700;
  font-size: 0.9rem;
}

.door .door-body { position: relative; z-index: 1; }
.door .door-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}
.door .door-num { font-weight: 800; letter-spacing: 0.5px; color: var(--text); }
.door .door-date { color: var(--muted); }
.door .door-title {
  margin: 8px 0 6px;
  font-size: 1.1rem;
  font-weight: 700;
}
.door .door-desc {
  margin: 0 0 10px 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.98rem;
}

.door .door-status {
  margin-top: 8px;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px dashed rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.04);
  display: grid;
  gap: 6px;
}
.door .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  font-weight: 700;
  font-size: 0.9rem;
}
.chip-locked { border-style: dashed; color: var(--muted); }
.chip-open { background: rgba(124,255,199,0.14); border-color: rgba(124,255,199,0.35); color: #bfffe6; }
.chip-today { background: rgba(255,210,138,0.16); border-color: rgba(255,210,138,0.48); color: #ffe6b7; }
.door .status-label { font-weight: 600; color: var(--text); font-size: 0.98rem; }
.door .status-label small { color: var(--muted); font-weight: 600; }
.door .door-status.is-locked { opacity: 0.88; }
.door .door-status.is-open { border-style: solid; }

.command {
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  padding: 10px 12px;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.35;
  margin: 0 0 8px 0;
}
.command-in { color: #b5f6ff; }
.command-out { color: #fcd7ff; opacity: 0.9; }

.door.locked { opacity: 0.9; }
.door.unlocked:hover { transform: translateY(-4px) rotate(-0.25deg); box-shadow: 0 20px 48px rgba(0,0,0,0.6); }
.door.locked:hover { transform: translateY(-2px); }
.door.zoom { animation: pop 480ms cubic-bezier(.24,.82,.28,1); }
.door.opening { transform: translateY(-3px) scale(1.02); filter: drop-shadow(0 16px 40px rgba(0,0,0,0.45)); }
.door[data-today="true"] { border-color: rgba(255,210,138,0.6); box-shadow: 0 14px 36px rgba(255,210,138,0.24), var(--shadow); }

.live-chip, .lock-chip { display: none; } /* legacy chips hidden */

.bg-nebula, .bg-hero-anim, .bg-grad, .bg-stars, .vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.bg-scene {
  position: fixed;
  inset: 0;
  background: url("/advent/assets/Setting.png") center top / cover no-repeat;
  filter: brightness(0.75);
  z-index: 0;
}
.bg-grad {
  background:
    radial-gradient(700px at 16% 20%, rgba(255,143,163,0.16), transparent 60%),
    radial-gradient(740px at 82% 18%, rgba(124,255,214,0.22), transparent 60%),
    radial-gradient(640px at 74% 70%, rgba(255,210,138,0.18), transparent 62%);
  filter: blur(18px);
  z-index: 1;
}
.bg-nebula {
  background: radial-gradient(1100px at 70% 30%, rgba(124,255,214,0.2), transparent 70%),
              radial-gradient(980px at 24% 60%, rgba(255,143,163,0.16), transparent 70%);
  opacity: 0.35;
  animation: nebula 36s ease-in-out infinite alternate;
  z-index: 2;
}
.bg-hero-anim {
  background: linear-gradient(120deg, rgba(255,255,255,0.05), transparent),
              linear-gradient(80deg, rgba(255,255,255,0.04), transparent);
  mix-blend-mode: screen;
  opacity: 0.24;
  animation: sweep 22s ease-in-out infinite alternate;
  z-index: 2;
}
.bg-stars {
  background-image:
    radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.85), transparent 55%),
    radial-gradient(1.4px 1.4px at 32% 68%, rgba(124,255,178,0.8), transparent 55%),
    radial-gradient(1.1px 1.1px at 72% 24%, rgba(92,224,255,0.8), transparent 55%),
    radial-gradient(1.5px 1.5px at 84% 72%, rgba(255,255,255,0.75), transparent 55%);
  animation: twinkle 10s ease-in-out infinite alternate;
  opacity: 0.7;
  z-index: 3;
}
.bg-stars::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.1px 1.1px at 22% 40%, rgba(255,255,255,0.65), transparent 55%),
    radial-gradient(1.2px 1.2px at 66% 22%, rgba(92,224,255,0.7), transparent 55%),
    radial-gradient(1px 1px at 18% 78%, rgba(124,255,178,0.65), transparent 55%);
  opacity: 0.9;
  animation: twinkle 12s ease-in-out infinite alternate-reverse;
}
.vignette {
  background: radial-gradient(circle at center, transparent 60%, rgba(0,0,0,0.45));
  z-index: 5;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 9, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 5;
}
.modal.show { display: flex; }
.modal .panel {
  width: min(560px, 92vw);
  background: linear-gradient(150deg, rgba(18,26,44,0.95), rgba(10,18,34,0.9));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}
.modal .panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255,255,255,0.05), transparent);
  opacity: 0.6;
  pointer-events: none;
}
.modal h2 { margin: 0 0 10px 0; }
.modal p { margin: 0 0 14px 0; color: var(--muted); }
.modal .row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.modal .count {
  font: 700 14px/1 "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.2px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
}

.btn {
  appearance: none;
  border: 0;
  background: linear-gradient(120deg, #ffe0a3, #ff9f8f);
  color: #201113;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(0,0,0,0.35);
  text-decoration: none;
}
.btn.disabled {
  opacity: 0.6;
  pointer-events: none;
  box-shadow: none;
}
.btn.close {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.14);
}

.footer {
  display: none;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.confetti {
  position: fixed;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  pointer-events: none;
  opacity: 0.95;
  z-index: 10;
}

@keyframes pop { from { transform: scale(0.98); } to { transform: scale(1); } }
@keyframes nebula { from { transform: translateY(-8px); } to { transform: translateY(8px) scale(1.01); } }
@keyframes sweep { from { transform: translateX(-10%); } to { transform: translateX(6%); } }
@keyframes twinkle { from { opacity: 0.6; } to { opacity: 1; } }
/* snowfall removed */

@media (max-width: 720px) {
  .container { padding: 10px 10px 12px; }
  .advent-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .theme-switch { align-self: flex-start; }
  .grid { min-height: 420px; }
  #gift-pile-zone {
    right: clamp(-24px, -8vw, 10px);
    left: auto;
    bottom: 32px;
    width: min(84vw, 380px);
    height: min(46vh, 320px);
  }
  .bg-scene { background-position: center 28%; background-size: cover; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .door.unlocked:hover,
  .door.locked:hover { transform: none; }
}
