.game-fast-tap-race {
  --race-stage-art: none;
  --race-speed: 0;
  --race-pace: 0;
  --race-intensity: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.portal-page.is-game-focus .mini-game-card:has(.game-fast-tap-race) {
  --game-card-play-min-height: 452px;
  --game-card-play-max-height: 780px;
  --game-stage-play-min-height: 322px;
}

.game-fast-tap-race .game-hud {
  gap: 6px;
  padding: 8px;
  border-bottom: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.13), transparent 36%),
    linear-gradient(180deg, #19345e 0%, #0b1736 66%, #070f24 100%);
  box-shadow: inset 0 -4px 0 rgba(2, 7, 19, 0.45);
}

.game-fast-tap-race .game-hud-item {
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid rgba(32, 200, 246, 0.28);
  border-radius: 12px;
  background: rgba(4, 16, 40, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.11),
    0 3px 0 rgba(0, 4, 16, 0.25);
}

.game-fast-tap-race .game-hud-label {
  color: #79e6ff;
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.08em;
}

.game-fast-tap-race .game-hud-value {
  color: #ffffff;
  font-size: 18px;
  line-height: 1;
  text-shadow: 0 0 12px rgba(32, 200, 246, 0.36);
}

.game-fast-tap-race .game-stage {
  min-height: 322px;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 24px 16px 18px;
  background:
    linear-gradient(180deg, rgba(3, 10, 25, 0.02) 0%, rgba(3, 10, 25, 0.06) 40%, rgba(3, 10, 25, 0.38) 100%),
    var(--race-stage-art) center / cover no-repeat,
    linear-gradient(180deg, #112449, #050b19);
}

.game-fast-tap-race .game-stage::before {
  z-index: 0;
  inset: auto 7% -22px;
  height: 58%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at center, rgba(32, 200, 246, calc(0.1 + var(--race-intensity) * 0.22)), transparent 62%),
    radial-gradient(ellipse at center, rgba(230, 33, 41, calc(var(--race-intensity) * 0.16)), transparent 70%);
  filter: blur(16px);
  transition: background 180ms ease;
}

.game-fast-tap-race .game-stage::after {
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(2, 7, 19, 0.24), transparent 12% 88%, rgba(2, 7, 19, 0.24)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 45%, rgba(2, 7, 19, 0.18));
}

.portal-page.is-game-focus .game-fast-tap-race:not(.is-countdown):not(.is-playing):not(.is-completing):not(.is-finished) .game-stage {
  min-height: clamp(364px, 50svh, 420px);
}

@supports (height: 100dvh) {
  .portal-page.is-game-focus .game-fast-tap-race:not(.is-countdown):not(.is-playing):not(.is-completing):not(.is-finished) .game-stage {
    min-height: clamp(364px, 50dvh, 420px);
  }
}

.portal-page.is-game-focus .game-fast-tap-race.is-countdown .game-stage,
.portal-page.is-game-focus .game-fast-tap-race.is-playing .game-stage,
.portal-page.is-game-focus .game-fast-tap-race.is-completing .game-stage {
  min-height: var(--game-stage-play-min-height);
  height: clamp(340px, calc(100svh - 236px), 566px);
}

@supports (height: 100dvh) {
  .portal-page.is-game-focus .game-fast-tap-race.is-countdown .game-stage,
  .portal-page.is-game-focus .game-fast-tap-race.is-playing .game-stage,
  .portal-page.is-game-focus .game-fast-tap-race.is-completing .game-stage {
    height: clamp(340px, calc(100dvh - 236px), 566px);
  }
}

@supports selector(:has(*)) {
  .portal-page.is-game-focus .game-fast-tap-race.is-countdown .game-stage,
  .portal-page.is-game-focus .game-fast-tap-race.is-playing .game-stage,
  .portal-page.is-game-focus .game-fast-tap-race.is-completing .game-stage {
    min-height: var(--game-stage-play-min-height);
    height: clamp(340px, calc(100dvh - 236px), 566px);
  }
}

.game-fast-tap-race.is-playing .game-stage {
  touch-action: manipulation;
}

.game-fast-tap-race.is-finished .game-stage {
  min-height: 0;
  height: auto;
  padding: 0;
  background: #ffffff;
}

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

.game-fast-tap-race.is-finished .game-overlay-panel {
  width: 100%;
  padding: 0;
  color: #111827;
  background: transparent;
  box-shadow: none;
  text-align: left;
}

