* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  user-select: none;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: transparent;
}

/* ==============================================
   WEB MODE: Cozy apartment interior
   ============================================== */
body.web-mode {
  background: #d4a574; /* fallback warm tone */
}

body.web-mode #room { display: block; }
body.web-mode #download-bar { display: flex; }
body.web-mode #help-hint { display: block; }

/* --- Room container --- */
#room {
  display: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* --- Wall --- */
#wall {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 35%;
  background: linear-gradient(180deg, #f5e6d3 0%, #efe0cc 60%, #e8d5be 100%);
  /* Subtle wallpaper texture via repeating gradient */
  background-image:
    linear-gradient(180deg, #f5e6d3 0%, #efe0cc 60%, #e8d5be 100%),
    repeating-linear-gradient(90deg, transparent, transparent 60px, rgba(0,0,0,0.015) 60px, rgba(0,0,0,0.015) 61px);
}

/* --- Window --- */
#window-frame {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  height: 180px;
  background: #8b7355;
  border-radius: 4px;
  padding: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.1);
}

#window-pane {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #87CEEB 0%, #b8e4f0 60%, #d4edda 100%);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  border: 2px solid #7a6548;
}

#sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #6bb3d9 0%, #a8d8ea 100%);
}

/* Clouds */
.cloud {
  position: absolute;
  background: rgba(255,255,255,0.9);
  border-radius: 20px;
}
.cloud-1 {
  width: 60px; height: 20px;
  top: 20%; left: 10%;
  animation: drift 18s linear infinite;
}
.cloud-2 {
  width: 45px; height: 15px;
  top: 35%; left: 60%;
  animation: drift 24s linear infinite;
  animation-delay: -8s;
}
.cloud-3 {
  width: 35px; height: 12px;
  top: 15%; left: 40%;
  animation: drift 20s linear infinite;
  animation-delay: -4s;
}

@keyframes drift {
  0% { transform: translateX(-80px); }
  100% { transform: translateX(280px); }
}

#window-sill {
  position: absolute;
  bottom: -8px;
  left: -12px;
  right: -12px;
  height: 12px;
  background: linear-gradient(180deg, #9c8568, #8b7355);
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Curtains */
#curtain-left, #curtain-right {
  position: absolute;
  top: -8px;
  width: 35px;
  height: calc(100% + 16px);
  background: linear-gradient(180deg, #b85450, #a04440);
  opacity: 0.85;
}
#curtain-left {
  left: -38px;
  border-radius: 0 4px 8px 0;
  background: linear-gradient(90deg, #c45550, #b84a45 60%, #a84040);
}
#curtain-right {
  right: -38px;
  border-radius: 4px 0 0 8px;
  background: linear-gradient(90deg, #a84040, #b84a45 40%, #c45550);
}

/* --- Picture frame on wall --- */
#picture-frame {
  position: absolute;
  top: 12%;
  right: 12%;
  width: 60px;
  height: 50px;
  background: #8b7355;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.15);
}
#picture-bone {
  font-size: 24px;
  background: #faf0e6;
  width: 46px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 1px;
}

