:root {
  --bg: #070d2a;
  --panel: #10194a;
  --panel-2: #172260;
  --line: rgba(255, 255, 255, 0.14);
  --text: #f3f5ff;
  --muted: #aeb8e6;
  --accent: #ffc928;
  --accent-ink: #2a1c00;
  --red: #ef5350;
  --green: #43a047;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 500;
}

body {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ---------- greeting (over the sky) ---------- */
.greeting {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  pointer-events: none;
  font-family: "Mountains of Christmas", "Georgia", serif;
  font-weight: 700;
  font-size: clamp(30px, 6.4vw, 64px);
  line-height: 1.05;
  color: var(--accent);
  text-shadow: 0 2px 16px rgba(255, 201, 40, 0.45), 0 2px 2px rgba(0, 0, 0, 0.5);
}
/* the greeting appears when the choir wakes up (the opening panel has its own) */
.greeting { opacity: 0; transform: translateY(-8px) scale(0.96); transition: opacity 1.2s ease 0.4s, transform 1.2s ease 0.4s; }
body.awake .greeting, .shot .greeting { opacity: 1; transform: none; }
.help-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(8, 12, 40, 0.6);
  color: var(--text);
  font: 800 18px "Nunito", system-ui, sans-serif;
  cursor: pointer;
}
.help-btn:hover { background: rgba(20, 30, 90, 0.85); }
.help-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

select, .btn {
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 12px;
  min-height: 38px;
}
select { cursor: pointer; }
select:focus-visible, .btn:focus-visible, input:focus-visible + .track, input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:hover { background: #1f2c78; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { background: #ffd65a; }
.btn.big { font-size: 18px; padding: 12px 26px; border-radius: 999px; }

input[type="range"] { accent-color: var(--accent); cursor: pointer; }

/* ---------- stage ---------- */
.stage-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #0c1847;
}
#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#snow { position: absolute; inset: 0; pointer-events: none; }

.char { cursor: grab; }
.char.dragging { cursor: grabbing; }
.char.muted .body { opacity: 0.55; }
body.playing .char { cursor: default; }

