/* -------------------- Fonts -------------------- */
/* Import Pixel Font */
@import url('../assets/fonts/04b03.css');

/* ================== Global Reset & Body ================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "04b03", Verdana, sans-serif;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0; /* Changed from 24px to 0 to handle full layout */
  font-family: "04b03", Verdana;
  font-size: 16px;
  line-height: 15px;
  text-align: center;
  color: #3a2f3f;
  border: 0;
  background: #fde3f1; /* Base Layout Background */
  
  /* Game Cursor */
  cursor: url("../assets/cursor2.png"), auto;
  
  /* Prevent horizontal scroll from effects */
  overflow-x: hidden; 
}

a {
    color: #8b63b5;         
    text-decoration: underline; 
    transition: all 0.2s ease-in-out;
    cursor: pointer;
}

a:hover {
    color: #b8a5eb;         
}

body {
  display: flex;
  min-height: 100vh;
}

/* ================== Sidebar ================== */
.sidebar {
  width: 230px;
  background: #e8dff0;
  padding: 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-right: 4px solid #d6c4e8;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 4000; /* High z-index to stay above game elements */
}

.sidebar-item {
  background: rgba(255,255,255,0.7);
  padding: 8px;
  border-radius: 8px;
  font-size:  18px;
  text-align: left;
  display: flex;
  align-items: baseline;
  gap: 5px;
  transition: background 0.2s ease;
}
.sidebar-item img {
    position: relative;
    top: 2px;
}
.sidebar-item:hover {
  background: rgba(255,255,255,0.9);
}
.sidebar-item a {
  text-decoration: none;
  color: #3a2f3f;
}

/* Sidebar Scrollbar */
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 4px; }

/* Sidebar Clock */
#clock {
  width: 190px;
  height: 54px;
  background-image: url("../../../assets/clock.png");
  background-size: cover;
  background-repeat: no-repeat;
  position: relative;
  line-height: 1;
  color: #3a2f3f;
  image-rendering: pixelated;
  text-shadow: 1px 1px 0 #fff;
  text-align: center;
  padding-left: 9px;
  margin: 0 auto 12px auto;
}
#clock span {
  font-family: "04b03", monospace;
  font-size: 18px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateX(7px);
  line-height: 1;
  width: 210px;
  white-space: nowrap; 
    pointer-events: none;
}
@keyframes clockGlow {
  0%, 100% { text-shadow: 0 0 2px #fff, 0 0 4px #ff77ff, 0 0 6px #ff77ff; }
  50% { text-shadow: 0 0 4px #fff, 0 0 6px #ff99ff, 0 0 8px #ff99ff; }
}
#clock { animation: clockGlow 2s infinite ease-in-out; 
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0); /* Triggers hardware acceleration */
}

/* ================== Top Auth ================== */
.top-auth {
    display: block;        
    position: relative;
    top: 20px;
    right: 20px;
    z-index: 1000;
    width: fit-content;
    
    /* Pushes to the right */
    margin-top: 20px;
    margin-right: 20px;
    margin-bottom: 10px;
    margin-left: auto;     

    background: rgba(255,255,255,0.9);
    padding: 8px 16px;     
    border-radius: 8px;
    border: 2px solid #b8a5eb;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-family: "04b03", Verdana, sans-serif; 
    font-size: 14px;
}
.top-row {
    width: 100%;
    display: flex;
    justify-content: space-between; /* Logo on left, Auth on right */
    align-items: center;           /* Perfectly center them vertically */
    padding: 0 20px;
    margin-bottom: 20px;           /* Space between this row and the content below */
}

#auth-container {
  display: flex;
  flex-direction: row;
  gap: 12px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  padding: 0;
}

#auth-container a {
  color: #3a2f3f;
  text-decoration: none;
  margin: 0 4px;
  font-size: 14px;
  transition: color 0.2s ease;
}

#auth-container a:hover {
  color: #8b63b5;
}

#welcome {
  display: flex;
  align-items: center;
  flex-direction: row;
  gap: 10px;
  font-weight: bold;
  white-space: nowrap;
}

.divider {
    margin: 0 10px;
    color: #b8a5eb;
    font-weight: normal;
}
.crystal-display {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid #d6c4e8;
    cursor: pointer;
}

.crystal-display:hover {
    background: rgba(184, 165, 235, 0.2);
}

