#cube-viewport,
.cube-viewport {
  position: relative;
  width: 100%;
  height: clamp(280px, 35vw, 480px);
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  cursor: grab;
  background: var(--bg-surface-alt, #faf8f3);
  border-radius: 6px;
  box-sizing: border-box;
}

#cube-viewport:active,
.cube-viewport:active {
  cursor: grabbing;
}

#cube-viewport:focus-visible,
.cube-viewport:focus-visible {
  outline: 2px solid var(--accent-forest, #184a3b);
  outline-offset: 2px;
}

.cube-scene {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 900px;
  perspective-origin: 50% 50%;
  transform-style: preserve-3d;
  pointer-events: none;
  box-sizing: border-box;
}

.cube-camera {
  position: absolute;
  width: 0;
  height: 0;
  left: 50%;
  top: 50%;
  transform-style: preserve-3d;
  transform-origin: 0 0 0;
  will-change: transform;
}

.cube-object {
  position: absolute;
  width: 0;
  height: 0;
  left: 0;
  top: 0;
  transform-style: preserve-3d;
  transform-origin: 0 0 0;
}

.cube-layer {
  position: absolute;
  width: 0;
  height: 0;
  left: 0;
  top: 0;
  transform-style: preserve-3d;
  transform-origin: 0 0 0;
  will-change: transform;
}

.cube-sticker {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--sticker-size, 44px);
  height: var(--sticker-size, 44px);
  margin-left: calc(-1 * var(--sticker-size, 44px) / 2);
  margin-top: calc(-1 * var(--sticker-size, 44px) / 2);
  transform-style: preserve-3d;
  transform-origin: center center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-sizing: border-box;
  padding: 1.5px;
  background-color: #111418;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.cube-sticker-inner {
  width: 100%;
  height: 100%;
  border-radius: 2.5px;
  background-color: var(--sticker-color, #ffffff);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14), inset 1px 1px 2px rgba(255, 255, 255, 0.28);
  box-sizing: border-box;
  transition: filter 0.15s ease;
}

.cube-sticker:hover .cube-sticker-inner {
  filter: brightness(1.08);
}

.cube-face-label {
  position: absolute;
  left: 0;
  top: 0;
  transform-style: preserve-3d;
  transform-origin: center center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 2px 7px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-hairline, #eaeaea);
  border-radius: 4px;
  color: var(--text-primary, #1d231f);
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  box-sizing: border-box;
}

.cube-face-letter {
  font-weight: 700;
  color: var(--accent-forest, #184a3b);
}

.cube-face-name {
  font-size: 10px;
  color: var(--text-secondary, #48544c);
}

.cube-unsupported {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  text-align: center;
  color: #334155;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  font-family: var(--font-sans, system-ui, sans-serif);
  max-width: 90%;
  margin: auto;
  box-sizing: border-box;
}

.cube-unsupported-title {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: #0f172a;
}

.cube-unsupported-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #64748b;
}

@media (max-width: 640px) {
  #cube-viewport,
  .cube-viewport {
    min-height: 240px;
  }

  .cube-face-label {
    padding: 1.5px 5px;
    font-size: 10px;
  }

  .cube-face-name {
    font-size: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cube-camera,
  .cube-object,
  .cube-layer,
  .cube-sticker {
    transition: none !important;
    animation-duration: 0.001ms !important;
  }
}
