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

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

.stage {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.clock {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.pair { display: flex; gap: 3px; }

.label {
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.28);
}

.sep {
  align-self: center;
  padding-bottom: 10px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.2);
  user-select: none;
}

.digit {
  --h: 32px;
  --w: 22px;
  --fs: 17px;
  position: relative;
  width: var(--w);
  height: var(--h);
  font-size: var(--fs);
  font-weight: 600;
  line-height: var(--h);
  border-radius: 4px;
  background: #111;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
  perspective: 160px;
}

.digit .face {
  position: absolute;
  left: 0;
  right: 0;
  height: 50%;
  overflow: hidden;
  background: #1a1a1a;
}

.digit .face .n {
  position: absolute;
  left: 0;
  right: 0;
  height: 200%;
  line-height: var(--h);
  text-align: center;
  color: #eee;
}

.digit .top {
  top: 0;
  border-radius: 4px 4px 0 0;
  border-bottom: 1px solid #000;
  z-index: 1;
}

.digit .top .n { top: 0; }

.digit .bottom {
  bottom: 0;
  border-radius: 0 0 4px 4px;
  z-index: 1;
}

/* нижняя половина: сдвиг ровно на высоту лица (−100%), без grid-center */
.digit .bottom .n { top: -100%; }

.digit .hinge {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 50%;
  transform-origin: bottom center;
  transform-style: preserve-3d;
  border-radius: 4px 4px 0 0;
  z-index: 4;
  display: none;
}

.digit .hinge .front,
.digit .hinge .back {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: #1a1a1a;
  border-radius: 4px 4px 0 0;
}

.digit .hinge .front .n,
.digit .hinge .back .n {
  position: absolute;
  left: 0;
  right: 0;
  height: 200%;
  line-height: var(--h);
  text-align: center;
  color: #eee;
}

/* front = верх текущей цифры */
.digit .hinge .front .n { top: 0; }

/* back после -180° становится низом следующей цифры */
.digit .hinge .back {
  transform: rotateX(180deg);
  background: #151515;
}
.digit .hinge .back .n { top: -100%; }

.digit.flip .hinge {
  display: block;
  animation: hingeFlip 0.5s ease-in-out forwards;
}

@keyframes hingeFlip {
  from { transform: rotateX(0deg); }
  to { transform: rotateX(-180deg); }
}

@media (prefers-reduced-motion: reduce) {
  .digit.flip .hinge {
    animation: none;
    display: none;
  }
}