.tag { cursor: pointer; }
.tag rect { fill: rgba(8, 12, 40, 0.72); stroke: rgba(255, 255, 255, 0.25); stroke-width: 1.5; }
.tag text { fill: #fff; font: 700 15px "Nunito", system-ui, sans-serif; pointer-events: none; }
.tag:hover rect { fill: rgba(20, 30, 90, 0.85); }
.tag.muted rect { fill: rgba(60, 60, 80, 0.75); stroke-dasharray: 4 4; }
.tag.muted text { fill: #c9cde0; }
.tag:focus { outline: none; }
.tag:focus-visible rect { stroke: var(--accent); stroke-width: 3; }

.stars .tw { animation: twinkle 3.6s ease-in-out infinite; }
.house .win { animation: window 9s steps(1) infinite; }
.lights .halo { animation: bulb 2.4s ease-in-out infinite; }
.smoke circle { fill: #cfd8ee; opacity: 0; animation: smoke 4.5s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.smoke circle:nth-child(2) { animation-delay: -1.5s; }
.smoke circle:nth-child(3) { animation-delay: -3s; }
.chimney.santa-up .smoke { display: none; }

.chimney { cursor: pointer; }
.chimney:focus { outline: none; }
.chimney:focus-visible .chimney-hit { stroke: var(--accent); stroke-width: 3; stroke-dasharray: 6 6; }
.santa-bubble { opacity: 0; transform: translateY(8px) scale(0.9); transform-box: fill-box; transform-origin: 80% 100%; transition: opacity 0.2s ease, transform 0.25s ease; pointer-events: none; }
.santa-bubble.show { opacity: 1; transform: none; }
.santa-bubble text { fill: #c62828; font: 700 26px "Mountains of Christmas", Georgia, serif; }

@keyframes twinkle { 0%, 100% { opacity: 0.9; } 50% { opacity: 0.35; } }
@keyframes window { 0%, 85% { opacity: 1; } 86%, 100% { opacity: 0.35; } }
@keyframes bulb { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes smoke {
  0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
  15% { opacity: 0.55; }
  100% { opacity: 0; transform: translate(-40px, -120px) scale(2.2); }
}

.hint {
  position: absolute;
  top: calc(18px + clamp(30px, 6.4vw, 64px));
  left: 50%;
  transform: translate(-50%, -8px);
  max-width: min(92%, 560px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(6, 10, 34, 0.82);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 15px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.hint.show { opacity: 1; transform: translate(-50%, 0); }

.splash {
  position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(4, 8, 32, 0.45), rgba(4, 8, 32, 0.8));
}
.splash[hidden] { display: none; }
.splash-card {
  text-align: center; max-width: 440px; margin: auto; padding: 24px 28px; border-radius: 22px;
  background: rgba(12, 20, 70, 0.88); border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.splash-card h2 {
  margin: 0 0 8px; font-family: "Mountains of Christmas", Georgia, serif; font-size: 50px; line-height: 1.05; color: var(--accent);
}
.splash-card p { margin: 0 0 14px; color: var(--muted); font-size: 16px; }
.splash-card .small { margin: 14px 0 0; font-size: 13px; }
.howto {
  list-style: none; margin: 0 0 20px; padding: 0; text-align: left; display: grid; gap: 8px;
  font-size: 15px; line-height: 1.35; color: var(--text);
}
.howto li { display: grid; grid-template-columns: 26px 1fr; gap: 6px; }
.howto b { color: var(--accent); }

/* ---------- song bar ---------- */
.songbar {
  flex: none;
  padding: 10px 14px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.songbar .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.songbar .row + .row { margin-top: 10px; }
.transport #seek { flex: 1 1 160px; min-width: 120px; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; min-width: 88px; }
#stop { min-width: 42px; }
.songbar .songs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.song-btn { white-space: normal; text-align: center; line-height: 1.2; padding: 9px 12px; min-height: 46px; }
.song-btn .ico { font-size: 13px; color: var(--accent); flex: none; }
.song-btn .short { display: none; }
.song-btn.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.song-btn.active .ico { color: var(--accent-ink); }

/* phones: one row of 4 short song buttons, a slim transport row */
@media (max-width: 640px) {
  .help-btn { top: 8px; right: 8px; width: 32px; height: 32px; font-size: 16px; }
  .greeting { top: 8px; padding: 0 40px; }
  .hint { top: calc(14px + clamp(30px, 6.4vw, 64px)); font-size: 14px; padding: 7px 12px; }
  .songbar { padding: 8px 8px 10px; }
  .songbar .songs { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .songbar .row + .row { margin-top: 8px; }
  .song-btn { font-size: 13px; padding: 4px 5px; min-height: 42px; gap: 4px; border-radius: 9px; line-height: 1.15; }
  .song-btn .full { display: none; }
  .song-btn .short { display: inline; }
  .song-btn .ico { display: none; } /* the playing song is the yellow one */
  #stop { min-height: 34px; padding: 4px 10px; }
  #stop .lbl { display: none; }
  .time { display: none; }
  .howto { font-size: 14px; }
  .howto .santa-tip { display: none; } /* the chimney is out of view on phones */
  .splash-card { padding: 18px 18px; border-radius: 18px; }
  .splash-card h2 { font-size: 40px; }
  .splash-card p { font-size: 15px; margin-bottom: 12px; }
  .btn.big { font-size: 17px; padding: 11px 22px; }
}
/* short frames (wide but low): tighter song bar */
@media (max-height: 480px) and (min-width: 641px) {
  .songbar { padding: 6px 12px 8px; }
  .songbar .row + .row { margin-top: 6px; }
  .song-btn { min-height: 38px; padding: 6px 10px; }
  .btn, select { min-height: 34px; padding: 5px 10px; }
  .howto { gap: 5px; font-size: 14px; }
  .splash-card { padding: 16px 22px; }
  .splash-card h2 { font-size: 40px; }
}

/* ?shot=1: still picture for the card thumbnails */
.shot .songbar, .shot .help-btn, .shot .hint { display: none; }

@media (prefers-reduced-motion: reduce) {
  .stars .tw, .house .win, .lights .halo, .smoke circle { animation: none; }
}