.game-fast-tap-race.is-finished .game-overlay-panel h2 {
  color: #111827;
}

.race-console {
  position: relative;
  z-index: 3;
  display: grid;
  place-items: center;
  align-content: center;
  width: min(330px, 100%);
  min-height: 300px;
  padding-top: 4px;
}

.race-gauge {
  position: relative;
  width: min(270px, 85vw);
  height: 147px;
  overflow: hidden;
  filter: drop-shadow(0 16px 18px rgba(0, 3, 14, 0.46));
}

.race-gauge__dial,
.race-gauge__ticks {
  position: absolute;
  left: 50%;
  top: 6px;
  width: 244px;
  height: 244px;
  border-radius: 50%;
  transform: translateX(-50%);
}

.race-gauge__dial {
  border: 2px solid rgba(121, 230, 255, 0.38);
  background:
    radial-gradient(circle at 50% 50%, rgba(7, 15, 36, 0.97) 0 51%, transparent 52%),
    conic-gradient(
      /* Match the needle's 140deg upper arc: cool at left, redline at far right. */
      from 290deg,
      #20c8f6 0 32deg,
      #7be7ff 32deg 62deg,
      #ffd45a 62deg 98deg,
      #ff7a1a 98deg 122deg,
      #e62129 122deg 140deg,
      rgba(9, 22, 50, 0.7) 140deg 360deg
    );
  box-shadow:
    inset 0 0 0 10px rgba(4, 13, 32, 0.8),
    inset 0 0 34px rgba(32, 200, 246, 0.15),
    0 0 calc(7px + var(--race-intensity) * 24px) rgba(32, 200, 246, calc(0.16 + var(--race-intensity) * 0.28));
}

.race-gauge__dial::before {
  content: "";
  position: absolute;
  inset: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 30%, rgba(32, 200, 246, 0.1), transparent 42%),
    linear-gradient(180deg, #122344, #050b19 72%);
  box-shadow: inset 0 18px 34px rgba(0, 0, 0, 0.36);
}

.race-gauge__ticks {
  z-index: 2;
  background: repeating-conic-gradient(from 199deg, rgba(255, 255, 255, 0.76) 0 1deg, transparent 1deg 8deg);
  -webkit-mask: radial-gradient(circle, transparent 0 80px, #000 81px 91px, transparent 92px);
  mask: radial-gradient(circle, transparent 0 80px, #000 81px 91px, transparent 92px);
  clip-path: polygon(0 0, 100% 0, 100% 52%, 0 52%);
  opacity: 0.74;
}

.race-gauge__needle {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 128px;
  width: 92px;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd45a, #fff6ba 72%, #ffffff);
  box-shadow:
    0 0 10px rgba(255, 212, 90, 0.72),
    0 2px 4px rgba(0, 0, 0, 0.44);
  transform: rotate(calc(-160deg + var(--race-speed) * 1.4deg));
  transform-origin: 0 50%;
  transition: transform 120ms cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

.race-gauge__hub {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 128px;
  width: 25px;
  height: 25px;
  border: 4px solid #ffd45a;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #e62129 34%, #8e0d16 72%);
  box-shadow: 0 0 14px rgba(255, 212, 90, 0.54);
  transform: translate(-50%, -50%);
}

.race-gauge__readout {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 82px;
  min-width: 76px;
  color: #ffffff;
  font-size: 33px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 0 14px rgba(32, 200, 246, 0.65),
    0 3px 0 rgba(0, 0, 0, 0.4);
  transform: translateX(-50%);
}

.race-tap-pad {
  position: relative;
  z-index: 5;
  width: 164px;
  height: 164px;
  margin-top: -10px;
  padding: 12px;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.28), transparent 38%),
    linear-gradient(180deg, #7e1220, #3a0711);
  box-shadow:
    0 20px 30px rgba(0, 4, 17, 0.58),
    0 0 0 2px rgba(255, 212, 90, 0.62),
    0 0 calc(8px + var(--race-intensity) * 34px) rgba(230, 33, 41, calc(0.26 + var(--race-intensity) * 0.42)),
    inset 0 -9px 16px rgba(57, 4, 11, 0.68),
    inset 0 3px 0 rgba(255, 255, 255, 0.22);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transform: translateZ(0);
}

.race-tap-pad::before {
  content: "";
  position: absolute;
  inset: -9px;
  border: 2px solid rgba(32, 200, 246, 0.62);
  border-radius: 50%;
  box-shadow:
    0 0 18px rgba(32, 200, 246, 0.34),
    inset 0 0 16px rgba(32, 200, 246, 0.2);
  opacity: calc(0.55 + var(--race-intensity) * 0.45);
}

.race-tap-pad::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(255, 244, 188, 0.34);
  border-radius: 50%;
  box-shadow: inset 0 0 10px rgba(255, 212, 90, 0.14);
}

.race-tap-pad__glow {
  position: absolute;
  inset: -32px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 73, 69, calc(0.42 + var(--race-intensity) * 0.22)) 0 34%,
    rgba(230, 33, 41, 0.24) 52%,
    transparent 73%
  );
  opacity: 0.46;
  pointer-events: none;
  transform: scale(0.94);
  will-change: opacity, transform;
}

