/* ---------- Theme tokens: SV Elversberg blue/white + space accents ---------- */
:root {
  --sve-blue-dark: #071b3f;
  --sve-blue: #0c3f91;
  --sve-blue-light: #2f6fd6;
  --sve-white: #f4f8ff;
  --space-cyan: #5be3ff;
  --space-cyan-dim: rgba(91, 227, 255, 0.35);
  --space-purple: #8b6cff;
  --space-bg: #04061a;
}

/* ---------- Reset & base ---------- */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Helvetica Neue", Arial, system-ui, -apple-system, sans-serif;
  background: var(--space-bg);
  color: var(--sve-white);
  overflow-x: hidden;
}

/* ---------- Space background ---------- */
.space-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(47, 111, 214, 0.35), transparent 55%),
    linear-gradient(180deg, #030414 0%, #050826 40%, #070a2e 70%, #04061a 100%);
}

.stars {
  position: absolute;
  inset: -50% -50%;
  background-repeat: repeat;
  opacity: .9;
}
.stars-small {
  background-image:
    radial-gradient(1.4px 1.4px at 15px 25px, #ffffff, transparent),
    radial-gradient(1.4px 1.4px at 90px 60px, #ffffff, transparent),
    radial-gradient(1px 1px at 150px 15px, #cfe3ff, transparent),
    radial-gradient(1.4px 1.4px at 200px 120px, #ffffff, transparent),
    radial-gradient(1px 1px at 55px 140px, #cfe3ff, transparent),
    radial-gradient(1.6px 1.6px at 240px 70px, #ffffff, transparent);
  background-size: 260px 260px;
  animation: drift-slow 140s linear infinite;
}
.stars-big {
  background-image:
    radial-gradient(2.2px 2.2px at 40px 90px, #bfe0ff, transparent),
    radial-gradient(2px 2px at 180px 40px, #ffffff, transparent),
    radial-gradient(2.4px 2.4px at 260px 160px, #cfe3ff, transparent),
    radial-gradient(2px 2px at 100px 190px, #ffffff, transparent);
  background-size: 320px 320px;
  animation: drift-slow 220s linear infinite reverse, twinkle 4s ease-in-out infinite;
}
@keyframes drift-slow {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-300px, 300px, 0); }
}
@keyframes twinkle {
  0%, 100% { opacity: .7; }
  50% { opacity: 1; }
}

.planet {
  position: absolute;
  border-radius: 50%;
}
.planet-ring {
  top: 6%;
  right: -6%;
  width: 190px;
  height: 190px;
  background: radial-gradient(circle at 35% 30%, #9db8ff, var(--sve-blue) 55%, var(--sve-blue-dark) 90%);
  box-shadow: 0 0 60px rgba(47, 111, 214, .45), inset -12px -10px 30px rgba(0,0,0,.5);
  transform: translate(calc(var(--parallax-x, 0px) * 1.6), calc(var(--parallax-y, 0px) * 1.6));
  transition: transform .3s ease-out;
}
.planet-ring::after {
  content: "";
  position: absolute;
  top: 46%;
  left: -35%;
  width: 170%;
  height: 22px;
  background: linear-gradient(90deg, transparent, rgba(244,248,255,.55), rgba(91,227,255,.4), transparent);
  border-radius: 50%;
  transform: rotate(-16deg);
}
.planet-moon {
  top: 22%;
  left: -5%;
  width: 70px;
  height: 70px;
  background: radial-gradient(circle at 40% 35%, #e9eefc, #b9c6e6 60%, #7c88a8 100%);
  box-shadow: 0 0 25px rgba(255,255,255,.25);
  opacity: .85;
  transform: translate(calc(var(--parallax-x, 0px) * -1.1), calc(var(--parallax-y, 0px) * -1.1));
  transition: transform .3s ease-out;
}

.nebula {
  position: absolute;
  width: 55vw;
  height: 55vw;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .28;
}
.neb-1 { top: -10%; left: -15%; background: radial-gradient(circle, var(--space-purple), transparent 65%); }
.neb-2 { bottom: -15%; right: -10%; background: radial-gradient(circle, var(--space-cyan), transparent 65%); }

/* ---------- Layout ---------- */
.app {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 18px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.app-header { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }

.sve-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--sve-blue-light), var(--sve-blue) 70%);
  border: 1px solid rgba(255,255,255,.5);
  box-shadow: 0 0 14px var(--space-cyan-dim), inset 0 1px 0 rgba(255,255,255,.35);
  font-weight: 800;
  font-size: .78rem;
  letter-spacing: .12em;
  color: var(--sve-white);
}
.sve-badge-star { color: var(--sve-white); font-size: .7rem; }

.app-header h1 {
  margin: 0 0 2px;
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  letter-spacing: .5px;
  text-shadow: 0 0 18px var(--space-cyan-dim), 0 2px 12px rgba(0,0,0,.5);
}
.subtitle {
  margin: 0;
  color: #cdd9f7;
  font-size: .95rem;
  max-width: 480px;
  line-height: 1.4;
}
.subtitle strong { color: var(--space-cyan); }

/* ---------- Scoreboard ---------- */
.scoreboard {
  display: flex;
  gap: 12px;
  background: rgba(7, 27, 63, .55);
  border: 1px solid rgba(91, 227, 255, .3);
  border-radius: 16px;
  padding: 10px 20px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0,0,0,.4), 0 0 18px var(--space-cyan-dim);
}
.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}
.score-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--space-cyan);
  text-shadow: 0 0 10px var(--space-cyan-dim), 0 2px 6px rgba(0,0,0,.4);
  transition: transform .2s ease;
}
.score-value.bump { transform: scale(1.35); }
.score-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #a9bde6;
}

/* ---------- Prize panel ---------- */
.prize-panel {
  width: 100%;
  background: rgba(7, 27, 63, .5);
  border: 1px solid rgba(91, 227, 255, .3);
  border-radius: 16px;
  padding: 14px 16px 16px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0,0,0,.35), 0 0 18px var(--space-cyan-dim);
  transition: box-shadow .3s ease, border-color .3s ease;
}
.prize-panel.reset-flash {
  border-color: #ff6b7a;
  box-shadow: 0 8px 24px rgba(0,0,0,.35), 0 0 26px rgba(255, 90, 100, .55);
}
.prize-heading {
  margin: 0 0 10px;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #a9bde6;
  text-align: center;
}
.prize-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
.prize-item {
  position: relative;
  text-align: center;
  padding: 8px 6px;
  border-radius: 10px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--sve-white);
  background: linear-gradient(180deg, var(--sve-blue-light), var(--sve-blue) 80%);
  border: 1px solid rgba(255,255,255,.35);
  box-shadow: 0 0 8px var(--space-cyan-dim), inset 0 1px 0 rgba(255,255,255,.25);
  animation: prize-in .3s ease-out;
  transition: opacity .45s ease, transform .45s ease;
}
.prize-count {
  display: block;
  font-size: .7rem;
  font-weight: 600;
  opacity: .8;
  margin-top: 1px;
}
.prize-item.bumped {
  animation: prize-bump .4s ease;
}
@keyframes prize-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); box-shadow: 0 0 18px var(--space-cyan); }
  100% { transform: scale(1); }
}
.prize-item.winning {
  background: linear-gradient(180deg, #ffe066, #ffb703);
  color: #241900;
  border-color: #fff;
  box-shadow: 0 0 22px rgba(255, 183, 3, .8);
  transform: scale(1.15);
  z-index: 2;
}
.prize-item.won {
  opacity: 0;
  transform: scale(.4) translateY(6px);
}
@keyframes prize-in {
  from { opacity: 0; transform: scale(.6); }
  to { opacity: 1; transform: scale(1); }
}
.prize-empty {
  grid-column: 1 / -1;
  text-align: center;
  font-size: .85rem;
  color: #9fb6e6;
  padding: 6px;
}

/* ---------- Pitch / goal (spaceship cargo deck) ---------- */
.pitch {
  width: 100%;
  position: relative;
  background:
    linear-gradient(180deg, rgba(12, 63, 145, .18), transparent 40%),
    repeating-linear-gradient(90deg, rgba(91,227,255,.05) 0 2px, transparent 2px 58px),
    repeating-linear-gradient(0deg, rgba(91,227,255,.04) 0 2px, transparent 2px 58px),
    linear-gradient(180deg, #0a1230 0%, #070c24 55%, #05081c 100%);
  border-radius: 22px;
  padding: 26px 18px 14px;
  box-shadow: inset 0 0 50px rgba(0,0,0,.5), 0 10px 30px rgba(0,0,0,.45), inset 0 0 0 1px rgba(91,227,255,.15);
  border: 1px solid rgba(91, 227, 255, .25);
  overflow: hidden;
  perspective: 1400px;
}
.deck-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 38px, rgba(91,227,255,.05) 38px 39px);
  opacity: .6;
}

