:root {
  --bg: #0b0d10;
  --digit: #f5f2ea;
  --muted: #8b93a7;
  --accent: #e8c547;
  --flap: #1c222c;
  --shadow: rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a2230 0%, transparent 55%),
    var(--bg);
  color: var(--digit);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  cursor: pointer;
  user-select: none;
}

.board {
  width: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: 75% 25%;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1vh;
  min-height: 0;
  padding: 1vh 1vw 0;
}

.label {
  letter-spacing: 0.35em;
  text-transform: uppercase;
  font-size: clamp(0.65rem, 1.2vh, 0.9rem);
  color: var(--muted);
  flex-shrink: 0;
}

.sound-tip {
  flex-shrink: 0;
  font-size: clamp(0.75rem, 1.6vh, 1rem);
  color: var(--accent);
  letter-spacing: 0.04em;
}

.sound-tip[hidden] {
  display: none;
}

.flaps {
  /* JS sets --digits to 4 / 5 / 6 — grid utne equal columns banata hai */
  --digits: 4;
  --gap: clamp(0.25rem, 0.9vw, 0.75rem);
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--digits), minmax(0, 1fr));
  align-items: center;
  gap: var(--gap);
  width: 100%;
  min-height: 0;
  perspective: 1400px;
  padding: 0 1.5vw 1vh;
}

.flap {
  position: relative;
  container-type: size;
  width: 100%;
  height: min(58vh, 88%);
  justify-self: stretch;
  background: var(--flap);
  border-radius: 0.45rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 24px var(--shadow);
  overflow: hidden;
  transform-style: preserve-3d;
}

.flap::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  background: rgba(0, 0, 0, 0.65);
  z-index: 4;
  transform: translateY(-50%);
  pointer-events: none;
}

.flap .half {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flap .top {
  top: 0;
  background: linear-gradient(180deg, #2a3240, #1a2029);
}

.flap .bottom {
  bottom: 0;
  background: linear-gradient(180deg, #151a22, #0e1218);
}

.flap .char {
  position: absolute;
  left: 0;
  width: 100%;
  height: 200%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Roboto Mono", "Courier New", monospace;
  font-weight: 700;
  /* Har flap ke andar fit — 4/5/6 digit automatic */
  font-size: min(78cqw, 52cqh);
  color: var(--digit);
  line-height: 1;
  user-select: none;
}

.flap .top .char {
  top: 0;
}

.flap .bottom .char {
  bottom: 0;
}

.flap .static-top,
.flap .static-bottom {
  z-index: 1;
}

.flap .flip-top {
  z-index: 3;
  transform-origin: bottom center;
  transform: rotateX(0deg);
}

.flap .flip-bottom {
  z-index: 2;
  transform-origin: top center;
  transform: rotateX(90deg);
}

.flap.animate .flip-top {
  animation: flipTop 0.35s ease-in forwards;
}

.flap.animate .flip-bottom {
  animation: flipBottom 0.35s ease-out 0.35s forwards;
}

@keyframes flipTop {
  from {
    transform: rotateX(0deg);
  }
  to {
    transform: rotateX(-90deg);
  }
}

@keyframes flipBottom {
  from {
    transform: rotateX(90deg);
  }
  to {
    transform: rotateX(0deg);
  }
}

.meta {
  container-type: size;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0.6vh;
  min-height: 0;
  padding: 1vh 2vw;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.meta-row {
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 2vw;
  gap: 3vw;
  box-sizing: border-box;
}

/* LEFT: naam — meta height ka ~55%, koi chhota max-cap nahi */
.meta .name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: min(8vw, 55cqh);
  font-weight: 600;
  /* line-height: 1; */
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* RIGHT: amount — almost same scale */
.meta .amount {
  flex: 0 0 auto;
  font-size: min(7vw, 50cqh);
  font-weight: 600;
  /* line-height: 1; */
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}
