/* Mini-game polish layer: visual-only upgrades that preserve existing game logic. */

.mg-overlay {
  padding: 18px;
  background:
    radial-gradient(circle at 50% 18%, rgba(249, 115, 22, 0.18), transparent 30%),
    radial-gradient(circle at 15% 85%, rgba(96, 165, 250, 0.14), transparent 26%),
    rgba(2, 4, 9, 0.86);
  backdrop-filter: blur(10px) saturate(1.1);
}

.mg-card {
  position: relative;
  width: min(560px, 100%);
  overflow: hidden;
  border-radius: 24px;
  border-color: rgba(249, 115, 22, 0.62);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), transparent 28%),
    radial-gradient(circle at 88% 14%, rgba(249, 115, 22, 0.18), transparent 24%),
    radial-gradient(circle at 12% 88%, rgba(96, 165, 250, 0.12), transparent 24%),
    linear-gradient(180deg, rgba(17, 17, 20, 0.98), rgba(5, 7, 12, 0.98));
  box-shadow:
    0 34px 80px rgba(0, 0, 0, 0.68),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 0 46px rgba(249, 115, 22, 0.22);
}

.mg-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.75), transparent 72%);
}

.mg-header,
.mg-content,
.mg-footer {
  position: relative;
  z-index: 1;
}

.mg-header {
  padding: 20px 20px 8px;
  text-align: center;
}

.mg-kicker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  margin-bottom: 7px;
  padding: 4px 9px;
  border: 1px solid rgba(249, 115, 22, 0.35);
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.1);
  color: #fdba74;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mg-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: clamp(22px, 5vw, 30px);
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(249, 115, 22, 0.22);
}