/* tilted runway grid receding toward the goal */
.floor-grid {
  position: absolute;
  left: 50%;
  bottom: 34px;
  width: 150%;
  height: 110px;
  transform: translateX(-50%) perspective(300px) rotateX(64deg);
  transform-origin: center top;
  background-image:
    repeating-linear-gradient(90deg, rgba(91,227,255,.4) 0 2px, transparent 2px 32px),
    repeating-linear-gradient(0deg, rgba(91,227,255,.3) 0 2px, transparent 2px 20px);
  -webkit-mask-image: linear-gradient(to top, black, transparent 85%);
  mask-image: linear-gradient(to top, black, transparent 85%);
  opacity: .6;
  pointer-events: none;
}

/* the goal + its extruded frame share one 3D stage that reacts to pointer tilt */
.goal-frame {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  transform-style: preserve-3d;
  transform: perspective(1000px)
    rotateX(calc(12deg + var(--tilt-y, 0deg)))
    rotateY(var(--tilt-x, 0deg));
  transition: transform .3s ease-out;
  will-change: transform;
}

.goal {
  position: relative;
  width: 100%;
  height: 220px;
  border: 9px solid var(--sve-white);
  border-image: repeating-linear-gradient(-45deg, var(--sve-white) 0 12px, var(--sve-blue) 12px 24px) 9;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, rgba(5, 15, 45, .55), rgba(5, 15, 45, .1) 60%);
  box-shadow: 0 0 0 2px rgba(0,0,0,.25) inset, 0 0 26px var(--space-cyan-dim), 0 12px 24px rgba(0,0,0,.4);
  overflow: hidden;
  transform-style: preserve-3d;
}

