/* AP Junior Racing Academy – visuelle Verfeinerungen */
.start-number {
  position: absolute;
  top: 18px;
  right: 21px;
  z-index: 2;
  display: grid;
  justify-items: end;
  gap: 1px;
  color: rgba(255,255,255,.48);
  font-size: .58rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.start-number strong {
  color: rgba(255,255,255,.22);
  font-size: 2.05rem;
  line-height: 1;
  letter-spacing: -.05em;
}
.driver-copy small { font-size: .9rem; }

.mission { min-height: 420px; }
.mission.done {
  border-color: rgba(255,216,74,.55);
  box-shadow: 0 15px 55px rgba(255,216,74,.08);
}
.mission.done::after {
  content: "★";
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid #fff0a2;
  border-radius: 50%;
  color: #5a4000;
  background: radial-gradient(circle at 35% 30%,#fff7b6,#ffd84a 58%,#dca100);
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  transform: none;
  box-shadow: 0 0 30px rgba(255,216,74,.28);
  animation: academy-star-pop .45s cubic-bezier(.2,.9,.3,1.35) both;
}
.mission.done .topline { padding-right: 56px; }
@keyframes academy-star-pop {
  from { opacity: 0; transform: scale(.25) rotate(-45deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

.mission-visual {
  display: grid;
  place-items: center;
  width: 150px;
  height: 112px;
  margin: 34px 0 22px;
  border: 1px solid rgba(184,243,74,.32);
  border-radius: 13px;
  color: inherit;
  background: radial-gradient(circle,rgba(184,243,74,.11),transparent 68%),#101410;
  font-size: inherit;
  overflow: hidden;
}
.memory-preview {
  grid-template-columns: repeat(2,48px);
  grid-template-rows: repeat(2,42px);
  gap: 6px;
}
.preview-card {
  display: grid;
  place-items: center;
  width: 48px;
  height: 42px;
  border: 1px solid #3e493a;
  border-radius: 6px;
  overflow: hidden;
  background: #263221;
}
.preview-card.back {
  color: #b8f34a;
  background: repeating-conic-gradient(#24321e 0 25%,#182216 0 50%) 0/18px 18px;
  font-size: .72rem;
  font-weight: 900;
}
.preview-card.front { background: #4a8fc0; }
.preview-car {
  display: block;
  width: 66px;
  height: 71px;
  background-image: url("https://kenney.nl/media/pages/assets/racing-pack/6a496d39f9-1677662437/preview.png");
  background-repeat: no-repeat;
  background-size: 918px 515px;
  background-position: -141px -320px;
  image-rendering: pixelated;
  transform: scale(.55);
  filter: drop-shadow(0 7px 7px rgba(0,0,0,.3));
}
.preview-car.blue {
  width: 76px;
  height: 82px;
  background-position: -141px -232px;
  transform: scale(.48);
}
.traffic-preview { position: relative; }
.traffic-preview::after {
  content: "";
  position: absolute;
  bottom: 5px;
  width: 7px;
  height: 22px;
  border-radius: 3px;
  background: #4d554a;
}
.traffic-housing {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3,30px);
  gap: 8px;
  padding: 11px 13px;
  border: 2px solid #4c5449;
  border-radius: 11px;
  background: #080a08;
  box-shadow: 0 10px 18px rgba(0,0,0,.4);
}
.traffic-housing span {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 5px rgba(0,0,0,.28);
}
.traffic-housing span:nth-child(1) {
  background: #ff4f4f;
  box-shadow: inset 0 0 0 5px rgba(100,0,0,.28),0 0 15px rgba(255,79,79,.28);
}
.traffic-housing span:nth-child(2) {
  background: #ffd84a;
  box-shadow: inset 0 0 0 5px rgba(100,70,0,.28),0 0 15px rgba(255,216,74,.22);
}
.traffic-housing span:nth-child(3) {
  background: #b8f34a;
  box-shadow: inset 0 0 0 5px rgba(42,80,0,.28),0 0 17px rgba(184,243,74,.3);
}

#memoryScreen .head {
  padding: 20px 0 16px;
}
#memoryScreen .head h1 {
  font-size: clamp(2.65rem,6vw,5rem);
}
#memoryScreen .head p:last-child { margin-top: 14px; }
#memoryScreen .stats {
  max-width: 640px;
  margin: 0 auto 12px;
  gap: 8px;
}
#memoryScreen .stats span {
  min-width: 116px;
  padding: 10px 14px;
  font-size: .68rem;
}
#memoryScreen .stats strong {
  margin-top: 2px;
  font-size: .96rem;
}
#board.memory {
  max-width: 640px;
  gap: 9px;
}
#board .card { aspect-ratio: 1.08/1; }
#board .face { border-radius: 11px; }
#board .back {
  background-position: 0 0,12px 12px;
  background-size: 24px 24px;
}
#board .back::after {
  width: 40px;
  height: 40px;
  font-size: .88rem;
}
#memoryResult.result {
  position: relative;
  max-width: 640px;
  margin-top: 14px;
  overflow: hidden;
}
#memoryResult.result.celebrate {
  animation: academy-result-pop .45s ease both;
}
@keyframes academy-result-pop {
  from { opacity: 0; transform: translateY(18px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.finish-animation {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
#memoryResult > *:not(.finish-animation) { position: relative; z-index: 1; }
.finish-star {
  position: absolute;
  color: #ffd84a;
  font-size: 1.1rem;
  animation: academy-sparkle 1.5s ease-out infinite;
}
.finish-star:nth-child(1) { left: 8%; top: 18%; animation-delay: -.2s; }
.finish-star:nth-child(2) { left: 52%; top: 10%; animation-delay: -.7s; }
.finish-star:nth-child(3) { right: 8%; top: 24%; animation-delay: -1.1s; }
@keyframes academy-sparkle {
  0%,100% { opacity: .15; transform: scale(.5) rotate(0); }
  45% { opacity: 1; transform: scale(1.25) rotate(25deg); }
}
.finish-car {
  position: absolute;
  bottom: 5px;
  left: -110px;
  display: grid;
  place-items: center;
  width: 95px;
  height: 55px;
  animation: academy-finish-drive 2.4s ease-in-out infinite;
}
.finish-car::after {
  content: "";
  display: block;
  width: 66px;
  height: 71px;
  background-image: url("https://kenney.nl/media/pages/assets/racing-pack/6a496d39f9-1677662437/preview.png");
  background-repeat: no-repeat;
  background-size: 918px 515px;
  background-position: -141px -320px;
  image-rendering: pixelated;
  transform: scale(.7) rotate(90deg);
  filter: drop-shadow(0 8px 8px rgba(0,0,0,.28));
}
@keyframes academy-finish-drive {
  0% { left: -110px; }
  60%,100% { left: calc(100% + 15px); }
}

.special-note {
  display: block;
  margin-top: 8px;
  color: #a6ada2;
  font-size: .72rem;
}

@media (max-width:760px) {
  .mission { min-height: 405px; }
  #board.memory { gap: 7px; }
  #board .face { border-radius: 8px; }
  #board .vehicle { transform: scale(calc(var(--s,1)*.78)); }
}
@media (max-width:430px) {
  #board.memory { gap: 5px; }
  #board .back::after { width: 32px; height: 32px; font-size: .72rem; }
  #memoryScreen .stats span { flex: 1; min-width: 90px; padding: 9px 10px; }
}
