:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-2: #8a6bff;
  --secondary: #2a2b3d;
  --text: #fff;
  --muted: #aaadbe;
  --gold: #ffc93c;
  --c-red: #f0364a;
  --c-blue: #3a8cf0;
  --c-yellow: #ffd23a;
  --c-green: #3fc25a;
  --c-purple: #9a52f0;
  --c-white: #f4f6fb;
  --u: 44px;
  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 {
  margin: 0;
  width: 100%;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
body {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
button:disabled {
  cursor: default;
}
:focus-visible {
  outline: 3px solid #ffd23a;
  outline-offset: 2px;
}
.er-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- shell */
.er-shell {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* HUD */
.er-hud {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  width: min(100%, calc((100vh - 150px) * 5 / 3));
  min-width: min(100%, 300px);
  margin: 0 auto;
}
.er-hud-gap {
  flex: 1;
}
.er-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(180deg, #282a3c, #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;
  font-weight: 900;
  white-space: nowrap;
  min-width: 0;
}
.er-chip svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: none;
}
.er-chip strong {
  font-variant-numeric: tabular-nums;
}
.er-chip-room {
  color: #ffd98a;
  overflow: hidden;
}
.er-chip-room span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.er-chip-btn {
  transition: transform 0.12s ease, filter 0.12s ease;
}
.er-chip-btn:hover {
  filter: brightness(1.18);
}
.er-chip-btn:active {
  transform: scale(0.94);
}
.er-icon {
  width: 40px;
  padding: 0;
  justify-content: center;
}
.er-hint-btn {
  background: linear-gradient(180deg, #ffe066, #f5a511);
  color: #3a2300;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    0 3px 0 #a66a00;
}
.er-hint-count {
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #3a2300;
  color: #ffe066;
  font-size: 12px;
  display: inline-grid;
  place-items: center;
}
#mute-btn .er-x {
  display: none;
}
#mute-btn.muted .er-x {
  display: inline;
}
#mute-btn.muted .er-wave {
  display: none;
}

/* ---------------------------------------------------------------- stage */
.er-stage-wrap {
  position: relative;
  width: min(100%, calc((100vh - 150px) * 5 / 3));
  min-width: min(100%, 300px);
  margin: 0 auto;
  container-type: inline-size;
}
.er-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 3;
  border-radius: 18px;
  overflow: hidden;
  background: #0a0b16;
  box-shadow:
    0 0 0 3px #2a2b3d,
    0 14px 40px rgba(0, 0, 0, 0.55);
}
.er-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.er-scene text {
  font-family: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  font-weight: 900;
}
.er-hotspots {
  position: absolute;
  inset: 0;
}
.er-hot {
  position: absolute;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
@media (hover: hover) {
  .er-hot:hover {
    background: rgba(255, 255, 255, 0.07);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  }
}
.er-hot:focus-visible {
  outline: 3px dashed #ffd23a;
  outline-offset: -3px;
  background: rgba(255, 210, 58, 0.12);
}
.er-viewname {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(10, 11, 22, 0.6);
  backdrop-filter: blur(4px);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #e8e9f5;
  pointer-events: none;
  white-space: nowrap;
}
.er-turn {
  position: absolute;
  top: 50%;
  width: 48px;
  height: 64px;
  margin-top: -32px;
  border: 0;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(122, 92, 255, 0.92), rgba(78, 46, 220, 0.92));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    0 4px 0 #2d1a8a,
    0 8px 18px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s ease;
  z-index: 3;
}
.er-turn svg {
  width: 28px;
  height: 28px;
}
.er-turn:active {
  transform: scale(0.9);
}
.er-turn-l {
  left: 8px;
}
.er-turn-r {
  right: 8px;
}
.er-back {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 3;
  height: 44px;
  padding: 0 16px 0 10px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(180deg, #7a5cff, #5230e6);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    0 3px 0 #2d1a8a;
  font-weight: 900;
  font-size: 15px;
}
.er-back svg {
  width: 20px;
  height: 20px;
}
.er-back:active {
  transform: scale(0.94);
}

.er-toast {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translate(-50%, 20px);
  max-width: min(88%, 560px);
  padding: 10px 18px;
  border-radius: 16px;
  background: rgba(20, 21, 36, 0.92);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.12),
    0 8px 20px rgba(0, 0, 0, 0.45);
  font-size: 15px;
  line-height: 1.3;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.3);
  z-index: 4;
}
.er-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.er-toast.bad {
  box-shadow:
    0 0 0 2px #ff5a6a,
    0 8px 20px rgba(0, 0, 0, 0.45);
}