.game-fast-tap-race.is-playing .race-tap-pad__glow {
  animation: race-pad-ambient-glow 1500ms ease-in-out infinite;
}

.game-fast-tap-race.is-playing .race-tap-pad::before {
  border-color: rgba(255, 220, 101, 0.86);
  background: transparent;
  box-shadow: 0 0 18px rgba(255, 48, 58, 0.46), inset 0 0 10px rgba(255, 212, 90, 0.2);
  animation: race-pad-energy-wave 1500ms cubic-bezier(0.18, 0.72, 0.32, 1) infinite;
}

.race-tap-pad__surface {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  width: 100%;
  height: 100%;
  border: 3px solid rgba(255, 235, 178, 0.74);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.55), transparent 18%),
    radial-gradient(circle at 50% 35%, #ff5a58 0%, #e62129 42%, #a60f19 78%, #710812 100%);
  box-shadow:
    inset 0 8px 14px rgba(255, 255, 255, 0.12),
    inset 0 -11px 16px rgba(86, 4, 13, 0.5),
    0 5px 0 #5d0711;
  transform: translateY(-3px);
  transition: transform 70ms ease, box-shadow 70ms ease;
}

.game-fast-tap-race.is-playing .race-tap-pad__surface {
  animation: race-pad-rim-breathe 1500ms ease-in-out infinite;
}

.race-tap-pad__bolt {
  width: 29px;
  height: 42px;
  background: linear-gradient(180deg, #fffad1, #ffd45a 68%, #ff9f1c);
  clip-path: polygon(55% 0, 100% 0, 70% 40%, 100% 40%, 35% 100%, 47% 56%, 12% 56%);
  filter: drop-shadow(0 0 8px rgba(255, 212, 90, 0.66));
}

.race-tap-pad__label {
  color: #ffffff;
  font-size: 13px;
  font-weight: 950;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 rgba(79, 3, 10, 0.54);
}

.race-tap-pad:focus-visible {
  outline: 4px solid #ffffff;
  outline-offset: 5px;
}

.game-fast-tap-race.is-impacting .race-tap-pad__surface,
.race-tap-pad:active .race-tap-pad__surface {
  animation: none;
  box-shadow:
    inset 0 8px 14px rgba(255, 255, 255, 0.08),
    inset 0 -7px 12px rgba(86, 4, 13, 0.48),
    0 1px 0 #5d0711;
  transform: translateY(2px) scale(0.965);
}

.game-fast-tap-race.is-rate-limited .race-tap-pad {
  filter: saturate(0.72) brightness(0.86);
  transform: scale(0.97);
}

.game-fast-tap-race[data-speed-band="great"] .race-tap-pad::before {
  border-color: rgba(255, 212, 90, 0.9);
  box-shadow:
    0 0 28px rgba(255, 212, 90, 0.58),
    inset 0 0 20px rgba(255, 212, 90, 0.28);
}

.race-speed-lines {
  position: absolute;
  z-index: 2;
  top: 28%;
  bottom: 4%;
  width: 35%;
  overflow: hidden;
  opacity: calc(var(--race-intensity) * 0.78);
  pointer-events: none;
}

.race-speed-lines::before,
.race-speed-lines::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(180deg, transparent 0 20px, rgba(121, 230, 255, 0.88) 21px 24px, transparent 25px 42px);
  filter: drop-shadow(0 0 5px rgba(32, 200, 246, 0.5));
  transform: skewY(-22deg);
  animation: race-speed-stream calc(760ms - var(--race-pace) * 28ms) linear infinite;
}

