:root {
  --pj-bg: #0f1020;
  --pj-panel: #1a1b28;
  --pj-panel-2: #212233;
  --pj-accent: #6842ff;
  --pj-accent-2: #8a6bff;
  --pj-secondary: #2a2b3d;
  --pj-text: #fff;
  --pj-muted: #aaadbe;
  --pj-gold: #ffc93c;
  --pj-font:
    "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system,
    "Segoe UI", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--pj-bg);
  color: var(--pj-text);
  font-family: var(--pj-font);
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow-x: hidden;
}

.pj-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.pj-shell {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* HUD ---------------------------------------------------------------- */
.pj-hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.pj-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: 34px;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #25263a, var(--pj-panel));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 3px 0 rgba(0, 0, 0, 0.35);
}

.pj-chip span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pj-muted);
}

.pj-chip strong {
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.pj-chip-level {
  background: linear-gradient(180deg, var(--pj-accent-2), var(--pj-accent));
}

.pj-chip-level span {
  color: rgba(255, 255, 255, 0.8);
}

.pj-chip-stars strong {
  color: var(--pj-gold);
  letter-spacing: 1px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

.pj-chip-stars .pj-star-off {
  color: #4a4b62;
}

.pj-chip.pj-bump strong {
  animation: pj-pop 0.3s ease-out;
}

/* Stage -------------------------------------------------------------- */
.pj-stage {
  position: relative;
  max-width: 100%;
  border-radius: 22px;
  overflow: hidden;
  box-shadow:
    0 0 0 3px #2b2c42,
    0 14px 34px rgba(0, 0, 0, 0.55);
  background: #3d4155;
}

#pj-canvas {
  display: block;
  touch-action: none;
  outline: none;
  cursor: pointer;
}

#pj-canvas:focus-visible {
  outline: 3px solid var(--pj-gold);
  outline-offset: -3px;
}

.pj-stage.pj-shake {
  animation: pj-stage-shake 0.28s ease-out;
}

/* Overlays ----------------------------------------------------------- */
.pj-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  background: radial-gradient(
    circle at 50% 40%,
    rgba(40, 30, 90, 0.72),
    rgba(10, 10, 24, 0.86)
  );
  backdrop-filter: blur(3px);
  z-index: 2;
}

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

.pj-card {
  width: min(360px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 20px 20px 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, #26273b, var(--pj-panel));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 18px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: pj-card-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.pj-card h2 {
  margin: 0;
  font-size: 30px;
  font-weight: 900;
  line-height: 1.05;
  background: linear-gradient(180deg, #fff 30%, #ffd86b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.35));
}

.pj-card p {
  margin: 0;
  color: var(--pj-muted);
  font-size: 15px;
  line-height: 1.35;
}

.pj-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #4f8cff, #2a4fd8);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.35),
    inset 0 -5px 0 rgba(0, 0, 0, 0.2),
    0 8px 18px rgba(40, 80, 255, 0.45);
  transform: rotate(-6deg);
}

.pj-logo-p {
  font-size: 46px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

.pj-kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px !important;
  font-weight: 900;
  color: var(--pj-accent-2) !important;
}

.pj-win-stars {
  display: flex;
  gap: 6px;
  font-size: 50px;
  line-height: 1;
}

.pj-win-stars span {
  color: #3b3c55;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  transform: scale(0.4);
  opacity: 0;
  animation: pj-star-in 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) forwards;
}

.pj-win-stars span:nth-child(2) {
  font-size: 62px;
  margin-top: -10px;
  animation-delay: 0.15s;
}

.pj-win-stars span:nth-child(3) {
  animation-delay: 0.3s;
}

.pj-win-stars span.pj-on {
  color: var(--pj-gold);
  text-shadow:
    0 4px 0 #c47f00,
    0 0 18px rgba(255, 201, 60, 0.6);
}

.pj-win-score {
  font-size: 16px !important;
  color: #fff !important;
  font-weight: 800;
}

.pj-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}

.pj-card-levels {
  width: min(430px, 100%);
}