.nav-crystal-icon {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    image-rendering: pixelated;
}

#nav-crystal-count {
    color: #8b63b5;
    font-weight: bold;
}


/* ================== Main Content Area ================== */
.main-content {
  margin-left: 230px; /* Aligns with Sidebar width */
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px; /* Reduced gap for game layout */
  background-color: #fde3f1; /* Or use game bg #dfcbf1 */
  min-height: 100vh;
  position: relative;
}

/* ================== GAME STYLES START HERE ================== */

/* -------------------- Title -------------------- */
.page-title {
  background-image: url("../assets/headerbg.png");
  background-repeat: repeat;
  background-position: top center;
  color: #ff0044;
  text-align: center;
  padding: 30px 0; /* Reduced padding slightly */
  width: 100%;
  margin: 0 auto 20px auto;
  font-weight: normal;
  font-size: 1.5rem;
  text-shadow:
     -2px -2px 0 #fff, -2px 0px 0 #fff, -2px 2px 0 #fff,
      0px -2px 0 #fff, 0px 2px 0 #fff,
      2px -2px 0 #fff, 2px 0px 0 #fff, 2px 2px 0 #fff,
      0 0 4px #fff, 0 0 6px #fff, 0 0 8px #fff;
}

/* -------------------- Builder & Scene -------------------- */
.builder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  position: relative;
}

.scene {
  position: relative;
  width: 600px;
  height: 600px;
  z-index: 1;
}

.layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* -------------------- Controls -------------------- */
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  max-width: 620px;
  width: 100%;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  padding: 14px;
  z-index: 2;
}

.controls > div {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  padding: 2px;
  font-size: 0.9rem;
}

.controls button, .export-buttons button {
  background: #e8dff0;
  font-family: "04b03", Verdana;
  border: none;
  border-radius: 8px;
  padding: 4px 8px;
  margin: 2px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.controls button:hover, .export-buttons button:hover {
  background: #d8cbe6;
  color: #8b63b5;
}

.controls .reset { background: #d6c4e8; }
.controls .reset:hover { background: #c7b1dd; }

/* Riddle Book Button */
#riddle-book {
  font-size: 30px;
  padding: 12px 16px;
  cursor: pointer;
  display: inline-block;
  background: transparent;
  border: none;
}
#riddle-book.unlocked { background: rgba(255,255,255,0.7); }

/* -------------------- Export Buttons -------------------- */
.export-buttons {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

/* -------------------- Floating Buttons (Help/Updates) -------------------- */
.floating-btn {
  position: fixed;
  width: 40px;
  height: 40px;
  font-size: 22px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  z-index: 1500;
  image-rendering: pixelated;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.floating-btn:hover {
  transform: scale(1.15);
  opacity: 0.9;
}

#help-button { top: 70px; right: 30px; } /* Moved down slightly to avoid Auth */
#updates-btn { top: 70px; left: 260px; } /* 230px sidebar + 30px gap */

/* -------------------- Secret Message -------------------- */
#secret-message {
  position: absolute;
  top: 150px; 
  left: 60%;
  width: 140px;
  max-width: 140px;
  height: 80px;
  background: url("../assets/secretmessagebg.png");
  padding: 10px;
  font-family: "04b03", Verdana;
  font-size: 12px;
  color: #3a2f3f;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 1200;
}

.secret-button {
  background: none; border: none; padding: 0; cursor: pointer;
  display: inline-block; opacity: 0; transform: scale(0.8);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}
.secret-button.unlocked { opacity: 1; transform: scale(1); pointer-events: auto; }

.secret-icon-wrapper img {
  width: 38px; height: 36px; display: block;
  image-rendering: pixelated;
}

/* -------------------- Modals (Auth & Info) -------------------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  padding: 10px;
  z-index: 6000; /* Above top auth */
  align-items: center;
  justify-content: center;
}

.modal.open { display: flex;    
align-items: center;
  justify-content: center;
  padding: 10px;}

/* Game Info Modal specific adjustments */
#info-modal .modal-window {
  background: url('../assets/infomessage.png') no-repeat center/cover;
  width: 400px;
  max-width: 90vw; 
  height: 400px;
  max-height: 90vh;
  padding: 20px;
  position: relative;
  font-family: "04b03", Verdana;
  color: #3a2f3f;
  text-align: center;
  line-height: 1.4;
  overflow: hidden;
  image-rendering: pixelated;
  border-radius: 6px
}
}