/* extruded side/underside faces for the goal frame beams */
.post {
  position: absolute;
  top: 0;
  width: 9px;
  height: 220px;
  background: linear-gradient(90deg, var(--sve-blue-dark), var(--sve-blue-light));
}
.post-left { left: -9px; transform-origin: right center; transform: rotateY(-88deg); }
.post-right { right: -9px; transform-origin: left center; transform: rotateY(88deg); }
.crossbar {
  position: absolute;
  top: -9px;
  left: 0;
  width: 100%;
  height: 9px;
  transform-origin: bottom center;
  transform: rotateX(88deg);
  background: linear-gradient(180deg, var(--sve-blue-light), var(--sve-blue-dark));
}

.net {
  position: absolute;
  inset: 0;
  transform: translateZ(-26px) scale(1.06);
  background-image:
    repeating-linear-gradient(0deg, rgba(91,227,255,.35) 0 1px, transparent 1px 14px),
    repeating-linear-gradient(90deg, rgba(91,227,255,.35) 0 1px, transparent 1px 14px);
  opacity: .75;
  animation: net-pulse 3.2s ease-in-out infinite;
}
@keyframes net-pulse {
  0%, 100% { opacity: .55; }
  50% { opacity: .85; }
}

/* ---------- Goalkeeper (astronaut, SVE blue/white suit) ---------- */
.keeper {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 54px;
  height: 100px;
  transform: translateX(-50%) translateZ(16px) scale(1.89);
  transform-origin: center bottom;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
  transform-style: preserve-3d;
  z-index: 3;
}
.keeper-shadow {
  position: absolute;
  bottom: -4px;
  left: 50%;
  width: 46px;
  height: 12px;
  transform: translate(-50%, 0) translateZ(-16px) rotateX(90deg) scale(1, .5);
  background: radial-gradient(ellipse at center, rgba(0,0,0,.55), transparent 72%);
  border-radius: 50%;
}
.keeper-head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--sve-white), #cfe0ff 70%);
  box-shadow: 0 2px 6px rgba(0,0,0,.4), 0 0 10px var(--space-cyan-dim);
}
.keeper-visor {
  position: absolute;
  top: 5px;
  left: 4px;
  width: 18px;
  height: 12px;
  border-radius: 8px;
  background: radial-gradient(circle at 35% 30%, var(--space-cyan), var(--sve-blue-dark) 80%);
  box-shadow: inset 0 0 4px rgba(0,0,0,.6), 0 0 6px var(--space-cyan-dim);
}
.keeper-antenna {
  position: absolute;
  top: -8px;
  left: 50%;
  width: 2px;
  height: 8px;
  background: var(--sve-blue-light);
  transform: translateX(-50%);
}
.keeper-antenna::after {
  content: "";
  position: absolute;
  top: -3px;
  left: -1.5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--space-cyan);
  box-shadow: 0 0 6px var(--space-cyan);
}
.keeper-torso {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 42px;
  border-radius: 10px 10px 6px 6px;
  background: linear-gradient(180deg, var(--sve-blue-light), var(--sve-blue) 75%);
  box-shadow: inset 0 -6px 8px rgba(0,0,0,.25), 0 0 10px var(--space-cyan-dim);
  overflow: hidden;
}
.keeper-stripe {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
  background: var(--sve-white);
}
.keeper-shorts {
  position: absolute;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 16px;
  border-radius: 4px;
  background: var(--sve-white);
  box-shadow: inset 0 0 0 2px var(--sve-blue);
}
.keeper-leg {
  position: absolute;
  top: 76px;
  width: 10px;
  height: 24px;
  border-radius: 4px;
  background: var(--sve-blue-dark);
}
.keeper-leg-left { left: 12px; }
.keeper-leg-right { right: 12px; }
.keeper-arm {
  position: absolute;
  top: 28px;
  width: 12px;
  height: 34px;
  border-radius: 6px;
  background: var(--sve-blue-light);
  transform-origin: top center;
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
}
.keeper-arm-left { left: -6px; transform: rotate(-25deg); }
.keeper-arm-right { right: -6px; transform: rotate(25deg); }
.keeper-glove {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sve-white);
  box-shadow: 0 0 8px var(--space-cyan-dim), 0 1px 3px rgba(0,0,0,.3);
}

