/* Camera and dimensional finish */
.camera-scene {
  position: fixed;
  inset: 0;
  z-index: 1;
  transform-origin: 50% 50%;
  transform-style: preserve-3d;
  will-change: transform;
  --cam-x: 0px;
  --cam-y: 0px;
  --cam-yaw: -18deg;
  --cam-pitch: 18deg;
  --cam-zoom: 1;
  transform: perspective(1450px) translate3d(var(--cam-x), var(--cam-y), 0) rotateX(var(--cam-pitch)) rotateY(var(--cam-yaw)) scale(var(--cam-zoom));
  transition: transform 180ms cubic-bezier(.2,.7,.2,1);
}
#scene-backdrop { z-index: 1; pointer-events: auto; }
#scene-world { z-index: 10; pointer-events: none; }
#playground { pointer-events: auto; }
.camera-scene.camera-moving { transition: none; cursor: grabbing; }
/* Fill the perspective edges with matching sky colors as the view tilts. */
html, body { background-color: #8fd8f8; }
html.night body { background-color: #0b1026; }
html.sunset body { background-color: #3b2f63; }
html.sunrise body { background-color: #4a6a9e; }
/* A real CSS 3D floor plane: broad at the viewer, narrowing toward the horizon. */
#grass {
  isolation: isolate;
  background: linear-gradient(180deg, #82ce4f 0%, #6ab93e 30%, #57a233 100%);
  box-shadow: inset 0 11px 0 rgba(211,255,164,.22), 0 -12px 26px rgba(38,91,44,.12);
}
#grass::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: -12%;
  top: -510px;
  width: 124%;
  height: 570px;
  transform: perspective(780px) rotateX(67deg);
  transform-origin: 50% 100%;
  background-color: #6fbd45;
  background-image:
    repeating-linear-gradient(90deg, transparent 0 54px, rgba(31,88,39,.23) 55px 57px),
    repeating-linear-gradient(0deg, transparent 0 28px, rgba(31,88,39,.21) 29px 31px),
    linear-gradient(180deg, #9bdd62 0%, #69b942 72%, #4f9e35 100%);
  box-shadow: 0 -5px 0 rgba(203,255,154,.72), 0 16px 32px rgba(34,74,36,.24);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,.18) 18%, #000 92%);
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,.18) 18%, #000 92%);
  pointer-events: none;
}
html.night #grass::before {
  background-color: #244a2a;
  background-image: repeating-linear-gradient(90deg, transparent 0 54px, rgba(140,200,122,.13) 55px 57px),
    repeating-linear-gradient(0deg, transparent 0 28px, rgba(140,200,122,.12) 29px 31px),
    linear-gradient(180deg, #385f36, #244a2a 72%, #18371d);
}
html.sunset #grass::before { background-image: repeating-linear-gradient(90deg, transparent 0 54px, rgba(44,63,31,.18) 55px 57px), repeating-linear-gradient(0deg, transparent 0 28px, rgba(44,63,31,.16) 29px 31px), linear-gradient(180deg,#75a94b,#4f7a3a 72%,#335326); }
html.sunrise #grass::before { background-image: repeating-linear-gradient(90deg, transparent 0 54px, rgba(53,97,43,.15) 55px 57px), repeating-linear-gradient(0deg, transparent 0 28px, rgba(53,97,43,.14) 29px 31px), linear-gradient(180deg,#91cc68,#6fae47 72%,#4d8531); }
/* Each unit is a genuine 3D cuboid: the original rounded square stays as
   its front, while two 32px faces fold back from its top and right edges. */
#playground, .block, .block * { transform-style: preserve-3d; }
.block { translate: 0 0 32px; }
.block .cube {
  overflow: visible;
  backface-visibility: visible;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.16), inset 0 2px 0 rgba(255,255,255,.24), 1px 3px 5px rgba(27,44,60,.18);
}
.block .cube::before,
.block .cube::after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(0,0,0,.12);
  background: inherit;
  pointer-events: none;
  backface-visibility: hidden;
}
/* Top plane: full cube depth, lit from above, with a soft rounded outer edge. */
.block .cube::before {
  left: 0;
  top: 0;
  border-radius: 4px 4px 0 0;
  filter: brightness(1.2);
  transform-origin: 50% 0%;
  transform: rotateX(-90deg);
}
/* Right plane: same dimensions as the front, shaded to read as a solid side. */
.block .cube::after {
  left: 0;
  top: 0;
  border-radius: 0 4px 4px 0;
  filter: brightness(.68);
  transform-origin: 100% 50%;
  transform: rotateY(-90deg);
}
#camera-panel {
  position: fixed;
  z-index: 80;
  left: 12px;
  bottom: max(128px, calc(env(safe-area-inset-bottom) + 128px));
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 9px;
  border: 1px solid rgba(255,255,255,.68);
  border-radius: 16px;
  color: #f7fbff;
  background: rgba(22,39,64,.72);
  box-shadow: 0 8px 24px rgba(20,38,61,.2);
  backdrop-filter: blur(10px);
  font: 600 12px/1 system-ui, sans-serif;
  touch-action: manipulation;
}
#camera-panel .cam-title { padding: 0 5px 0 2px; letter-spacing: .09em; font-size: 9px; opacity: .86; white-space: nowrap; }
#camera-panel button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 10px;
  color: white;
  background: rgba(255,255,255,.12);
  font: 700 17px/1 system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}
#camera-panel button:active { transform: scale(.92); background: rgba(255,255,255,.26); }
#camera-panel .cam-reset { font-size: 14px; }
#camera-hint { position: absolute; left: 0; top: calc(100% + 5px); padding: 5px 8px; border-radius: 8px; color: white; background: rgba(22,39,64,.62); font: 10px system-ui,sans-serif; white-space: nowrap; opacity: .72; pointer-events:none; }
@media (max-width: 560px) {
  #camera-panel { left: 8px; bottom: max(112px, calc(env(safe-area-inset-bottom) + 112px)); gap: 3px; padding: 6px; }
  #camera-panel button { width: 32px; height: 32px; }
  #camera-panel .cam-title { font-size: 8px; }
}
@media (prefers-reduced-motion: reduce) { .camera-scene { transition: none; } }