/* Auth Modal Styles (Preserved from Base) */
#auth-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 6000;
  align-items: center;
  justify-content: center;
}



.modal-content {
  width: 100%;
  height: 100%;
  overflow-y: auto;  
  padding: 10px;
  text-align: left;
}

/* Optional: hide scrollbar but still scrollable */
.modal-content::-webkit-scrollbar {
  width: 6px;
}
.modal-content::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,0.3);
  border-radius: 3px;
}

/* Left-aligned lists */
.modal-content .how-to-play {
  text-align: left;
  margin-top: 10px;
  padding-left: 10px;
}

/* Close button */
.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 18px;
  cursor: pointer;
  user-select: none;
  font-weight: bold;
}

.modal-content p, .modal-content .how-to-play {
  margin: 5px 0;
  padding-right: 5px; /* prevent cutting off text */
}


/* Mobile */
@media (max-width: 480px) {
  .modal-window {
    width: 90%;
    height: auto;
    max-height: 80%;
  }
}
#auth-modal .modal-window {
  position: relative;
  background: #fff;
  padding: 24px;
  width: 320px;
  max-width: 90vw;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}
#auth-modal input {
  width: 100%; margin: 8px 0; padding: 8px; font-size: 14px; border-radius: 6px; border: 1px solid #ccc;
}
#auth-modal button {
  padding: 8px 16px; font-size: 14px; border-radius: 6px; border: none; background: #e8dff0; cursor: pointer; margin-top: 6px;
}
#auth-modal button:hover { background: #d8cbe6; }
.modal-close {
  position: absolute; top: 8px; right: 12px; font-size: 20px; cursor: pointer;
}

/* -------------------- Riddle Book Window -------------------- */
#riddle-book-window {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* This works fine now that it's outside .scene */
    width: 410px;
    height: 200px;
    background-image: url('../assets/recipebook.png');
    background-size: cover;
    z-index: 2000; /* Higher than the scene */
    display: none;
}
#riddle-page-left, #riddle-page-right {
    position: absolute; 
    top: 20px; 
    width: 165px; 
    height: 160px;
    padding: 10px;   
    box-sizing: border-box; 
    font-size: 12px; 
    line-height: 1.4; 
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

#riddle-page-left { 
    left: 18px; 
}

#riddle-page-right {
    right: 18px;
    top: 35px;
    width: 165px;
    height: 140px;
    z-index: 10;
    pointer-events: none; 
}

/* -------------------- Arrows -------------------- */
#riddle-left-arrow, #riddle-right-arrow {
    position: absolute; 
    cursor: pointer; 
    font-weight: bold; 
    font-size: 26px;
    text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff;  
    user-select: none;
    transition: transform 0.15s ease, opacity 0.15s ease;
    z-index: 10002;
}

#riddle-left-arrow { bottom: 15px; left: 20px; }
#riddle-right-arrow { bottom: 15px; right: 20px; }

#riddle-left-arrow:hover, #riddle-right-arrow:hover {
    filter: brightness(1.2);
    opacity: 0.85;
}

#riddle-left-arrow:active, #riddle-right-arrow:active {
    transform: scale(0.95);
}

/* -------------------- The Close Button (The X) -------------------- */
#magic-close-x {
    position: absolute;
    background: none !important;
    top: 5px;
    right: 15px;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer !important;
    pointer-events: auto !important;
    z-index: 2001;
    font-family: "04b03", Verdana, sans-serif;
    font-size: 28px;
    font-weight: bold;
    color: #4a3728;
}

#magic-close-x:hover {
    color: #ff0000;
    transform: scale(1.1);
}

.layer, #sparkles, #watermark {
    pointer-events: none; 
}
/* -------------------- Sparkles -------------------- */
.sparkle {
  position: absolute; width: 12px; height: 12px; pointer-events: none;
  background: #fff;
  clip-path: polygon(50% 0%, 54% 46%, 100% 50%, 54% 54%, 50% 100%, 46% 54%, 0% 50%, 46% 46%);
  image-rendering: pixelated;
  animation: sparklePop 0.8s ease-out forwards;
}
@keyframes sparklePop {
  0% { transform: scale(0) translateY(0); opacity: 1; }
  50% { transform: scale(1.5) translateY(-6px); opacity: 1; }
  100% { transform: scale(2) translateY(-15px); opacity: 0; }
}

