/* Dag er standard; data-mode="night" sættes fra JS ud fra systemets farvetema. */
:root {
  --fade: 2s;
  --sky-top: #4fa3e3;
  --sky-bottom: #d4ecff;
  --hill: #e3eef9;
  --ground: #f5f9fd;
  --window: #cfe9f8;
  --window-glow: 0px;
  --brightness: 1;
  --sun-opacity: 1;
  --moon-opacity: 0;
  --stars-opacity: 0;
  --smoke: #c9d2dc;
  --fort-outline: #c4d0de;
  --hud-text: #1d3557;
  --hud-background: rgb(255 255 255 / .6);
}

:root[data-mode="night"] {
  --sky-top: #070d24;
  --sky-bottom: #253764;
  --hill: #b9c7dd;
  --ground: #d5dfee;
  --window: #ffd166;
  --window-glow: 6px;
  --brightness: .6;
  --sun-opacity: 0;
  --moon-opacity: 1;
  --stars-opacity: 1;
  --smoke: #8e9ab0;
  --fort-outline: #9fadc2;
  --hud-text: #e8eefc;
  --hud-background: rgb(10 20 50 / .45);
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sky-top);
  transition: background var(--fade);
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* Under en snebolde-kamp er musen en vante (#hand) */
#scene.fighting {
  cursor: none;
}

#fort,
#snow,
#ui-fx,
#hand {
  pointer-events: none;
}

/* ---------- himmel ---------- */
stop {
  transition: stop-color var(--fade);
}

.sky-top {
  stop-color: var(--sky-top);
}

.sky-bottom {
  stop-color: var(--sky-bottom);
}

#sun,
#moon,
#stars {
  transition: opacity var(--fade);
}

#sun {
  opacity: var(--sun-opacity);
}

#moon {
  opacity: var(--moon-opacity);
}

#stars {
  opacity: var(--stars-opacity);
}

.star {
  animation: twinkle 3s infinite;
}

@keyframes twinkle {
  50% { opacity: .3; }
}

/* ---------- landskab ---------- */
.hill,
.ground,
.window {
  transition: fill var(--fade);
}

.hill {
  fill: var(--hill);
}

.ground {
  fill: var(--ground);
}

.night-dim {
  filter: brightness(var(--brightness));
  transition: filter var(--fade);
}

/* ---------- huse ---------- */
.window {
  fill: var(--window);
  filter: drop-shadow(0 0 var(--window-glow) #ffc94d);
}

.smoke circle {
  fill: var(--smoke);
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: smoke 4s linear infinite;
}

@keyframes smoke {
  0%   { transform: translate(0, 0) scale(.5); opacity: .8; }
  50%  { transform: translate(5px, -28px) scale(1.3); opacity: .5; }
  100% { transform: translate(22px, -56px) scale(2); opacity: 0; }
}

/* ---------- snemand: dæmpes mindre om natten (.6 × 1.4 ≈ .85) ---------- */
.snowman {
  transition: filter var(--fade);
}

:root[data-mode="night"] .snowman {
  filter: brightness(1.4);
}

/* ---------- sneborg ---------- */
#fort {
  fill: var(--ground);
  stroke: var(--fort-outline);
  transition: fill var(--fade), stroke var(--fade);
}

.flag-cloth {
  transform-box: fill-box;
  transform-origin: left center;
  animation: wave 1.2s ease-in-out infinite alternate;
}

@keyframes wave {
  to { transform: scaleX(.7) skewY(6deg); }
}

/* ---------- score ---------- */
#hud {
  position: fixed;
  top: 12px;
  left: 16px;
  padding: 6px 12px;
  border-radius: 10px;
  font: 600 15px/1.4 system-ui, sans-serif;
  white-space: pre-line;
  color: var(--hud-text);
  background: var(--hud-background);
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s, color var(--fade), background var(--fade);
}

#hud.visible {
  opacity: 1;
}
