.game-stop-the-bar {
  --bar-stage-art: none;
  --bar-position: 0%;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.portal-page.is-game-focus .mini-game-card:has(.game-stop-the-bar) {
  --game-card-play-min-height: 452px;
  --game-card-play-max-height: 780px;
  --game-stage-play-min-height: 300px;
}

.game-stop-the-bar .game-stage {
  min-height: 280px;
  border-top: 1px solid rgba(255, 255, 255, 0.72);
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 214, 94, 0.2), transparent 22%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(11, 16, 32, 0.1) 42%, rgba(11, 16, 32, 0.32)),
    var(--bar-stage-art) center / cover no-repeat,
    linear-gradient(180deg, #fff3e1, #101625);
  box-shadow:
    inset 0 10px 18px rgba(255, 255, 255, 0.18),
    inset 0 -18px 28px rgba(11, 16, 32, 0.32);
}

.game-stop-the-bar .game-stage::before {
  z-index: 0;
  inset: auto 12% 24px;
  height: 28px;
  border-radius: 999px;
  background: rgba(11, 16, 32, 0.4);
  filter: blur(18px);
}

.game-stop-the-bar .game-stage::after {
  z-index: 1;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 214, 94, 0.24), transparent 18%),
    radial-gradient(circle at 84% 14%, rgba(255, 255, 255, 0.2), transparent 18%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 58%, rgba(11, 16, 32, 0.18));
}

.portal-page.is-game-focus .game-stop-the-bar .game-stage {
  height: clamp(292px, calc(100svh - 330px), 380px);
  min-height: 292px;
}

@supports (height: 100dvh) {
  .portal-page.is-game-focus .game-stop-the-bar .game-stage {
    height: clamp(292px, calc(100dvh - 330px), 380px);
  }
}

.portal-page.is-game-focus .game-stop-the-bar:not(.is-countdown):not(.is-playing):not(.is-completing):not(.is-finished) .game-stage {
  height: clamp(352px, 55svh, 420px);
  min-height: 352px;
}

@supports (height: 100dvh) {
  .portal-page.is-game-focus .game-stop-the-bar:not(.is-countdown):not(.is-playing):not(.is-completing):not(.is-finished) .game-stage {
    height: clamp(352px, 55dvh, 420px);
  }
}

.portal-page.is-game-focus .game-stop-the-bar.is-countdown .game-stage,
.portal-page.is-game-focus .game-stop-the-bar.is-playing .game-stage,
.portal-page.is-game-focus .game-stop-the-bar.is-completing .game-stage {
  height: clamp(318px, calc(100svh - 236px), 560px);
  min-height: var(--game-stage-play-min-height);
}

@supports (height: 100dvh) {
  .portal-page.is-game-focus .game-stop-the-bar.is-countdown .game-stage,
  .portal-page.is-game-focus .game-stop-the-bar.is-playing .game-stage,
  .portal-page.is-game-focus .game-stop-the-bar.is-completing .game-stage {
    height: clamp(318px, calc(100dvh - 236px), 560px);
  }
}

@supports selector(:has(*)) {
  .portal-page.is-game-focus .game-stop-the-bar.is-countdown .game-stage,
  .portal-page.is-game-focus .game-stop-the-bar.is-playing .game-stage,
  .portal-page.is-game-focus .game-stop-the-bar.is-completing .game-stage {
    height: clamp(318px, calc(100dvh - 236px), 560px);
    min-height: var(--game-stage-play-min-height);
  }
}

.game-stop-the-bar.is-finished .game-stage {
  height: auto;
  min-height: 0;
  background: #ffffff;
}

.game-stop-the-bar.is-finished .game-overlay {
  position: static;
  display: block;
  padding: 12px 16px;
  background: #ffffff;
  backdrop-filter: none;
}

.game-stop-the-bar.is-finished .game-overlay-panel {
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
}

.game-stop-the-bar.is-finished .game-overlay-panel h2 {
  margin: 0;
  color: var(--color-primary);
  font-size: 14px;
  line-height: 1.2;
}