/* -------------------- Save Panel -------------------- */
#save-panel {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 230px;
    /* Remove min-height to let it grow/shrink naturally */
    background: #fffaf3;
    border: 3px solid #b8a5eb; /* Slightly thicker border for the theme */
    border-radius: 12px;
    padding: 20px 5px 10px 5px; /* More top padding for the toggle button */
    font-size: 13px;
    z-index: 2000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.save-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: bold;
  padding: 0 5px;
}

#save-house-button {
  width: 95%;
  margin: 0 auto 10px auto;
  display: block;
  cursor: pointer;
}

/* CAROUSEL CONTAINER */
.gallery-carousel-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 10px; /* Space for the navigation at the bottom */
}

/* THE "WINDOW" - Hides everything except the 2 active slots */
.gallery-window {
    width: 195px; 
    height: 130px; /* Fixed height to prevent cutting off the slots */
    overflow: hidden; 
    position: relative;
    margin: 5px auto;
}

/* THE STRIP - Holds all 10 slots in a long horizontal line */
#gallery-slots {
  display: flex;
  flex-wrap: nowrap; /* Forces single line */
  gap: 10px;
  width: max-content; 
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1); /* Smooth slide */
  padding-left: 0; /* Reset default padding */
  margin-top: 0; /* Reset default margin */
}

.slot {
    position: relative;
  flex: 0 0 90px;
  height: 120px; /* Taller slot */
  flex-direction: column;
  text-align: center;
  padding: 6px;
  gap: 6px;
  margin-top: 5px;
  border: 2px solid #b8a5eb;
  box-sizing: border-box; 
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.slot-preview {
  width: 100%;
  height: 60px;
  background: #eee;
  border-radius: 4px;
  margin-bottom: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ddd;
  background: #f0f0f0;
}

.slot-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Keeps house aspect ratio */
  image-rendering: pixelated;
}

.slot-name {
  font-size: 13px; 
  line-height: 1.2;
  text-align: center;
  word-wrap: break-word; 
  white-space: normal;
  width: 100%;
  color: #3a2f3f;
}

.slot.filled {
  background: #e8dff0;
  border: 2px solid #b8a5eb;
  font-weight: bold;
}

.slot.empty {
  opacity: 1;
  background: #f4f4f4;
  cursor: default;
  border: 2px solid #b8a5eb;
}

/* DELETE BUTTON */
.delete-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  background: #ff7675;
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 20;
}

.delete-btn:hover {
  background: #d63031;
  transform: scale(1.1);
}


.houses-grid {
    display: grid;
    /* This creates a 2-column layout on desktop, 1 on mobile */
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.house-card {
    background: #fffaf3;
    border: 4px solid #b8a5eb;
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}

.house-preview-large {
    width: 100%; /* Spans the card width */
    aspect-ratio: 1 / 1; /* Keeps it square */
    background: #f0f0f0;
    border-radius: 10px;
    margin-bottom: 15px;
    overflow: hidden;
    border: 2px solid #e8dff0;
}

.house-preview-large img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated; /* Keeps that crisp mushroom-house look */
}

.house-info h3 {
    font-family: "04b03", sans-serif;
    color: #3a2f3f;
    margin-bottom: 10px;
}

/* NAVIGATION */
.gallery-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 190px;
    margin: 10px auto 5px auto; /* Ensure it's not sticking to the bottom edge */
}

.nav-btn {
  background: #b8a5eb;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 14px;
}

.nav-btn:hover {
  background: #9b84d1;
}
#gallery-slots .slot:first-child {
  border-style: dashed !important;
}
#page-indicator {
    font-size: 14px;
    color: #555;
    background: rgba(255,255,255,0.8);
    padding: 2px 6px;
    border-radius: 4px;
}
#delete-modal .modal-window {
    border: 4px solid #d6c4e8; /* Matches your game theme */
    background: #fff;
    text-align: center;
}

#confirm-delete-btn:hover {
    background: #d63031 !important; /* Darker red on hover */
    transform: scale(1.05);
}

#cancel-delete-btn:hover {
    background: #bbb !important;
    transform: scale(1.05);
}

