/* Mint background with a faint grid across the WHOLE screen */
body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-family: Arial, sans-serif;
  color: #14413a;
  background: linear-gradient(160deg, #f1fbf8 0%, #d9f5ec 55%, #eaf9f4 100%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(20, 160, 133, 0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 160, 133, 0.10) 1px, transparent 1px);
  background-size: 44px 44px;
}

/* ----- 3D scene covers the whole screen ----- */
#scene {
  position: fixed;
  inset: 0;
  z-index: 1;
}
#scene canvas { display: block; }

/* ----- Welcome screen ----- */
#welcome {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(241, 251, 248, 0.55);
  transition: opacity 0.6s ease;
}
#welcome.gone { opacity: 0; pointer-events: none; }

.welcome-card {
  background: rgba(255, 255, 255, 0.82);
  border-radius: 24px;
  padding: 26px 40px 22px;
  text-align: center;
  max-width: 520px;
  box-shadow: 0 10px 40px rgba(20, 120, 100, 0.15);
  backdrop-filter: blur(6px);
}
.welcome-card h1 { margin: 10px 0 6px; font-size: 34px; color: #0d2f2b; }
.welcome-card p { margin: 0 0 16px; font-size: 16px; color: #3d6b64; line-height: 1.5; }
.welcome-card small { display: block; margin-top: 12px; font-size: 13px; color: #5b8a83; }

#open-door {
  font-size: 18px;
  padding: 13px 28px;
  border: none;
  border-radius: 12px;
  background: #1aa58a;
  color: #ffffff;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(20, 160, 133, 0.35);
}
#open-door:hover { background: #158f78; }

/* Two small wooden cabinets with doors on the welcome card */
.cab-pair {
  display: flex;
  justify-content: center;
  gap: 16px;
  perspective: 900px;
}
.cab {
  width: 130px;
  height: 170px;
  box-sizing: border-box;
  padding: 8px;
  display: flex;
  gap: 4px;
  background: #b98456;
  border-radius: 6px;
  box-shadow: inset 0 0 0 4px #8a5a33;
}
.door {
  flex: 1;
  border: 3px solid #9c6b3d;
  border-radius: 3px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.15)),
    #e3bc91;
  transition: transform 1.1s ease;
}
.door.left { transform-origin: left center; }
.door.right { transform-origin: right center; }
#welcome.open .door.left { transform: rotateY(-100deg); }
#welcome.open .door.right { transform: rotateY(100deg); }

/* ----- Top bar ----- */
.topbar {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}
.brand {
  background: rgba(255, 255, 255, 0.92);
  padding: 10px 16px;
  border-radius: 14px;
  font-weight: bold;
  font-size: 18px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
}
.badge {
  margin-left: 8px;
  font-size: 11px;
  color: #00796b;
  background: #d4f5ec;
  padding: 3px 8px;
  border-radius: 10px;
}
.stat {
  background: #ffffff;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
}
.stat span { font-weight: bold; color: #0a7f68; }

/* ----- Bottom-left controls ----- */
#controls {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 6;
  width: min(440px, 92vw);
  box-sizing: border-box;
  padding: 14px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}
#controls .row { display: flex; flex-wrap: wrap; gap: 10px; }
#controls select,
#controls button {
  font-size: 15px;
  padding: 10px 14px;
  border: 1px solid #1aa58a;
  border-radius: 10px;
  background: #ffffff;
  color: #0b3d33;
}
#controls button {
  background: #0a7f68;
  border-color: #0a7f68;
  color: #ffffff;
  font-weight: bold;
  cursor: pointer;
}
#controls button.ghost { background: #ffffff; color: #0a7f68; }
#controls button:disabled { opacity: 0.5; cursor: wait; }
#status { margin: 10px 0 0; font-size: 14px; color: #00796b; min-height: 18px; }
#status.error { color: #c62828; }

/* ----- Bottom-right tip and centre hint ----- */
.tip {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 6;
  background: #ffffff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.hint {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 3;
  font-size: 13px;
  color: #3d6b64;
  pointer-events: none;
}

/* ----- Loading ----- */
#loading {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.75);
}
.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid #b2dfdb;
  border-top-color: #0a7f68;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Details panel ----- */
#panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 25;
  width: 340px;
  height: 100%;
  box-sizing: border-box;
  padding: 24px;
  overflow-y: auto;
  background: #ffffff;
  border-left: 2px solid #1aa58a;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
}
#close { float: right; border: none; background: none; font-size: 20px; cursor: pointer; color: #0b3d33; }
.printed { white-space: pre-wrap; background: #e0f2f1; padding: 10px; border-radius: 8px; font-size: 13px; }
.note { font-size: 12px; font-style: italic; opacity: 0.8; }

.hidden { display: none !important; }

@media (max-width: 700px) {
  .tip, .hint { display: none; }
  #panel { width: 100%; }
  .stat { font-size: 12px; }
  .brand { font-size: 15px; }
  .badge { display: none; }
}
