/* ---------- Black hole level ---------- */
.bh-level {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #000;
  cursor: grab;
  animation: fade-in 0.4s ease;
}
.bh-level:active {
  cursor: grabbing;
}
.bh-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.bh-loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  z-index: 100;
  transition: opacity 0.6s;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: rgba(244, 241, 232, 0.6);
}
.bh-loading.hide {
  opacity: 0;
  pointer-events: none;
}

.bh-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 32;
}
.bh-title {
  position: absolute;
  top: 28px;
  left: 32px;
  font-family: "Fraunces", serif;
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.8);
  color: #f4f1e8;
}
.bh-subtitle {
  margin-top: 4px;
  font-size: 12px;
  font-family: "Inter", sans-serif;
  font-weight: 400;
  color: rgba(244, 241, 232, 0.55);
  letter-spacing: 0.02em;
}
.bh-stats {
  position: absolute;
  bottom: 24px;
  left: 32px;
  font-size: 11px;
  color: rgba(244, 241, 232, 0.5);
  letter-spacing: 0.04em;
  line-height: 1.8;
}
.bh-stats b {
  color: rgba(244, 241, 232, 0.85);
  font-weight: 500;
  margin-right: 6px;
}

.bh-btn-back-floating {
  position: fixed;
  top: 26px;
  right: 32px;
  z-index: 33;
  min-width: 60px;
  min-height: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(244, 241, 232, 0.92);
  border: 1px solid rgba(244, 241, 232, 0.18);
  border-radius: 999px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.04em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s,
    transform 0.15s,
    opacity 0.15s,
    box-shadow 0.15s,
    filter 0.15s;
}
.bh-btn-back-floating:hover {
  background: rgba(0, 0, 0, 0.65);
  border-color: rgba(244, 241, 232, 0.4);
}

.bh-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  justify-content: center;
  color: var(--ink-dim);
  font-size: 14px;
}

.bh-finished {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 3, 18, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 34;
  animation: fade-in 0.5s ease;
}
.bh-finished-card {
  background: linear-gradient(
    180deg,
    rgba(28, 16, 40, 0.96),
    rgba(8, 4, 22, 0.96)
  );
  border: 1px solid rgba(255, 170, 80, 0.35);
  border-radius: 24px;
  padding: 36px 44px;
  text-align: center;
  max-width: 460px;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(255, 130, 60, 0.18);
  animation: detail-enter 0.5s ease;
}
.bh-finished-emoji {
  font-size: 56px;
  margin-bottom: 8px;
}
.bh-finished h1 {
  font-family: "Fraunces", serif;
  font-size: 38px;
  font-weight: 400;
  color: #ffd9a8;
  margin-bottom: 6px;
  letter-spacing: 0.005em;
}
.bh-finished p {
  color: var(--ink-dim);
  margin-bottom: 24px;
  font-size: 15px;
}
.bh-finished-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.bh-btn-primary {
  min-width: 44px;
  min-height: 44px;
  background: #ffb066;
  color: #2a1408;
  border: none;
  border-radius: 999px;
  padding: 10px 24px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s,
    transform 0.15s,
    opacity 0.15s,
    box-shadow 0.15s,
    filter 0.15s;
}
.bh-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(255, 176, 102, 0.45);
}
.bh-btn-secondary {
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 10px 22px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s,
    transform 0.15s,
    opacity 0.15s,
    box-shadow 0.15s,
    filter 0.15s;
}
.bh-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.3);
}

@media (max-width: 900px) {
  .bh-title {
    top: 16px;
    left: 18px;
    font-size: 22px;
  }
  .bh-subtitle {
    font-size: 11px;
  }
  .bh-stats {
    bottom: 16px;
    left: 18px;
    font-size: 10px;
  }
  .bh-btn-back-floating {
    top: 14px;
    right: 16px;
    padding: 6px 14px;
    font-size: 11px;
  }
  .bh-finished-card {
    padding: 28px 22px;
    max-width: 92vw;
  }
  .bh-finished h1 {
    font-size: 30px;
  }
}

