:root {
  --pink: #f071b5;
  --pink-soft: #ffe0f1;
  --purple: #7657d8;
  --purple-dark: #4e368f;
  --purple-soft: #eee8ff;
  --blue: #4eb9e8;
  --blue-soft: #dff6ff;
  --ink: #2e2545;
  --white: #ffffff;
  --shadow: 0 18px 50px rgba(78, 54, 143, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #f9f5ff;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Trebuchet MS", "Avenir Next", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(240, 113, 181, 0.24), transparent 23rem),
    radial-gradient(circle at 88% 18%, rgba(78, 185, 232, 0.26), transparent 25rem),
    linear-gradient(145deg, #fff9fd 0%, #f1edff 50%, #e9f9ff 100%);
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 4px solid rgba(78, 185, 232, 0.48);
  outline-offset: 3px;
}

.page-shell {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--purple);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  line-height: 0.95;
}

.subtitle {
  margin: 7px 0 0;
  color: #695c82;
  font-weight: 700;
}

.sound-button {
  width: 50px;
  height: 50px;
  border: 1px solid rgba(118, 87, 216, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 8px 24px rgba(78, 54, 143, 0.12);
  cursor: pointer;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.hud-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 54px;
  padding: 10px 14px;
  border: 1px solid rgba(118, 87, 216, 0.13);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.83);
  box-shadow: 0 8px 24px rgba(78, 54, 143, 0.09);
}

.hud-label {
  color: #786d8d;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.praga-card.ready {
  border-color: rgba(78, 185, 232, 0.5);
  background: var(--blue-soft);
}

.praga-card.used {
  opacity: 0.68;
}

.game-stage {
  position: relative;
  height: min(65vh, 650px);
  min-height: 430px;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.88);
  border-radius: 32px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(118, 87, 216, 0.08)),
    linear-gradient(180deg, #c9f0ff 0%, #ebe6ff 52%, #fce7f4 100%);
  box-shadow: var(--shadow);
  touch-action: none;
  isolation: isolate;
}

.game-stage::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  height: 18%;
  content: "";
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.95), transparent 66%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), #d4c9ff);
}

.cloud {
  position: absolute;
  width: 140px;
  height: 44px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  filter: blur(1px);
}

.cloud::before,
.cloud::after {
  position: absolute;
  bottom: 12px;
  content: "";
  border-radius: 50%;
  background: inherit;
}

.cloud::before {
  left: 23px;
  width: 58px;
  height: 58px;
}

.cloud::after {
  right: 21px;
  width: 74px;
  height: 74px;
}

.cloud-one {
  top: 18%;
  left: 8%;
}

.cloud-two {
  top: 10%;
  right: 10%;
  transform: scale(0.78);
}

.player {
  position: absolute;
  bottom: 1.5%;
  left: 50%;
  z-index: 5;
  width: clamp(145px, 22vw, 235px);
  height: auto;
  user-select: none;
  transform: translateX(-50%);
  transform-origin: center bottom;
  filter: drop-shadow(0 12px 11px rgba(61, 38, 112, 0.22));
  will-change: left, transform;
}

.game-stage.running .player {
  animation: run-bob 420ms ease-in-out infinite alternate;
}

.game-stage.hit .player {
  animation: hit-shake 440ms ease-out;
}

.game-stage.won .player {
  animation: victory 650ms ease-in-out infinite alternate;
}

.collectible {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  pointer-events: none;
  will-change: transform, top;
}

.collectible.heart {
  filter: drop-shadow(0 7px 8px rgba(240, 68, 154, 0.3));
}

