.passmaze-panel {
  --passmaze-lime: #a8ff35;
  --passmaze-cyan: #47f5ea;
  --passmaze-blue: #3ea8ff;
  --passmaze-ink: #03110f;
  --passmaze-deep: #041713;
  --passmaze-panel: #08251f;
  --passmaze-danger: #ff5f67;
  color: #eefcf7;
}

.card-passmaze {
  background:
    radial-gradient(circle at 82% 24%, rgba(71, 245, 234, .28), transparent 31%),
    radial-gradient(circle at 18% 90%, rgba(168, 255, 53, .13), transparent 36%),
    linear-gradient(145deg, #06231d, #06110d 72%);
}

.card-passmaze .card-top > b,
.card-passmaze .card-top b {
  color: var(--passmaze-cyan, #47f5ea);
}

.card-passmaze .play-card {
  color: #03110f;
  background: linear-gradient(100deg, #a8ff35, #47f5ea);
}

.passmaze-card-preview,
.passmaze-preview {
  position: absolute;
  z-index: 1;
  top: 67px;
  right: 35px;
  width: 196px;
  height: 145px;
  padding: 9px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 4px;
  border: 1px solid rgba(71, 245, 234, .42);
  background: rgba(2, 18, 15, .78);
  box-shadow:
    8px 8px 0 rgba(71, 245, 234, .09),
    inset 0 0 28px rgba(71, 245, 234, .06);
  transform: rotate(2deg);
}

.passmaze-card-preview::before,
.passmaze-preview::before {
  content: "";
  position: absolute;
  inset: 9px;
  background:
    linear-gradient(90deg, transparent 0 18%, rgba(71, 245, 234, .2) 18% 20%, transparent 20% 58%, rgba(71, 245, 234, .2) 58% 60%, transparent 60%),
    linear-gradient(transparent 0 22%, rgba(71, 245, 234, .2) 22% 25%, transparent 25% 70%, rgba(71, 245, 234, .2) 70% 73%, transparent 73%);
}

.passmaze-card-preview > *,
.passmaze-preview > * {
  position: relative;
  z-index: 2;
}

.passmaze-card-preview span,
.passmaze-preview span {
  grid-column: 1;
  grid-row: 4;
  font-size: 37px;
  line-height: 1;
  filter: drop-shadow(0 7px 5px rgba(0, 0, 0, .4));
}

.passmaze-card-preview b,
.passmaze-preview b {
  grid-column: 5;
  grid-row: 1;
  font-size: 35px;
  line-height: 1;
}

.passmaze-card-preview i,
.passmaze-preview i {
  grid-column: 3;
  grid-row: 2;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #03110f;
  background: #a8ff35;
  font: 950 10px/1 ui-monospace, monospace;
  box-shadow: 0 0 15px rgba(168, 255, 53, .45);
}

.passmaze-card-preview i:nth-of-type(1),
.passmaze-preview i:nth-of-type(1) {
  grid-column: 2;
  grid-row: 3;
}

.passmaze-card-preview i:nth-of-type(2),
.passmaze-preview i:nth-of-type(2) {
  grid-column: 3;
  grid-row: 2;
}

.passmaze-card-preview i:nth-of-type(3),
.passmaze-preview i:nth-of-type(3) {
  grid-column: 4;
  grid-row: 1;
}

.passmaze-hud {
  min-height: 72px;
  height: auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  padding: 0;
  background: #03120f;
}

.passmaze-hud > div {
  min-width: 0;
  min-height: 72px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid rgba(255, 255, 255, .08);
  text-align: left;
}

.passmaze-hud > div:last-child {
  border-right: 0;
  text-align: right;
}

.passmaze-hud strong {
  overflow: hidden;
  color: var(--passmaze-cyan);
  font-size: clamp(18px, 4vw, 28px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.passmaze-hud > div:first-child strong,
.passmaze-hud > div:nth-child(2) strong {
  color: var(--passmaze-lime);
}

.passmaze-stage {
  position: relative;
  min-height: 650px;
  padding: clamp(16px, 4vw, 34px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 190px);
  grid-template-areas:
    "prompt prompt"
    "grid controls"
    "feedback feedback";
  align-items: center;
  gap: 16px clamp(16px, 3vw, 28px);
  overflow: hidden;
  background:
    radial-gradient(circle at 70% 15%, rgba(71, 245, 234, .12), transparent 34%),
    radial-gradient(circle at 16% 82%, rgba(168, 255, 53, .08), transparent 34%),
    linear-gradient(rgba(71, 245, 234, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(71, 245, 234, .035) 1px, transparent 1px),
    linear-gradient(145deg, #061e19, #03100d);
  background-size: auto, auto, 34px 34px, 34px 34px, auto;
  isolation: isolate;
}

.passmaze-stage::before {
  content: "PASS / MAZE / LVL";
  position: absolute;
  z-index: -1;
  right: -20px;
  bottom: 20px;
  color: rgba(71, 245, 234, .035);
  font-size: clamp(54px, 11vw, 102px);
  font-style: italic;
  font-weight: 950;
  line-height: .8;
  letter-spacing: -.07em;
  white-space: nowrap;
  transform: rotate(-6deg);
}

.passmaze-stage-head {
  grid-area: prompt;
  width: 100%;
  margin: 0 auto;
  text-align: center;
}

.passmaze-prompt,
#passmazePrompt {
  max-width: 680px;
  min-height: 40px;
  margin: 0 auto;
  color: #eafff7;
  font-size: clamp(22px, 4vw, 38px);
  font-style: italic;
  line-height: .92;
  letter-spacing: -.04em;
  text-align: center;
}

.passmaze-grid {
  --passmaze-size: 5;
  grid-area: grid;
  width: min(100%, 500px);
  aspect-ratio: 1;
  margin: auto;
  padding: clamp(8px, 2vw, 13px);
  display: grid;
  grid-template-columns: repeat(var(--passmaze-size), minmax(0, 1fr));
  grid-template-rows: repeat(var(--passmaze-size), minmax(0, 1fr));
  gap: clamp(3px, .8vw, 7px);
  border: 1px solid rgba(71, 245, 234, .48);
  outline: 7px solid rgba(71, 245, 234, .035);
  background:
    linear-gradient(135deg, rgba(71, 245, 234, .08), transparent 43%),
    rgba(1, 11, 9, .86);
  box-shadow:
    11px 11px 0 rgba(71, 245, 234, .07),
    inset 0 0 42px rgba(71, 245, 234, .055);
}

.passmaze-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(125, 174, 157, .2);
  background: rgba(8, 42, 34, .62);
  box-shadow: inset 0 0 9px rgba(0, 0, 0, .26);
  transition:
    border-color .16s ease,
    background .16s ease,
    box-shadow .16s ease,
    transform .16s ease;
}

.passmaze-cell::before,
.passmaze-cell::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.passmaze-cell::before {
  inset: 19%;
  border: 1px solid rgba(71, 245, 234, .045);
}

.passmaze-cell::after {
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(71, 245, 234, .18);
  transform: translate(-50%, -50%);
}

.passmaze-cell i {
  position: relative;
  z-index: 3;
  display: grid;
  place-items: center;
  color: #dffbf2;
  font: 950 clamp(10px, 3.3vw, 24px)/1 ui-monospace, monospace;
  font-style: normal;
}

.passmaze-cell.is-path {
  border-color: rgba(168, 255, 53, .29);
  background: rgba(86, 140, 40, .18);
}

.passmaze-cell.is-path::after {
  width: 22%;
  height: 22%;
  background: var(--passmaze-lime);
  box-shadow: 0 0 11px rgba(168, 255, 53, .55);
}

.passmaze-cell.is-blocked {
  border-color: rgba(71, 245, 234, .23);
  background:
    repeating-linear-gradient(135deg, rgba(71, 245, 234, .12) 0 5px, rgba(1, 15, 12, .85) 5px 10px),
    #03110e;
}

.passmaze-cell.is-blocked i {
  color: rgba(71, 245, 234, .46);
}

.passmaze-cell.is-checkpoint {
  border-color: rgba(168, 255, 53, .72);
  background: rgba(168, 255, 53, .1);
  box-shadow:
    inset 0 0 14px rgba(168, 255, 53, .14),
    0 0 0 2px rgba(168, 255, 53, .05);
}

.passmaze-cell.is-checkpoint i {
  width: 58%;
  height: 58%;
  border: 1px solid var(--passmaze-lime);
  border-radius: 50%;
  color: var(--passmaze-lime);
  background: rgba(3, 17, 14, .9);
}

.passmaze-cell.is-checkpoint.is-collected i {
  color: #03110f;
  background: var(--passmaze-lime);
  box-shadow: 0 0 16px rgba(168, 255, 53, .5);
}

.passmaze-cell.is-goal {
  border-color: rgba(71, 245, 234, .7);
  background: rgba(71, 245, 234, .1);
}

.passmaze-cell.is-goal i {
  font-family: sans-serif;
  font-size: clamp(14px, 4.4vw, 34px);
  filter: drop-shadow(0 0 8px rgba(71, 245, 234, .48));
}

.passmaze-cell.is-player {
  z-index: 2;
  border-color: var(--passmaze-lime);
  background:
    radial-gradient(circle, rgba(168, 255, 53, .28), transparent 70%),
    rgba(17, 55, 34, .9);
  box-shadow:
    0 0 0 3px rgba(168, 255, 53, .1),
    0 0 22px rgba(168, 255, 53, .28);
  transform: scale(1.055);
}

.passmaze-cell.is-player i {
  font-family: sans-serif;
  font-size: clamp(16px, 5vw, 39px);
  filter: drop-shadow(0 5px 4px rgba(0, 0, 0, .45));
}

.passmaze-cell.is-collision {
  border-color: var(--passmaze-danger);
  background: rgba(255, 95, 103, .2);
  box-shadow: 0 0 20px rgba(255, 95, 103, .34);
  animation: passmaze-collision .28s ease-in-out 2;
}

.passmaze-controls {
  grid-area: controls;
  width: min(100%, 184px);
  margin: auto;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(48px, 1fr));
  grid-template-rows: repeat(3, minmax(48px, 1fr));
  gap: 7px;
  border: 1px solid rgba(71, 245, 234, .2);
  background: rgba(2, 16, 13, .72);
  box-shadow: 8px 8px 0 rgba(71, 245, 234, .055);
}

.passmaze-controls::before {
  display: none;
}

.passmaze-controls > span {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  place-items: center;
  font-size: 25px;
  filter: drop-shadow(0 5px 4px rgba(0, 0, 0, .45));
}

.passmaze-controls button {
  position: relative;
  z-index: 2;
  width: 100%;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 1px solid rgba(71, 245, 234, .5);
  color: var(--passmaze-cyan);
  background:
    linear-gradient(145deg, rgba(71, 245, 234, .1), rgba(3, 17, 14, .92));
  cursor: pointer;
  touch-action: manipulation;
  font: 950 22px/1 ui-monospace, monospace;
  box-shadow: 3px 3px 0 rgba(71, 245, 234, .08);
  transition:
    color .14s ease,
    border-color .14s ease,
    background .14s ease,
    transform .14s ease;
}

.passmaze-controls button[data-passmaze-move="up"] {
  grid-column: 2;
  grid-row: 1;
}

.passmaze-controls button[data-passmaze-move="left"] {
  grid-column: 1;
  grid-row: 2;
}

.passmaze-controls button[data-passmaze-move="down"] {
  grid-column: 2;
  grid-row: 3;
}

.passmaze-controls button[data-passmaze-move="right"] {
  grid-column: 3;
  grid-row: 2;
}

.passmaze-controls button[data-passmaze-move]::before {
  content: none;
}

.passmaze-controls button:hover:not(:disabled) {
  border-color: var(--passmaze-lime);
  color: #03110f;
  background: var(--passmaze-lime);
  transform: translateY(-2px);
}

.passmaze-controls button:active:not(:disabled) {
  transform: translateY(1px) scale(.97);
}

.passmaze-controls button:disabled {
  opacity: .32;
  cursor: not-allowed;
  filter: grayscale(.65);
}

.passmaze-controls button:focus-visible,
.passmaze-cover button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.passmaze-feedback {
  grid-area: feedback;
  min-height: 48px;
  margin: 0;
  padding: 12px 16px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(71, 245, 234, .18);
  color: #9eb9ae;
  background: rgba(2, 16, 13, .76);
  font: 900 9px/1.45 ui-monospace, monospace;
  letter-spacing: .09em;
  text-align: center;
}

.passmaze-feedback.is-correct {
  border-color: rgba(168, 255, 53, .58);
  color: var(--passmaze-lime);
  background: rgba(168, 255, 53, .075);
}

.passmaze-feedback.is-wrong {
  border-color: rgba(255, 95, 103, .58);
  color: #ffafb3;
  background: rgba(255, 95, 103, .075);
}

.passmaze-cover {
  z-index: 12;
  padding: clamp(22px, 5vw, 46px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 82% 15%, rgba(71, 245, 234, .18), transparent 33%),
    radial-gradient(circle at 12% 84%, rgba(168, 255, 53, .11), transparent 30%),
    rgba(2, 15, 12, .95);
  backdrop-filter: blur(10px);
}

.passmaze-cover[hidden],
.passmaze-rules[hidden],
#passmazeRules[hidden] {
  display: none;
}

.passmaze-cover > small {
  display: block;
  margin-bottom: 11px;
  color: var(--passmaze-cyan);
  font: 950 8px/1 ui-monospace, monospace;
  letter-spacing: .19em;
}

.passmaze-cover h3 {
  max-width: 650px;
  margin: 0;
  color: #f0fff9;
  font-size: clamp(34px, 7vw, 62px);
  font-style: italic;
  line-height: .86;
  letter-spacing: -.055em;
}

.passmaze-cover > p {
  max-width: 600px;
  margin: 13px auto 20px;
  color: #aac3b9;
  font-size: 13px;
  line-height: 1.55;
}

.passmaze-rules,
#passmazeRules {
  width: min(100%, 670px);
  margin: 0 auto 20px;
}

.passmaze-rules ol,
#passmazeRules ol {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
}

.passmaze-rules li,
#passmazeRules li {
  min-width: 0;
  padding: 14px 12px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  border: 1px solid rgba(71, 245, 234, .19);
  background: rgba(71, 245, 234, .045);
  text-align: left;
}

