/* === Reset & Base === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --room-bg: #2a1f14;
  --wall-color: #5c3d2e;
  --floor-color: #8b6914;
  --floor-dark: #6b4f0f;
  --tree-green: #2d5a27;
  --tree-dark: #1a3d15;
  --fire-orange: #ff6b35;
  --fire-yellow: #ffd23f;
  --cat-black: #1a1a1a;
  --santa-red: #cc2936;
  --santa-white: #f0e6d3;
  --owner-color: #3d3d3d;
  --gold: #ffd700;
  --night-bg: #0d1b2a;
  --snow-color: #e8e8e8;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Fredoka', sans-serif;
  background: var(--room-bg);
}

/* === Screens === */
#game-container {
  width: 100%;
  height: 100%;
  position: relative;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

/* === Title Screen === */
#screen-title {
  background: linear-gradient(180deg, #1a3d15 0%, #2a1f14 100%);
  color: #f0e6d3;
  gap: 1.5rem;
}

.title {
  font-size: 3rem;
  font-weight: 700;
  text-shadow: 0 3px 6px rgba(0,0,0,0.4);
}

.tagline {
  font-size: 1.2rem;
  opacity: 0.8;
  font-style: italic;
}

.btn-big {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  padding: 0.8rem 2.5rem;
  border: none;
  border-radius: 50px;
  background: var(--santa-red);
  color: white;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn-big:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.btn-big:active {
  transform: scale(0.97);
}

.btn-mute {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.85rem;
  padding: 0.4rem 1rem;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  background: transparent;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: border-color 0.2s;
}

.btn-mute:hover {
  border-color: rgba(255,255,255,0.6);
}

.back-link {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  transition: color 0.2s;
}

.back-link:hover {
  color: rgba(255,255,255,0.8);
}

/* === Game Screen / Room === */
#screen-game {
  background: var(--wall-color);
  flex-direction: column;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.5rem;
  z-index: 100;
  background: rgba(0,0,0,0.3);
}

.hud-section {
  color: #f0e6d3;
  font-size: 1rem;
  font-weight: 500;
}

#hud-lives {
  display: flex;
  gap: 0.3rem;
}

.life-icon {
  width: 20px;
  height: 18px;
  background: var(--santa-red);
  clip-path: path('M10 17 C10 17 0 11 0 6 C0 2.7 2.7 0 5.5 0 C7.5 0 9.2 1.3 10 3 C10.8 1.3 12.5 0 14.5 0 C17.3 0 20 2.7 20 6 C20 11 10 17 10 17Z');
  transition: opacity 0.3s, transform 0.3s;
}

.life-icon.lost {
  opacity: 0.2;
  transform: scale(0.5);
}

#room {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  overflow: hidden;
}

/* Danger vignette when owner is watching */
#room::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 0;
  box-shadow: inset 0 0 80px 30px rgba(200, 0, 0, 0.6);
  transition: opacity 0.3s;
}

#room.danger::after {
  opacity: 1;
  animation: dangerPulse 1s ease-in-out infinite;
}

@keyframes dangerPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Tree area */
#tree-area {
  position: relative;
  width: 35%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 60px;
}

#tree {
  position: relative;
  width: 220px;
  height: 320px;
}

.tree-layer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-left: solid transparent;
  border-right: solid transparent;
  border-bottom-style: solid;
}