.pj-levels-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pj-level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.pj-level {
  position: relative;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-weight: 900;
  font-size: 17px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #3a3c58, var(--pj-secondary));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 3px 0 rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}

.pj-level small {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--pj-gold);
}

.pj-level.pj-current {
  background: linear-gradient(180deg, var(--pj-accent-2), var(--pj-accent));
}

.pj-level:disabled {
  cursor: not-allowed;
  color: #5d5f78;
  background: #1c1d2b;
  box-shadow: none;
}

/* Buttons ------------------------------------------------------------ */
.pj-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.pj-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    filter 0.12s ease;
  touch-action: manipulation;
}

.pj-btn:active {
  transform: translateY(2px) scale(0.97);
}

.pj-btn:focus-visible,
.pj-level:focus-visible {
  outline: 3px solid var(--pj-gold);
  outline-offset: 2px;
}

.pj-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.pj-btn-primary {
  background: linear-gradient(180deg, var(--pj-accent-2), var(--pj-accent));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 4px 0 #3d22b3,
    0 8px 16px rgba(104, 66, 255, 0.35);
}

.pj-btn-secondary {
  background: linear-gradient(180deg, #34364c, var(--pj-secondary));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 4px 0 #15161f;
}

.pj-btn-ghost {
  background: transparent;
  color: var(--pj-muted);
  min-height: 40px;
}

.pj-btn-big {
  min-height: 56px;
  min-width: 190px;
  font-size: 22px;
  margin-top: 4px;
}

.pj-btn-icon {
  padding: 0;
  width: 44px;
}

.pj-ico {
  width: 20px;
  height: 20px;
  flex: none;
}

.pj-btn.pj-glow {
  animation: pj-glow 1.2s ease-in-out infinite;
}

.pj-help {
  margin: 0;
  font-size: 12px;
  color: var(--pj-muted);
  text-align: center;
  line-height: 1.5;
}

kbd {
  display: inline-block;
  padding: 0 5px;
  border-radius: 5px;
  background: var(--pj-secondary);
  font: inherit;
  font-size: 11px;
  color: #fff;
}

@media (max-width: 420px) {
  .pj-shell {
    padding: 8px 8px 6px;
  }
  .pj-chip {
    padding: 5px 10px;
    gap: 4px;
  }
  .pj-chip span {
    font-size: 10px;
  }
  .pj-chip strong {
    font-size: 15px;
  }
  .pj-actions {
    gap: 6px;
  }
  .pj-btn {
    padding: 0 12px;
    font-size: 14px;
  }
  .pj-actions .pj-btn > span[aria-hidden="true"],
  .pj-actions .pj-btn:not(.pj-btn-icon) > .pj-ico {
    display: none;
  }
  .pj-level-grid {
    gap: 6px;
  }
  .pj-overlay {
    padding: 8px;
  }
  .pj-card {
    padding: 16px 12px 14px;
  }
  .pj-level {
    font-size: 15px;
    min-height: 44px;
  }
  .pj-level small {
    font-size: 8px;
    letter-spacing: 0;
  }
}

@media (max-width: 370px) {
  .pj-lbl {
    display: none;
  }
  .pj-actions .pj-btn > span[aria-hidden="true"],
  .pj-actions .pj-btn:not(.pj-btn-icon) > .pj-ico {
    display: inline;
  }
  .pj-btn {
    padding: 0;
    width: 48px;
  }
  .pj-btn-big,
  .pj-card-actions .pj-btn,
  .pj-btn-ghost {
    width: auto;
    padding: 0 16px;
  }
  .pj-help {
    display: none;
  }
}

@keyframes pj-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes pj-card-in {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes pj-star-in {
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes pj-stage-shake {
  25% {
    transform: translateX(-4px);
  }
  50% {
    transform: translateX(3px);
  }
  75% {
    transform: translateX(-2px);
  }
}

@keyframes pj-glow {
  50% {
    filter: brightness(1.25);
    transform: scale(1.04);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pj-card,
  .pj-win-stars span,
  .pj-chip.pj-bump strong,
  .pj-stage.pj-shake,
  .pj-btn.pj-glow {
    animation: none !important;
  }
  .pj-win-stars span {
    transform: none;
    opacity: 1;
  }
}