.keeper.diving .keeper-arm-left { transform: rotate(-70deg); }
.keeper.diving .keeper-arm-right { transform: rotate(70deg); }
.keeper.diving {
  transform:
    translateX(-50%) translateZ(30px) scale(1.89)
    rotateZ(var(--dive-rot, 0deg))
    rotateY(calc(var(--dive-rot, 0deg) * 0.5));
}

/* ---------- Ball (cosmic plasma football) ---------- */
.ball {
  position: absolute;
  left: 50%;
  bottom: -34px;
  width: 30px;
  height: 30px;
  transform: translate(-50%, 0) translateZ(46px) scale(1) rotateX(0deg) rotateY(0deg);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #e3ecff 70%, #c3d3f5);
  box-shadow: 0 3px 8px rgba(0,0,0,.45), 0 0 14px var(--space-cyan-dim), inset 0 -3px 5px rgba(0,0,0,.15);
  z-index: 4;
  transform-style: preserve-3d;
  transition: left .55s cubic-bezier(.2,.7,.3,1), bottom .55s cubic-bezier(.2,.7,.3,1), transform .55s cubic-bezier(.2,.7,.3,1);
}
.ball.no-anim { transition: none !important; }
.ball.flying {
  transform: translate(-50%, 0) translateZ(-30px) scale(.6) rotateX(420deg) rotateY(160deg);
}
.ball-glow {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--space-cyan-dim), transparent 70%);
  animation: ball-glow-pulse 1.6s ease-in-out infinite;
}
@keyframes ball-glow-pulse {
  0%, 100% { opacity: .5; transform: scale(1); }
  50% { opacity: .9; transform: scale(1.15); }
}
.ball-patch {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--sve-blue);
  clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
}
.p1 { top: 4px; left: 11px; transform: scale(.9); }
.p2 { top: 15px; left: 3px; transform: rotate(30deg) scale(.8); }
.p3 { top: 15px; left: 18px; transform: rotate(-30deg) scale(.8); }