.tree-layer-1 {
  top: 0;
  border-left-width: 50px;
  border-right-width: 50px;
  border-bottom-width: 100px;
  border-bottom-color: var(--tree-green);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.tree-layer-2 {
  top: 70px;
  border-left-width: 70px;
  border-right-width: 70px;
  border-bottom-width: 120px;
  border-bottom-color: var(--tree-green);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.tree-layer-3 {
  top: 150px;
  border-left-width: 90px;
  border-right-width: 90px;
  border-bottom-width: 140px;
  border-bottom-color: var(--tree-dark);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.tree-trunk {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 40px;
  background: linear-gradient(90deg, #4a2c17, #6b3e22, #4a2c17);
  border-radius: 2px;
}

.tree-star {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  background: var(--gold);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

#ornaments {
  position: absolute;
  inset: 0;
}

.ornament {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
  box-shadow: inset -2px -2px 4px rgba(0,0,0,0.3), 0 0 3px rgba(255,255,255,0.2);
  z-index: 10;
}

.ornament:hover {
  transform: scale(1.3);
}

.ornament.falling {
  transition: transform 0.6s cubic-bezier(0.55, 0, 1, 0.45), opacity 0.3s 0.5s;
  z-index: 5;
}

.ornament.shattered {
  opacity: 0;
  pointer-events: none;
}

/* Living room middle */
#living-room {
  position: relative;
  width: 40%;
  height: 100%;
}

#fireplace {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 100px;
  background: linear-gradient(180deg, #4a3728, #2a1f14);
  border: 8px solid #6b4f3a;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}

.fire-glow {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 40px;
  background: radial-gradient(ellipse, var(--fire-yellow) 0%, var(--fire-orange) 50%, transparent 70%);
  border-radius: 50%;
  animation: fireFlicker 1.5s ease-in-out infinite alternate;
}

@keyframes fireFlicker {
  0% { opacity: 0.8; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.1); }
  100% { opacity: 0.7; transform: translateX(-50%) scale(0.95); }
}

#clock {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 4px solid #8b6914;
  background: #f0e6d3;
}

#rug {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 30px;
  background: linear-gradient(90deg, var(--santa-red), #991f28, var(--santa-red));
  border-radius: 50%;
  opacity: 0.6;
}

/* Doorway */
#doorway {
  position: relative;
  width: 25%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

#doorway::before {
  content: '';
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 180px;
  background: #1a1a1a;
  border-radius: 4px 4px 0 0;
  border: 6px solid #6b4f3a;
  border-bottom: none;
}

/* Owner */
#owner {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  transition: transform 0.3s;
  z-index: 20;
}

#owner.hidden {
  transform: translateX(150%);
  visibility: hidden;
}

#owner.approaching {
  animation: ownerWalkIn 1.2s ease-out forwards;
}

#owner.leaving {
  animation: ownerWalkOut 1.5s ease-in forwards;
}

@keyframes ownerWalkIn {
  from { transform: translateX(150%); }
  to { transform: translateX(-50%); }
}

@keyframes ownerWalkOut {
  from { transform: translateX(-50%); }
  to { transform: translateX(150%); }
}

.owner-head {
  width: 30px;
  height: 30px;
  background: var(--owner-color);
  border-radius: 50%;
  margin: 0 auto 4px;
}

.owner-body {
  width: 40px;
  height: 60px;
  background: var(--owner-color);
  border-radius: 8px 8px 0 0;
  margin: 0 auto;
}

.owner-legs {
  width: 40px;
  height: 50px;
  background: var(--owner-color);
  margin: 0 auto;
  border-radius: 0 0 4px 4px;
}

/* Cat */
#cat {
  position: absolute;
  bottom: 60px;
  left: 50%;
  width: 60px;
  height: 50px;
  pointer-events: none;
  z-index: 50;
  transition: left 0.1s ease-out, bottom 0.1s ease-out;
}

#cat.caught {
  animation: catShoo 0.5s ease-out;
}

@keyframes catShoo {
  0% { transform: scale(1); }
  30% { transform: scale(0.8) rotate(-10deg); }
  100% { transform: scale(1) rotate(0); }
}

.cat-body {
  position: absolute;
  bottom: 0;
  width: 50px;
  height: 30px;
  background: var(--cat-black);
  border-radius: 50% 50% 40% 40%;
}

.cat-head {
  position: absolute;
  bottom: 22px;
  left: 0;
  width: 28px;
  height: 24px;
  background: var(--cat-black);
  border-radius: 50% 50% 40% 40%;
}

.cat-ears {
  position: absolute;
  top: -8px;
  left: 2px;
  width: 24px;
  height: 12px;
}

.cat-ears::before,
.cat-ears::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 10px solid var(--cat-black);
}

.cat-ears::before { left: 0; }
.cat-ears::after { right: 0; }

.santa-hat {
  position: absolute;
  top: -14px;
  left: 4px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 16px solid var(--santa-red);
}