.race-speed-lines::after {
  inset: 7% 18%;
  background: repeating-linear-gradient(180deg, transparent 0 32px, rgba(255, 212, 90, 0.72) 33px 36px, transparent 37px 58px);
  animation-duration: calc(980ms - var(--race-pace) * 34ms);
}

.race-speed-lines--left {
  left: -12%;
  transform: perspective(280px) rotateY(30deg);
}

.race-speed-lines--right {
  right: -12%;
  transform: scaleX(-1) perspective(280px) rotateY(30deg);
}

.race-impact-ring,
.race-impact-spark {
  position: absolute;
  z-index: 7;
  pointer-events: none;
}

.race-impact-ring {
  width: 62px;
  height: 62px;
  border: 4px solid rgba(255, 212, 90, 0.92);
  border-radius: 50%;
  box-shadow:
    0 0 18px rgba(255, 212, 90, 0.58),
    inset 0 0 14px rgba(255, 255, 255, 0.35);
  transform: translate(-50%, -50%);
  animation: race-impact-ring 440ms ease-out forwards;
}

.race-impact-spark {
  width: 5px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #ffd45a 58%, #ff7a1a);
  box-shadow: 0 0 9px rgba(255, 212, 90, 0.72);
  transform: translate(-50%, -50%);
  animation: race-impact-spark 460ms ease-out forwards;
}

.game-fast-tap-race .game-overlay {
  z-index: 9;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 30%, rgba(32, 200, 246, 0.13), transparent 42%),
    linear-gradient(180deg, rgba(2, 8, 22, 0.26), rgba(2, 8, 22, 0.6));
  backdrop-filter: blur(2px);
}

.game-fast-tap-race .game-overlay-panel {
  width: min(292px, 100%);
  padding: 16px 18px 18px;
  border: 1px solid rgba(121, 230, 255, 0.55);
  border-radius: 24px;
  color: #ffffff;
  background:
    radial-gradient(circle at 50% 0%, rgba(32, 200, 246, 0.2), transparent 46%),
    linear-gradient(180deg, rgba(18, 38, 75, 0.97), rgba(5, 13, 32, 0.98));
  box-shadow:
    0 22px 44px rgba(0, 3, 14, 0.55),
    0 0 0 6px rgba(32, 200, 246, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.game-fast-tap-race .game-overlay-panel h2 {
  color: #ffffff;
  text-shadow: 0 0 16px rgba(32, 200, 246, 0.36);
}

.game-fast-tap-race .game-overlay-panel p {
  color: #d7f6ff;
}

.race-ready-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 11px;
  border-radius: 999px;
  color: #0b1736;
  background: linear-gradient(180deg, #fff6a7, #ffd45a);
  box-shadow: 0 4px 12px rgba(255, 212, 90, 0.2);
  font-size: 11px;
  font-weight: 950;
}

.race-ready-art {
  position: relative;
  width: 112px;
  height: 100px;
  margin: 7px auto 3px;
}

.race-ready-art__heat {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 91, 66, 0.72) 0 24%, rgba(230, 33, 41, 0.38) 44%, transparent 70%);
  filter: blur(2px);
  animation: race-ready-heat 1500ms ease-in-out infinite;
}

.race-ready-pedal {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 82px;
  height: 82px;
  padding: 7px;
  border: 0;
  border-radius: 50%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.28), transparent 38%),
    linear-gradient(180deg, #7e1220, #3a0711);
  box-shadow:
    0 11px 18px rgba(0, 4, 17, 0.48),
    0 0 0 2px rgba(255, 212, 90, 0.66),
    0 0 24px rgba(230, 33, 41, 0.72),
    inset 0 -5px 9px rgba(57, 4, 11, 0.68),
    inset 0 2px 0 rgba(255, 255, 255, 0.22);
  transform: translate(-50%, -50%);
  animation: race-ready-pedal-glow 1500ms ease-in-out infinite;
}

.race-ready-pedal::before {
  content: "";
  position: absolute;
  inset: -7px;
  border: 2px solid rgba(255, 218, 94, 0.8);
  border-radius: 50%;
  animation: race-ready-energy-wave 1500ms cubic-bezier(0.18, 0.72, 0.32, 1) infinite;
}