.mg-title::before {
  content: "";
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 12px;
  background:
    radial-gradient(circle at 35% 30%, #fff7ed 0 10%, transparent 11%),
    linear-gradient(145deg, #ffb03a, #f97316 58%, #7c2d12);
  box-shadow: 0 0 18px rgba(249, 115, 22, 0.45);
}

.mg-theme-card-flip-match .mg-title::before {
  border-radius: 8px;
  background:
    linear-gradient(135deg, transparent 42%, rgba(255, 255, 255, 0.3) 44%, transparent 48%),
    linear-gradient(145deg, #f97316, #1d4ed8);
}

.mg-theme-safe-cracker .mg-title::before {
  border-radius: 50%;
  background:
    radial-gradient(circle, #111827 0 27%, #f97316 28% 35%, #111827 36% 52%, #93c5fd 53% 58%, #111827 59%);
}

.mg-theme-laser-cut .mg-title::before {
  border-radius: 10px;
  background:
    linear-gradient(90deg, transparent 45%, #bfdbfe 46% 54%, transparent 55%),
    linear-gradient(145deg, #0f172a, #f97316);
}

.mg-content {
  padding: 10px 20px 16px;
}

.mg-footer {
  justify-content: center;
  padding: 0 20px 20px;
}

.mg-button-primary,
.mg-button-secondary {
  min-height: 46px;
  border-radius: 14px;
  transform: translateZ(0);
}

.mg-button-primary {
  min-width: 148px;
  color: #120804;
  background: linear-gradient(180deg, #ffd08a, #ff7a18 62%, #d9480f);
  box-shadow:
    0 10px 24px rgba(249, 115, 22, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.mg-button-secondary {
  min-width: 116px;
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(255, 255, 255, 0.16);
}

.mg-target-zone {
  border-style: solid;
  border-color: rgba(249, 115, 22, 0.42);
  background:
    linear-gradient(90deg, rgba(249, 115, 22, 0.16), rgba(96, 165, 250, 0.1)),
    rgba(255, 255, 255, 0.035);
  color: #fff7ed;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

.mg-timing-wrap {
  margin-top: 18px;
  padding: 18px 14px;
  border-radius: 18px;
  border: 1px solid rgba(96, 165, 250, 0.22);
  background: rgba(0, 0, 0, 0.24);
}

.mg-timing-track {
  height: 22px;
  overflow: visible;
  background:
    linear-gradient(90deg, rgba(96, 165, 250, 0.1), rgba(249, 115, 22, 0.08), rgba(96, 165, 250, 0.1)),
    #08111f;
}

.mg-target-zone-marker {
  top: -5px;
  height: calc(100% + 10px);
  border-color: rgba(249, 115, 22, 0.9);
  background: linear-gradient(90deg, rgba(249, 115, 22, 0.18), rgba(255, 208, 138, 0.54), rgba(249, 115, 22, 0.18));
  box-shadow: 0 0 22px rgba(249, 115, 22, 0.36);
}

.mg-timing-indicator {
  width: 16px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 10px;
  background: linear-gradient(180deg, #fff7ed, #ff7a18 58%, #7c2d12);
}

.mg-card-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.mg-flip-card {
  min-height: 118px;
}

.mg-card-face {
  border-radius: 16px;
}

.mg-card-back {
  border-color: rgba(249, 115, 22, 0.36);
  color: #fff7ed;
  font-size: 30px;
  background:
    radial-gradient(circle at 50% 18%, rgba(249, 115, 22, 0.28), transparent 30%),
    linear-gradient(145deg, #172033, #070b13);
}

.mg-card-back::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.mg-card-front {
  box-shadow: inset 0 0 16px rgba(255, 255, 255, 0.08);
}

.mg-card-face-main {
  font-size: clamp(26px, 6vw, 36px);
}

.mg-flip-card:not(:disabled):hover .mg-card-back {
  transform: translateY(-3px);
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.28), inset 0 0 12px rgba(249, 115, 22, 0.18);
}

.mg-safe-dial {
  width: min(300px, 74vw);
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.08) 0%, rgba(9, 12, 19, 0.88) 44%, rgba(2, 4, 9, 0.98) 100%),
    repeating-conic-gradient(from -2deg, rgba(255, 255, 255, 0.16) 0 2deg, transparent 2deg 15deg),
    conic-gradient(from 0deg, rgba(96, 165, 250, 0.12), rgba(249, 115, 22, 0.16), rgba(96, 165, 250, 0.12));
}

.mg-safe-zone {
  height: 8px;
  width: 23%;
  transform: rotate(var(--zone-angle)) translateX(calc((min(300px, 74vw) * 0.5) - 24px));
}

.mg-safe-center-cap {
  width: 28px;
  height: 28px;
  border-width: 2px;
}

.mg-safe-needle {
  width: 5px;
  height: 45%;
}

.mg-laser-stage {
  padding: 18px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 0%, rgba(96, 165, 250, 0.12), transparent 34%),
    rgba(2, 6, 12, 0.62);
}

.mg-laser-shape {
  height: 128px;
  border-radius: 18px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 25% 22%, rgba(96, 165, 250, 0.18), transparent 42%),
    radial-gradient(circle at 76% 78%, rgba(249, 115, 22, 0.22), transparent 42%),
    linear-gradient(180deg, #0a1020, #05070c);
  background-size: 18px 18px, 18px 18px, auto, auto, auto;
}

.mg-laser-target-zone {
  border-left-width: 2px;
  border-right-width: 2px;
}

.mg-laser-line {
  width: 4px;
  background: linear-gradient(180deg, #ffffff, #93c5fd 38%, #2563eb);
  box-shadow:
    0 0 10px rgba(255, 255, 255, 0.74),
    0 0 24px rgba(96, 165, 250, 0.72),
    0 0 44px rgba(96, 165, 250, 0.36);
}

.mg-laser-line::before,
.mg-laser-line::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: rgba(147, 197, 253, 0.9);
  filter: blur(4px);
}

.mg-laser-line::before { top: -7px; }
.mg-laser-line::after { bottom: -7px; }

.mg-results-panel {
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), transparent 42%),
    rgba(0, 0, 0, 0.42);
}

.mg-result-text.success {
  color: #86efac;
}

.mg-result-text.info {
  color: #bfdbfe;
}

.mg-result-text.fail {
  color: #fca5a5;
}

@media (max-width: 600px) {
  .mg-overlay {
    padding: 10px;
  }

  .mg-header {
    padding: 16px 14px 6px;
  }

  .mg-content {
    padding: 8px 14px 14px;
  }

  .mg-footer {
    padding: 0 14px 16px;
  }

  .mg-title {
    gap: 8px;
  }

  .mg-title::before {
    width: 28px;
    height: 28px;
    border-radius: 10px;
  }

  .mg-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mg-flip-card {
    min-height: 104px;
  }

  .mg-laser-shape {
    height: 112px;
  }
}