.santa-hat::after {
  content: '';
  position: absolute;
  top: 12px;
  left: -12px;
  width: 24px;
  height: 5px;
  background: var(--santa-white);
  border-radius: 3px;
}

.cat-eyes {
  position: absolute;
  top: 8px;
  left: 4px;
  width: 20px;
  height: 6px;
}

.cat-eyes::before,
.cat-eyes::after {
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  background: #aaff44;
  border-radius: 50%;
}

.cat-eyes::before { left: 2px; }
.cat-eyes::after { right: 2px; }

.cat-tail {
  position: absolute;
  bottom: 8px;
  right: -10px;
  width: 30px;
  height: 8px;
  background: var(--cat-black);
  border-radius: 0 50% 50% 0;
  transform-origin: left center;
  animation: tailSwish 2s ease-in-out infinite;
}

@keyframes tailSwish {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(10deg); }
}

.cat-paw {
  position: absolute;
  bottom: 25px;
  left: -5px;
  width: 12px;
  height: 15px;
  background: var(--cat-black);
  border-radius: 50% 50% 40% 40%;
  opacity: 0;
  transform: rotate(-20deg);
}

.cat-paw.swatting {
  opacity: 1;
  animation: swatPaw 0.2s ease-out;
}

@keyframes swatPaw {
  0% { transform: rotate(-20deg) translateY(0); }
  50% { transform: rotate(10deg) translateY(-10px); }
  100% { transform: rotate(-20deg) translateY(0); }
}

/* Floor */
#floor {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(180deg, var(--floor-color), var(--floor-dark));
}

/* Tree topple animation */
#tree.toppling {
  animation: treeTopple 1.5s ease-in forwards;
  transform-origin: bottom center;
}

@keyframes treeTopple {
  0% { transform: rotate(0deg); }
  20% { transform: rotate(-3deg); }
  40% { transform: rotate(2deg); }
  60% { transform: rotate(-5deg); }
  100% { transform: rotate(85deg) translateX(50px); }
}

#tree.toppling .ornament {
  animation: ornamentScatter 0.5s ease-out forwards;
  animation-delay: calc(var(--scatter-delay, 0) * 0.02s);
}

@keyframes ornamentScatter {
  to {
    transform: translateY(200px) translateX(calc((var(--scatter-x, 0) - 0.5) * 100px));
    opacity: 0;
  }
}

/* === Game Over Screen === */
#screen-gameover {
  background: var(--night-bg);
  color: var(--snow-color);
  gap: 1.5rem;
}

#gameover-scene {
  position: relative;
  width: 240px;
  height: 180px;
  margin-bottom: 1rem;
}

#street-bg {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: linear-gradient(180deg, #444, #222);
  border-radius: 2px;
}

#box-cat {
  position: absolute;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 65px;
  background: linear-gradient(180deg, #a07820, #8b6914);
  border: 3px solid #6b4f0f;
  border-radius: 3px;
}

.box-label {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: #4a3000;
  font-weight: 700;
  letter-spacing: 1px;
}

/* Cat head poking out of box */
.box-cat-head {
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  width: 42px;
  height: 34px;
  background: var(--cat-black);
  border-radius: 50% 50% 40% 40%;
}

/* Ears - triangles attached to top of head */
.box-cat-ears::before,
.box-cat-ears::after {
  content: '';
  position: absolute;
  top: -1px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 14px solid var(--cat-black);
}

.box-cat-ears::before { left: 1px; }
.box-cat-ears::after { right: 1px; }

/* Santa hat - bigger, tilted */
.box-cat-santa-hat {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%) rotate(8deg);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 20px solid var(--santa-red);
}

.box-cat-santa-hat::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -3px;
  width: 8px;
  height: 8px;
  background: var(--santa-white);
  border-radius: 50%;
}

.box-cat-santa-hat::after {
  content: '';
  position: absolute;
  top: 15px;
  left: -14px;
  width: 28px;
  height: 6px;
  background: var(--santa-white);
  border-radius: 3px;
}

/* Sad eyes */
.box-cat-eyes {
  position: absolute;
  top: 11px;
  left: 7px;
  width: 28px;
  height: 10px;
}