.passmaze-rules li > i,
#passmazeRules li > i {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--passmaze-cyan);
  border-radius: 50%;
  color: #03110f;
  background: var(--passmaze-cyan);
  font: 950 9px/1 ui-monospace, monospace;
  font-style: normal;
}

.passmaze-rules strong,
#passmazeRules strong {
  display: block;
  color: #effff9;
  font: 950 9px/1.2 ui-monospace, monospace;
  letter-spacing: .06em;
}

.passmaze-rules p,
#passmazeRules p {
  margin: 6px 0 0;
  color: #87a398;
  font-size: 10px;
  line-height: 1.45;
}

.passmaze-rule-summary {
  padding: 10px 12px;
  border: 1px solid rgba(168, 255, 53, .25);
  color: var(--passmaze-lime) !important;
  background: rgba(168, 255, 53, .05);
  font: 900 8px/1.4 ui-monospace, monospace !important;
  letter-spacing: .08em;
  text-align: center;
}

.passmaze-cover #startPassmaze {
  width: min(100%, 670px);
  min-height: 56px;
  flex: 0 0 auto;
  border: 0;
  color: #03110f;
  background: linear-gradient(90deg, var(--passmaze-lime), var(--passmaze-cyan));
  cursor: pointer;
  touch-action: manipulation;
  font: 950 10px/1.2 ui-monospace, monospace;
  letter-spacing: .1em;
  box-shadow: 7px 7px 0 rgba(71, 245, 234, .1);
}

