* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; }
body { font-family: 'Fredoka', system-ui, sans-serif; color: #fff3d6; }

/* The picture is a 16:9 box, letterboxed in black */
#frame {
  position: absolute; left: 50%; top: 50%;
  width: min(100vw, calc(100vh * 16 / 9)); height: min(100vh, calc(100vw * 9 / 16));
  transform: translate(-50%, -50%); overflow: hidden; background: #000;
}
#stage, #snow { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#snow { pointer-events: none; }

/* ---------- Character animation (clocks pinned to the song by engine.js) ---------- */
.char .leg, .char .arm { transform-box: fill-box; transform-origin: 50% 4%; }
.char-yeti .leg { transform-origin: 50% 10%; }
.bob, .walking, .galloping { transform-box: fill-box; transform-origin: 50% 100%; }
.walking { animation: bob var(--step) ease-in-out infinite alternate; }
.walking .leg-a { animation: swing var(--step) ease-in-out infinite alternate; }
.walking .leg-b { animation: swing var(--step) ease-in-out infinite alternate-reverse; }
.galloping { animation: gallop var(--step) ease-in-out infinite alternate; }
.galloping .leg-a { animation: gswing var(--step) ease-in-out infinite alternate; }
.galloping .leg-b { animation: gswing var(--step) ease-in-out infinite alternate-reverse; }
.slump { transform: translateY(10px) rotate(-3deg); }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-4%); } }
@keyframes swing { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }
@keyframes gswing { from { transform: rotate(-30deg); } to { transform: rotate(30deg); } }
@keyframes gallop { from { transform: translateY(0) rotate(2deg); } to { transform: translateY(-9%) rotate(-3deg); } }

.lasso-loop { transform-box: fill-box; transform-origin: center; animation: lasso .45s linear infinite; }
@keyframes lasso { 0% { transform: scaleX(1); } 50% { transform: scaleX(.3); } 100% { transform: scaleX(1); } }
.char-penguin .pg-scarf { transform-box: fill-box; transform-origin: 100% 0; animation: scarfFlap .3s ease-in-out infinite alternate; }
@keyframes scarfFlap { from { transform: rotate(-6deg); } to { transform: rotate(8deg); } }
.yeti-arm { transform-box: fill-box; transform-origin: 50% 0; }
.yeti.reach .yeti-arm { transform: rotate(-160deg); }

/* ---------- Barn scenery (from the countdown page) ---------- */
.bulb, .red-nose-glow, .nose-glow { animation: twinkle 1.4s ease-in-out infinite alternate; }
.red-nose-glow, .nose-glow { animation-duration: .9s; }
@keyframes twinkle { from { opacity: 1; } to { opacity: .3; } }
.castle .puff { transform-box: fill-box; transform-origin: center; animation: puff 4.2s linear infinite; }
@keyframes puff {
  0%   { transform: translate(0, 0) scale(.6); opacity: 0; }
  10%  { opacity: .85; }
  100% { transform: translate(-16px, -70px) scale(2); opacity: 0; }
}
.castle-flag { transform-box: fill-box; transform-origin: 0 50%; animation: flutter .7s ease-in-out infinite alternate; }
@keyframes flutter { from { transform: scaleX(1) skewY(0deg); } to { transform: scaleX(.8) skewY(6deg); } }
.peeker { transform: translateY(72px); }
.wave-arm { transform-box: fill-box; transform-origin: 50% 100%; }
.peeker.up .wave-arm { animation: wave .32s ease-in-out infinite alternate; }
@keyframes wave { from { transform: rotate(-22deg); } to { transform: rotate(22deg); } }
.jack { transform: translateY(60px); }
.jack-head, .lid { transform-box: fill-box; transform-origin: 50% 100%; }
.lid { transform-origin: 0% 100%; }
.star-ring { opacity: 0; }
.star-glow { transform-box: fill-box; transform-origin: center; animation: starGlow 1.1s ease-in-out infinite alternate; }
@keyframes starGlow { from { opacity: .55; transform: scale(.9); } to { opacity: 1; transform: scale(1.25); } }