/* ---------- Maze level ---------- */
.btn-maze {
  background: linear-gradient(
    135deg,
    rgba(120, 220, 255, 0.18),
    rgba(255, 140, 220, 0.18)
  );
  color: #e8f4ff;
  border: 1px solid rgba(150, 220, 255, 0.4);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition:
    background 0.2s,
    color 0.2s,
    border-color 0.2s,
    transform 0.2s,
    opacity 0.2s,
    box-shadow 0.2s,
    filter 0.2s;
}
.btn-maze:hover {
  background: linear-gradient(
    135deg,
    rgba(120, 220, 255, 0.3),
    rgba(255, 140, 220, 0.3)
  );
  border-color: rgba(150, 220, 255, 0.7);
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(120, 220, 255, 0.25);
}

.maze-level {
  position: fixed;
  inset: 0;
  z-index: 30;
  animation: fade-in 0.3s ease;
}
.maze-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.maze-planets-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 31;
}
.maze-planet {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 35%,
    color-mix(in srgb, var(--planet-color, #ffd66b) 80%, white),
    var(--planet-color, #ffd66b) 65%,
    color-mix(in srgb, var(--planet-color, #ffd66b) 60%, black) 100%
  );
  transform-origin: center center;
  will-change: transform, opacity;
  transition: opacity 0.45s ease;
  filter: drop-shadow(0 0 14px var(--glow, #ffd66b));
}
.maze-planet::after {
  content: "";
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--glow, #ffd66b) 38%, transparent) 0%,
    transparent 65%
  );
  z-index: -1;
  animation: maze-planet-pulse 2.4s ease-in-out infinite;
}
.maze-planet.next {
  filter: drop-shadow(0 0 18px var(--glow, #ffd66b))
    drop-shadow(0 0 28px rgba(255, 214, 107, 0.52));
}
.maze-planet.next::before {
  content: "";
  position: absolute;
  inset: -28%;
  border: 2px solid rgba(255, 214, 107, 0.62);
  border-radius: 50%;
  animation: target-ring-pulse 1.25s ease-in-out infinite;
  pointer-events: none;
}
.maze-planet-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
@keyframes maze-planet-pulse {
  0%,
  100% {
    opacity: 0.7;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

.maze-hud-top {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 8px 14px 8px 8px;
  z-index: 32;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.maze-btn-back {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 12px 18px;
  min-height: 44px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  letter-spacing: 0.02em;
  transition:
    background 0.16s cubic-bezier(0.22, 0.61, 0.36, 1),
    color 0.16s cubic-bezier(0.22, 0.61, 0.36, 1),
    border-color 0.16s cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 0.16s cubic-bezier(0.22, 0.61, 0.36, 1),
    opacity 0.16s cubic-bezier(0.22, 0.61, 0.36, 1),
    box-shadow 0.16s cubic-bezier(0.22, 0.61, 0.36, 1),
    filter 0.16s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.maze-btn-back:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}
.maze-btn-back:active {
  transform: translateY(0) scale(0.97);
}
.maze-counter {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: "Fraunces", serif;
}
.maze-counter-num {
  font-size: 26px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
}
.maze-counter-sep {
  font-size: 18px;
  color: var(--ink-faint);
}
.maze-counter-total {
  font-size: 18px;
  color: var(--ink-dim);
}
.maze-counter-label {
  font-family: "Inter", sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  margin-left: 4px;
}
.maze-icons {
  display: flex;
  gap: 6px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}
.maze-icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid;
  transition:
    background 0.4s,
    color 0.4s,
    border-color 0.4s,
    transform 0.4s,
    opacity 0.4s,
    box-shadow 0.4s,
    filter 0.4s;
}
.maze-icon.found {
  transform: scale(1.15);
  box-shadow: 0 0 10px currentColor;
}
.maze-next-card {
  position: absolute;
  left: 50%;
  top: auto;
  bottom: 82px;
  z-index: 30;
  display: grid;
  grid-template-columns: auto 34px minmax(0, auto) auto;
  align-items: center;
  gap: 9px;
  padding: 10px 16px;
  border: 2px solid rgba(154, 215, 255, 0.42);
  border-radius: 999px;
  background: rgba(13, 12, 32, 0.68);
  color: var(--ink);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.28);
  max-width: calc(100vw - 48px);
  transform: translateX(-50%);
  pointer-events: auto;
}
.maze-next-card span {
  color: #7ee7ff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.maze-next-card strong {
  font-size: 20px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.maze-next-card em {
  color: var(--ink-dim);
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
}
.maze-guide-next {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: #7ee7ff;
  color: #071024;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(126, 231, 255, 0.38);
}
.maze-guide-next:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
.maze-next-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.maze-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  color: #fff7d8;
  font-weight: 900;
  letter-spacing: 0;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 10px 18px;
  z-index: 32;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  line-height: 1.3;
  text-align: center;
}

.maze-toast {
  position: absolute;
  top: 32%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-family: "Fraunces", serif;
  font-size: 36px;
  letter-spacing: 0.01em;
  background: rgba(14, 12, 32, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 14px 28px;
  z-index: 33;
  pointer-events: none;
  animation: toast-pop 2.6s ease forwards;
  white-space: nowrap;
}
.maze-toast-text {
  color: var(--ink-dim);
  font-size: 22px;
  font-weight: 300;
}
.maze-toast-name {
  font-weight: 500;
  text-shadow: 0 0 24px currentColor;
}
.maze-toast-emoji {
  font-size: 28px;
}
@keyframes toast-pop {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.8) translateY(8px);
  }
  18% {
    opacity: 1;
    transform: translateX(-50%) scale(1.05) translateY(0);
  }
  28% {
    transform: translateX(-50%) scale(1) translateY(0);
  }
  82% {
    opacity: 1;
    transform: translateX(-50%) scale(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(0.96) translateY(-12px);
  }
}

.maze-victory {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 4, 20, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 34;
  animation: fade-in 0.4s ease;
}
.maze-victory-card {
  background: linear-gradient(
    180deg,
    rgba(20, 18, 44, 0.95),
    rgba(10, 8, 28, 0.95)
  );
  border: 1px solid rgba(255, 214, 107, 0.3);
  border-radius: 24px;
  padding: 40px 48px;
  text-align: center;
  max-width: 460px;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(255, 214, 107, 0.15);
  animation: detail-enter 0.5s ease;
}
.maze-victory-emoji {
  font-size: 64px;
  margin-bottom: 12px;
  animation: rocket-bob 1.6s ease-in-out infinite;
}
@keyframes rocket-bob {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }
  50% {
    transform: translateY(-8px) rotate(4deg);
  }
}
.maze-victory h1 {
  font-family: "Fraunces", serif;
  font-size: 42px;
  font-weight: 400;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 0.005em;
}
.maze-victory p {
  color: var(--ink-dim);
  margin-bottom: 24px;
  font-size: 15px;
}
.maze-victory-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}
.maze-victory-planet {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.4);
  animation: vp-pop 0.6s ease backwards;
}
.maze-victory-planet:nth-child(1) {
  animation-delay: 0.05s;
}
.maze-victory-planet:nth-child(2) {
  animation-delay: 0.12s;
}
.maze-victory-planet:nth-child(3) {
  animation-delay: 0.19s;
}
.maze-victory-planet:nth-child(4) {
  animation-delay: 0.26s;
}
.maze-victory-planet:nth-child(5) {
  animation-delay: 0.33s;
}
.maze-victory-planet:nth-child(6) {
  animation-delay: 0.4s;
}
.maze-victory-planet:nth-child(7) {
  animation-delay: 0.47s;
}
@keyframes vp-pop {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.maze-victory-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.maze-memory-start {
  margin: 0 auto 18px;
  min-height: 46px;
  border: 1px solid rgba(126, 231, 255, 0.42);
  border-radius: 999px;
  padding: 11px 18px;
  background: rgba(126, 231, 255, 0.16);
  color: #dff8ff;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
}
.maze-memory-mission {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 13px;
  border: 1px solid rgba(126, 231, 255, 0.25);
  border-radius: 16px;
  background: rgba(126, 231, 255, 0.08);
}
.maze-memory-mission > strong {
  color: #dff8ff;
  font-size: 15px;
}
.maze-memory-sequence {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
}
.maze-memory-sequence.hide button {
  background: rgba(255, 255, 255, 0.1) !important;
}
.maze-memory-sequence button {
  position: relative;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255, 255, 255, 0.62);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.24);
}
.maze-memory-sequence button.tapped {
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 0 18px rgba(126, 231, 255, 0.55);
}
.maze-memory-sequence button span {
  position: absolute;
  right: -4px;
  bottom: -4px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #fff7d8;
  color: #1a1108;
  font-size: 10px;
  font-weight: 900;
}
.maze-memory-picks {
  display: flex;
  justify-content: center;
  gap: 6px;
}
.maze-memory-picks i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}
.maze-memory-picks i.on {
  background: var(--pick-color, #7ee7ff);
  box-shadow: 0 0 10px var(--pick-color, #7ee7ff);
}
.maze-btn-primary {
  background: var(--accent);
  color: #1a1108;
  border: none;
  border-radius: 999px;
  padding: 16px 28px;
  min-height: 56px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  letter-spacing: 0.02em;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s,
    transform 0.15s,
    opacity 0.15s,
    box-shadow 0.15s,
    filter 0.15s;
}
.maze-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(255, 214, 107, 0.4);
}
.maze-btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 16px 26px;
  min-height: 56px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  letter-spacing: 0.02em;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s,
    transform 0.15s,
    opacity 0.15s,
    box-shadow 0.15s,
    filter 0.15s;
}
.maze-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.3);
}

@media (max-width: 900px) {
  .helmet-rotate-btn {
    width: 52px;
    height: 52px;
  }
  .helmet-rotate-btn.prev {
    left: -8px;
  }
  .helmet-rotate-btn.next {
    right: -8px;
  }
  .maze-next-card {
    left: 50%;
    top: auto;
    bottom: 78px;
    right: auto;
    grid-template-columns: auto 28px minmax(62px, 1fr) auto;
    gap: 8px;
    width: min(296px, calc(100vw - 32px));
    padding: 7px 11px;
  }
  .maze-guide-next {
    grid-column: 1 / -1;
    width: 100%;
  }
  .maze-next-card strong {
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
  }
  .maze-hint {
    bottom: 10px;
    white-space: normal;
  }
}

.maze-joy {
  position: fixed;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 214, 107, 0.4);
  background: rgba(14, 12, 32, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 33;
  pointer-events: none;
}
.maze-joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 35%,
    rgba(255, 255, 255, 0.9),
    rgba(255, 214, 107, 0.9)
  );
  box-shadow: 0 4px 14px rgba(255, 214, 107, 0.5);
  transition: transform 0.05s linear;
}

@media (max-width: 900px) {
  .maze-hud-top {
    top: 10px;
    gap: 10px;
    padding: 6px 10px 6px 6px;
  }
  .maze-icons {
    display: none;
  }
  .maze-counter-num {
    font-size: 22px;
  }
  .maze-victory-card {
    padding: 28px 24px;
    max-width: 92vw;
  }
  .maze-victory h1 {
    font-size: 32px;
  }
  .maze-toast {
    max-width: calc(100vw - 32px);
    white-space: normal;
    text-align: center;
    flex-wrap: wrap;
    justify-content: center;
    font-size: 26px;
    padding: 10px 20px;
  }
  .maze-toast-text {
    font-size: 16px;
  }
}