.passmaze-cover #startPassmaze:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.passmaze-cover #startPassmaze:disabled {
  opacity: .62;
  cursor: wait;
}

.passmaze-discard-save,
#discardPassmazeSave {
  min-height: 44px;
  margin-top: 12px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, .13);
  color: #91aba0;
  background: rgba(255, 255, 255, .025);
  cursor: pointer;
  touch-action: manipulation;
  font: 850 8px/1.35 ui-monospace, monospace;
  letter-spacing: .07em;
}

.passmaze-discard-save[hidden],
#discardPassmazeSave[hidden] {
  display: none;
}

.passmaze-stage[data-phase="checking"] .passmaze-grid {
  border-color: var(--passmaze-blue);
  box-shadow:
    0 0 0 5px rgba(62, 168, 255, .08),
    11px 11px 0 rgba(62, 168, 255, .07);
}

.passmaze-stage[data-phase="correct"] .passmaze-grid,
.passmaze-stage[data-phase="won"] .passmaze-grid,
.passmaze-stage[data-phase="goal"] .passmaze-grid {
  border-color: var(--passmaze-lime);
  box-shadow:
    0 0 0 5px rgba(168, 255, 53, .08),
    0 0 34px rgba(168, 255, 53, .13);
}

.passmaze-stage[data-phase="wrong"] .passmaze-grid,
.passmaze-stage[data-phase="lost"] .passmaze-grid,
.passmaze-stage[data-phase="collision"] .passmaze-grid,
.passmaze-stage[data-phase="limit"] .passmaze-grid {
  border-color: var(--passmaze-danger);
}

