:root {
  --fir: #1e5631;
  --fir-dark: #123a20;
  --red: #c23b3b;
  --red-dark: #9c2b2b;
  --gold: #d4af37;
  --cream: #fff8ef;
  --snow-white: #ffffff;
  --ink: #2c2420;
  --radius: 18px;

  --bear-fur: #a9713f;
  --bear-fur-dark: #8a5a30;
  --bear-muzzle: #f3dcb6;
  --penguin-body: #2b2b33;
  --penguin-belly: #ffffff;
  --penguin-beak: #f2a444;
  --mascot-cheek: #f7a8a8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Quicksand", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #0f3d2e 0%, #1e5631 45%, #2d6a3e 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  position: relative;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Ctext x='14' y='20' font-size='22' text-anchor='middle'%3E%E2%9D%84%EF%B8%8F%3C/text%3E%3C/svg%3E") 14 14, auto;
}

.page-header {
  text-align: center;
  padding: 2.2rem 1rem 1rem;
  position: relative;
  z-index: 2;
}

.page-header h1 {
  font-family: "Mountains of Christmas", cursive;
  font-size: clamp(2rem, 5vw, 3.2rem);
  color: var(--cream);
  text-shadow: 0 3px 0 var(--red-dark), 0 6px 12px rgba(0, 0, 0, 0.35);
  margin: 0 0 0.4rem;
}

.subtitle {
  color: #e9f3ea;
  font-size: 1.05rem;
  margin: 0;
}

.garland {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 1rem 0;
}

.garland-light {
  width: 10px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px currentColor;
  animation: light-blink 1.6s ease-in-out infinite;
}

@keyframes light-blink {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* Mascots (Bär & Pinguin SVGs) */
.mascot-ear, .mascot-head { fill: var(--bear-fur); }
.mascot-ear-inner { fill: var(--bear-fur-dark); }
.mascot-muzzle { fill: var(--bear-muzzle); }
.mascot-nose { fill: var(--ink); }
.mascot-eye {
  fill: var(--ink);
  transform-box: fill-box;
  transform-origin: center;
  animation: mascot-blink 5s ease-in-out infinite;
}

@keyframes mascot-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  94% { transform: scaleY(0.1); }
  96% { transform: scaleY(1); }
}
.mascot-eye-shine { fill: #ffffff; }
.mascot-cheek { fill: var(--mascot-cheek); opacity: 0.7; }
.mascot-mouth { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; }

.penguin-body, .penguin-flipper { fill: var(--penguin-body); }
.penguin-belly { fill: var(--penguin-belly); }
.penguin-beak, .penguin-foot { fill: var(--penguin-beak); }

.mascot {
  display: inline-block;
  width: 3.2rem;
  height: 3.2rem;
  vertical-align: middle;
}

.mascot svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.header-mascot {
  animation: mascot-sway 3s ease-in-out infinite;
}

.header-mascot.mascot-penguin {
  animation-delay: 0.4s;
}

@keyframes mascot-sway {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}

.door-mascot {
  width: 2.5rem;
  height: 2.5rem;
  margin-top: 2px;
}

.solve-mascot {
  display: block;
  width: 4.5rem;
  height: 4.5rem;
  margin: 0.4rem auto 0;
  animation: mascot-pop 0.5s ease;
}

.solve-mascot:empty {
  display: none;
}

@keyframes mascot-pop {
  0% { transform: scale(0) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  .header-mascot, .solve-mascot, .mascot-eye, .garland-light {
    animation: none !important;
  }
}

.mute-toggle,
.reset-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 20;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 248, 239, 0.9);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.reset-toggle {
  right: 64px;
}

.progress-row {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 0 1rem;
}

.candle-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  max-width: 700px;
  margin: 0 auto;
}