.bar-machine {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  isolation: isolate;
  width: min(92%, 456px);
  padding: 28px 18px 18px;
  border: 2px solid rgba(255, 236, 156, 0.92);
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.4), transparent 26%),
    linear-gradient(180deg, #6dc8ff 0 28%, #78d786 28% 42%, #4f5a63 42% 100%);
  box-shadow:
    0 30px 42px rgba(23, 28, 35, 0.32),
    0 0 0 6px rgba(255, 214, 94, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    inset 0 -16px 22px rgba(16, 20, 26, 0.24);
  transform: translate(-50%, -50%);
}

.bar-machine::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 0;
  width: 82px;
  height: 18px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 20% 50%, #ff4050 0 5px, transparent 6px),
    radial-gradient(circle at 50% 50%, #ffd65e 0 5px, transparent 6px),
    radial-gradient(circle at 80% 50%, #28d38c 0 5px, transparent 6px),
    linear-gradient(180deg, #25313a, #111820);
  box-shadow:
    0 4px 0 rgba(17, 24, 32, 0.22),
    0 0 12px rgba(255, 214, 94, 0.34);
  transform: translateX(-50%);
}

.bar-machine::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 9px;
  z-index: 0;
  height: 18px;
  border-radius: 999px;
  background: rgba(22, 27, 34, 0.22);
  filter: blur(10px);
}

.bar-score-callout {
  position: relative;
  z-index: 2;
  min-height: 46px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  color: #ffffff;
  font-size: 28px;
  font-weight: 950;
  text-shadow:
    0 3px 0 rgba(17, 24, 32, 0.26),
    0 0 18px rgba(255, 214, 94, 0.36);
}

.bar-track {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 86px;
  isolation: isolate;
  overflow: hidden;
  border: 2px solid rgba(255, 236, 156, 0.88);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(16, 20, 26, 0.18)),
    linear-gradient(180deg, #5b646f, #2e343b 48%, #222831);
  box-shadow:
    inset 0 2px 12px rgba(0, 0, 0, 0.34),
    0 9px 18px rgba(21, 26, 34, 0.24);
  touch-action: manipulation;
  cursor: pointer;
}

.bar-track::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 50%;
  z-index: 0;
  height: 6px;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.82) 0 24px, transparent 24px 44px);
  opacity: 0.7;
  transform: translateY(-50%);
}

.bar-track::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 88px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 214, 94, 0.2) 0 34%, transparent 72%);
  transform: translate(-50%, -50%);
  animation: bar-checkpoint-pulse 980ms ease-in-out infinite;
}

.bar-zone {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 50%;
  z-index: 1;
  border-radius: 12px;
  transform: translateX(-50%);
}

.bar-zone--ok {
  width: 18%;
  background: rgba(118, 215, 134, 0.18);
}

.bar-zone--close {
  width: 10%;
  background: rgba(255, 214, 94, 0.28);
}

.bar-zone--perfect {
  z-index: 3;
  width: 4.5%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.44), transparent),
    rgba(40, 211, 140, 0.62);
  box-shadow: 0 0 24px rgba(40, 211, 140, 0.64);
}

.bar-car-target {
  position: absolute;
  top: 53%;
  left: 50%;
  z-index: 4;
  width: 104px;
  height: 45px;
  pointer-events: none;
  background: url("/assets/games/stop-the-bar/porsche-911-target.svg") center / contain no-repeat;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 10px rgba(255, 245, 170, 0.72));
}

.bar-indicator {
  position: absolute;
  top: 53%;
  left: var(--bar-position);
  z-index: 5;
  width: 86px;
  height: 37px;
  background: transparent;
  transform: translate(-50%, -50%);
  will-change: left;
}

.bar-indicator::before,
.bar-car-shadow {
  position: absolute;
  display: block;
  pointer-events: none;
}

.bar-indicator::before {
  content: "";
  inset: 0;
  z-index: 2;
  background: url("/assets/games/stop-the-bar/porsche-911-line.svg?v=2") center / contain no-repeat;
  filter:
    drop-shadow(0 0 5px rgba(255, 236, 156, 0.5))
    drop-shadow(0 3px 3px rgba(12, 18, 24, 0.46));
}