.box-cat-eyes::before,
.box-cat-eyes::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: #66bb44;
  border-radius: 50%;
}

.box-cat-eyes::before { left: 2px; }
.box-cat-eyes::after { right: 2px; }

/* Sad mouth - frown (curved top border = upside down arc) */
.box-cat-mouth {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 6px;
  border-top: 2px solid #666;
  border-radius: 50% 50% 0 0;
  border-bottom: none;
}

/* === Victory Screen === */
#screen-victory {
  background: linear-gradient(180deg, var(--wall-color), var(--room-bg));
  color: var(--santa-white);
  gap: 1.5rem;
}

#victory-scene {
  position: relative;
  width: 280px;
  height: 160px;
  margin-bottom: 0.5rem;
}

/* Fallen tree on its side */
#fallen-tree {
  position: absolute;
  bottom: 10px;
  left: 0;
  width: 180px;
  height: 50px;
  background: linear-gradient(180deg, var(--tree-green), var(--tree-dark));
  border-radius: 8px 25px 25px 8px;
  transform: rotate(-3deg);
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

/* Trunk sticking out */
#fallen-tree::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  width: 25px;
  height: 14px;
  background: linear-gradient(90deg, #4a2c17, #6b3e22);
  border-radius: 3px;
}

.fallen-ornament {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: inset -1px -1px 3px rgba(0,0,0,0.3);
}

.fallen-ornament:nth-child(1) {
  background: #ff4444;
  top: 8px;
  left: 40px;
}

.fallen-ornament:nth-child(2) {
  background: #4488ff;
  top: 30px;
  left: 100px;
}

.fallen-ornament:nth-child(3) {
  background: #ffdd44;
  bottom: 5px;
  left: 60px;
}

.fallen-star {
  position: absolute;
  right: 5px;
  top: 12px;
  width: 14px;
  height: 14px;
  background: var(--gold);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* Smug cat sitting on the fallen tree */
#smug-cat {
  position: absolute;
  bottom: 45px;
  right: 30px;
}

.smug-cat-body {
  width: 50px;
  height: 35px;
  background: var(--cat-black);
  border-radius: 50% 50% 40% 40%;
}

.smug-cat-head {
  position: absolute;
  top: -20px;
  left: 0;
  width: 32px;
  height: 26px;
  background: var(--cat-black);
  border-radius: 50% 50% 40% 40%;
}

.smug-cat-ears {
  position: absolute;
  top: -10px;
  left: 2px;
  width: 28px;
  height: 14px;
}

.smug-cat-ears::before,
.smug-cat-ears::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 11px solid var(--cat-black);
}

.smug-cat-ears::before { left: 0; }
.smug-cat-ears::after { right: 0; }

.smug-cat-santa-hat {
  position: absolute;
  top: -16px;
  left: 6px;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 15px solid var(--santa-red);
}

.smug-cat-santa-hat::after {
  content: '';
  position: absolute;
  top: 11px;
  left: -11px;
  width: 22px;
  height: 4px;
  background: var(--santa-white);
  border-radius: 2px;
}

/* Smug squinty eyes */
.smug-cat-eyes {
  position: absolute;
  top: 9px;
  left: 5px;
  width: 22px;
  height: 8px;
}

.smug-cat-eyes::before,
.smug-cat-eyes::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 3px;
  background: #aaff44;
  border-radius: 50%;
}

.smug-cat-eyes::before { left: 1px; }
.smug-cat-eyes::after { right: 1px; }

/* Smug little grin */
.smug-cat-mouth {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 4px;
  border-top: 2px solid #aaff44;
  border-radius: 50% 50% 0 0;
}

.smug-cat-tail {
  position: absolute;
  bottom: 12px;
  right: -12px;
  width: 25px;
  height: 8px;
  background: var(--cat-black);
  border-radius: 0 50% 50% 0;
  transform: rotate(-15deg);
}

/* === Responsive === */
@media (max-width: 768px) {
  .title { font-size: 2rem; }
  .btn-big { font-size: 1.1rem; padding: 0.6rem 2rem; }
  #tree { width: 160px; height: 240px; }
  .ornament { width: 12px; height: 12px; }
}
