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

html, body {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: #000;
  user-select: none;
}

.room {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  background: #000;
}

.stars, .css-stars {
  z-index: 1;
}

.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.css-stars {
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  pointer-events: none;
  z-index: 1;
}

.viewport {
  position: absolute;
  inset: 0;
  perspective: 1600px;
  overflow: hidden;
  z-index: 2;
  touch-action: none;
}

.lens {
  position: relative;
  transform-origin: center center;
  will-change: transform;
}

.ink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: multiply;
}

body.marking .ink {
  pointer-events: auto;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Crect x='9' y='3' width='11' height='22' rx='2' fill='%23ffe14a' stroke='%236a4a00'/%3E%3C/svg%3E") 8 22, crosshair;
}

body.erasing .ink {
  pointer-events: auto;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28'%3E%3Crect x='6' y='8' width='16' height='12' rx='2' fill='%23f4d7c8' stroke='%235a4030'/%3E%3Crect x='10' y='4' width='8' height='6' rx='1' fill='%23c9a090'/%3E%3C/svg%3E") 8 16, cell;
}

.bar {
  position: absolute;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100vw - 16px);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

body.chrome-hidden .bar {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  z-index: 8;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(170, 200, 255, 0.35);
  background: rgba(6, 10, 28, 0.55);
  color: #e8eefc;
  backdrop-filter: blur(10px);
  border-radius: 50%;
  cursor: pointer;
  transform: translateY(-50%);
}

.nav-arrow.prev { left: 14px; }
.nav-arrow.next { right: 14px; }

.nav-arrow:hover {
  border-color: #c5d6ff;
  color: #fff;
  background: rgba(12, 20, 48, 0.75);
}

.nav-arrow svg {
  width: 22px;
  height: 22px;
  display: block;
}

.nav-arrow.prev svg { transform: translateX(-1px); }
.nav-arrow.next svg { transform: translateX(1px); }

.ink-btn {
  border: 0;
  background: #ffe14a;
  color: #3a2a00;
  padding: 11px 18px;
  border-radius: 999px;
  font: 600 12px/1 system-ui, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

.ink-btn[aria-pressed="true"] {
  background: #ffd000;
  box-shadow: 0 0 0 3px rgba(255, 225, 74, 0.45);
}

.erase-btn {
  border: 0;
  background: #f3d0bf;
  color: #4a2f24;
  padding: 11px 18px;
  border-radius: 999px;
  font: 600 12px/1 system-ui, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

.erase-btn[aria-pressed="true"] {
  background: #e8b49a;
  box-shadow: 0 0 0 3px rgba(232, 180, 154, 0.5);
}

.social {
  position: absolute;
  top: 18px;
  right: 16px;
  z-index: 8;
  display: flex;
  gap: 8px;
}

.social a {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #f2f5ff;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 50%;
}

.social a:hover {
  color: #fff;
  background: rgba(255,255,255,0.18);
}

.social svg {
  width: 16px;
  height: 16px;
  display: block;
}

.stage.zoomed {
  animation: none;
}

.stage.zoomed img {
  animation: none;
}

.tilt {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 8px 10px 72px;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.stage {
  position: relative;
  transform-style: preserve-3d;
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 36%, rgba(255, 236, 200, 0.14) 50%, transparent 64%);
  background-size: 220% 100%;
  animation: shine 11s ease-in-out infinite;
}

@keyframes shine {
  0%, 100% { background-position: 120% 0; opacity: 0.2; }
  45% { background-position: -20% 0; opacity: 1; }
}

.stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(96vw, 1600px);
  max-height: calc(100dvh - 84px);
  object-fit: contain;
  transform-origin: center center;
}

.stage.turn img {
  animation: none;
}

.stage.leaving {
  animation: none;
  transform: rotateY(-18deg) translateX(-8%) scale(0.96);
  opacity: 0;
  transition: transform 0.9s ease, opacity 0.9s ease;
}

.stage.entering {
  animation: none;
  opacity: 0;
  transform: rotateY(16deg) translateX(8%) scale(0.96);
}

.stage.entering.on {
  opacity: 1;
  transform: none;
  transition: transform 1.1s ease, opacity 1.1s ease;
}

.whole {
  border: 1px solid rgba(170, 200, 255, 0.35);
  background: rgba(6, 10, 28, 0.55);
  color: #e8eefc;
  backdrop-filter: blur(10px);
  padding: 11px 18px;
  border-radius: 999px;
  font: 500 12px/1 system-ui, sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
}

.whole:hover {
  border-color: #c5d6ff;
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .stage, .stage img { animation: none; }
}
