/* =========================================================
   Tiny Office Escape — styles
   The entire game is a fixed 320 x 320 box so it embeds
   cleanly inside an iframe ad slot.
   ========================================================= */

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

body {
  /* Center the box if the page is bigger than the game */
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #1b1d24;
  font-family: "Segoe UI", system-ui, sans-serif;
}

/* ---- The fixed stage --------------------------------- */
#game {
  position: relative;
  width: 320px;
  height: 320px;
  overflow: hidden;
  background: #2a2d38;
  color: #fff;
  border-radius: 6px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
  user-select: none;
}

/* ---- Title bar --------------------------------------- */
#titlebar {
  height: 28px;
  line-height: 28px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .5px;
  background: linear-gradient(#3a3f4f, #2f3340);
  border-bottom: 1px solid #11131a;
}

/* ---- The room ---------------------------------------- */
#room {
  position: absolute;
  top: 28px;
  left: 0;
  right: 0;
  bottom: 46px;               /* leave room for status + restart */
  /* Wall + floor split using a hard gradient stop */
  background:
    linear-gradient(#3c4255 0 62%, #6b5641 62% 100%);
}

/* Subtle floor "rug" for depth */
#room::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 8px;
  height: 40px;
  background: rgba(0, 0, 0, .15);
  border-radius: 50%;
  filter: blur(2px);
}

/* ---- Generic prop behaviour -------------------------- */
.prop {
  position: absolute;
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}
.prop:hover {
  transform: scale(1.06);
  filter: drop-shadow(0 0 6px rgba(255, 221, 87, .9));
}
.prop:active { transform: scale(.97); }

/* ---- Picture frame (top-left wall) ------------------- */
#frame { top: 14px; left: 18px; width: 52px; height: 44px; }
.frame-art {
  width: 100%; height: 100%;
  background: linear-gradient(135deg, #7fb5ff 0 50%, #b6f0c8 50% 100%);
  border: 4px solid #d8b46a;
  border-radius: 3px;
}

/* ---- Plant (floor, left) ----------------------------- */
#plant { bottom: 6px; left: 16px; width: 44px; height: 70px; }
.leaf {
  position: absolute;
  width: 18px; height: 30px;
  background: #3fae6a;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}
.leaf.l1 { left: 13px; top: 0;  transform: rotate(0deg); }
.leaf.l2 { left: 2px;  top: 8px; transform: rotate(-35deg); }
.leaf.l3 { left: 24px; top: 8px; transform: rotate(35deg); }
.pot {
  position: absolute;
  bottom: 0; left: 7px;
  width: 30px; height: 28px;
  background: linear-gradient(#c8743a, #9c5326);
  border-radius: 4px 4px 8px 8px;
}

/* ---- Desk + drawer (center-right floor) -------------- */
#desk { bottom: 6px; right: 60px; width: 120px; height: 74px; }
.desk-top {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 16px;
  background: #8a5a32;
  border-radius: 3px;
}
.drawer {
  position: absolute;
  top: 20px; left: 18px;
  width: 84px; height: 50px;
  background: #a06a3c;
  border: 2px solid #6e4624;
  border-radius: 3px;
  transition: transform .18s ease, background .18s ease;
}
.drawer .handle {
  position: absolute;
  top: 20px; left: 50%;
  width: 30px; height: 6px;
  margin-left: -15px;
  background: #f1d488;
  border-radius: 3px;
}
/* Open drawer slides down + darkens to look pulled out */
.drawer.open {
  transform: translateY(14px);
  background: #2c1d10;
}

/* ---- Laptop (on the desk) ---------------------------- */
#laptop { bottom: 64px; right: 70px; width: 50px; height: 40px; }
.screen {
  width: 100%; height: 28px;
  background: #0d1326;
  border: 2px solid #444;
  border-radius: 3px 3px 0 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  color: #6fe06f;
  font-family: "Courier New", monospace;
}
.base {
  width: 116%; height: 6px;
  margin-left: -8%;
  background: #888;
  border-radius: 0 0 4px 4px;
}

/* ---- Door (right wall) ------------------------------- */
#door { top: 4px; right: 12px; width: 56px; height: 96px; }
.door-panel {
  width: 100%; height: 100%;
  background: linear-gradient(#7a5230, #5e3d20);
  border: 3px solid #3d2713;
  border-radius: 4px;
}
.knob {
  position: absolute;
  top: 46px; left: 8px;
  width: 8px; height: 8px;
  background: #ffd95e;
  border-radius: 50%;
}
.lock {
  position: absolute;
  top: 38px; right: 6px;
  font-size: 14px;
}
/* Unlocked door swings open to reveal bright daylight */
#door.unlocked .door-panel {
  transform: perspective(200px) rotateY(-55deg);
  transform-origin: left center;
  background: linear-gradient(#ffe9a8, #ffd36b);
}

/* ---- Inventory (the found key) ----------------------- */
#inventory {
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  min-height: 20px;
}

/* ---- Status line + restart --------------------------- */
#status {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 46px;
  padding: 6px 70px 6px 10px;     /* keep clear of restart button */
  font-size: 11px;
  line-height: 1.3;
  display: flex;
  align-items: center;
  background: #1f2129;
  border-top: 1px solid #11131a;
}

#restart {
  position: absolute;
  right: 8px; bottom: 10px;
  padding: 5px 8px;
  font-size: 11px;
  color: #fff;
  background: #4a4f63;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
#restart:hover { background: #5b6178; }

/* =========================================================
   Overlays (keypad + win screen)
   ========================================================= */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 13, .82);
  z-index: 10;
}
.overlay.hidden { display: none; }

/* ---- Keypad ------------------------------------------ */
.keypad-box {
  width: 180px;
  padding: 12px;
  background: #20232e;
  border: 1px solid #3a3f4f;
  border-radius: 8px;
  text-align: center;
}
#code-display {
  font-family: "Courier New", monospace;
  font-size: 22px;
  letter-spacing: 4px;
  color: #6fe06f;
  margin-bottom: 10px;
}
.keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.key {
  padding: 8px 0;
  font-size: 14px;
  color: #fff;
  background: #3a4053;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
.key:hover { background: #4c5470; }
.key:active { transform: scale(.95); }
.key-ok { background: #2e8b57; }
.key-ok:hover { background: #37a567; }

/* ---- Win screen -------------------------------------- */
.win-box { text-align: center; }
.win-emoji { font-size: 46px; }
.win-title { font-size: 22px; font-weight: 800; margin-top: 6px; }
.win-sub   { font-size: 13px; color: #ffd95e; margin-top: 4px; }
#win-restart {
  margin-top: 16px;
  padding: 8px 16px;
  font-size: 13px;
  color: #fff;
  background: #2e8b57;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}
#win-restart:hover { background: #37a567; }

/* Tiny shake animation for wrong code feedback */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.shake { animation: shake .3s; }