.bar-car-shadow {
  left: 7px;
  right: 7px;
  bottom: 0;
  height: 6px;
  border-radius: 999px;
  background: rgba(12, 18, 24, 0.34);
  filter: blur(2px);
}

.bar-legend {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  color: #ffe58f;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.bar-legend span {
  flex: 1;
  text-align: center;
  text-shadow: 0 2px 0 rgba(83, 0, 9, 0.28);
}

.bar-legend span:nth-child(2) {
  color: #ffd278;
}

.bar-legend span:nth-child(3) {
  color: #bfffdc;
}

.game-stop-the-bar.is-hit .bar-machine {
  animation: bar-machine-hit 260ms ease-out;
}

.game-stop-the-bar.is-hit .bar-indicator {
  animation: bar-car-brake 260ms cubic-bezier(0.18, 1.4, 0.28, 1);
}

.game-stop-the-bar.is-hit .bar-score-callout {
  color: #ffffff;
  animation: bar-score-pop 260ms cubic-bezier(0.18, 1.4, 0.28, 1);
}

.game-stop-the-bar.is-hit .bar-track {
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.32),
    0 0 28px rgba(255, 214, 94, 0.5),
    0 12px 22px rgba(80, 0, 10, 0.22);
}

.game-stop-the-bar.is-miss .bar-machine {
  animation: bar-machine-miss 240ms ease-out;
}

.game-stop-the-bar.is-miss .bar-indicator {
  animation: bar-car-skid 240ms ease-out;
}

.game-stop-the-bar.is-miss .bar-score-callout {
  color: #ffb2b8;
}

.bar-stop-burst {
  --burst-core: rgba(255, 255, 255, 0.92);
  --burst-edge: #ffd65e;
  --burst-label: #ffffff;
  position: absolute;
  z-index: 8;
  width: 0;
  height: 0;
  pointer-events: none;
}

.bar-stop-burst--miss {
  --burst-core: #ffc2c8;
  --burst-edge: #ff4350;
  --burst-label: #ffd6da;
}

.bar-stop-burst > span,
.bar-stop-burst > strong {
  position: absolute;
  left: 0;
  top: 0;
}

.bar-stop-burst-flare {
  width: 62px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 26% 56%, var(--burst-core) 0 22%, transparent 24%),
    radial-gradient(circle at 54% 42%, var(--burst-core) 0 22%, transparent 24%),
    radial-gradient(circle at 76% 62%, var(--burst-core) 0 18%, transparent 20%),
    radial-gradient(circle, rgba(255, 214, 94, 0.48), transparent 62%);
  transform: translate(-50%, -50%) scale(0.28);
  animation: bar-burst-flare 420ms ease-out forwards;
}

.bar-stop-burst-ring {
  width: 38px;
  height: 38px;
  border: 3px solid var(--burst-core);
  border-radius: 50%;
  box-shadow: 0 0 18px var(--burst-edge);
  transform: translate(-50%, -50%) scale(0.38);
  animation: bar-burst-ring 620ms ease-out forwards;
}

.bar-stop-burst-spark {
  width: 8px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, var(--burst-edge));
  box-shadow: 0 0 10px var(--burst-edge);
  transform: translate(-50%, -50%) rotate(var(--spark-angle)) translateY(-10px) scaleY(0.58);
  transform-origin: center;
  animation: bar-burst-spark 680ms ease-out forwards;
}

.bar-stop-burst strong {
  min-width: 78px;
  color: var(--burst-label);
  font-size: 20px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 2px 0 rgba(84, 0, 10, 0.38),
    0 0 16px var(--burst-edge);
  transform: translate(-50%, -54%) scale(0.58);
  animation: bar-burst-label 620ms cubic-bezier(0.18, 1.4, 0.28, 1) forwards;
}

