/* For all */
* {
  box-sizing: border-box;
  image-rendering: pixelated;
}
/* Same function kinda */
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: black;
  overflow: hidden; /* prevents scrolling */
  font-family: monospace;
}

/* Whole section */
#game {
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  background: black;
}

/* Blur background */
#bg-blur {
  position: absolute;
  inset: 0;
  background: url("pictures/Background.png") center / cover no-repeat;
  filter: blur(24px) brightness(0.65);
  transform: scale(1.1);
  z-index: 0;
}

/* Game section */
#scene {
  position: relative;
  width: 1280px;
  height: 720px;
  background: url("pictures/Background.png") center / contain no-repeat;
  z-index: 1;
  transform-origin: center center;
  flex-shrink: 0;
  isolation: isolate; 
  overflow: visible;
}

/* For objects */
.obj {
  position: absolute;
  cursor: pointer;
  transition: transform .25s, filter .25s;
  backface-visibility: hidden; 
  transform: translateZ(0); /* for performance */
  -webkit-transform-style: preserve-3d;
  image-rendering: pixelated;
}

.obj:hover {
  filter: drop-shadow(0 0 8px gold);
}

.hidden {
  visibility: hidden;
  pointer-events: none; /* cannot be clicked */
}

/* Overlay for paper decorations and etc */
#overlay {
  position: fixed;
  display: flex;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  align-items: center;
  justify-content: center;
  z-index: 999;
}

#overlay-box {
  background: #fff1f1;
  padding: 20px;
  border: 1px solid #000000;
  max-width: 320px;
  text-align: center;
}

#overlay-text {
  margin: 0;
  font-size: 16px;
}

#overlay-btn {
  margin-top: 15px;
  padding: 8px 13px;
  cursor: pointer;
  background-color: #d8a78bce;
}
#overlay-box {
  animation: pop 0.25s ease-out;
}

@keyframes pop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
/* Tree section */
#tree {
  position: absolute;
  bottom: 140px;
  left: 520px;
  width: 260px;
}

#tree img {
  width: 100%;
}

#tree-lights {
  position: absolute;
  inset: 0;
  animation: blink 1s infinite alternate; /* animation plays forever */
  pointer-events: none;
}

/* Flicker animation */
@keyframes blink {
  from { opacity: .5; }
  to { opacity: 1; }
}

/* Window section */
#window-wrapper {
  position: absolute;
  width: 220px;
  height: 220px;
  top:150px; left:190px;
}
#snow {
  position: absolute;
  inset: 0;
  background-image: url("pictures/Snow.png");
  background-repeat: repeat;
  background-size: 64px 64px;

  animation: snowFall 4s linear infinite; /* moves downward infinitely */
  z-index: 1;
  pointer-events: none;
}
@keyframes snowFall {
  from { background-position: 0 0; }
  to   { background-position: 0 128px; }
}

#window-closed, #window-open { width:220px; transform: scale(1.4); z-index: 5;}
#window-open {
  width:220px;
  top : 10px;
  transform: scale(1.5);
  z-index: 2;
}
#window-cat {
  position: absolute;
  bottom: 20px; 
  left: 30%;
  transform: translateX(-50%) translateY(20px); 
  width: 70px;
  z-index: 10; 
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none; 
  cursor: pointer; 
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
}
#window-cat:hover {
  filter: drop-shadow(0 0 12px gold) brightness(1.2);
  transform: translateX(-50%) translateY(-2px) scale(1.05); 
}

#window-cat.peek {
  opacity: 1;
  transform: translateX(-50%) translateY(0); 
  pointer-events: auto; 
}
#cat-bubble {
  position: absolute;
  bottom: 110px; 
  left: 30%;
  transform: translateX(-50%);
  
  background: white;
  border: 2px solid black;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: bold;
  color: black;
  white-space: nowrap;
  z-index: 20;
  box-shadow: 3px 3px 0px rgba(0,0,0,0.2);
}
#cat-bubble::before {
  content: '';
  position: absolute;
  bottom: -13px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 11px solid black;
  z-index: -1;
}
#cat-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px; 
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid white; 
}

/* Clock wall object */
#clock-wrapper {
  position: absolute;
  width: 110px;       
  top: 65px;        
  left: 593px;    
  transform: scale(1.2);    
  z-index: 4;
}

#clock-secret {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 25px;
  top: 50px;
  display: flex;
  z-index: 0;     
  font-family: 'Finger Paint', cursive;
  color: rgba(0, 0, 0, 0.5); 
  font-size: 15px;
  text-shadow: 
    -1px -1px 0px rgba(0,0,0,0.3),  
     1px  1px 0px rgba(255,255,255,0.1); 
  filter: contrast(1.5) blur(0.5px); 
  user-select: none;
  cursor: default;
}