.er-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  overflow: visible;
}
.er-particle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}
.er-ripple {
  position: absolute;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
}
.er-pop {
  position: absolute;
  font-size: 30px;
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 1.5px #2d1a8a;
  text-shadow:
    0 3px 0 #6842ff,
    0 6px 14px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}
.er-fly {
  position: fixed;
  width: 56px;
  height: 56px;
  z-index: 50;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}
.er-fly svg {
  width: 100%;
  height: 100%;
}

/* pickups in the scene */
.er-twinkle {
  transform-box: fill-box;
  transform-origin: center;
  animation: er-twinkle 1.6s ease-in-out infinite;
}
@keyframes er-twinkle {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.3) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1) rotate(45deg);
  }
}
.er-flicker {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: er-flicker 0.5s ease-in-out infinite alternate;
}
@keyframes er-flicker {
  from {
    transform: scale(1, 1);
  }
  to {
    transform: scale(1.06, 0.93) skewX(2deg);
  }
}
.er-swing {
  transform-box: view-box;
  transform-origin: 780px 300px;
  animation: er-swing 1.2s ease-in-out infinite alternate;
}
@keyframes er-swing {
  from {
    transform: rotate(-6deg);
  }
  to {
    transform: rotate(4deg);
  }
}
.er-blink {
  animation: er-blink 1s steps(2) infinite;
}
@keyframes er-blink {
  50% {
    opacity: 0.2;
  }
}
.er-laser {
  animation: er-laser 0.9s ease-in-out infinite alternate;
}
@keyframes er-laser {
  from {
    opacity: 0.55;
  }
  to {
    opacity: 1;
  }
}

/* coach */
.er-coach {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 5;
  pointer-events: none;
}
.er-ring {
  position: absolute;
  left: -30px;
  top: -30px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 4px solid #ffd23a;
  animation: er-ring 1.3s ease-out infinite;
}
@keyframes er-ring {
  from {
    transform: scale(0.5);
    opacity: 1;
  }
  to {
    transform: scale(1.5);
    opacity: 0;
  }
}
.er-hand {
  position: absolute;
  left: -8px;
  top: 4px;
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
  animation: er-tap 1.3s ease-in-out infinite;
}
@keyframes er-tap {
  0%,
  100% {
    transform: translate(8px, 14px);
  }
  45% {
    transform: translate(0, 0) scale(0.92);
  }
}
.er-coach-bubble {
  position: absolute;
  left: 34px;
  top: 38px;
  padding: 8px 14px;
  border-radius: 14px;
  background: #fff;
  color: #1a1b28;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
}
.er-coach.flip .er-coach-bubble {
  left: auto;
  right: 34px;
}

/* hint card */
.er-hint-card {
  position: absolute;
  left: 50%;
  top: 56px;
  transform: translate(-50%, 0);
  width: min(92%, 420px);
  z-index: 7;
  padding: 14px 16px 12px;
  border-radius: 20px;
  background: linear-gradient(180deg, #2b2c44, #1d1e30);
  box-shadow:
    0 0 0 2px #ffd23a,
    0 16px 40px rgba(0, 0, 0, 0.6);
}
.er-hint-top {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffd98a;
  font-size: 15px;
}
.er-hint-top svg {
  width: 22px;
  height: 22px;
}
.er-hint-card p {
  margin: 8px 0 12px;
  font-size: 17px;
  line-height: 1.35;
}
.er-hint-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.er-hint-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* pills */
.er-pill {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 900;
  transition:
    transform 0.12s ease,
    filter 0.12s ease;
}
.er-pill:active {
  transform: scale(0.95);
}
.er-pill:hover {
  filter: brightness(1.1);
}
.er-pill:disabled {
  opacity: 0.45;
  filter: none;
}
.er-pill-primary {
  background: linear-gradient(180deg, #8466ff, #6842ff 55%, #5230e6);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    0 4px 0 #2d1a8a,
    0 8px 20px rgba(104, 66, 255, 0.4);
}
.er-pill-secondary {
  background: linear-gradient(180deg, #34364c, #2a2b3d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 3px 0 #16172a;
}
.er-pill-big {
  min-height: 56px;
  padding: 0 34px;
  font-size: 20px;
}

/* ------------------------------------------------------------- puzzles */
.er-puzzle {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 2;
  --u: clamp(40px, 5.6cqw, 58px);
}
.pz {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 0.22);
  padding: calc(var(--u) * 0.28) calc(var(--u) * 0.4);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(38, 40, 62, 0.94), rgba(22, 23, 38, 0.94));
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 18px 40px rgba(0, 0, 0, 0.55);
  max-width: 96%;
}
.pz.solved {
  box-shadow:
    0 0 0 3px #3fe07a,
    0 0 30px rgba(63, 224, 122, 0.45),
    0 18px 40px rgba(0, 0, 0, 0.55);
}
.pz-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: calc(var(--u) * 0.36);
  color: #ffd98a;
  letter-spacing: 0.03em;
}
.pz-badge {
  padding: 2px 10px;
  border-radius: 999px;
  background: #3fe07a;
  color: #08331a;
  font-size: 0.8em;
}
.pz-help {
  margin: 0;
  font-size: calc(var(--u) * 0.28);
  color: var(--muted);
  text-align: center;
  max-width: 30em;
}