/* Target the very first slot specifically */
#gallery-slots .slot:first-child {
    background: #fdfdfd;
    border: 2px dashed #b8a5eb;
    color: #8b63b5;
}

#gallery-slots .slot:first-child.filled {
    background: #f5f0ff;
}

@keyframes savePulse {
  0% { transform: scale(1); box-shadow: 0 0 0px #b8a5eb; }
  50% { transform: scale(1.05); box-shadow: 0 0 15px #b8a5eb; background-color: #ffffff; }
  100% { transform: scale(1); box-shadow: 0 0 0px #b8a5eb; }
}

.save-success-anim {
  animation: savePulse 0.6s ease-out;
  z-index: 5;
}

/* Ensure the panel can transition smoothly */
#save-panel {
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    padding-top: 30px; /* Make room for the toggle button */
}

/* This class will be added/removed via JavaScript */
#save-panel.minimized {
    transform: translateY(calc(100% - 30px)); 
}

/* The actual Toggle Button */
#toggle-panel-btn {
    position: absolute;
    top: -20px; /* Moves it up to sit on the top edge */
    left: 50%;
    transform: translateX(-50%);
    background: #b8a5eb;
    color: white;
    border: 3px solid white;
    border-radius: 12px 12px 0 0;
    padding: 4px 12px;
    cursor: pointer;
    font-family: "04b03", sans-serif;
    font-size: 11px;
    white-space: nowrap;
    box-shadow: 0 -3px 6px rgba(0,0,0,0.1);
    z-index: 2100;
}

#toggle-panel-btn:hover {
    background: #a389e6;
}

.card-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

.download-btn {
    background: #74b9ff !important; /* Soft Blue */
    color: white !important;
}

.download-btn:hover {
    background: #0984e3 !important;
}

.edit-btn {
    background: #b8a5eb !important;
    color: white !important;
}

.slot[style*="dashed"] {
    border-color: #b8a5eb;
    background-color: #fffcf9; /* Light highlight for auto-save slot */
}

.slot-preview img {
    image-rendering: pixelated; /* Keeps your mushroom art sharp in the sidebar */
}

.autosave-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #b8a5eb;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: bold;
    color: #b8a5eb;
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 10001;
    pointer-events: none;
}

.autosave-indicator.active {
    opacity: 1;
    transform: translateY(0);
}

/* A tiny spinning dot */
.dot-spin {
    width: 8px;
    height: 8px;
    border: 2px solid #b8a5eb;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.footer-links {
    font-size: 13px;
    text-align: center;
}

/* -------------------- Mobile -------------------- */
@media (max-width: 780px) {
  body {
    /* This is the magic line that forces the stack */
    flex-direction: column !important;
    overflow-x: hidden;
    height: auto !important;
  }

  .sidebar {
    /* Change from Fixed to Relative so it sits at the TOP */
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    border-right: none !important;
    border-bottom: 4px solid #d6c4e8;
    padding: 20px 10px !important;
    z-index: 100;
    /* Ensure it doesn't try to scroll internally */
    overflow-y: visible !important; 
  }

  .main-content {
    /* Remove the left margin so it fills the screen under the sidebar */
    margin-left: 0 !important;
    width: 100% !important;
    padding: 10px !important;
    min-height: 0 !important;
  }

  #clock {
    display: block !important;
    visibility: visible !important;
    width: 190px !important;
    height: 54px !important;
    background-image: url("../../../assets/clock.png") !important; 
    background-size: 100% 100% !important;
    margin: 0 auto 15px auto !important;
  }

  .sidebar-item {
    width: 90% !important;
    margin: 4px auto !important;
  }

  /* Reset scene size for small screens */
  .scene {
    width: 300px !important;
    height: 300px !important;
    margin: 0 auto !important;
    transform: none !important; /* Scale can cause blurriness */
  }

  /* Scale the house layers to fit the new scene size */
  .layer {
    width: 100% !important;
    height: 100% !important;
  }

  .controls {
    grid-template-columns: 1fr 1fr !important;
    max-width: 100% !important;
  }

  /* Move floating buttons so they don't cover text */
  #updates-btn {
    left: 10px !important;
    top: 10px !important;
  }
  #help-button {
    right: 10px !important;
    top: 10px !important;
  }
}