#clock-wrapper img {
  position: relative; 
  width: 100%;        
  z-index: 12;        
  transition: transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1); 
  cursor: pointer;
}

#clock-wrapper img.moved {
  transform: translateX(-80%); 
}

/* Shelf section */
#shelf-closed, #shelf-open { width:200px; top:205px; transform: scale(1.4); right: 190px;}
#shelf-hitbox {
  position: absolute;
  width: 245px;
  height: 83px;
  top: 540px;     
  right: 167px;
  cursor: pointer;
  z-index: 5;
}

#shelf-books-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
/* Books inside shelf */
.book {
  position: absolute;
  width: 35px; 
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.2s, filter 0.2s;
}

.pos-analysis { bottom: 170px; right: 345px; transform: scale(2);}
.pos-physics { bottom: 170px; right: 270px; transform: scale(2); }
.pos-differential { bottom: 170px; right: 195px; transform: scale(2);}

.book:hover {
  transform: scale(2.1);
  filter: drop-shadow(0 0 8px gold) brightness(1.2);
}

#book-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#book-open-view {
  background: #f4e4bc; 
  width: 600px;
  height: 350px;
  display: flex;
  border: 10px solid #5d4037;
  position: relative;
  box-shadow: 0 0 50px black;
}

#book-open-view::after {
  content: '';
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 2px;
  background: rgba(0,0,0,0.1);
}
.book-page-left, 
.book-page-right {
  flex: 1; 
  padding: 30px;
  display: flex;
  flex-direction: column;
  overflow-y: auto; 
}

#book-view-text-left, 
#book-view-text-right {
  font-family: 'Georgia', serif;
  font-size: 16px;
  line-height: 1.5;
  color: #222;
  margin: 0;
}
.book-page-left { padding-right: 40px; }
.book-page-right { padding-left: 40px; }

#book-close-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  padding: 8px 15px;
  cursor: pointer;
  background: #8d6e63;
  color: white;
  border: 2px solid #3e2723;
  font-weight: bold;
}

/* Chests on shelf */
#box1 { width:80px; top:350px; right:299px; transform: scale(1.5); }
#box1-open {
  top: 312px;   
  right: 296px;
  width:85px;
  transform: scale(1.38);
}
#paper1 {
  width: 48px;
  cursor: pointer;
  top: 320px;
  left: 940px;
}
#box2 { width:80px; top:435px; right:182px; transform: scale(1.3);}
#box2-open {
  top: 414px;   
  right: 180px;
  width:85px;
  transform: scale(1.2);
}
#paper2 {
  width: 50px;
  cursor: pointer;
  top: 425px;
  right: 195px;
}
/* Present under tree, not locked one */
#present1 { width:90px; bottom:56px; left:430px; transform: scale(0.6); z-index: 5; }
#present2 { width:90px; bottom:110px; left:505px; transform: scale(1.5); z-index: 5; }
#present3 { width:90px; bottom:100px; left:690px; transform: scale(1); z-index: 5; }
#present4 { width:90px; bottom:90px; left:760px; transform: scale(0.9); z-index: 5; }

.present {
  cursor: pointer;
  transition: filter 0.3s, transform 0.3s;
}

.present:hover {
  filter: drop-shadow(0 0 10px gold) brightness(1.2);
}

#present-bubble {
  position: absolute;
  background: white;
  border: 2px solid #1f1d1d;
  border-radius: 15px;
  padding: 10px;
  width: 140px;
  z-index: 2000;
  box-shadow: 4px 4px 0px rgba(0,0,0,0.1);
  pointer-events: auto; 
  left: 0; 
  top: 0;
}

#present-bubble::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 10px;
  border-width: 10px 10px 0;
  border-style: solid;
  border-color: white transparent;
}

#present-paper-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 3000;
}

.paper-container {
  background: #fff;
  padding: 20px;
  border: 4px solid #5d4037;
  text-align: center;
}

#paper-display-img {
  max-width: 70vw;
  max-height: 60vh;
  display: block;
}

/* Locked Present */
#locked-present {
  width:120px; bottom:78px; left:595px; transform: scale(1.2);
  z-index: 10; cursor: pointer; transition: filter 0.3s;
}
#locked-present-open {
  width:130px; bottom:78px; left:592px; transform: scale(1.14);
  z-index: 10; cursor: pointer;
}