/* Snowmobile */
.sm-puff { transform-box: fill-box; transform-origin: center; animation: smPuff .8s linear infinite; }
.sm-scarf { transform-box: fill-box; transform-origin: 100% 50%; animation: smScarf .25s ease-in-out infinite alternate; }
.sm-wobble, .sm-wobble2 { transform-box: fill-box; transform-origin: 50% 100%; animation: smWobble .36s ease-in-out infinite alternate; }
.sm-wobble2 { animation-delay: -.18s; }
.sm-wave-arm { display: none; transform-box: fill-box; transform-origin: 15% 100%; }
.waving .sm-wave-arm { display: inline; animation: smWave .3s ease-in-out infinite alternate; }
@keyframes smWave { from { transform: rotate(-22deg); } to { transform: rotate(18deg); } }
@keyframes smPuff { from { transform: translate(0, 0) scale(.5); opacity: .8; } to { transform: translate(-26px, -10px) scale(1.8); opacity: 0; } }
@keyframes smScarf { from { transform: skewY(-6deg) scaleX(1); } to { transform: skewY(6deg) scaleX(.9); } }
@keyframes smWobble { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }

/* ---------- New bits ---------- */
.sl-wave { transform-box: fill-box; transform-origin: 0% 100%; animation: slWave .3s ease-in-out infinite alternate; }
@keyframes slWave { from { transform: rotate(-12deg); } to { transform: rotate(16deg); } }
.flicker { transform-box: fill-box; transform-origin: 50% 100%; animation: flicker .23s ease-in-out infinite alternate; }
.flicker.f2 { animation-duration: .17s; }
@keyframes flicker { from { transform: scale(1, .86) skewX(-4deg); } to { transform: scale(.94, 1.08) skewX(5deg); } }
.flame { transform-box: fill-box; transform-origin: 50% 100%; animation: flicker .2s ease-in-out infinite alternate; }
.steam path { animation: steam 1.6s linear infinite; }
.steam path + path { animation-delay: -.8s; }
@keyframes steam { from { transform: translateY(10px); opacity: 0; } 40% { opacity: .8; } to { transform: translateY(-24px); opacity: 0; } }
.tear { animation: tear .7s ease-in infinite; }
.tear2 { animation-delay: -.35s; }
@keyframes tear { from { transform: translateY(0); opacity: 1; } to { transform: translateY(14px); opacity: 0; } }
.tv-runner { animation: tvRun 1.8s ease-in-out infinite alternate; }
.tv-chaser { animation: tvRun 1.8s ease-in-out -.2s infinite alternate; }
.tv-ball { animation: tvBall 1.8s ease-in-out infinite alternate; }
@keyframes tvRun { from { transform: translateX(0); } to { transform: translateX(70px); } }
@keyframes tvBall { from { transform: translate(-30px, 6px); } to { transform: translate(40px, -6px); } }
.rec-dot { animation: twinkle .5s steps(2) infinite; }

/* ---------- Player UI ---------- */
.start {
  position: absolute; inset: 0; z-index: 10; display: grid; place-items: center;
  background: rgba(10, 14, 40, .55); backdrop-filter: blur(2px);
}
.start[hidden] { display: none; }
.start-card {
  text-align: center; padding: 1.6em 2.4em; border-radius: 22px; max-width: 90%;
  background: rgba(59, 36, 18, .92); border: 4px solid #8b5a2b; box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.start-card h1 { margin: 0 0 .1em; font: 700 clamp(28px, 5vw, 64px) 'Mountains of Christmas', cursive; color: #ffd23f; }
.start-card p { margin: .2em 0 1.1em; font-size: clamp(13px, 1.6vw, 20px); opacity: .9; }
.big-btn {
  font: 600 clamp(16px, 2vw, 26px) 'Fredoka', sans-serif; color: #fff; cursor: pointer;
  padding: .55em 1.6em; border: 0; border-radius: 999px; background: #c1121f;
  box-shadow: 0 4px 0 #7a0b13; transition: transform .1s;
}
.big-btn:hover { transform: translateY(-2px); }
.big-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #7a0b13; }

.controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 9;
  display: flex; align-items: center; gap: 12px; padding: 10px 16px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .65));
  transition: opacity .4s; font-size: 15px;
}
.controls.idle { opacity: 0; pointer-events: none; }
.controls button {
  width: 40px; height: 40px; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, .15); color: #fff; font-size: 18px; line-height: 1;
}
.controls button:hover { background: rgba(255, 255, 255, .3); }
.controls input[type=range] { flex: 1; accent-color: #c1121f; cursor: pointer; }
.controls .time { font-variant-numeric: tabular-nums; min-width: 92px; text-align: center; }
body.render .controls, body.render .start { display: none; }
body.idle-cursor { cursor: none; }
