/* Shared cube net grid and 3D scene primitives */

.cube-net {
  display: grid;
  grid-template-columns: repeat(4, 42px);
  grid-template-rows: repeat(3, 42px);
  gap: 3px;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}

.cube-net .cell {
  width: 42px;
  height: 42px;
  background: var(--net-cell-bg, #fff);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--ink);
  border: 2px solid var(--net-cell-border, #111827);
  border-radius: 4px;
  box-sizing: border-box;
  overflow: hidden;
}

.cube-net .cell-icon {
  display: inline-block;
  line-height: 1;
  transform: rotate(var(--icon-rotate, 0deg));
  transition: transform 0.25s ease;
}

.cube-net .empty {
  width: 42px;
  height: 42px;
  visibility: hidden;
}

.cube-stage {
  background: var(--net-stage-bg, #fff);
  border: 1px dashed var(--net-stage-border, #9ca3af);
  border-radius: 12px;
  padding: 32px 28px;
  margin-bottom: 12px;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cube-scene {
  width: 100%;
  max-width: 400px;
  height: 400px;
  min-height: 400px;
  margin: 0 auto;
  perspective: 900px;
  position: relative;
  overflow: visible;
}

.cube-scene .cube {
  width: 200px;
  height: 200px;
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -100px 0 0 -100px;
  transform-style: preserve-3d;
  transform-origin: center center;
  transition: transform 0.55s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.cube-scene .face {
  position: absolute;
  width: 200px;
  height: 200px;
  background: #fff;
  color: #111827;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 48px;
  border: 2px solid #111827;
  box-sizing: border-box;
  backface-visibility: hidden;
  border-radius: 4px;
  overflow: hidden;
}

.cube-scene .face-icon {
  display: inline-block;
  line-height: 1;
  transform: rotate(var(--icon-rotate, 0deg));
  transition: transform 0.35s ease;
}

.cube-scene .front {
  transform: rotateY(0deg) translateZ(100px);
}
.cube-scene .back {
  transform: rotateY(180deg) translateZ(100px);
}
.cube-scene .right {
  transform: rotateY(90deg) translateZ(100px);
}
.cube-scene .left {
  transform: rotateY(-90deg) translateZ(100px);
}
.cube-scene .top {
  transform: rotateX(90deg) translateZ(100px);
}
.cube-scene .bottom {
  transform: rotateX(-90deg) translateZ(100px);
}

.cube-option-label {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid #111827;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
  background: #f9fafb;
  line-height: 1;
}

@keyframes cube-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

@media (max-width: 520px) {
  .cube-stage {
    min-height: 320px;
    padding: 24px 16px;
  }

  .cube-scene {
    max-width: 300px;
    height: 300px;
    min-height: 300px;
  }

  .cube-net {
    grid-template-columns: repeat(4, 36px);
    grid-template-rows: repeat(3, 36px);
  }

  .cube-net .cell,
  .cube-net .empty {
    width: 36px;
    height: 36px;
  }

  .cube-net .cell {
    font-size: 1.1rem;
  }
}
