body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-family: Arial, sans-serif;
  color: #0b3d33;
  background: #d4f5ec;
}

/* ----- Door screen (cyan-green, covers the whole screen) ----- */
#door {
  position: fixed;
  inset: 0;
  z-index: 20;
  perspective: 1600px;
  background: #d4f5ec;
}
#door .leaf {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  background: #2ec4a6;
  border: 14px solid #1aa58a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #ffffff;
  transform-origin: left center;   /* the door hinges on the left edge */
  transition: transform 1.2s ease;
}
#door.open .leaf { transform: rotateY(-100deg); }
#door .handle {
  position: absolute;
  right: 12%;
  top: 50%;
  width: 14px;
  height: 120px;
  margin-top: -60px;
  border-radius: 8px;
  background: #ffffff;
}
#door h1 { margin: 0; font-size: 38px; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); }
#door p { margin: 0; font-size: 18px; opacity: 0.95; }
#door button {
  margin-top: 16px;
  font-size: 20px;
  padding: 14px 32px;
  border: none;
  border-radius: 12px;
  background: #ffffff;
  color: #0a7f68;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ----- Heading ----- */
header {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 5;
  pointer-events: none;
}
header h2 { margin: 0; font-size: 22px; }
header p { margin: 2px 0 0; font-size: 13px; opacity: 0.75; }

/* ----- 3D scene (full width) ----- */
#scene {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 0;
}
#scene canvas { display: block; }

/* ----- Controls: bottom left, in one row ----- */
#controls {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  max-width: 70vw;
  padding: 12px;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}
#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#clear { background: #ffffff; color: #0a7f68; }
#controls button:disabled { opacity: 0.5; cursor: wait; }
#count, #status {
  flex-basis: 100%;
  margin: 0;
  font-size: 13px;
  color: #00796b;
}
#count { order: -1; }
#status.error { color: #c62828; }

/* ----- 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: 600px) {
  #panel { width: 100%; }
  #controls { max-width: 92vw; }
}