/* wheels */
.pz-wheels {
  display: flex;
  gap: calc(var(--u) * 0.2);
}
.pz-wheel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.pz-wlabel {
  height: calc(var(--u) * 0.6);
  display: grid;
  place-items: center;
  font-size: calc(var(--u) * 0.45);
  color: #fff;
}
.pz-wlabel svg {
  width: calc(var(--u) * 0.62);
  height: calc(var(--u) * 0.62);
}
.pz-wbtn {
  width: calc(var(--u) * 1.15);
  height: calc(var(--u) * 0.82);
  min-height: 40px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #3a3c55, #2a2b3d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 3px 0 #111222;
  font-size: calc(var(--u) * 0.36);
  color: #c9c3ff;
}
.pz-wbtn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #111222;
}
.pz-wval {
  width: calc(var(--u) * 1.15);
  height: calc(var(--u) * 1.3);
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff1b0, #f2c14e 45%, #a8701c);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.6),
    inset 0 -6px 10px rgba(90, 50, 0, 0.45),
    0 4px 0 #6a4410;
  color: #3a2300;
  font-size: calc(var(--u) * 0.72);
  font-weight: 900;
  overflow: hidden;
}

/* sequences */
.pz-slots {
  display: flex;
  gap: 8px;
}
.pz-slot {
  width: calc(var(--u) * 0.62);
  height: calc(var(--u) * 0.62);
  border-radius: 50%;
  background: #0e0f1c;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  font-size: calc(var(--u) * 0.4);
  color: #fff;
}
.pz-slot.on {
  background: #6842ff;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    0 0 12px rgba(255, 255, 255, 0.3);
}
.pz-seq {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: calc(var(--u) * 0.18);
}
.pz-gem {
  width: calc(var(--u) * 1.3);
  height: calc(var(--u) * 1.3);
  border: 0;
  border-radius: 18px;
  padding: 6px;
  background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.3));
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.12),
    0 4px 0 #111222;
  transition: transform 0.1s ease;
}
.pz-gem svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.45));
}
.pz-gem:active:not(:disabled) {
  transform: scale(0.88);
}
.pz-dirpad {
  display: grid;
  grid-template-areas:
    ". up ."
    "left down right";
  gap: 6px;
}
.pz-arrow {
  width: calc(var(--u) * 1.2);
  height: calc(var(--u) * 1.05);
  min-height: 42px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffe066, #f5a511);
  color: #3a2300;
  font-size: calc(var(--u) * 0.6);
  font-weight: 900;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    0 4px 0 #a66a00;
}
.pz-arrow:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #a66a00;
}
.pz-arrow-up {
  grid-area: up;
}
.pz-arrow-down {
  grid-area: down;
}
.pz-arrow-left {
  grid-area: left;
}
.pz-arrow-right {
  grid-area: right;
}

