.maze-page {
  width: min(1120px, 100% - 32px);
  margin: clamp(12px, 2.4vw, 28px) auto 36px;
}
.maze-page ~ .ui-cookie { position: static; margin: 0 12px 24px; }

.maze {
  --maze-purple: #7934e9;
  --maze-ink: #18273a;
  --maze-soft: #f5f8fa;
  --maze-line: #dce5ef;
  --maze-green: #117d3b;
  min-width: 0;
  padding: 14px;
  border: 1px solid #dce7ea;
  border-radius: 23px;
  background: #fff;
  color: var(--maze-ink);
  box-shadow: 0 12px 40px #254a4217, 0 -12px 46px #dff9e7;
}

.maze [hidden] { display: none !important; }
.maze :where(button) { cursor: pointer; touch-action: manipulation; }
.maze button:disabled { cursor: default; }
.maze .ui-icon { flex: none; width: 19px; height: 19px; }
.maze button:focus-visible, .maze-board:focus-visible { outline: 3px solid #7137e2; outline-offset: 3px; }

.maze-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.maze-brand {
  position: relative;
  display: grid;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  padding: 2px;
  place-items: center;
  border: 1px solid #a5e9b5;
  border-radius: 14px;
  background: #e5ffe8;
  box-shadow: 0 3px 0 #9fdeb4;
}
.maze-brand img { width: 100%; height: 100%; object-fit: contain; }
.maze-brand span {
  position: absolute;
  left: -7px;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid #fff;
  border-radius: 50%;
  background: var(--maze-green);
  color: #fff;
}
.maze-brand .ui-icon { width: 12px; height: 12px; }
.maze-heading { flex: 1; min-width: 0; }
.maze-heading h1 { margin: 0; color: #0d7b39; font-size: clamp(21px, 3vw, 29px); font-weight: 900; line-height: 1.15; letter-spacing: -.025em; }
.maze-heading p { margin: 3px 0 0; color: #5b6e85; font-size: 14px; line-height: 1.3; }
.maze-toolbar { display: flex; align-items: center; gap: 8px; }
.maze-rating {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid #ffd793;
  border-radius: 14px;
  background: #fff4e0;
  color: #f4d39c;
  font-size: 20px;
  letter-spacing: -.04em;
  white-space: nowrap;
}
.maze-rating small { color: #78552e; font-size: 12px; font-weight: 900; }
.maze-rating span { display: flex; gap: 1px; }
.maze-rating .lit { color: #e88b09; }
.maze-button {
  display: inline-flex;
  min-height: 44px;
  min-width: 44px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--maze-line);
  border-radius: 14px;
  background: var(--maze-soft);
  color: var(--maze-ink);
  box-shadow: 0 3px 0 #b2d6cc, 0 5px 10px #1831460b;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}
.maze-button:hover:not(:disabled) { background: #eaf6f3; }
.maze-button:disabled { opacity: .5; }
.maze-button:active:not(:disabled), .maze-primary:active { transform: translateY(2px); }
.maze-sound[aria-pressed="true"] { color: #008836; border-color: #008836; }
.maze-sound[aria-pressed="true"] .maze-sound-off,
.maze-sound[aria-pressed="false"] .maze-sound-on,
.maze [data-game-fullscreen-toggle][aria-pressed="false"] .maze-shrink,
.maze [data-game-fullscreen-toggle][aria-pressed="true"] .maze-expand { display: none; }

.maze-menu-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.maze-difficulties, .maze-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.maze-tier { border-radius: 24px; font-weight: 750; padding-inline: 15px; }
.maze-tier[aria-pressed="true"] { background: #efe8ff; color: #6330cc; border: 2px solid #9e72ff; }
.maze-stats { color: #53697e; font-size: 13px; font-weight: 900; }
.maze-stats span { display: inline-flex; align-items: center; gap: 5px; }
.maze-stats span:last-child { padding: 3px 10px; border-radius: 20px; background: #efe8ff; color: #6c2bd6; }
.maze-stats img, .maze-stats .ui-icon { width: 22px; height: 20px; object-fit: contain; }
.maze-worlds { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; margin-bottom: 10px; }
.maze-world {
  display: grid;
  min-height: 82px;
  align-content: center;
  justify-items: center;
  gap: 1px;
  padding: 5px;
  border: 2px solid #ffffff8f;
  border-radius: 18px;
  background: var(--world-wash, #eaffdf);
  color: #516176;
  box-shadow: inset 0 2px 0 #ffffffa0, 0 3px 0 #c7ead5;
  font-size: 14px;
  line-height: 1.17;
  text-align: center;
}
.maze-world:nth-child(1) { --world-wash: linear-gradient(#effbd7, #e6fae6); --world-active: linear-gradient(#daf89a, #baf6d4); }
.maze-world:nth-child(2) { --world-wash: linear-gradient(#f3fbe8, #edf9d9); --world-active: linear-gradient(#def7ad, #baf4ba); }
.maze-world:nth-child(3) { --world-wash: linear-gradient(#e7fafc, #fff9e5); --world-active: linear-gradient(#bbf0f8, #fff1bc); }
.maze-world:nth-child(4) { --world-wash: linear-gradient(#eae3f5, #e6e0f5); --world-active: linear-gradient(#ddcefa, #c0b5f1); }
.maze-world:nth-child(5) { --world-wash: linear-gradient(#edf6ff, #faf0ff); --world-active: linear-gradient(#c8e7ff, #f1d7fc); }
.maze-world[aria-pressed="true"] { background: var(--world-active); border-color: #7934e9; color: #22363a; }
.maze-world:hover { filter: saturate(1.3); }
.maze-world span { font-size: 22px; line-height: 1.15; }
.maze-world strong { font-weight: 950; }
.maze-world small { margin-top: 3px; color: inherit; font-size: 12px; font-weight: 800; }

.maze-map {
  --map-flower: #e3c6f7;
  --map-wash: linear-gradient(#f8f1ff, #fbeaf6);
  position: relative;
  isolation: isolate;
  height: clamp(248px, 33vw, 340px);
  overflow: hidden;
  border: 3px solid #9057ff;
  border-radius: 25px;
  background: var(--map-wash);
}
.maze-map[data-world="1"] { --map-wash: linear-gradient(#f2fde6, #e2fbef); --map-flower: #c4e6bc; }
.maze-map[data-world="2"] { --map-wash: linear-gradient(#e4faff, #fff5dc); --map-flower: #c4e7f3; }
.maze-map[data-world="3"] { --map-wash: linear-gradient(#eae2fc, #e0d9f5); --map-flower: #cdbbea; }
.maze-map[data-world="4"] { --map-wash: linear-gradient(#e7f5ff, #faedff); --map-flower: #ccdffa; }
.maze-map::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    radial-gradient(circle at 13px 15px, #ffc96b 0 2px, transparent 2.6px),
    radial-gradient(circle at 13px 10px, var(--map-flower) 0 4.5px, transparent 5px),
    radial-gradient(circle at 18px 15px, var(--map-flower) 0 4.5px, transparent 5px),
    radial-gradient(circle at 13px 20px, var(--map-flower) 0 4.5px, transparent 5px),
    radial-gradient(circle at 8px 15px, var(--map-flower) 0 4.5px, transparent 5px);
  background-size: 55px 50px;
  opacity: .65;
  content: "";
}
.maze-map-line { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; overflow: visible; }
.maze-map-line path { fill: none; stroke: #b8a0fe; stroke-width: 9; stroke-linecap: round; opacity: .77; }
.maze-stops { display: grid; grid-template: repeat(3, 1fr) / repeat(4, 1fr); height: 100%; align-items: center; justify-items: center; }
.maze-stop {
  position: relative;
  display: grid;
  width: clamp(55px, 8.4vw, 85px);
  aspect-ratio: 1;
  place-items: center;
  padding: 0;
  border: 3px solid #c1a5fe;
  border-radius: 50%;
  background: #f2e9ff;
  color: #6631cb;
  box-shadow: inset 0 -3px 0 #a8d8b7, 0 0 0 3px #ffffff9c;
  font-size: 19px;
  font-weight: 900;
}
.maze-stop[aria-pressed="true"] { border-color: #9e67fc; background: linear-gradient(145deg, #8543ea, #641cd3); color: #fff; }
.maze-stop:disabled { border-color: #d1b8fa; border-style: dashed; background: #ffffffa8; color: #77859f; }
.maze-stop-check { position: absolute; top: -4px; right: -4px; display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; background: #defbea; color: #098345; }
.maze-stop-check .ui-icon { width: 14px; height: 14px; }
.maze-primary {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 15px;
  border: 1px solid #aa71ff;
  border-radius: 18px;
  background: linear-gradient(#8338ec, #6d26d5);
  color: #fff;
  box-shadow: 0 3px 0 #296246, 0 6px 12px #30114b1c;
  font-weight: 900;
}
.maze-primary:hover { background: linear-gradient(#9148fa, #7430de); }
.maze-play-button { width: min(100%, 430px); margin-top: 12px; justify-content: flex-start; padding-block: 9px; text-align: left; }
.maze-play-button strong, .maze-play-button small { display: block; }
.maze-play-button strong { font-size: 22px; line-height: 1.25; }
.maze-play-button small { color: #efe0ff; font-size: 14px; }
.maze-play-icon { display: grid; width: 45px; height: 45px; place-items: center; border-radius: 50%; background: #ffffff30; }
.maze-play-icon .ui-icon { fill: currentColor; }

.maze-gameplay { display: grid; grid-template-columns: minmax(260px, .84fr) minmax(0, 1.16fr); grid-template-rows: auto 1fr; gap: 14px 28px; }
.maze-coach { grid-area: 1 / 1; }
.maze-coach-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.maze-coach-row img { flex: 0 0 58px; width: 58px; height: 58px; object-fit: contain; }
.maze-message {
  position: relative;
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 10px 13px;
  border: 2px solid #dce4ef;
  border-radius: 16px;
  background: var(--maze-soft);
  color: #172639;
  font-size: 16px;
  font-weight: 850;
  line-height: 1.42;
}
.maze-message::before { position: absolute; top: 50%; left: -7px; width: 11px; height: 11px; border: inherit; border-width: 0 0 2px 2px; background: inherit; transform: translateY(-50%) rotate(45deg); content: ""; }
.maze-message.is-positive { border-color: #22a859; }
.maze-mission {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 86px;
  padding: 6px 12px;
  border: 2px solid #e3f9d1;
  border-left: 6px solid #9258ff;
  border-radius: 21px;
  background: linear-gradient(#d9f79f, #bff6d7);
  box-shadow: inset 0 0 0 1px #f8ffdf70;
}
.maze-mission img { width: 72px; height: 68px; object-fit: contain; }
.maze-mission p { margin: 0; color: #456356; font-size: 14px; font-weight: 850; }
.maze-mission h2 { margin: 1px 0 0; font-size: 22px; line-height: 1.2; font-weight: 950; }
.maze-board {
  position: relative;
  grid-area: 1 / 2 / 3 / 3;
  align-self: start;
  justify-self: center;
  width: min(100%, 550px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 4px solid #9258ff;
  border-radius: 26px;
  background: #438c35;
  box-shadow: 0 8px 22px #223b471b;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
.maze-board:active { cursor: grabbing; }
.maze-board canvas { display: block; width: 100%; height: 100%; }
.maze-pieces { position: absolute; inset: 0; pointer-events: none; }
.maze-piece, .maze-home-lock { position: absolute; display: block; transform: translate(-50%, -50%); }
.maze-piece { height: auto; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 2px 2px #492e2640); }
.maze-piece--animal { width: calc(var(--maze-cell) * .86); margin-top: calc(var(--maze-cell) * -.12); transition: top .105s ease-out, left .105s ease-out; }
.maze-piece--home { width: calc(var(--maze-cell) * .94); margin-top: calc(var(--maze-cell) * -.09); }
.maze-piece--star { width: calc(var(--maze-cell) * .67); filter: saturate(1.7) drop-shadow(0 2px 2px #7953003d); }
.maze-home-lock { margin: calc(var(--maze-cell) * .23) 0 0 calc(var(--maze-cell) * .26); font-size: clamp(11px, 1.6vw, 19px); line-height: 1; }
.maze-preview { display: flex; width: fit-content; align-items: center; justify-content: center; gap: 9px; margin: 10px auto 0; padding: 5px 8px 5px 12px; border-radius: 14px; background: #452577; color: #fff; font-size: 13px; }
.maze-preview .maze-button { min-height: 40px; padding: 4px 8px; box-shadow: none; white-space: normal; }
.maze-controls { grid-area: 2 / 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.maze-collection { display: inline-flex; align-items: center; gap: 7px; margin-block: auto; padding: 6px 12px; border: 2px solid #eae4ff; border-radius: 28px; background: #fff; }
.maze-collection img { width: 34px; height: 34px; object-fit: contain; filter: saturate(1.7); }
.maze-collection img.is-empty { filter: grayscale(1); opacity: .33; }
.maze-collection .maze-collected-home { width: 38px; }
.maze-actions { display: flex; width: 100%; gap: 8px; margin-top: 8px; }
.maze-actions .maze-button { min-height: 48px; }
.maze-hint { flex: 1; min-width: 0; padding-inline: 6px; border-color: #ffdc9b; background: #fff4e0; color: #675335; box-shadow: 0 3px 0 #eac865; }
.maze-hint:hover:not(:disabled) { background: #ffe9bd; }
.maze-input-help { margin: 10px 0 0; color: #5b6e85; font-size: 12px; line-height: 1.4; text-align: center; }

.maze-dialog {
  width: min(480px, 100% - 30px);
  max-height: 90dvh;
  padding: 23px;
  border: 2px solid #ddd0fa;
  border-radius: 23px;
  background: #fff;
  color: var(--maze-ink);
  box-shadow: 0 18px 55px #24213940;
  line-height: 1.5;
}
.maze-dialog::backdrop { background: #241c42a0; }
.maze-dialog h2 { margin: 0 0 8px; color: #5524b0; font-size: 25px; line-height: 1.2; }
.maze-dialog ol { padding-left: 22px; }
.maze-dialog li + li { margin-top: 5px; }
.maze-dialog-close { position: absolute; top: 9px; right: 9px; }
.maze-parent-stats { color: #5928b5; font-weight: 900; }
.maze-win { text-align: center; }
.maze-win img { width: 100px; height: 100px; object-fit: contain; }
.maze-win p { margin: 0; }
.maze-win-stars { margin: 0 auto 12px; color: #d98a00; font-size: 36px; letter-spacing: .05em; }
.maze-win-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ui-game-fullscreen.is-fullscreen .maze { max-width: 1150px; }

@media (max-width: 780px) {
  .maze-gameplay { grid-template-columns: minmax(240px, .86fr) minmax(0, 1.14fr); column-gap: 14px; }
  .maze-actions { gap: 6px; }
  .maze-actions .maze-button { padding-inline: 7px; }
  .maze-message { font-size: 14px; }
}

@media (max-width: 665px) {
  .maze-page { width: calc(100% - 16px); }
  .maze { padding: 10px; border-radius: 19px; }
  .maze-top { flex-wrap: wrap; row-gap: 10px; margin-bottom: 10px; }
  .maze-toolbar { justify-content: flex-end; width: 100%; }
  .maze-rating { margin-right: auto; }
  .maze-menu-bar { flex-wrap: wrap; row-gap: 8px; margin-bottom: 9px; }
  .maze-worlds { gap: 4px; }
  .maze-world { padding-inline: 2px; font-size: 12px; border-radius: 12px; }
  .maze-world span { font-size: 18px; }
  .maze-world small { font-size: 10px; }
  .maze-map { border-radius: 18px; }
  .maze-play-button { width: 100%; }
  .maze-gameplay { display: flex; flex-direction: column; gap: 9px; }
  .maze-coach { display: grid; gap: 6px; }
  .maze-coach-row { margin: 0; }
  .maze-coach-row img { width: 43px; height: 43px; flex-basis: 43px; }
  .maze-message { padding: 7px 9px; }
  .maze-mission { min-height: 54px; padding: 3px 9px; border-radius: 14px; }
  .maze-mission img { width: 46px; height: 46px; }
  .maze-mission h2 { font-size: 18px; }
  .maze-mission p { font-size: 12px; }
  .maze-board { align-self: center; width: min(100%, 440px); border-width: 3px; border-radius: 18px; }
  .maze-collection { padding: 3px 9px; }
  .maze-collection img { width: 28px; height: 28px; }
  .maze-input-help { margin-top: 8px; }
}

@media (max-width: 370px) {
  .maze-toolbar { gap: 6px; }
  .maze-parents span { display: none; }
  .maze-stats { font-size: 12px; }
  .maze-map { height: 222px; }
}
