/* Menu screens (splash, tutorial) and overlays (countdown, pause, victory, score).
   They are laid out on a 360 px wide artboard (design px) that is scaled to the viewport with --ui-scale. */

.screen {
  position: absolute;
  inset: 0;
  animation: screen-in 0.25s ease-out;
}

.screen--menu { z-index: 5; }

.screen--overlay {
  z-index: 20;
  background: var(--color-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.artboard {
  position: absolute;
  left: 50%;
  width: 360px;
  transform: translateX(-50%) scale(var(--ui-scale, 1));
  transform-origin: top center;
}

.artboard--menu {   /* below the header */
  top: var(--header-h);
  height: calc((var(--app-height) - var(--header-h)) / var(--ui-scale, 1));
}

.artboard--full {
  top: 0;
  height: calc(var(--app-height) / var(--ui-scale, 1));
}

.artboard--center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.actions--static {
  position: static;
  width: 100%;
}

.window {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  width: 328px;
  padding: 32px;
  border-radius: 8px;
  background: var(--color-surface);
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.1);
  animation: window-in 0.3s ease-out;
}

.window__title {
  padding: 0 16px;
  font: 64px / 1 var(--font-display);
  text-align: center;
  text-transform: var(--type-display-transform);
  color: var(--color-text);
}

/* Footer links (Impressum • Datenschutz) at the bottom of splash, pause and score. Text colour: --color-text on the
   paper background of the splash, --color-on-primary on the dark overlays. The padding enlarges the touch target. */
.legal {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 12px / 1.25 var(--font-body);
  color: var(--color-text);
}
.screen--overlay .legal { color: var(--color-on-primary); }

.legal__link {
  padding: 8px 4px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.legal__link:hover { text-decoration: underline; }
.legal__link:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; border-radius: 4px; }
.legal__dot { padding: 0 4px; }

/* ---- Splash ------------------------------------------------------------------ */

.splash__decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.splash__decor-item {
  position: absolute;
  height: auto;
}

/* Subtitle under the splash title ("Fangspiel"; a theme without strings.splash.subtitle leaves it empty and hidden).
   Colour and top edge per theme (colors.splashSubtitle, type.splashSubtitleTop). */
.splash__subtitle {
  position: absolute;
  left: 50%;
  top: var(--type-splash-subtitle-top, 346.5px);
  translate: -50% 0;
  margin: 0;
  font: 48px / 1 var(--font-display);
  text-transform: var(--type-display-transform);
  white-space: nowrap;
  color: var(--color-splash-subtitle);
  pointer-events: none;
}
.splash__subtitle:empty { display: none; }

/* Idle: a slow, small rotation back and forth (theme: splashDecor[].sway). Off with prefers-reduced-motion (base.css). */
.splash__decor-item.is-swaying {
  animation: splash-sway var(--sway-s, 6s) ease-in-out infinite alternate;
}

/* ---- Tutorial ---------------------------------------------------------------- */

.tutorial {
  position: absolute;
  top: 32px;
  left: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tutorial__row {
  display: flex;
  gap: 8px;
}

.card {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  height: 208px;
  padding: 16px;
  border-radius: 8px;
  background: var(--color-card);
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.1);
}
.card--wide { flex: none; height: 188px; }

.card__badge {
  position: absolute;
  top: 16px;
  left: 16px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 24px;
  background: var(--color-surface);
  color: var(--color-text);
  font: 20px / 1 var(--font-display);
  text-transform: var(--type-display-transform);
}

.card__value {
  position: absolute;
  top: 44px;
  right: 16px;
  font: 20px / 1 var(--font-display);
  text-transform: var(--type-display-transform);
}
.card__value--positive { color: var(--color-positive); }
.card__value--negative { color: var(--color-negative); }

.card__sprite { display: block; width: auto; }
.card__sprite--catcher { height: 70px; margin-top: 8px; }
.card__sprite--positive { height: 72px; margin-top: 36px; }
.card__sprite--negative { height: 60px; margin-top: 40px; }

.card__controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--color-text);
}

.card__text {
  position: absolute;
  top: 144px;
  left: 0;
  right: 0;
  width: 128px;
  margin: 0 auto;
  font: 12px / 1.25 var(--font-body);
  text-align: center;
  color: var(--color-text);
}
.card__text--wide { width: 232px; top: 126px; }

