.maze-page {
  min-height: 100dvh;
  background: radial-gradient(ellipse at 4% 14%, #dbf7ed, transparent 44%),
    radial-gradient(ellipse at 100% 35%, #eee6ff, transparent 42%), #f8fcff;
}
.maze-main { padding-block: 16px 28px; }
.maze-intro { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.maze-intro h1 { font-size: clamp(2.35rem, 6vw, 4rem); letter-spacing: -.07em; line-height: 1.04; }
.maze-layout { display: grid; grid-template-columns: minmax(180px, 224px) minmax(0, 1fr); align-items: start; gap: 14px; }
.maze-panel, .maze-cabinet { min-width: 0; padding: 12px; border: 1px solid #d4e7e4; border-radius: 20px; background: #fff; box-shadow: 0 10px 26px #3b656610; }
.maze-guide { display: flex; align-items: center; gap: 6px; min-height: 66px; padding: 4px; border-radius: 13px; background: linear-gradient(125deg, #dff8ec, #fff0ce); }
.maze-guide img { width: 55px; height: 61px; object-fit: contain; }
.maze-guide .eyebrow, .maze-scorebar .eyebrow { color: #32605d; font-size: .64rem; }
.maze-guide h2 { font-size: 1.05rem; line-height: 1.2; }
.maze-progress { margin-block: 8px 6px; color: #36605e; font-size: .78rem; font-weight: 800; }
.maze-track { display: grid; gap: 3px; font-size: .73rem; font-weight: 800; color: #325954; }
.maze-track select { min-height: 36px; width: 100%; padding: 4px 8px; border: 1px solid #bdd9d0; border-radius: 8px; background: #f0faf6; color: #244d48; font: inherit; }
.maze-track-count { margin-block: 6px 4px; font-size: .68rem; color: #486461; }
.maze-levels { display: grid; gap: 4px; margin: 0 0 9px; padding: 0; list-style: none; }
.maze-pages { display: flex; align-items: center; justify-content: space-between; gap: 5px; margin-bottom: 7px; font-size: .7rem; font-weight: 800; color: #365b57; }
.maze-pages .maze-soft { width: 36px; min-height: 32px; font-size: .95rem; }
.maze-level { width: 100%; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 6px; min-height: 36px; padding: 4px 6px; border: 1px solid #dfebea; border-radius: 9px; background: #f5faf9; color: #2b4d4a; text-align: left; font-size: .73rem; font-weight: 800; }
.maze-level[aria-current="step"] { border-color: #78bda9; background: #e0f7ed; color: #1f5650; }
.maze-level:disabled { color: #566465; background: #f7f8f9; cursor: default; }
.maze-level .level-number { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 7px; background: #dceee8; color: #25554c; }
.maze-level .level-mark { font-size: .66rem; }
.maze-listen { width: 100%; }
.maze-crossings { margin-bottom: 6px; }
.maze-soft, .maze-primary, .maze-block {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 37px;
  padding: 4px 9px; border: 1px solid #dcd1ef; border-radius: 9px;
  background: #f7f2ff; color: #4c3480; font-size: .76rem; font-weight: 800; line-height: 1.14;
}
.maze-soft:hover:not(:disabled), .maze-block:hover:not(:disabled) { filter: brightness(.96); }
.maze-soft:disabled, .maze-block:disabled, .maze-primary:disabled { opacity: .54; cursor: default; }
.maze-primary { background: #e8ffa6; color: #344517; border-color: #c9e17d; }
.maze-primary:hover:not(:disabled) { background: #efffc1; }
.maze-soft .icon { width: 17px; height: 17px; }

.maze-cabinet { display: grid; gap: 9px; background: linear-gradient(150deg, #fff 30%, #f6fbff); }
.maze-scorebar, .maze-editor-heading, .maze-tools, .maze-actions, .maze-edit { display: flex; align-items: center; gap: 5px; }
.maze-scorebar, .maze-editor-heading { justify-content: space-between; }
.maze-scorebar h2 { font-size: clamp(1.34rem, 2.8vw, 1.95rem); letter-spacing: -.04em; line-height: 1.12; }
.maze-tools { flex: none; }
.maze-muted, #maze-sound[aria-pressed="true"] .maze-waves, .maze-shrink { display: none; }
#maze-sound[aria-pressed="true"] .maze-muted { display: block; }
.maze-play { display: grid; grid-template-columns: minmax(0, 1fr) clamp(244px, 25vw, 320px); align-items: stretch; gap: 9px; }
.maze-field, .maze-editor { min-width: 0; min-height: 0; border-radius: 14px; border: 1px solid #d4e7e1; }
.maze-field {
  display: grid; grid-template-rows: auto minmax(min-content, 1fr) auto; gap: 7px; padding: 9px;
  background: linear-gradient(160deg, #f0fff4df, #ccefe1f2),
    url("../assets/paxa-school-city-v1.webp") center / cover;
}
.maze-goal, .maze-map-note { display: flex; align-items: center; gap: 6px; color: #255550; font-size: .72rem; font-weight: 800; line-height: 1.2; }
.maze-goal > span:first-child { color: #9b491c; font-size: 1.13rem; }
.maze-gems, .maze-map-note > span { padding: 4px 6px; border: 1px solid #c4e6d7; border-radius: 7px; background: #f1fff6; }
.maze-gems { margin-left: auto; flex: none; color: #714915; background: #fff3ce; border-color: #eddb9b; }
.maze-map-note { justify-content: space-between; }
.maze-map-frame { display: grid; place-items: center; min-height: 0; }
.maze-map {
  --map-room: min(56dvh, 510px);
  --rim: #42765d; --base: #356348;
  --path: #fff0cf; --path-alt: #ffebc4; --path-line: #a77a3f44;
  --leaf-light: #a8dc80; --leaf-mid: #86c879; --leaf-dark: #76b66b;
  --leaf-base: #6fb567; --leaf-shade: #4a9162;
  display: grid; position: relative; isolation: isolate;
  grid-template-columns: repeat(var(--cols, 7), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 3), minmax(0, 1fr));
  width: min(100%, calc(var(--cols, 7) * 73px), calc(var(--map-room) * var(--cols, 7) / var(--rows, 3)));
  aspect-ratio: var(--cols, 7) / var(--rows, 3);
  border-radius: 13px; box-shadow: 0 0 0 2px var(--rim), 0 6px 0 var(--base), 0 9px 19px #29574730;
  overflow: hidden; container-type: inline-size;
}
.maze-map[data-color="sky"] {
  --rim: #51849c; --base: #466b85;
  --path: #e9f8ff; --path-alt: #dff1fd; --path-line: #6ea4c750;
  --leaf-light: #b3e7ef; --leaf-mid: #90cedf; --leaf-dark: #7bb8d4;
  --leaf-base: #7cc1dc; --leaf-shade: #5a98bb;
}
.maze-map[data-color="lavender"] {
  --rim: #7865a4; --base: #624e84;
  --path: #fff2fe; --path-alt: #f5eaff; --path-line: #ac82c94d;
  --leaf-light: #e2d0fb; --leaf-mid: #c8b1ef; --leaf-dark: #b59bda;
  --leaf-base: #baa6e5; --leaf-shade: #8d77c0;
}
.maze-map[data-color="peach"] {
  --rim: #a3725e; --base: #875849;
  --path: #fff5df; --path-alt: #fff0d6; --path-line: #bb805e45;
  --leaf-light: #ffdbbb; --leaf-mid: #edbd9e; --leaf-dark: #dd9f89;
  --leaf-base: #e7ac95; --leaf-shade: #be8875;
}
.maze-cell { display: grid; place-items: center; position: relative; background: var(--path); box-shadow: inset 0 0 0 1px var(--path-line); }
.maze-cell:nth-child(even) { background: var(--path-alt); }
.maze-cell.is-hedge {
  background: radial-gradient(ellipse at 30% 25%, var(--leaf-light) 0 19%, transparent 21%),
    radial-gradient(ellipse at 72% 46%, var(--leaf-mid) 0 27%, transparent 29%),
    radial-gradient(ellipse at 32% 78%, var(--leaf-dark) 0 22%, transparent 24%),
    linear-gradient(144deg, var(--leaf-base), var(--leaf-shade));
  box-shadow: inset 0 0 0 1px var(--path-line);
}
.maze-cell.is-hedge:nth-child(3n)::after { content: ""; width: 9%; aspect-ratio: 1; border-radius: 50%; background: #fff0a5; box-shadow: 3px -2px 0 #fff9d0, -3px -1px 0 #ffd997; }
.maze-cell.is-start { background: #dff7e6; box-shadow: inset 0 0 0 2px #82bda0; }
.maze-cell.is-flag { background: #fae2a0; box-shadow: inset 0 0 0 2px #d9a65c; }
.maze-cell.is-trail:not(.is-start, .is-flag)::before { content: ""; width: 18%; aspect-ratio: 1; border-radius: 50%; background: #69bda2; opacity: .86; }
.maze-cell.is-flag .icon { width: 58%; height: 58%; color: #934824; fill: #ff9160; stroke-width: 1.7; }
.maze-cell:is(.is-hurdle, .is-fire) svg { width: 70%; height: 70%; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.maze-cell.is-hurdle { background: #f8ddaa; }
.maze-cell.is-hurdle svg { stroke: #79452f; fill: #cc8251; }
.maze-cell.is-fire { background: #ffcaab; }
.maze-cell.is-fire svg { stroke: #ae4225; fill: #f96a3e; }
.maze-cell.is-fire .maze-ember { stroke: none; fill: #ffe37b; }
.maze-crystal { position: absolute; width: 28%; aspect-ratio: 1; transform: rotate(45deg); border: 1px solid #9369be; border-radius: 2px; background: linear-gradient(130deg, #f9d7ff, #a575df); box-shadow: 0 2px 3px #8253995a; }
.maze-cell[data-collected] .maze-crystal { opacity: 0; }
.maze-pawn {
  position: absolute; z-index: 1; left: calc(100% * var(--x) / var(--cols)); top: calc(100% * var(--y) / var(--rows));
  display: grid; place-items: center; width: calc(100% / var(--cols)); height: calc(100% / var(--rows));
  transition: left .24s ease, top .24s ease; pointer-events: none;
}
.maze-avatar { width: 91%; height: 92%; filter: drop-shadow(0 2px 2px #3f413e5b); }
.maze-pawn[data-facing="west"] .maze-avatar { transform: scaleX(-1); }
.maze-pawn[data-crossing] { transition-duration: .36s; }
.maze-pawn[data-reset] { transition: none; }
.maze-pawn-arrow { position: absolute; display: grid; place-items: center; inset: auto 0 1% auto; width: 34%; height: 34%; border-radius: 50%; background: #fff; color: #3e4268; font-size: clamp(.5rem, calc(48cqw / var(--cols)), .9rem); line-height: 1; transform: rotate(calc(90deg * var(--direction))); }
.maze-pawn[data-bump] { animation: maze-bump .28s ease; }
@keyframes maze-bump { 40% { translate: 2px 0; } 68% { translate: -2px 0; } }

.maze-editor { display: grid; align-self: start; gap: 6px; padding: 8px; background: #fbf8ff; border-color: #e0d7ef; }
.maze-editor-heading h3 { color: #45346b; font-size: 1.03rem; letter-spacing: -.025em; }
.maze-budget { color: #51426b; font-size: .68rem; font-weight: 800; text-align: right; }
.maze-palette { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.maze-block { padding-inline: 4px; white-space: nowrap; }
.maze-block[data-add="until"] { white-space: normal; }
.maze-block[data-add="forward"], .maze-command[data-kind="forward"] { background: #dcf7ed; border-color: #a2d8c6; color: #23584f; }
.maze-block:is([data-add="left"], [data-add="right"]), .maze-command:is([data-kind="left"], [data-kind="right"]) { background: #e6efff; border-color: #b8cbed; color: #2c4d7b; }
.maze-block[data-add="repeat"], .maze-command[data-kind="repeat"] { background: #fff0c8; border-color: #e6ca7f; color: #75521a; }
.maze-block[data-add="until"], .maze-command[data-kind="until"] { background: #f0e4ff; border-color: #d5b9ec; color: #603b8a; }
.maze-block[data-add="jump"], .maze-command[data-kind="jump"] { background: #ffe8d4; border-color: #edc09c; color: #82452f; }
.maze-block[data-add="fly"], .maze-command[data-kind="fly"] { background: #dcf6ff; border-color: #a0d5e9; color: #276078; }
.maze-insertion { font-size: .67rem; color: #534765; line-height: 1.24; }
.maze-workspace { min-width: 0; min-height: 0; height: clamp(74px, 20dvh, 178px); overflow: auto; padding: 5px; background: #fff; border: 1px solid #e0d8ed; border-radius: 9px; scrollbar-color: #c8b8dd #faf7ff; }
.maze-empty { display: grid; place-items: center; min-height: 40px; border: 1px dashed #d5c4eb; border-radius: 6px; background: #faf7ff; color: #5d4a75; text-align: center; font-size: .72rem; }
.maze-workspace ol { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.maze-workspace li { min-width: 0; }
.maze-command { display: flex; align-items: center; justify-content: flex-start; gap: 6px; width: 100%; min-height: 31px; padding: 4px 6px; border: 1px solid; border-radius: 7px; font-size: .73rem; font-weight: 800; text-align: left; }
.maze-command[aria-pressed="true"] { outline: 2px solid #825bc0; outline-offset: -2px; }
.maze-command[data-executing] { outline: 2px solid #118278; outline-offset: -2px; box-shadow: inset 0 0 0 3px #fffd; }
.maze-command[data-error] { outline: 2px solid #b84d53; outline-offset: -2px; }
.maze-command small { margin-left: auto; }
.maze-repeat { padding: 4px; border: 1px solid #e4cf99; border-radius: 8px; background: #fffae8; }
.maze-repeat-options { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-block: 4px; }
.maze-repeat-options label { display: flex; align-items: center; gap: 3px; font-size: .66rem; font-weight: 800; color: #654a26; }
.maze-repeat-options select { min-height: 29px; padding-inline: 3px; border: 1px solid #d7bf8d; border-radius: 6px; background: #fff; color: #5f481c; font: inherit; }
.maze-repeat-options button { min-height: 29px; padding-inline: 5px; font-size: .66rem; }
.maze-repeat-options button[aria-pressed="true"] { border-color: #9976c8; background: #efe4fc; }
.maze-workspace .maze-loop-body { margin-left: 9px; padding-left: 5px; border-left: 2px solid #dfbf75; }
.maze-loop-empty { padding: 2px 4px; color: #695329; font-size: .65rem; }
.maze-edit > button { min-height: 31px; }
.maze-clear { margin-left: auto; }
.maze-actions { align-items: stretch; }
.maze-actions .maze-primary { flex: 1; }
.maze-actions .maze-soft { flex: 0 1 auto; }

.maze-feedback { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px; min-width: 0; min-height: 45px; padding: 4px 6px; border-radius: 10px; background: #e9f5ff; color: #244969; }
.maze-feedback:has(#maze-next:not([hidden])) { grid-template-columns: auto minmax(0, 1fr) auto auto; }
.maze-feedback[data-tone="win"] { background: #e6faeb; color: #27553c; }
.maze-feedback[data-tone="wall"] { background: #ffeef1; color: #853d4d; }
.maze-feedback img { width: 27px; height: 34px; object-fit: contain; }
.maze-feedback p { flex: 1; font-size: .74rem; font-weight: 800; line-height: 1.24; }
.maze-feedback button { flex: none; min-height: 33px; }
.maze-recovery { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 5px; }
.maze-recovery button { min-height: 29px; }
.maze-local { margin-top: 7px; color: #4e5d68; font-size: .73rem; }
.maze-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

html:has(.maze-layout.is-expanded) { overflow: hidden; }
.maze-page:has(.maze-layout:is(:fullscreen, .is-expanded)) :is(.site-header, .skip, .game-crumbs, .maze-intro, .maze-local, .game-reading, .games-footer) { visibility: hidden; }
.maze-layout:is(:fullscreen, .is-expanded) {
  position: fixed; z-index: 10; inset: 0; display: block; width: 100%; height: 100dvh; overflow: hidden;
  padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  background: #eefaf7;
}
.maze-layout:is(:fullscreen, .is-expanded) .maze-panel { display: none; }
.maze-layout:is(:fullscreen, .is-expanded) .maze-cabinet { height: 100%; grid-template-rows: auto minmax(0, 1fr) auto; }
.maze-layout:is(:fullscreen, .is-expanded) .maze-play { min-height: 0; }
.maze-layout:is(:fullscreen, .is-expanded) .maze-field { grid-template-rows: auto minmax(0, 1fr) auto; }
.maze-layout:is(:fullscreen, .is-expanded) .maze-map-frame { container-type: size; }
.maze-layout:is(:fullscreen, .is-expanded) .maze-map {
  --map-room: max(32px, calc(100cqh - 9px));
  width: min(100%, calc(var(--map-room) * var(--cols, 7) / var(--rows, 3)));
}
.maze-layout:is(:fullscreen, .is-expanded) .maze-tools .maze-soft { width: 38px; min-height: 36px; padding: 4px; background: #ffffff8f; }
.maze-layout:is(:fullscreen, .is-expanded) .maze-tools span, .maze-layout:is(:fullscreen, .is-expanded) .maze-expand { display: none; }
.maze-layout:is(:fullscreen, .is-expanded) .maze-shrink { display: block; }
.maze-layout:is(:fullscreen, .is-expanded) .maze-editor { align-self: stretch; grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; }
.maze-layout:is(:fullscreen, .is-expanded) .maze-workspace { height: auto; }

@media (min-width: 611px) and (min-height: 650px) {
  .maze-layout:is(:fullscreen, .is-expanded) .maze-editor { align-self: start; grid-template-rows: none; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-workspace { height: min(27dvh, 240px); }
}
@media (max-width: 1040px) {
  .maze-layout { grid-template-columns: minmax(160px, 188px) minmax(0, 1fr); }
}
@media (max-width: 880px) {
  .maze-layout { grid-template-columns: minmax(0, 1fr); }
  .maze-levels { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .maze-listen { width: auto; }
}
@media (max-width: 610px) {
  .maze-layout { gap: 9px; }
  .maze-cabinet { padding: 7px; gap: 6px; }
  .maze-levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .maze-play { grid-template-columns: minmax(0, 1fr); }
  .maze-field { min-height: 165px; }
  .maze-map { --map-room: 460px; }
  .maze-tools .maze-soft span { display: none; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-play { grid-template-rows: minmax(0, 1fr) auto; gap: 5px; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-scorebar .eyebrow { font-size: .59rem; letter-spacing: .08em; }
  .maze-palette { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .maze-block { font-size: .69rem; }
}
@media (max-width: 610px), (max-height: 500px) {
  .maze-layout:is(:fullscreen, .is-expanded) .maze-field { min-height: 0; padding: 4px 6px; gap: 3px; }
  .maze-layout:is(:fullscreen, .is-expanded) :is(.maze-gems, .maze-map-note > span) { padding: 2px 4px; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-goal > span:first-child { font-size: .88rem; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-editor {
    align-self: start;
    grid-template: "heading heading" "palette palette" "note note" "workspace edit" "actions actions" / minmax(0, 1fr) 100px;
    padding: 5px; gap: 3px;
  }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-editor-heading { grid-area: heading; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-editor-heading h3 { font-size: .86rem; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-palette { grid-area: palette; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-block { flex-direction: column; gap: 1px; padding: 2px 1px; font-size: .60rem; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-block[data-add="forward"] { letter-spacing: -.035em; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-block span { font-size: .82rem; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-insertion { grid-area: note; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-editor:not(:has([data-inside][aria-pressed="true"])) .maze-insertion { display: none; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-workspace { grid-area: workspace; height: clamp(60px, 11dvh, 92px); }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-edit {
    grid-area: edit; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px;
  }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-edit .maze-soft { min-height: 27px; padding-inline: 3px; font-size: .62rem; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-clear { margin: 0; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-actions { grid-area: actions; }
  .maze-layout:is(:fullscreen, .is-expanded) :is(.maze-block, .maze-actions .maze-soft, .maze-actions .maze-primary) { min-height: 30px; }
}
@media (max-height: 500px) and (min-width: 611px) {
  .maze-layout:is(:fullscreen, .is-expanded) .maze-cabinet { padding: 7px; gap: 5px; }
  .maze-layout:is(:fullscreen, .is-expanded) .maze-play { grid-template-columns: minmax(0, 1fr) clamp(280px, 25vw, 320px); }
}
@media (prefers-reduced-motion: reduce) {
  .maze-pawn { transition: none; animation: none !important; }
}
