:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-2: #8a6bff;
  --secondary: #2a2b3d;
  --text: #fff;
  --muted: #aaadbe;
  --gold: #ffc93c;
  font-family:
    "Nunito",
    ui-rounded,
    "SF Pro Rounded",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  font-weight: 800;
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  min-width: 0;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
body {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  color: inherit;
}
.pq-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.pq-shell {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* HUD */
.pq-hud {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}
.pq-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 11px;
  border-radius: 999px;
  background: linear-gradient(180deg, #262839, #1c1d2b);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 2px 0 rgba(0, 0, 0, 0.35);
  font-size: 15px;
  white-space: nowrap;
  min-width: 0;
}
.pq-chip strong {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.pq-chip-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pq-chip-level strong {
  color: #c9bcff;
}
.pq-chip-score {
  margin-left: auto;
}
.pq-ico {
  width: 20px;
  height: 20px;
  flex: none;
}
.pq-hearts {
  display: inline-flex;
  gap: 1px;
}
.pq-hearts .pq-ico.is-empty {
  opacity: 0.22;
  filter: grayscale(1);
}
.pq-hearts .pq-ico.is-pop,
.pq-chip.is-pop {
  animation: pq-pop 0.35s ease-out;
}
.pq-chip-star .pq-ico {
  opacity: 0.25;
  filter: grayscale(1);
  transition: opacity 0.2s;
}
.pq-chip-star.is-found .pq-ico {
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(255, 207, 64, 0.8));
}
.pq-icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #3a3c55, var(--secondary));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 3px 0 rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.pq-icon-btn svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}
.pq-icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Stage */
.pq-stage {
  position: relative;
  width: 100%;
  height: 420px;
  border-radius: 20px;
  overflow: hidden;
  background: #5fb8ff;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.06),
    0 14px 40px rgba(0, 0, 0, 0.5);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.pq-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}
.pq-stage canvas:focus-visible {
  box-shadow: inset 0 0 0 3px var(--accent-2);
}
.pq-stage.is-shake {
  animation: pq-shake 0.32s ease-out;
}
.pq-toast {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translate(-50%, -10px);
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(15, 16, 32, 0.78);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  font-size: 15px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.25s,
    transform 0.25s;
  white-space: nowrap;
}
.pq-toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Overlays */
.pq-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow-y: auto;
  background: radial-gradient(
    ellipse at center,
    rgba(15, 16, 32, 0.35),
    rgba(15, 16, 32, 0.75)
  );
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.pq-overlay[hidden] {
  display: none;
}
.pq-card {
  width: min(460px, 100%);
  padding: 20px 20px 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, #252739 0%, var(--panel) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 18px 50px rgba(0, 0, 0, 0.55);
  text-align: center;
  animation: pq-card-in 0.32s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.pq-card h2 {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 900;
}
.pq-card-title {
  background: linear-gradient(
    180deg,
    rgba(37, 39, 57, 0.92),
    rgba(26, 27, 40, 0.94)
  );
}
.pq-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.pq-logo {
  margin: 2px 0 8px !important;
  font-size: clamp(36px, 8vw, 58px) !important;
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: #ffd84a;
  background: linear-gradient(180deg, #fff6b8 0%, #ffd23c 45%, #ff9a1f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #b8480c) drop-shadow(0 6px 0 rgba(0, 0, 0, 0.35));
}
.pq-logo-sm {
  font-size: clamp(28px, 6vw, 40px) !important;
}
.pq-logo-sad {
  background: linear-gradient(180deg, #ffd0dc 0%, #ff7b95 50%, #e0305a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 3px 0 #7d1030) drop-shadow(0 6px 0 rgba(0, 0, 0, 0.35));
}
.pq-sub {
  margin: 0 auto 16px;
  max-width: 34ch;
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.4;
}
.pq-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.pq-row-stack {
  flex-direction: column;
  align-items: stretch;
  max-width: 240px;
  margin: 0 auto;
}
.pq-btn {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 0.12s,
    filter 0.12s;
}
.pq-btn:active {
  transform: translateY(2px) scale(0.98);
}
.pq-btn:hover {
  filter: brightness(1.08);
}
.pq-btn-primary {
  background: linear-gradient(180deg, #8c6dff, var(--accent));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 4px 0 #3f22b8,
    0 8px 18px rgba(104, 66, 255, 0.4);
}
.pq-btn-secondary {
  background: linear-gradient(180deg, #373950, var(--secondary));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 4px 0 #15161f;
}
.pq-btn-big {
  min-height: 56px;
  min-width: 190px;
  font-size: 22px;
}
.pq-btn:focus-visible,
.pq-icon-btn:focus-visible,
.pq-level:focus-visible,
.pq-touch-btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

/* Level select */
.pq-card-levels {
  width: min(560px, 100%);
}
.pq-level-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.pq-level {
  position: relative;
  min-height: 84px;
  padding: 8px 4px 6px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #7ed957 0%, #3ea636 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -3px 0 rgba(0, 0, 0, 0.18),
    0 4px 0 #23661f;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 0.12s;
}
.pq-level:active {
  transform: translateY(2px);
}
.pq-level[data-theme="sunset"] {
  background: linear-gradient(180deg, #ffb35c, #ef6b3a);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -3px 0 rgba(0, 0, 0, 0.18),
    0 4px 0 #9c3a18;
}
.pq-level[data-theme="dusk"] {
  background: linear-gradient(180deg, #5bd0c2, #2a8f8f);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -3px 0 rgba(0, 0, 0, 0.18),
    0 4px 0 #1a5a5c;
}
.pq-level[data-theme="night"] {
  background: linear-gradient(180deg, #8c7bff, #4a38c9);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -3px 0 rgba(0, 0, 0, 0.18),
    0 4px 0 #2a1f80;
}
.pq-level:disabled {
  background: linear-gradient(180deg, #33354a, #26283a);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 0 #15161f;
  cursor: default;
}
.pq-level-num {
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}
.pq-level-name {
  font-size: 11px;
  font-weight: 800;
  opacity: 0.92;
  line-height: 1.1;
}
.pq-level-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 900;
}
.pq-level-meta .pq-ico {
  width: 15px;
  height: 15px;
}
.pq-level-meta .pq-ico.is-empty {
  opacity: 0.3;
  filter: grayscale(1) brightness(1.5);
}
.pq-level .pq-lock {
  width: 24px;
  height: 24px;
}

/* Win */
.pq-win-star {
  width: 64px;
  height: 64px;
  margin: -4px auto 8px;
}
.pq-win-star svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 12px rgba(255, 207, 64, 0.8));
  animation: pq-star-in 0.6s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.pq-win-star.is-missing svg {
  filter: grayscale(1);
  opacity: 0.28;
  animation: none;
}
.pq-results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 16px;
}
.pq-results div {
  padding: 8px 4px;
  border-radius: 14px;
  background: var(--panel-2);
}
.pq-results dt {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pq-results dd {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* Touch controls */
.pq-touch {
  display: none;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 2px;
}
.pq-touch-dpad {
  display: flex;
  gap: 10px;
}
.pq-touch-btn {
  width: 72px;
  height: 64px;
  border: 0;
  border-radius: 22px;
  background: linear-gradient(180deg, #3b3d57, #25263a);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.14),
    0 4px 0 #111220;
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
.pq-touch-btn svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: #fff;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.pq-touch-btn.is-down {
  transform: translateY(3px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.14),
    0 1px 0 #111220;
  filter: brightness(1.2);
}
.pq-touch-jump {
  width: 112px;
  border-radius: 999px;
  font-size: 19px;
  font-weight: 900;
  background: linear-gradient(180deg, #8c6dff, var(--accent));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    0 4px 0 #3f22b8;
}
.pq-touch-jump.is-down {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    0 1px 0 #3f22b8;
}
body.is-touch .pq-touch {
  display: flex;
}
body.is-touch .pq-help {
  display: none;
}

.pq-help {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  margin: 0 1px;
  border-radius: 6px;
  background: var(--secondary);
  box-shadow: 0 2px 0 #111220;
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
}

@media (max-width: 560px) {
  .pq-shell {
    padding: 6px 6px 8px;
    gap: 6px;
  }
  .pq-hud {
    gap: 4px;
  }
  .pq-chip {
    height: 32px;
    padding: 0 8px;
    font-size: 13px;
    gap: 3px;
  }
  .pq-chip-label {
    display: none;
  }
  .pq-ico {
    width: 16px;
    height: 16px;
  }
  .pq-icon-btn {
    width: 40px;
    height: 40px;
  }
  .pq-stage {
    border-radius: 16px;
  }
  .pq-card {
    padding: 14px 12px 14px;
    border-radius: 20px;
  }
  .pq-card h2 {
    font-size: 20px;
    margin-bottom: 8px;
  }
  .pq-sub {
    font-size: 13px;
    margin-bottom: 12px;
  }
  .pq-level-grid {
    gap: 6px;
    margin-bottom: 10px;
  }
  .pq-level {
    min-height: 62px;
    border-radius: 14px;
  }
  .pq-level-num {
    font-size: 21px;
  }
  .pq-level-name {
    display: none;
  }
  .pq-results {
    gap: 4px;
  }
  .pq-results dd {
    font-size: 15px;
  }
  .pq-btn {
    padding: 0 14px;
    font-size: 15px;
  }
  .pq-btn-big {
    min-height: 52px;
    font-size: 20px;
  }
}
@media (max-width: 360px) {
  .pq-chip {
    padding: 0 6px;
  }
  .pq-hearts .pq-ico {
    width: 13px;
    height: 13px;
  }
  .pq-touch-btn {
    width: 60px;
  }
  .pq-touch-jump {
    width: 96px;
  }
}

@keyframes pq-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes pq-shake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-6px, 2px);
  }
  40% {
    transform: translate(5px, -2px);
  }
  60% {
    transform: translate(-3px, 1px);
  }
  80% {
    transform: translate(2px, 0);
  }
}
@keyframes pq-card-in {
  from {
    transform: scale(0.85) translateY(10px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
@keyframes pq-star-in {
  from {
    transform: scale(0) rotate(-90deg);
  }
  to {
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .pq-card,
  .pq-win-star svg,
  .pq-stage.is-shake,
  .pq-hearts .pq-ico.is-pop,
  .pq-chip.is-pop {
    animation: none !important;
  }
  .pq-toast,
  .pq-btn,
  .pq-level {
    transition: none;
  }
}