/* --- Shelf --- */
#wall-shelf {
  position: absolute;
  top: 15%;
  left: 8%;
  width: 120px;
  height: 8px;
  background: linear-gradient(180deg, #9c8568, #8b7355);
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.12);
  display: flex;
  align-items: flex-end;
  padding: 0 8px;
  gap: 4px;
}
.shelf-book {
  width: 12px;
  border-radius: 1px 1px 0 0;
  position: relative;
  bottom: 0;
}
.book-1 { height: 28px; background: #c45550; }
.book-2 { height: 22px; background: #4477aa; }
.book-3 { height: 25px; background: #55a455; }
.shelf-plant {
  font-size: 18px;
  position: relative;
  bottom: 4px;
  margin-left: auto;
}

/* --- Floor --- */
#floor {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 35%;
  background:
    repeating-linear-gradient(
      90deg,
      #c49a6c 0px, #c49a6c 80px,
      #b8905f 80px, #b8905f 82px,
      #c9a070 82px, #c9a070 160px,
      #b8905f 160px, #b8905f 162px
    );
  box-shadow: inset 0 4px 12px rgba(0,0,0,0.12);
}

/* --- Persian Rug --- */
#rug {
  position: absolute;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 50%;
  border-radius: 3px;
  opacity: 0.88;
  box-shadow: 0 2px 18px rgba(0,0,0,0.18);
  /* Outer border band — navy with gold stripe accents */
  background:
    /* gold pinstripe outer */
    linear-gradient(0deg, #c8a84e 0px, #c8a84e 2px, transparent 2px) 0 0 / 100% 100% no-repeat,
    linear-gradient(0deg, transparent calc(100% - 2px), #c8a84e calc(100% - 2px)) 0 0 / 100% 100% no-repeat,
    linear-gradient(90deg, #c8a84e 0px, #c8a84e 2px, transparent 2px) 0 0 / 100% 100% no-repeat,
    linear-gradient(90deg, transparent calc(100% - 2px), #c8a84e calc(100% - 2px)) 0 0 / 100% 100% no-repeat,
    /* navy outer border fill */
    #1a2744;
  padding: 6px;
}

/* Inner border — gold band with geometric repeating motif */
#rug-inner-border {
  position: absolute;
  inset: 6px;
  border: 3px solid #c8a84e;
  border-radius: 2px;
  /* Tiny repeating diamond motif on border via gradient */
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0px, transparent 8px,
      rgba(200,168,78,0.25) 8px, rgba(200,168,78,0.25) 10px
    ),
    repeating-linear-gradient(
      0deg,
      transparent 0px, transparent 8px,
      rgba(200,168,78,0.25) 8px, rgba(200,168,78,0.25) 10px
    ),
    #1a2744;
  pointer-events: none;
  z-index: 1;
}

/* Main field of the rug — deep crimson */
#rug-field {
  position: absolute;
  inset: 12px;
  background:
    /* subtle woven texture */
    repeating-linear-gradient(
      0deg,
      rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 1px,
      transparent 1px, transparent 3px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(0,0,0,0.02) 0px, rgba(0,0,0,0.02) 1px,
      transparent 1px, transparent 3px
    ),
    /* warm gradient for depth */
    radial-gradient(ellipse at center, #a83232 0%, #8b1a1a 50%, #6e1414 100%);
  border-radius: 1px;
  overflow: hidden;
  z-index: 2;
}

/* Central medallion — the signature Persian motif */
#rug-medallion {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 38%;
  height: 55%;
  max-width: 80px;
  max-height: 80px;
  background:
    radial-gradient(ellipse, #1a2744 0%, #1a2744 30%, transparent 31%),
    radial-gradient(ellipse, #c8a84e 0%, #c8a84e 38%, transparent 39%),
    radial-gradient(ellipse, #8b1a1a 0%, #8b1a1a 50%, transparent 51%),
    radial-gradient(ellipse, #c8a84e 0%, #c8a84e 58%, transparent 59%),
    radial-gradient(ellipse, #1a2744 0%, #1a2744 70%, transparent 71%),
    radial-gradient(ellipse, #c8a84e 0%, #c8a84e 85%, transparent 86%),
    #a83232;
  border-radius: 4px;
  box-shadow: 0 0 0 2px #c8a84e, 0 0 0 4px #1a2744;
}

/* Corner quarter-medallions */
.rug-corner {
  position: absolute;
  width: 28%;
  height: 28%;
  max-width: 40px;
  max-height: 40px;
  background:
    radial-gradient(circle at center, #c8a84e 0%, #c8a84e 30%, #1a2744 31%, #1a2744 55%, #c8a84e 56%, #c8a84e 70%, transparent 71%);
  z-index: 1;
}
.rug-corner-tl { top: 4px; left: 4px; }
.rug-corner-tr { top: 4px; right: 4px; }
.rug-corner-bl { bottom: 4px; left: 4px; }
.rug-corner-br { bottom: 4px; right: 4px; }

/* Fringe tassels on short ends */
.rug-fringe {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 6px;
  z-index: 3;
  background:
    repeating-linear-gradient(
      90deg,
      #c8a84e 0px, #c8a84e 2px,
      transparent 2px, transparent 5px
    );
}
.rug-fringe-top { top: -5px; }
.rug-fringe-bottom { bottom: -5px; }

/* --- Couch --- */
#couch {
  position: absolute;
  bottom: 30%;
  right: 5%;
  width: 200px;
  height: 100px;
}
#couch-back {
  position: absolute;
  bottom: 30px;
  left: 10px;
  right: 10px;
  height: 55px;
  background: linear-gradient(180deg, #6b8f71, #5a7d60);
  border-radius: 12px 12px 4px 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
#couch-seat {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(180deg, #7aa680, #6b946f);
  border-radius: 6px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}
#couch-arm-left {
  position: absolute;
  bottom: 0;
  left: -8px;
  width: 22px;
  height: 55px;
  background: linear-gradient(90deg, #5a7d60, #6b946f);
  border-radius: 8px;
}
#couch-arm-right {
  position: absolute;
  bottom: 0;
  right: -8px;
  width: 22px;
  height: 55px;
  background: linear-gradient(90deg, #6b946f, #5a7d60);
  border-radius: 8px;
}
#couch-pillow {
  position: absolute;
  bottom: 36px;
  left: 30px;
  width: 45px;
  height: 30px;
  background: linear-gradient(135deg, #d4a04a, #c49040);
  border-radius: 8px;
  transform: rotate(-8deg);
}

/* --- Dog bed --- */
#dog-bed {
  position: absolute;
  bottom: 2%;
  left: 5%;
  width: 120px;
  height: 40px;
  background: linear-gradient(180deg, #8b6f55, #7a6048);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
#dog-bed-inside {
  position: absolute;
  top: 6px;
  left: 10px;
  right: 10px;
  bottom: 4px;
  background: linear-gradient(180deg, #a08060, #8b6f55);
  border-radius: 50%;
}

/* --- Food station --- */
#food-station {
  position: absolute;
  bottom: 3%;
  right: 25%;
  display: flex;
  gap: 10px;
  font-size: 20px;
}

/* ==============================================
   Dobby container
   ============================================== */
#pet-container {
  position: absolute;
  width: 180px;
  height: 260px;
  cursor: pointer;
  z-index: 10;
}

#dobby-canvas {
  image-rendering: pixelated;
  width: 180px;
  height: 260px;
}

/* ==============================================
   Speech bubble
   ============================================== */
#speech-bubble {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border: 2px solid #333;
  border-radius: 14px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: bold;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  box-shadow: 1px 2px 6px rgba(0,0,0,0.15);
}

#speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #333;
}

.hidden {
  display: none !important;
}

/* ==============================================
   Particles
   ============================================== */
#hearts-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.heart {
  position: absolute;
  font-size: 22px;
  animation: float-heart 1.2s ease-out forwards;
  pointer-events: none;
}

@keyframes float-heart {
  0% { opacity: 1; transform: translateY(0) scale(0.5); }
  100% { opacity: 0; transform: translateY(-80px) scale(1.3); }
}

#food-bowl {
  position: absolute;
  bottom: 10px;
  right: -35px;
  font-size: 30px;
  animation: food-appear 0.3s ease-out;
  pointer-events: none;
}

@keyframes food-appear {
  0% { transform: scale(0) rotate(-20deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.crumb {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #8B4513;
  border-radius: 50%;
  animation: crumb-fall 0.6s ease-in forwards;
  pointer-events: none;
}

@keyframes crumb-fall {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(30px); }
}

.zzz {
  position: absolute;
  font-size: 18px;
  font-weight: bold;
  color: #6666aa;
  animation: float-zzz 2s ease-out forwards;
  pointer-events: none;
}

@keyframes float-zzz {
  0% { opacity: 0.8; transform: translateY(0) translateX(0) scale(0.6); }
  100% { opacity: 0; transform: translateY(-70px) translateX(30px) scale(1.4); }
}

/* ==============================================
   Context menus
   ============================================== */
#context-menu,
#outfit-menu {
  position: absolute;
  top: 50%;
  left: 190px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.97);
  border: 2px solid #555;
  border-radius: 12px;
  padding: 6px;
  z-index: 200;
  box-shadow: 2px 4px 14px rgba(0,0,0,0.25);
  min-width: 145px;
  backdrop-filter: blur(8px);
}

.menu-title {
  text-align: center;
  font-weight: bold;
  font-size: 14px;
  padding: 3px 0 5px;
  border-bottom: 1px solid #ddd;
  margin-bottom: 4px;
  color: #333;
}

.menu-btn {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  padding: 7px 12px;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
  color: #333;
  transition: background 0.15s;
}

.menu-btn:hover {
  background: #e0e0ff;
}

/* ==============================================
   Download bar (web mode only)
   ============================================== */
#download-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: rgba(30, 30, 40, 0.92);
  backdrop-filter: blur(12px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

#download-inner {
  display: flex;
  align-items: center;
  gap: 16px;
}

#download-title {
  color: #fff;
  font-weight: bold;
  font-size: 16px;
  letter-spacing: 0.5px;
}

#download-subtitle {
  color: #bbb;
  font-size: 13px;
}

#download-btn {
  display: inline-block;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  text-decoration: none;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(99,102,241,0.4);
}

#download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99,102,241,0.5);
}

/* ==============================================
   Help hint (web mode only)
   ============================================== */
#help-hint {
  display: none;
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  color: #eee;
  font-size: 12px;
  padding: 6px 18px;
  border-radius: 20px;
  z-index: 500;
  pointer-events: none;
}

/* ==============================================
   Responsive
   ============================================== */
@media (max-width: 700px) {
  #couch { display: none; }
  #wall-shelf { display: none; }
  #picture-frame { display: none; }
  #window-frame { width: 160px; height: 130px; }
  #download-subtitle { display: none; }
}