@keyframes passmaze-collision {
  35% {
    transform: translateX(-4px) rotate(-2deg);
  }
  70% {
    transform: translateX(4px) rotate(2deg);
  }
}

@media (max-width: 720px) {
  .passmaze-hud {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .passmaze-hud > div {
    min-height: 64px;
    padding: 10px 7px;
    text-align: center;
  }

  .passmaze-hud > div:last-child {
    text-align: center;
  }

  .passmaze-hud small {
    font-size: 6px;
  }

  .passmaze-hud strong {
    font-size: clamp(14px, 5vw, 22px);
  }

  .passmaze-stage {
    min-height: calc(100svh - 140px);
    padding: 13px 12px 22px;
    grid-template-columns: 1fr;
    grid-template-areas:
      "prompt"
      "grid"
      "controls"
      "feedback";
    align-content: start;
    gap: 11px;
  }

  .passmaze-prompt,
  #passmazePrompt {
    min-height: 34px;
    padding-top: 2px;
    font-size: clamp(20px, 7vw, 29px);
  }

  .passmaze-grid {
    width: min(100%, 58svh, 480px);
    padding: 7px;
    gap: 3px;
    outline-width: 4px;
    box-shadow: 6px 6px 0 rgba(71, 245, 234, .07);
  }

  .passmaze-controls {
    width: min(100%, 250px);
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 52px);
    justify-content: center;
    padding: 8px;
    gap: 5px;
    box-shadow: none;
  }

  .passmaze-controls button {
    min-width: 52px;
    min-height: 52px;
  }

  .passmaze-feedback {
    min-height: 42px;
    padding: 9px 11px;
    font-size: 8px;
  }

  .passmaze-cover {
    justify-content: flex-start;
    padding: 25px 16px calc(25px + env(safe-area-inset-bottom));
  }

  .passmaze-cover h3 {
    font-size: clamp(32px, 11vw, 52px);
  }

  .passmaze-rules ol,
  #passmazeRules ol {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .passmaze-rules li,
  #passmazeRules li {
    padding: 10px;
  }

  .passmaze-card-preview,
  .passmaze-preview {
    right: 14px;
    transform: rotate(2deg) scale(.78);
    transform-origin: top right;
  }
}

@media (max-width: 390px) {
  .passmaze-stage {
    padding-inline: 9px;
  }

  .passmaze-grid {
    width: min(100%, 52svh, 430px);
  }

  .passmaze-controls {
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(3, 48px);
  }

  .passmaze-controls button {
    min-width: 48px;
    min-height: 48px;
  }
}

@media (max-height: 610px) and (pointer: coarse) {
  .game-modal[data-active-game="passmaze"] .modal-head {
    min-height: 54px;
    padding: 7px 13px 7px 18px;
  }

  .game-modal[data-active-game="passmaze"] .modal-head small {
    display: none;
  }

  .game-modal[data-active-game="passmaze"] .modal-head h2 {
    margin: 0;
    font-size: 20px;
  }

  .game-modal[data-active-game="passmaze"] .modal-close {
    width: 40px;
    height: 40px;
  }

  .passmaze-hud {
    min-height: 50px;
  }

  .passmaze-hud > div {
    min-height: 50px;
    padding-block: 6px;
  }

  .passmaze-stage {
    min-height: calc(100dvh - 104px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card-passmaze,
  .card-passmaze *,
  .passmaze-cell,
  .passmaze-controls button,
  .passmaze-cover button,
  .passmaze-stage,
  .passmaze-grid {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