.heart-shape {
  position: relative;
  width: 33px;
  height: 33px;
  border-radius: 7px 4px 7px 4px;
  background: linear-gradient(135deg, #ffb8dd 0%, #fa66b0 48%, #d92d88 100%);
  transform: rotate(-45deg);
}

.heart-shape::before,
.heart-shape::after {
  position: absolute;
  width: 33px;
  height: 33px;
  content: "";
  border-radius: 50%;
  background: inherit;
}

.heart-shape::before {
  top: -17px;
  left: 0;
}

.heart-shape::after {
  top: 0;
  left: 17px;
}

.collectible.potion {
  border: 3px solid rgba(255, 255, 255, 0.88);
  border-radius: 17px;
  color: white;
  font-size: 1.7rem;
  background: linear-gradient(145deg, #53c7ef, #7760ed 56%, #b45de1);
  box-shadow: inset 0 0 14px rgba(255, 255, 255, 0.42), 0 8px 16px rgba(74, 68, 191, 0.26);
  animation: cube-spin 1.2s ease-in-out infinite alternate;
}

.collectible.collected {
  opacity: 0;
  transform: scale(1.65) rotate(14deg);
  transition: 180ms ease-out;
}

.status-pill {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 10;
  padding: 9px 15px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  color: white;
  font-weight: 900;
  background: linear-gradient(90deg, #4eb9e8, #7657d8);
  box-shadow: 0 8px 22px rgba(78, 54, 143, 0.24);
  transform: translateX(-50%);
}

.speed-lines {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  background: repeating-linear-gradient(105deg, transparent 0 45px, rgba(255, 255, 255, 0.45) 46px 49px, transparent 50px 90px);
  transform: translateX(30%);
  transition: opacity 200ms ease;
}

.speed-lines.active {
  opacity: 0.55;
  animation: speed-sweep 600ms linear infinite;
}

.announcement {
  position: absolute;
  top: 70px;
  left: 50%;
  z-index: 20;
  width: max-content;
  max-width: 80%;
  margin: 0;
  padding: 8px 13px;
  border-radius: 13px;
  color: var(--purple-dark);
  font-weight: 900;
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 18px rgba(78, 54, 143, 0.15);
  opacity: 0;
  transform: translate(-50%, -6px);
  transition: 200ms ease;
  pointer-events: none;
}

.announcement.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(52, 36, 91, 0.45);
  backdrop-filter: blur(6px);
}

.game-overlay[hidden] {
  display: none;
}

.overlay-card {
  width: min(520px, 100%);
  padding: clamp(22px, 5vw, 38px);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  text-align: center;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 24px 60px rgba(38, 25, 78, 0.32);
}

.overlay-icon {
  display: block;
  margin-bottom: 8px;
  font-size: 2.4rem;
}

.overlay-card h2 {
  margin: 0 0 10px;
  color: var(--purple-dark);
  font-size: clamp(1.55rem, 4vw, 2.45rem);
}

.overlay-card p {
  margin: 0 auto;
  max-width: 42ch;
  color: #665b79;
  line-height: 1.5;
}

.instructions {
  margin: 18px auto;
  padding-left: 1.2rem;
  max-width: 410px;
  color: #554966;
  line-height: 1.45;
  text-align: left;
}

.primary-button {
  min-height: 50px;
  padding: 12px 24px;
  border: 0;
  border-radius: 16px;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  box-shadow: 0 10px 24px rgba(118, 87, 216, 0.28);
  cursor: pointer;
}

.touch-controls {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 14px 0 4px;
}

.touch-controls button {
  width: min(180px, 42vw);
  min-height: 58px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  color: white;
  font-size: 1.55rem;
  background: linear-gradient(145deg, #5cc8ee, #7657d8);
  box-shadow: 0 9px 22px rgba(78, 54, 143, 0.21);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.touch-controls button:active,
.touch-controls button.active {
  transform: translateY(2px) scale(0.98);
  filter: brightness(1.1);
}

.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  color: #746985;
  font-size: 0.88rem;
}

.game-footer p {
  margin: 0;
}

.text-button {
  border: 0;
  color: var(--purple-dark);
  font-weight: 900;
  background: transparent;
  cursor: pointer;
}

@keyframes run-bob {
  from { transform: translateX(-50%) translateY(0) rotate(-1deg); }
  to { transform: translateX(-50%) translateY(-6px) rotate(1deg); }
}

@keyframes hit-shake {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 14px)) rotate(-3deg); }
  50% { transform: translateX(calc(-50% + 13px)) rotate(3deg); }
  75% { transform: translateX(calc(-50% - 7px)); }
}

@keyframes victory {
  from { transform: translateX(-50%) translateY(0) rotate(-2deg); }
  to { transform: translateX(-50%) translateY(-18px) rotate(2deg); }
}

@keyframes cube-spin {
  from { transform: rotate(-8deg) scale(0.92); }
  to { transform: rotate(8deg) scale(1.04); }
}

@keyframes speed-sweep {
  from { transform: translateX(30%); }
  to { transform: translateX(-30%); }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 14px, 680px);
    padding-top: 10px;
  }

  .hud {
    grid-template-columns: repeat(2, 1fr);
  }

  .hud-card {
    min-height: 48px;
    padding: 8px 11px;
  }

  .game-stage {
    height: 58vh;
    min-height: 390px;
    border-radius: 24px;
  }

  .player {
    width: clamp(132px, 36vw, 190px);
  }

  .collectible {
    width: 51px;
    height: 51px;
  }

  .game-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