@keyframes bar-checkpoint-pulse {
  0%,
  100% {
    box-shadow:
      0 0 18px rgba(255, 214, 94, 0.58),
      inset 0 0 14px rgba(255, 245, 170, 0.28);
  }
  50% {
    box-shadow:
      0 0 30px rgba(34, 220, 143, 0.76),
      inset 0 0 18px rgba(255, 245, 170, 0.4);
  }
}

@keyframes bar-car-brake {
  0% {
    transform: translate(-50%, -50%) scale(1);
  }
  58% {
    transform: translate(-50%, -50%) scale(1.08) rotate(-2deg);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes bar-car-skid {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  30% {
    transform: translate(calc(-50% - 6px), -50%) rotate(-3deg);
  }
  70% {
    transform: translate(calc(-50% + 5px), -50%) rotate(2deg);
  }
}

@keyframes bar-machine-hit {
  0% {
    transform: translate(-50%, -50%) scale(1);
  }
  55% {
    transform: translate(-50%, -50%) scale(1.028);
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes bar-machine-miss {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  28% {
    transform: translate(calc(-50% - 5px), -50%);
  }
  62% {
    transform: translate(calc(-50% + 5px), -50%);
  }
}

@keyframes bar-score-pop {
  0% {
    transform: scale(0.76);
  }
  72% {
    transform: scale(1.14);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes bar-burst-flare {
  0% {
    opacity: 0.96;
    transform: translate(-50%, -50%) scale(0.2);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.55);
  }
}

@keyframes bar-burst-ring {
  0% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(0.34);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(2.2);
  }
}

@keyframes bar-burst-spark {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(var(--spark-angle)) translateY(-8px) scaleY(0.6);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--spark-angle)) translateY(-72px) scaleY(0.95);
  }
}

@keyframes bar-burst-label {
  0% {
    opacity: 0;
    transform: translate(-50%, -44%) scale(0.58);
  }
  42% {
    opacity: 1;
    transform: translate(-50%, -74%) scale(1.16);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -112%) scale(0.9);
  }
}

.game-stop-the-bar .game-overlay {
  z-index: 6;
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.58), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(11, 16, 32, 0.22));
  backdrop-filter: none;
}

.game-stop-the-bar .game-overlay-panel {
  width: min(284px, 100%);
  padding: 16px 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 248, 230, 0.86)),
    rgba(255, 255, 255, 0.9);
  box-shadow:
    0 14px 28px rgba(11, 16, 32, 0.2),
    0 0 0 6px rgba(255, 255, 255, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.bar-ready-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 11px;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(180deg, #ff4450, #bc1620);
  font-size: 11px;
  font-weight: 900;
}

.bar-ready-art {
  position: relative;
  width: 132px;
  height: 76px;
  margin: 10px auto 4px;
  border: 2px solid #ffd65e;
  border-radius: 18px;
  background:
    linear-gradient(180deg, #81d2ff 0 33%, #78d786 33% 45%, #4c555f 45% 100%);
  box-shadow:
    0 14px 22px rgba(21, 26, 34, 0.18),
    inset 0 -12px 18px rgba(17, 24, 32, 0.18);
  overflow: hidden;
}

.bar-ready-art::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 45px;
  height: 6px;
  border: 0;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.84) 0 18px, transparent 18px 34px),
    linear-gradient(90deg, transparent 0 36%, rgba(255, 214, 94, 0.72) 36% 64%, transparent 64%);
  box-shadow:
    0 -16px 0 14px rgba(255, 214, 94, 0.18),
    0 -16px 0 16px rgba(255, 245, 170, 0.78);
}

.bar-ready-art::after {
  content: "";
  position: absolute;
  left: 15px;
  top: 32px;
  width: 86px;
  height: 37px;
  background: url("/assets/games/stop-the-bar/porsche-911-line.svg?v=2") center / contain no-repeat;
  filter:
    drop-shadow(0 0 5px rgba(255, 236, 156, 0.48))
    drop-shadow(0 5px 5px rgba(18, 24, 32, 0.24));
  animation: bar-ready-marker 1.35s ease-in-out infinite;
}

@keyframes bar-ready-marker {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(31px);
  }
}