#inner-paper-item {
  width: 50px;      
  bottom: 112px;     
  left: 630px; 
  z-index: 20;      
  cursor: pointer;
  transform: scale(1.1) rotate(35deg);
  image-rendering: pixelated;
}

#final-paper-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.present-glow:hover {
  filter: drop-shadow(0 0 10px gold) brightness(1.2);
}

#keypad-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8);
  display: flex; justify-content: center; align-items: center; z-index: 5000;
}
.keypad-box {
  background: #ffe988; padding: 25px; border: 4px solid #5d4037; text-align: center;
}
#code-input {
  font-size: 24px; width: 85px; text-align: center; letter-spacing: 5px; margin-bottom: 30px; 
}
#keypad-error { color: red; font-size: 15px; margin-top: 5px; }
.keypad-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
}

.pixel-button {
  background-color: #baffbaef; 
  border: 1px solid #5d4037;
  color: #333;
  padding: 8px 16px;
  font-family: 'monospace'; 
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
  image-rendering: pixelated;
}

.pixel-button:hover {
  background-color: #ffffff !important;
  transform: translateY(-2px); 
  box-shadow: 0 4px 0 rgba(0,0,0,0.2);
}

.pixel-button:active {
  transform: translateY(1px);
  box-shadow: none;
}
#close-keypad, #close-paper {
  background-color: #ffdddd;
}
#final-paper-overlay {
  position: fixed; 
  inset: 0;        
  background: rgba(0, 0, 0, 0.8);
  display: flex;   
  justify-content: center; 
  align-items: center;     
  z-index: 9999;    
}

.paper-container {
  background: #fff7e8; 
  padding: 15px;
  border: 2px solid #5d4037; 
  text-align: center;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  max-width: 400px;
  font-family: 'Courier New', Courier, monospace; 
  font-size: 20px;
}

#close-final-paper {
  padding: 5px 15px;
  cursor: pointer;
  background: #5d4037;
  color: white;
  border: none;
}

/* Painting wall object */
#painting-wrapper {
  position: absolute;
  width: 120px;       
  top: 430px;        
  left: 180px;
  transform: scale(1.3);        
  z-index: 2;
}

#painting-secret {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 5px;
  display: flex;
  z-index: 0;    
 font-family: 'Finger Paint', cursive;
  color: rgb(0, 0, 0);
  font-size: 11px;
  text-shadow: 
    -1px -1px 0px rgba(0,0,0,0.3),  
     1px  1px 0px rgba(255,255,255,0.1); 
  filter: contrast(1.5) blur(0.5px); 
  user-select: none;
  cursor: default;
}

@keyframes flicker {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 0.4; }
}

#painting-wrapper img {
  position: relative; 
  width: 100%;        
  z-index: 10;        
  transition: transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1); 
  cursor: pointer;
}

#painting-wrapper img.moved {
  transform: translateY(60%); 
}

/* Poster1 wall object */
#poster1-wrapper {
  position: absolute;
  width: 90px;       
  top: 205px;        
  left: 740px;        
  z-index: 3;
}

#poster1-secret {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 23px;
  top: 45px;
  display: flex;
  z-index: 0;     
  font-family: 'Finger Paint', cursive;
  color: rgba(0, 0, 0, 0.849);
  font-size: 13px;
  text-shadow: 
    -1px -1px 0px rgba(0,0,0,0.3),  
     1px  1px 0px rgba(255,255,255,0.1); 
  filter: contrast(1.5) blur(0.5px); 
  user-select: none;
  cursor: default;
}

#poster1-wrapper img {
  position: relative; 
  width: 100%;        
  z-index: 11;        
  transition: transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1); 
  cursor: pointer;
}

#poster1-wrapper img.moved {
  transform: translateY(-60%); 
}

/* Poster2 wall object */
#poster2-wrapper {
  position: absolute;
  width: 90px;       
  top: 400px;        
  left: 350px;    
  transform: scale(1.1);    
  z-index: 4;
}

#poster2-secret {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 10px;
  top: 30px;
  display: flex;
  z-index: 0;     
  font-family: 'Finger Paint', cursive;
  color: rgba(0, 0, 0, 0.5); 
  font-size: 36px;
  text-shadow: 
    -1px -1px 0px rgba(0,0,0,0.3),  
     1px  1px 0px rgba(255,255,255,0.1); 
  filter: contrast(1.5) blur(0.5px); 
  user-select: none;
  cursor: default;
}

#poster2-wrapper img {
  position: relative; 
  width: 100%;        
  z-index: 12;        
  transition: transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1); 
  cursor: pointer;
}

#poster2-wrapper img.moved {
  transform: translateX(35%); 
}