/* ---- Countdown --------------------------------------------------------------- */

.countdown {
  font: 192px / 1 var(--font-display);
  text-transform: var(--type-display-transform);
  color: var(--color-on-overlay);
}
.countdown.is-go { font-size: 128px; }
.countdown.is-tick { animation: tick 0.5s ease-out; }

/* ---- Victory ----------------------------------------------------------------- */

.victory__shine,
.victory__product {
  position: absolute;
  left: 50%;
  top: 50%;
}

.victory__shine {
  width: 640px;
  height: 640px;
  transform: translate(-50%, -50%);
  animation: spin 30s linear infinite;
}

.victory__product {
  height: var(--type-victory-product-height, 360px);
  width: auto;
  transform: translate(-50%, -50%) rotate(5deg);
  animation: product-in 0.6s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.victory__mascots { position: absolute; inset: 0; pointer-events: none; }

/* Mascots: positioned by their centre (the `translate` property), so `transform` is free for the animations.
   First they come in from the side with a little overshoot, then they hop (squash and jump) or float (bob and tilt). */
.victory__mascot {
  position: absolute;
  height: auto;
  translate: -50% -50%;
  transform-origin: 50% 100%;
  animation:
    mascot-in 0.7s cubic-bezier(0.2, 1.3, 0.4, 1) var(--delay, 0s) backwards,
    mascot-float 2.4s ease-in-out calc(var(--delay, 0s) + 0.7s) infinite;
}
.victory__mascot.from-left { --from: -90px; --tilt: -12deg; }
.victory__mascot.from-right { --from: 90px; --tilt: 12deg; }
.victory__mascot--hop {
  animation:
    mascot-in 0.7s cubic-bezier(0.2, 1.3, 0.4, 1) var(--delay, 0s) backwards,
    mascot-hop 0.8s ease-in-out calc(var(--delay, 0s) + 0.7s) infinite;
}

.victory__title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 64px;
  padding: 0 16px;
  font: var(--type-victory-size) / 1 var(--font-display);
  text-align: center;
  text-transform: var(--type-display-transform);
  color: var(--color-on-overlay);
}

/* ---- Score ------------------------------------------------------------------- */

.confetti {   /* particles are drawn by rendering/particles.js, behind the window (it comes later in the DOM) */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.score__summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  text-align: center;
}

.score__headline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  color: var(--color-score);
  font-family: var(--font-display);
  line-height: 1;
  text-transform: var(--type-display-transform);
}
.score__value { font-size: var(--type-score-size); }
.score__label { font-size: var(--type-score-label-size); text-transform: uppercase; }

.score__result {
  font: 16px / 1.25 var(--font-body);
  color: var(--color-text);
}

.score__counts {
  display: flex;
  gap: 16px;
  width: 100%;
}

.score__count {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.score__count-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.score__count-sprite { height: 44px; width: auto; }

.score__count-number {
  font: 32px / 1 var(--font-display);
  text-transform: var(--type-display-transform);
}
.score__count-number--positive { color: var(--color-positive); }
.score__count-number--negative { color: var(--color-negative); }

.score__count-label {
  font: 12px / 1.25 var(--font-body);
  text-align: center;
  color: var(--color-text);
}

/* ---- Motion ------------------------------------------------------------------ */

@keyframes screen-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes window-in {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes tick {
  from { opacity: 0; transform: scale(1.5); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes splash-sway {
  from { transform: rotate(calc(var(--sway-deg) * -1)); }
  to { transform: rotate(var(--sway-deg)); }
}

@keyframes mascot-in {
  from { opacity: 0; transform: translateX(var(--from)) rotate(var(--tilt)) scale(0.7); }
  to { opacity: 1; transform: none; }
}

@keyframes mascot-hop {
  0%, 100% { transform: scale(1.05, 0.93); }
  35% { transform: translateY(-18px) rotate(-3deg) scale(0.97, 1.04); }
  65% { transform: translateY(-18px) rotate(3deg) scale(0.97, 1.04); }
}

@keyframes mascot-float {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-10px) rotate(1.5deg); }
}

@keyframes product-in {
  from { opacity: 0; transform: translate(-50%, -50%) rotate(-12deg) scale(0.6); }
  to { opacity: 1; transform: translate(-50%, -50%) rotate(5deg) scale(1); }
}