.candle {
  font-size: 1.15rem;
  opacity: 0.3;
  filter: grayscale(1);
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.candle.lit {
  opacity: 1;
  filter: none;
  text-shadow: 0 0 6px rgba(255, 200, 80, 0.9), 0 0 12px rgba(255, 160, 40, 0.6);
  animation: candle-flicker 2.4s ease-in-out infinite;
}

@keyframes candle-flicker {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.progress-text {
  color: #e9f3ea;
  font-size: 0.85rem;
  margin: 0.4rem 0 0.8rem;
}

.progress-mascot {
  position: absolute;
  top: -20px;
  width: 1.6rem;
  height: 1.6rem;
  transition: left 0.6s ease;
  pointer-events: none;
}

.progress-mascot svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

main {
  position: relative;
  z-index: 2;
  padding: 1rem 1rem 3rem;
  display: flex;
  justify-content: center;
}

.calendar {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 14px;
  perspective: 900px;
}

.door {
  position: relative;
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: var(--radius);
  font-family: "Mountains of Christmas", cursive;
  font-size: 1.7rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: linear-gradient(160deg, var(--red) 0%, var(--red-dark) 100%);
  color: var(--cream);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25), 0 10px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  transform-style: preserve-3d;
  transform-origin: left center;
}

.door:hover:not(.locked) {
  animation: door-wobble 0.5s ease;
  box-shadow: 0 9px 0 rgba(0, 0, 0, 0.25), 0 14px 22px rgba(0, 0, 0, 0.3);
}

@keyframes door-wobble {
  0% { transform: translateY(0) rotate(0deg) scale(1, 1); }
  25% { transform: translateY(-4px) rotate(-3deg) scale(1.05, 0.95); }
  50% { transform: translateY(-6px) rotate(3deg) scale(0.97, 1.03); }
  75% { transform: translateY(-3px) rotate(-1.5deg) scale(1.02, 0.98); }
  100% { transform: translateY(-3px) rotate(0deg) scale(1, 1); }
}

.door.door-opening {
  animation: door-flip 0.38s ease forwards;
}

@keyframes door-flip {
  0% { transform: rotateY(0deg); }
  60% { transform: rotateY(-100deg); }
  100% { transform: rotateY(-100deg); opacity: 0.5; }
}

.door:active:not(.locked) {
  transform: translateY(1px);
}

.door.locked {
  background: linear-gradient(160deg, #6b6b6b 0%, #494949 100%);
  color: #d8d8d8;
  cursor: not-allowed;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2), 0 8px 14px rgba(0, 0, 0, 0.2);
}

.door.solved {
  background: linear-gradient(160deg, var(--fir) 0%, var(--fir-dark) 100%);
}

.door .door-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.door .door-lock {
  font-size: 1.6rem;
}

.door .door-check {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 1.1rem;
  color: var(--gold);
}

.door .door-stars {
  position: absolute;
  bottom: 5px;
  font-size: 0.65rem;
  letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.door.today:not(.solved) {
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 6px 0 rgba(0,0,0,0.25), 0 10px 18px rgba(0,0,0,0.25), 0 0 0 0 rgba(212, 175, 55, 0.6); }
  50% { box-shadow: 0 6px 0 rgba(0,0,0,0.25), 0 10px 18px rgba(0,0,0,0.25), 0 0 0 10px rgba(212, 175, 55, 0); }
}

.page-footer {
  text-align: center;
  color: #e9f3ea;
  padding-bottom: 2rem;
  position: relative;
  z-index: 2;
}

/* Snow */
.snow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.stars-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.twinkle-star {
  position: absolute;
  color: #fff8ef;
  opacity: 0;
  animation: twinkle ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(0.6); }
  50% { opacity: 1; transform: scale(1.1); }
}

.snowflake {
  position: absolute;
  top: -10%;
  color: #fff;
  opacity: 0.85;
  user-select: none;
  animation-name: fall, sway;
  animation-timing-function: linear, ease-in-out;
  animation-iteration-count: infinite, infinite;
}

@keyframes fall {
  to { transform: translateY(110vh); }
}