.race-ready-pedal__surface {
  position: absolute;
  inset: 7px;
  display: block;
  border: 2px solid rgba(255, 235, 178, 0.82);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.55), transparent 18%),
    radial-gradient(circle at 50% 35%, #ff5a58 0%, #e62129 42%, #a60f19 78%, #710812 100%);
  box-shadow: inset 0 5px 8px rgba(255, 255, 255, 0.12), inset 0 -7px 10px rgba(86, 4, 13, 0.5), 0 3px 0 #5d0711;
}

.race-ready-pedal__bolt {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 23px;
  height: 34px;
  background: linear-gradient(180deg, #fffad1, #ffd45a 68%, #ff9f1c);
  clip-path: polygon(55% 0, 100% 0, 70% 40%, 100% 40%, 35% 100%, 47% 56%, 12% 56%);
  filter: drop-shadow(0 0 7px rgba(255, 212, 90, 0.72));
  transform: translate(-50%, -50%);
}

@keyframes race-pad-ambient-glow {
  0%, 100% { opacity: 0.44; transform: scale(0.94); }
  50% { opacity: 0.72; transform: scale(1.025); }
}

@keyframes race-pad-energy-wave {
  0% { opacity: 0.82; transform: scale(0.94); }
  68%, 100% { opacity: 0; transform: scale(1.28); }
}

@keyframes race-pad-rim-breathe {
  0%, 100% {
    border-color: rgba(255, 235, 178, 0.74);
    box-shadow: inset 0 8px 14px rgba(255, 255, 255, 0.12), inset 0 -11px 16px rgba(86, 4, 13, 0.5), 0 5px 0 #5d0711, 0 0 8px rgba(255, 48, 58, 0.36);
  }
  50% {
    border-color: rgba(255, 244, 194, 0.96);
    box-shadow: inset 0 8px 15px rgba(255, 255, 255, 0.16), inset 0 -11px 16px rgba(86, 4, 13, 0.46), 0 5px 0 #5d0711, 0 0 21px 5px rgba(255, 48, 58, 0.58);
  }
}

@keyframes race-speed-stream {
  from { transform: translateY(-30%) skewY(-22deg); }
  to { transform: translateY(30%) skewY(-22deg); }
}

@keyframes race-impact-ring {
  0% { opacity: 0.98; transform: translate(-50%, -50%) scale(0.48); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(calc(1.5 * var(--impact-scale))); }
}

@keyframes race-impact-spark {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(var(--spark-rot)) scaleY(0.7); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--spark-x)), calc(-50% + var(--spark-y))) rotate(var(--spark-rot)) scaleY(0.15); }
}

@keyframes race-ready-heat {
  0%, 100% { opacity: 0.58; transform: scale(0.92); }
  50% { opacity: 0.92; transform: scale(1.06); }
}

@keyframes race-ready-pedal-glow {
  0%, 100% { box-shadow: 0 11px 18px rgba(0, 4, 17, 0.48), 0 0 0 2px rgba(255, 212, 90, 0.66), 0 0 17px rgba(230, 33, 41, 0.58), inset 0 -5px 9px rgba(57, 4, 11, 0.68), inset 0 2px 0 rgba(255, 255, 255, 0.22); }
  50% { box-shadow: 0 11px 18px rgba(0, 4, 17, 0.48), 0 0 0 2px rgba(255, 226, 123, 0.86), 0 0 31px 8px rgba(230, 33, 41, 0.72), inset 0 -5px 9px rgba(57, 4, 11, 0.68), inset 0 2px 0 rgba(255, 255, 255, 0.22); }
}

@keyframes race-ready-energy-wave {
  0% { opacity: 0.82; transform: scale(0.92); }
  68%, 100% { opacity: 0; transform: scale(1.28); }
}

@media (max-width: 430px) {
  .race-console {
    min-height: 282px;
  }

  .race-gauge {
    width: 250px;
    transform: scale(0.94);
    transform-origin: 50% 100%;
  }

  .race-tap-pad {
    width: 154px;
    height: 154px;
    margin-top: -13px;
  }
}

@media (max-height: 700px) {
  .portal-page.is-game-focus .game-fast-tap-race.is-countdown .game-stage,
  .portal-page.is-game-focus .game-fast-tap-race.is-playing .game-stage,
  .portal-page.is-game-focus .game-fast-tap-race.is-completing .game-stage {
    min-height: 306px;
    height: clamp(306px, calc(100dvh - 220px), 430px);
  }

  .race-console {
    min-height: 272px;
    transform: scale(0.93);
  }
}