/* keypad */
.pz-display {
  min-width: calc(var(--u) * 3.6);
  padding: 4px 14px;
  border-radius: 10px;
  background: #07120c;
  color: #6dff9c;
  font-size: calc(var(--u) * 0.6);
  letter-spacing: 0.3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.8);
  text-shadow: 0 0 8px rgba(109, 255, 156, 0.7);
}
.pz-keys {
  display: grid;
  grid-template-columns: repeat(3, calc(var(--u) * 1.15));
  gap: 6px;
}
.pz-key {
  height: calc(var(--u) * 0.95);
  min-height: 40px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #f4f7fb, #b8c3d1);
  color: #1b2533;
  font-size: calc(var(--u) * 0.42);
  font-weight: 900;
  box-shadow:
    inset 0 2px 0 #fff,
    0 3px 0 #56627a;
}
.pz-key.ok {
  background: linear-gradient(180deg, #8ff0a8, #2fb85a);
  color: #06331a;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.6),
    0 3px 0 #16702c;
}
.pz-key.clr {
  background: linear-gradient(180deg, #ff9aa6, #e0364a);
  color: #fff;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.4),
    0 3px 0 #8a1020;
}
.pz-key:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #56627a;
}

/* grids */
.pz-grid {
  display: grid;
  grid-template-columns: repeat(var(--n), var(--cell));
  gap: 5px;
  --cell: calc(var(--u) * 1.15);
}
.pz-slide {
  --cell: calc(var(--u) * 1.4);
  padding: 5px;
  border-radius: 14px;
  background: #2a160b;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.6);
}
.pz-tile,
.pz-gap {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  border-radius: 8px;
}
.pz-tile {
  border: 0;
  padding: 0;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.25),
    0 3px 0 rgba(0, 0, 0, 0.5);
  background: #111;
  transition: transform 0.1s ease;
}
.pz-tile svg {
  display: block;
  width: 100%;
  height: 100%;
}
.pz-tile:active:not(:disabled) {
  transform: scale(0.94);
}
.pz-num {
  position: absolute;
  left: 4px;
  top: 3px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: rgba(10, 11, 22, 0.72);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
}
.pz-slide .pz-gap {
  background: rgba(0, 0, 0, 0.35);
}
.solved .pz-slide {
  gap: 0;
}
.solved .pz-slide .pz-tile {
  border-radius: 0;
  box-shadow: none;
}

