/* ── CrazyTime Bonus Board — Cash Hunt Style ──────────────────────────────── */

/* Overlay container */
#ct-bonus-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
#ct-bonus-overlay.cbo-visible {
  opacity: 1;
  pointer-events: all;
}

/* Blurred dark backdrop */
.cbo-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Modal panel */
.cbo-modal {
  position: relative;
  width: min(96vw, 760px);
  max-height: 94vh;
  overflow-y: auto;
  border-radius: 20px;
  padding: 24px 20px 28px;
  box-shadow:
    0 0 0 2px var(--bonus-color, #651FFF),
    0 0 50px var(--bonus-glow, rgba(101,31,255,.5)),
    0 24px 80px rgba(0,0,0,.8);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: cbo-pop 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes cbo-pop {
  from { transform: scale(0.7) translateY(40px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

/* Header */
.cbo-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.cbo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px currentColor);
  animation: cbo-pulse-icon 1.6s ease-in-out infinite;
}
@keyframes cbo-pulse-icon {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}
.cbo-title {
  font-size: clamp(18px, 3.5vw, 26px);
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0;
  text-shadow: 0 0 20px var(--bonus-color, #651FFF);
  font-family: Arial, sans-serif;
}

/* Subline: instruction + timer */
.cbo-subline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.cbo-instruction {
  color: #e0e0e0;
  font-size: 14px;
  font-family: Arial, sans-serif;
  flex: 1;
}

/* Circular countdown timer */
.cbo-timer-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}
.cbo-timer-ring {
  width: 44px;
  height: 44px;
  transform: rotate(-90deg);
}
.cbo-timer-track {
  fill: none;
  stroke: rgba(255,255,255,0.12);
  stroke-width: 4;
}
.cbo-timer-arc {
  fill: none;
  stroke: var(--bonus-color, #651FFF);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.9s linear;
  filter: drop-shadow(0 0 4px var(--bonus-color, #651FFF));
}
.cbo-timer-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  font-family: Arial, sans-serif;
  transition: color 0.3s;
}
.cbo-timer-urgent { color: #FF5252 !important; }

/* 8 × 8 grid */
.cbo-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
@media (max-width: 500px) {
  .cbo-grid { gap: 4px; }
}

/* Individual box */
.cbo-box {
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--box-bg, #4527A0);
  border: 1.5px solid rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  perspective: 600px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  overflow: hidden;
}
.cbo-box:hover:not(.cbo-box-dimmed):not(.cbo-box-selected) {
  background: var(--box-hover, #512DA8);
  border-color: rgba(255,255,255,0.35);
  transform: scale(1.07);
  box-shadow: 0 0 14px var(--bonus-glow, rgba(101,31,255,.5));
}

/* Front (?) and back (multiplier) faces */
.cbo-box-front,
.cbo-box-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Arial, sans-serif;
  font-weight: 900;
  backface-visibility: hidden;
  transition: transform 0.55s ease;
  border-radius: inherit;
}
.cbo-box-front {
  font-size: clamp(12px, 2.2vw, 18px);
  color: rgba(255,255,255,0.7);
  transform: rotateY(0deg);
}
.cbo-box-back {
  font-size: clamp(9px, 1.6vw, 13px);
  color: #fff;
  background: linear-gradient(135deg, rgba(0,0,0,0.3), rgba(255,255,255,0.08));
  transform: rotateY(180deg);
}

/* Flipped state — reveals multiplier */
.cbo-box-flipped .cbo-box-front { transform: rotateY(-180deg); }
.cbo-box-flipped .cbo-box-back  { transform: rotateY(0deg); }

/* Selected box */
.cbo-box-selected {
  border-color: #fff !important;
  box-shadow:
    0 0 0 2px #fff,
    0 0 20px var(--bonus-color, #651FFF),
    0 0 40px var(--bonus-glow, rgba(101,31,255,.5)) !important;
  z-index: 2;
}

/* Dimmed non-selected boxes */
.cbo-box-dimmed {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

/* Flash highlight during shuffle */
.cbo-box-flash {
  background: rgba(255,255,255,0.3) !important;
  box-shadow: 0 0 12px #fff;
  border-color: #fff !important;
}

/* Win display */
.cbo-win {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  background: rgba(0,0,0,0.55);
  border-radius: 14px;
  border: 1.5px solid var(--bonus-color, #651FFF);
  box-shadow: 0 0 30px var(--bonus-glow, rgba(101,31,255,.4));
  animation: cbo-win-in 0.6s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes cbo-win-in {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.cbo-win-label {
  font-family: Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
}
.cbo-win-multi {
  font-family: Arial, sans-serif;
  font-size: clamp(40px, 10vw, 72px);
  font-weight: 900;
  color: var(--bonus-color, #651FFF);
  text-shadow: 0 0 30px var(--bonus-glow, rgba(101,31,255,.7));
  line-height: 1;
  animation: cbo-number-pop 0.5s cubic-bezier(0.34,1.56,0.64,1) both 0.2s;
}
@keyframes cbo-number-pop {
  from { transform: scale(0.3); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.cbo-win-amount {
  font-family: Arial, sans-serif;
  font-size: clamp(18px, 4vw, 28px);
  font-weight: 700;
  color: #69FF47;
  text-shadow: 0 0 12px rgba(105,255,71,0.6);
}
.cbo-close-btn {
  margin-top: 8px;
  padding: 12px 32px;
  border-radius: 50px;
  border: 2px solid var(--bonus-color, #651FFF);
  background: linear-gradient(135deg, var(--bonus-color, #651FFF), rgba(0,0,0,0.4));
  color: #fff;
  font-family: Arial, sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.15s, box-shadow 0.15s;
}
.cbo-close-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px var(--bonus-glow, rgba(101,31,255,.6));
}
.cbo-close-btn:active { transform: scale(0.97); }