@keyframes sway {
  0%, 100% { margin-left: 0; }
  50% { margin-left: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .snowflake, .door.today:not(.solved), .candle.lit, .door:hover, .twinkle-star {
    animation: none !important;
  }
}

/* Fireworks */
.fireworks-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.fireworks-canvas.visible {
  opacity: 1;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 15, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background-color: var(--cream);
  background-image: linear-gradient(var(--cream), var(--cream)), repeating-linear-gradient(45deg, var(--red) 0 14px, var(--snow-white) 14px 28px);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  border-radius: var(--radius);
  padding: 1.6rem;
  max-width: 820px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  border: 8px solid transparent;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  cursor: pointer;
}

#modal-title {
  font-family: "Mountains of Christmas", cursive;
  color: var(--fir-dark);
  font-size: 2rem;
  margin: 0 0 1rem;
  text-align: center;
}

.modal-body {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem;
  justify-content: center;
}

.crossword-grid {
  display: grid;
  gap: 2px;
  background: var(--fir-dark);
  padding: 4px;
  border-radius: 8px;
  max-width: 100%;
  overflow: auto;
}

.cw-cell {
  width: 30px;
  height: 30px;
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: 3px;
  background: var(--snow-white);
  color: var(--ink);
  position: relative;
}

.cw-cell:focus {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

.cw-cell.correct {
  background: #cdeccd;
}

.cw-cell.incorrect {
  background: #f6cccc;
}

.cw-cell-empty {
  background: transparent;
}

.cw-number {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--red-dark);
  pointer-events: none;
  z-index: 2;
}

.clues {
  flex: 1 1 240px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.clue-group h3 {
  margin: 0 0 0.4rem;
  color: var(--fir-dark);
  font-size: 1rem;
}

.clue-list {
  margin: 0;
  padding-left: 0.2rem;
  list-style: none;
  font-size: 0.92rem;
  line-height: 1.4;
}

.clue-list li {
  cursor: pointer;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.clue-list li .clue-text {
  flex: 1;
}

.clue-list li.active .clue-text {
  font-weight: 700;
  color: var(--red-dark);
}

.clue-list li.solved .clue-text {
  color: var(--fir);
  text-decoration: line-through;
}

.reveal-btn {
  flex: none;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  opacity: 0.6;
}

.reveal-btn:hover:not(:disabled) {
  opacity: 1;
  background: rgba(212, 175, 55, 0.25);
}

.reveal-btn:disabled {
  opacity: 0.15;
  cursor: default;
}

.modal-actions {
  margin-top: 1.4rem;
  text-align: center;
}

.btn {
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--red);
  color: white;
  box-shadow: 0 4px 0 var(--red-dark);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--red-dark);
}

.feedback {
  margin-top: 0.8rem;
  font-weight: 700;
  min-height: 1.4em;
}

.feedback.success {
  color: var(--fir);
}

.feedback.error {
  color: var(--red-dark);
}

.daily-message {
  position: relative;
  margin: 0.8rem auto 0;
  max-width: 420px;
  background: #ffffff;
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 0.5rem 1rem;
  font-family: "Mountains of Christmas", cursive;
  font-size: 1.3rem;
  color: var(--red-dark);
  min-height: 1.4em;
}

.daily-message:empty {
  border-color: transparent;
  background: transparent;
}

.daily-message:not(:empty)::before,
.daily-message:not(:empty)::after {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-style: solid;
}

.daily-message:not(:empty)::before {
  border-width: 0 10px 10px 10px;
  border-color: transparent transparent var(--gold) transparent;
}

.daily-message:not(:empty)::after {
  top: -7px;
  border-width: 0 8px 8px 8px;
  border-color: transparent transparent #ffffff transparent;
}

.stars-feedback {
  margin: 0.3rem 0 0;
  font-size: 1.3rem;
  letter-spacing: 3px;
  color: var(--gold);
  min-height: 1.4em;
}

.fun-fact {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--fir-dark);
  font-style: italic;
  min-height: 1.3em;
}

@media (max-width: 520px) {
  .cw-cell {
    width: 24px;
    height: 24px;
    font-size: 0.85rem;
  }
}

/* Candy-cane cursor for interactive elements (defined last to win the cascade) */
.door,
.btn,
.reveal-btn,
.mute-toggle,
.reset-toggle,
.modal-close {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Ctext x='14' y='20' font-size='22' text-anchor='middle'%3E%F0%9F%8D%AD%3C/text%3E%3C/svg%3E") 14 14, pointer;
}

.door.locked {
  cursor: not-allowed;
}