/* ---------- Result banner ---------- */
.result-banner {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) translateZ(20px) perspective(500px) rotateX(-100deg) scale(.85);
  transform-origin: center top;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: .05em;
  padding: 8px 22px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  text-shadow: 0 2px 6px rgba(0,0,0,.4);
  transition: opacity .3s ease, transform .4s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap;
}
.result-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) translateZ(20px) perspective(500px) rotateX(0deg) scale(1);
}
.result-banner.goal {
  background: rgba(91, 227, 255, .18);
  color: #eafcff;
  border: 1px solid var(--space-cyan);
  box-shadow: 0 0 24px var(--space-cyan-dim);
}
.result-banner.saved {
  background: rgba(214, 40, 60, .22);
  color: #ffe9ea;
  border: 1px solid #ff6b7a;
  box-shadow: 0 0 24px rgba(255, 90, 100, .45);
}

/* ---------- Ground shadow / aim track ---------- */
.ground-shadow {
  width: 90%;
  max-width: 480px;
  height: 10px;
  margin: 6px auto 4px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.5), transparent 70%);
}

.aim-track {
  position: relative;
  width: 90%;
  max-width: 480px;
  height: 40px;
  margin: 0 auto;
}
.aim-track-rail {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 6px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, var(--sve-blue), var(--space-cyan), var(--sve-blue));
  border-radius: 4px;
  opacity: .65;
  box-shadow: 0 0 10px var(--space-cyan-dim);
}
.foot {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 1.8rem;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 6px var(--space-cyan)) drop-shadow(0 3px 4px rgba(0,0,0,.5)) hue-rotate(180deg) saturate(1.4);
  will-change: left;
}
.aim-caption {
  text-align: center;
  font-size: .75rem;
  color: #9fb6e6;
  margin: 4px 0 0;
}

/* ---------- Shoot button ---------- */
.shoot-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 16px 42px;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--sve-white);
  background: linear-gradient(180deg, var(--sve-blue-light), var(--sve-blue) 75%);
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 999px;
  box-shadow: 0 8px 0 var(--sve-blue-dark), 0 14px 24px rgba(0,0,0,.45), 0 0 22px var(--space-cyan-dim);
  transition: transform .15s ease, box-shadow .15s ease, filter .2s ease;
}
.shoot-btn:hover {
  filter: brightness(1.12);
  transform: perspective(400px) rotateX(8deg) translateY(-3px);
}
.shoot-btn:active {
  transform: perspective(400px) translateY(6px);
  box-shadow: 0 2px 0 var(--sve-blue-dark), 0 6px 10px rgba(0,0,0,.4);
}
.shoot-btn:disabled {
  cursor: not-allowed;
  filter: grayscale(.4) brightness(.75);
  transform: none;
  box-shadow: 0 8px 0 rgba(7,27,63,.7), 0 14px 20px rgba(0,0,0,.3);
}

.hint {
  min-height: 1.2em;
  font-size: .9rem;
  color: #cdd9f7;
  text-align: center;
}

.app-footer {
  margin-top: 6px;
  font-size: .72rem;
  color: #6f83b3;
  text-align: center;
}

/* ---------- Small screens ---------- */
@media (max-width: 420px) {
  .goal { height: 190px; }
  .post { height: 190px; }
  .shoot-btn { padding: 14px 32px; font-size: 1.02rem; }
  .planet-ring { width: 120px; height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .stars, .net, .ball-glow { animation: none !important; }
  .goal-frame, .planet-ring, .planet-moon { transition: none !important; }
}