.pz-lights {
  --cell: calc(var(--u) * 1.35);
  gap: 8px;
}
.pz-light {
  width: var(--cell);
  height: var(--cell);
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #3a3c55, #20212f);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 4px 0 #0c0d18;
  display: grid;
  place-items: center;
  transition: transform 0.1s ease;
}
.pz-light span {
  width: 55%;
  height: 55%;
  border-radius: 50%;
  background: #4a1a26;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.6);
  transition:
    background 0.18s ease,
    box-shadow 0.18s ease;
}
.fuse .pz-light.on span {
  background: radial-gradient(circle at 35% 30%, #d6ffe2, #3fe07a 55%, #17903e);
  box-shadow:
    0 0 16px #3fe07a,
    0 0 4px #fff;
}
.laser .pz-light span {
  background: #2a3040;
}
.laser .pz-light.on span {
  background: radial-gradient(circle at 35% 30%, #ffd6dc, #ff3050 55%, #9c1026);
  box-shadow:
    0 0 16px #ff3050,
    0 0 4px #fff;
}
.pz-light:active:not(:disabled) {
  transform: scale(0.9);
}

.pz-pattern {
  --cell: calc(var(--u) * 1.02);
  gap: 5px;
  padding: 8px;
  border-radius: 14px;
  background: #0b1520;
}
.pz-cell {
  width: var(--cell);
  height: var(--cell);
  min-width: 40px;
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: #1c2a3a;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.6);
  transition:
    background 0.15s ease,
    transform 0.1s ease;
}
.pz-cell.on {
  background: linear-gradient(180deg, #9fd8ff, #3a8cf0);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    0 0 12px rgba(58, 140, 240, 0.7);
}
.pz-pattern.ship .pz-cell {
  border-radius: 50%;
  background: #56627a;
}
.pz-pattern.ship .pz-cell.on {
  background: radial-gradient(circle at 35% 30%, #fff9d0, #ffd23a 55%, #b37a00);
  box-shadow: 0 0 14px #ffd23a;
}
.pz-cell:active:not(:disabled) {
  transform: scale(0.9);
}

.pz-jig {
  --cell: calc(var(--u) * 2);
  gap: 6px;
}
.pz-piece {
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.pz-piece > span {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.pz-piece svg {
  display: block;
  width: 100%;
  height: 100%;
}
.pz-piece.sel {
  transform: scale(1.08) translateY(-4px);
  box-shadow:
    0 0 0 4px #ffd23a,
    0 12px 22px rgba(0, 0, 0, 0.6);
  z-index: 1;
}
.solved .pz-jig {
  gap: 0;
}
.solved .pz-piece {
  border-radius: 0;
  box-shadow: none;
}
.pz-rot {
  min-height: 40px;
}

/* ---------------------------------------------------------------- bag */
.er-bag {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, calc((100vh - 150px) * 5 / 3));
  min-width: min(100%, 300px);
  margin: 0 auto;
  padding: 7px;
  border-radius: 18px;
  background: linear-gradient(180deg, #212233, #1a1b28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 4px 14px rgba(0, 0, 0, 0.35);
}
.er-slots {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: none;
  max-width: 62%;
  scrollbar-width: none;
}
.er-slot {
  position: relative;
  flex: none;
  width: 56px;
  height: 56px;
  padding: 4px;
  border: 0;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 30%, #3a3c58, #23243a);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -3px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.12s ease;
}
.er-slot svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}
.er-slot.empty {
  background: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}
.er-slot.sel {
  background: radial-gradient(circle at 50% 30%, #8a6bff, #5230e6);
  box-shadow:
    0 0 0 3px #ffd23a,
    0 0 16px rgba(255, 210, 58, 0.55);
  transform: translateY(-3px);
}
.er-slot.glow::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  box-shadow: 0 0 18px 6px rgba(255, 214, 110, 0.35);
  pointer-events: none;
}
.er-slot-num {
  position: absolute;
  right: 4px;
  bottom: 2px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
}
.er-slot:active:not(.empty) {
  transform: scale(0.92);
}
.er-bag-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 13px;
  line-height: 1.25;
  color: var(--muted);
}
.er-bag-info strong {
  color: #fff;
  font-size: 15px;
}
.er-bag-info span {
  color: #d9dbea;
}
.er-bag-info em {
  font-style: normal;
  font-size: 12px;
  color: #9d8bff;
}

/* ------------------------------------------------------------- overlays */
.er-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow-y: auto;
  background: radial-gradient(circle at 50% 30%, rgba(60, 40, 140, 0.55), rgba(8, 8, 20, 0.88));
  backdrop-filter: blur(3px);
}
.er-panel {
  position: relative;
  width: min(100%, 880px);
  padding: 18px 18px 20px;
  border-radius: 26px;
  background: linear-gradient(180deg, #25263a, #1a1b28);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.08),
    0 24px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
  overflow: hidden;
  animation: er-panel-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes er-panel-in {
  from {
    transform: scale(0.9) translateY(10px);
    opacity: 0;
  }
}
.er-panel h2 {
  margin: 0;
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 900;
  letter-spacing: 0.01em;
  background: linear-gradient(180deg, #fff, #d9ccff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #4a2cc9);
}
.er-sub {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 15px;
}
.er-logo {
  width: 58px;
  height: 58px;
  margin: 0 auto 2px;
  animation: er-bob 2.4s ease-in-out infinite;
}
.er-logo svg {
  width: 100%;
  height: 100%;
}
@keyframes er-bob {
  50% {
    transform: translateY(-5px) rotate(-3deg);
  }
}
.er-stars-total {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #2a2b3d;
  color: #ffd23a;
  font-size: 15px;
  margin-bottom: 12px;
}
.er-stars-total svg {
  width: 18px;
  height: 18px;
  fill: #ffd23a;
}
.er-rooms {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.er-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px 6px 8px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #34364f, #25263a);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 4px 0 #111222;
  text-align: left;
  transition: transform 0.14s ease;
  min-width: 0;
}
.er-card:hover:not(:disabled) {
  transform: translateY(-3px);
}
.er-card:active:not(:disabled) {
  transform: scale(0.96);
}
.er-card-art {
  position: relative;
  display: block;
  aspect-ratio: 5 / 3;
  border-radius: 11px;
  overflow: hidden;
  background: #0a0b16;
}
.er-card-art svg {
  width: 100%;
  height: 100%;
  display: block;
}
.er-card.locked .er-card-art svg:first-child {
  filter: grayscale(1) brightness(0.45);
}
.er-lock {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.er-lock svg {
  width: 40%;
  height: 60%;
}
.er-card-num {
  position: absolute;
  left: 10px;
  top: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #6842ff;
  font-size: 14px;
  box-shadow: 0 2px 0 #2d1a8a;
}
.er-card-name {
  font-size: 14px;
  font-weight: 900;
  line-height: 1.15;
  padding: 0 2px;
}
.er-card-stars {
  display: flex;
  gap: 2px;
  padding: 0 2px;
  font-style: normal;
}
.er-card-stars i {
  font-style: normal;
  color: #3a3c55;
  font-size: 16px;
}
.er-card-stars i.on {
  color: #ffd23a;
  text-shadow: 0 0 6px rgba(255, 210, 58, 0.6);
}
.er-card-badge,
.er-card-time {
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: #3fe07a;
  color: #06331a;
}
.er-card-time {
  background: rgba(10, 11, 22, 0.75);
  color: #fff;
}
.er-panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.er-panel-win {
  width: min(100%, 460px);
}
.er-rays {
  position: absolute;
  left: 50%;
  top: 40%;
  width: 700px;
  height: 700px;
  margin: -350px 0 0 -350px;
  background: repeating-conic-gradient(from 0deg, rgba(255, 210, 58, 0.09) 0 10deg, transparent 10deg 20deg);
  animation: er-spin 18s linear infinite;
  pointer-events: none;
}
@keyframes er-spin {
  to {
    transform: rotate(360deg);
  }
}
.er-panel-win > *:not(.er-rays) {
  position: relative;
}
.er-win-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 6px 0 10px;
}
.er-bigstar {
  width: 72px;
  height: 72px;
  animation: er-star-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.5) both;
  animation-delay: var(--d);
}
.er-bigstar:nth-child(2) {
  width: 88px;
  height: 88px;
  margin-top: -10px;
}
.er-bigstar svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35));
}
.er-bigstar.on svg {
  filter: drop-shadow(0 0 12px rgba(255, 210, 58, 0.7)) drop-shadow(0 4px 0 #8a5200);
}
@keyframes er-star-in {
  from {
    transform: scale(0) rotate(-40deg);
    opacity: 0;
  }
}
.er-win-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 0 0 16px;
}
.er-win-stats div {
  min-width: 88px;
  padding: 8px 10px;
  border-radius: 14px;
  background: #2a2b3d;
}
.er-win-stats dt {
  font-size: 12px;
  color: var(--muted);
}
.er-win-stats dd {
  margin: 2px 0 0;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 760px) {
  .er-rooms {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .er-shell {
    padding: 6px 6px 10px;
    gap: 6px;
  }
  .er-hud,
  .er-stage-wrap,
  .er-bag {
    width: 100%;
    min-width: 0;
  }
  .er-hud {
    gap: 4px;
  }
  .er-chip {
    height: 40px;
    padding: 0 9px;
    font-size: 14px;
  }
  .er-hide-xs {
    display: none;
  }
  .er-chip-room {
    display: none;
  }
  .er-hud .er-chip {
    flex: none;
  }
  .er-hud-gap {
    flex: 1 1 0;
    min-width: 0;
  }
  .er-chip-btn {
    min-width: 40px;
    justify-content: center;
  }
  .er-stage {
    border-radius: 14px;
  }
  .er-turn {
    width: 40px;
    height: 52px;
    margin-top: -26px;
    border-radius: 13px;
  }
  .er-turn-l {
    left: 4px;
  }
  .er-turn-r {
    right: 4px;
  }
  .er-back {
    height: 40px;
    left: 6px;
    top: 6px;
    font-size: 14px;
  }
  .er-viewname {
    top: 8px;
    font-size: 11px;
  }
  .er-toast {
    font-size: 13px;
    padding: 8px 12px;
    bottom: 8px;
  }
  /* close-ups: the puzzle panel sits below the picture on phones */
  .er-puzzle {
    position: static;
    --u: 46px;
    margin-top: 8px;
  }
  .er-stage-wrap:not(.has-puzzle) .er-puzzle {
    display: none;
  }
  .pz {
    width: 100%;
    max-width: 100%;
  }
  .er-bag {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .er-slots {
    max-width: 100%;
  }
  .er-hint-card {
    top: 8px;
  }
  .er-hint-card p {
    font-size: 15px;
  }
  .er-rooms {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .er-rooms .er-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
  .er-coach-bubble {
    font-size: 12px;
  }
}
@media (max-width: 360px) {
  .er-chip {
    padding: 0 7px;
    font-size: 13px;
  }
  .er-chip svg {
    width: 16px;
    height: 16px;
  }
  .er-slot {
    width: 50px;
    height: 50px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .er-coach .er-ring,
  .er-hand {
    animation: none;
  }
}
