/* Maze Munch: the canvas fills the stage; HUD, pad and menus are HTML over it */
.mm { display: flex; flex-direction: column; color: #dfe9ff; --mm-hud: 48px; }
.mm-stage { position: relative; width: 100%; height: min(78vh, 680px); min-height: 340px; background: #03050c; overflow: hidden;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
@media (max-width: 600px) { .mm-stage { height: auto; aspect-ratio: 2 / 3; max-height: 76vh; min-height: 0; }
  .mm-stage.mm-padded { aspect-ratio: 1 / 1.86; max-height: 84vh; } }
#mm-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }

.mm-hud { position: absolute; left: 0; right: 0; top: 0; height: var(--mm-hud); display: flex; align-items: center; gap: 16px; padding: 0 8px 0 14px;
  background: linear-gradient(#060b1a, rgba(6,11,26,0.82)); border-bottom: 1px solid #14213d; z-index: 3; }
.mm-stat { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.mm-k { font-size: 10px; letter-spacing: 0.09em; text-transform: uppercase; color: #8aa3c4; }
.mm-stat b { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: #dfe9ff; }
#mm-score { color: #ffd166; }
.mm-chain { display: flex; flex-direction: column; gap: 4px; width: 62px; opacity: 0.35; transition: opacity 0.2s; }
.mm-chain.mm-on { opacity: 1; }
.mm-chain b { font-size: 16px; line-height: 1; color: #55d6ff; font-variant-numeric: tabular-nums; }
.mm-chain.mm-hot b { color: #ffd166; }
.mm-chain i { display: block; height: 5px; border-radius: 3px; background: #16233f; overflow: hidden; }
.mm-chain span { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, #55d6ff, #ffd166); }
.mm-sp { flex: 1 1 auto; }
.mm-tool { width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; padding: 0; border: 1px solid #1c2b4a; border-radius: 10px;
  background: #0b1328; color: #bfe9ff; cursor: pointer; }
.mm-tool svg { width: 22px; height: 22px; }
.mm-tool:hover:not(:disabled) { border-color: #55d6ff; }
.mm-tool:disabled { opacity: 0.4; cursor: default; }
.mm-tool:focus-visible, .mm-btn:focus-visible, .mm-dp:focus-visible, .mm-link:focus-visible { outline: 2px solid #ffd166; outline-offset: 2px; }
.mm-tool[aria-pressed="true"] { color: #55d6ff; border-color: #2a4f7a; }
#mm-pause .pl { display: none; } #mm-pause.mm-paused .pl { display: block; } #mm-pause.mm-paused .pz { display: none; }
#mm-sound .off { display: none; } #mm-sound[aria-pressed="true"] .off { display: block; } #mm-sound[aria-pressed="true"] .on { display: none; }
#mm-sound[aria-pressed="true"] { color: #8aa3c4; border-color: #1c2b4a; }

.mm-pad[hidden], .mm-overlay[hidden], .mm-toast[hidden] { display: none; }
.mm-pad { position: absolute; right: 14px; bottom: 12px; width: 150px; height: 150px; z-index: 2; }
.mm-pad.mm-pad-mid { right: 50%; transform: translateX(50%); }
.mm-dp { position: absolute; width: 50px; height: 50px; display: grid; place-items: center; padding: 0; border: 1px solid #2a4f7a; border-radius: 12px;
  background: rgba(11,19,40,0.82); color: #bfe9ff; cursor: pointer; touch-action: none; }
.mm-dp svg { width: 26px; height: 26px; pointer-events: none; }
.mm-dp:active, .mm-dp.mm-held { background: #14325a; border-color: #55d6ff; color: #fff; }
.mm-dp-up { left: 50px; top: 0; } .mm-dp-down { left: 50px; top: 100px; } .mm-dp-left { left: 0; top: 50px; } .mm-dp-right { left: 100px; top: 50px; }

.mm-overlay { position: absolute; left: 0; right: 0; bottom: 0; top: var(--mm-hud); display: flex; align-items: center; justify-content: center; padding: 12px;
  background: rgba(3,5,12,0.62); z-index: 4; overflow: auto; }
.mm-overlay.mm-ov-title { background: radial-gradient(ellipse at center, rgba(3,6,16,0.35), rgba(3,5,12,0.7)); }
.mm-panel { width: min(100%, 380px); margin: auto; text-align: center; padding: 20px 20px 18px; border: 1px solid #1c2b4a; border-radius: 18px;
  background: rgba(8,14,30,0.94); box-shadow: 0 18px 50px rgba(0,0,0,0.55); animation: mm-pop 0.22s ease-out; }
@keyframes mm-pop { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }
.mm-logo { margin: 0 0 4px; font-size: 34px; font-weight: 800; letter-spacing: 0.01em; color: #55d6ff; text-shadow: 0 0 18px rgba(85,214,255,0.45); }
.mm-logo span { color: #ffd166; text-shadow: 0 0 18px rgba(255,209,102,0.4); }
.mm-h { margin: 0 0 6px; font-size: 24px; font-weight: 800; color: #dfe9ff; }
.mm-tag { margin: 0 0 14px; font-size: 14px; color: #8aa3c4; }
.mm-desc { margin: 0 0 12px; font-size: 14px; line-height: 1.45; color: #b9c9e6; }
.mm-big { margin: 2px 0 2px; font-size: 42px; font-weight: 800; line-height: 1; color: #ffd166; font-variant-numeric: tabular-nums; }
.mm-newbest { display: inline-block; margin: 0 0 8px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: #04060f; background: #ffd166; animation: mm-pulse 1s ease-in-out infinite alternate; }
@keyframes mm-pulse { to { transform: scale(1.06); } }
.mm-sub { margin: 0 0 10px; font-size: 13px; color: #8aa3c4; }
.mm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0 10px; }
.mm-stats div { padding: 5px 4px; border: 1px solid #16233f; border-radius: 10px; background: #0b1328; font-size: 11px; color: #8aa3c4; }
.mm-stats b { display: block; font-size: 17px; color: #dfe9ff; font-variant-numeric: tabular-nums; }
.mm-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.mm-badges li { padding: 3px 9px; border-radius: 999px; border: 1px solid #2a4f7a; font-size: 12px; color: #bfe9ff; background: #0b1b38; }
.mm-actions { display: flex; flex-direction: column; gap: 8px; }
.mm-row { display: flex; gap: 8px; } .mm-row > * { flex: 1 1 0; }
.mm-btn { min-height: 46px; padding: 10px 14px; border: 1px solid #2a4f7a; border-radius: 12px; background: #0f1d3a; color: #dfe9ff; font: inherit; font-size: 15px;
  font-weight: 700; cursor: pointer; }
.mm-btn:hover { border-color: #55d6ff; }
.mm-btn small { display: block; font-size: 11px; font-weight: 500; color: #8aa3c4; }
.mm-btn.mm-primary { border: 0; color: #04101c; background: linear-gradient(135deg, #55d6ff, #7df0c8); font-size: 17px; }
.mm-btn.mm-primary small { color: #0c3a4d; }
.mm-link { margin-top: 2px; padding: 8px; min-height: 40px; border: 0; background: none; color: #8ad7ff; font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; }
.mm-how { margin: 0 0 12px; padding: 0; list-style: none; text-align: left; font-size: 13.5px; line-height: 1.4; color: #c9d7f0; }
.mm-how li { display: flex; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid #111c36; }
.mm-how li:last-child { border-bottom: 0; }
.mm-how canvas { flex: 0 0 34px; width: 34px; height: 34px; }
.mm-how b { color: #dfe9ff; }
.mm-keys { margin: 0 0 10px; font-size: 12.5px; color: #8aa3c4; }
.mm-keys kbd { background: #16213a; color: #bfe9ff; border-radius: 3px; padding: 1px 5px; font-family: inherit; }

.mm-toast { position: absolute; left: 50%; top: calc(var(--mm-hud) + 10px); transform: translateX(-50%); max-width: 92%; padding: 7px 14px; border-radius: 999px;
  border: 1px solid #2a4f7a; background: rgba(8,14,30,0.92); color: #dfe9ff; font-size: 13.5px; font-weight: 600; text-align: center; z-index: 3; pointer-events: none;
  animation: mm-pop 0.2s ease-out; }
.mm-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mm-help .hint-touch { display: none; }
@media (hover: none) and (pointer: coarse) { .mm-help .hint-kb { display: none; } .mm-help .hint-touch { display: inline; } }

/* short stages (landscape phones, small laptop windows): tighter, wider panels */
.mm-short .mm-panel { padding: 12px 16px; width: min(100%, 520px); }
.mm-short .mm-logo { font-size: 26px; } .mm-short .mm-h { font-size: 20px; margin-bottom: 4px; }
.mm-short .mm-tag, .mm-short .mm-keys, .mm-short .mm-badges { display: none; }
.mm-short .mm-desc, .mm-short .mm-sub { margin-bottom: 8px; font-size: 13px; }
.mm-short .mm-big { font-size: 34px; }
.mm-short .mm-stats { margin: 6px 0 8px; grid-template-columns: repeat(6, 1fr); } .mm-short .mm-stats div { padding: 4px 2px; font-size: 10px; }
.mm-short .mm-btn { min-height: 42px; padding: 7px 12px; }
.mm-short .mm-actions { flex-direction: row; flex-wrap: wrap; } .mm-short .mm-actions > * { flex: 1 1 40%; }
.mm-short .mm-how { font-size: 12.5px; } .mm-short .mm-how li { break-inside: avoid; padding: 3px 0; }
@media (min-width: 560px) { .mm-short .mm-how { columns: 2; column-gap: 16px; } }
@media (min-width: 560px) and (min-height: 380px) { .mm-short .mm-ov-how .mm-keys { display: block; } }
@media (max-width: 430px) {
  .mm-hud { gap: 9px; padding: 0 6px 0 9px; } .mm-stat b { font-size: 17px; } .mm-chain { width: 46px; } .mm-stat-best { display: none; }
  .mm-panel { padding: 16px 14px 14px; } .mm-logo { font-size: 30px; }
}

.stage.is-immersive .stage-body > .mm { min-height: 0; flex: 1 1 auto; }
.stage.is-immersive .mm-stage { flex: 1 1 auto; height: auto; aspect-ratio: auto; max-height: none; min-height: 0; }
.stage.is-immersive .mm-help { display: none; }
@media (prefers-reduced-motion: reduce) { .mm-panel, .mm-toast, .mm-newbest { animation: none; } .mm-chain { transition: none; } }
/* How to play: the list scrolls inside the panel, so the button never leaves the screen */
.mm-ov-how .mm-panel { display: flex; flex-direction: column; max-height: 100%; }
.mm-ov-how .mm-h, .mm-ov-how .mm-keys, .mm-ov-how .mm-actions { flex: 0 0 auto; }
.mm-ov-how .mm-how { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #2a3d66 transparent; }
.mm-ov-how .mm-keys { margin: 0 0 8px; }
@media (max-width: 430px) {
  .mm-ov-how .mm-panel { padding: 12px 12px 12px; } .mm-ov-how .mm-h { font-size: 19px; margin-bottom: 2px; }
  .mm-how { font-size: 12.5px; line-height: 1.32; margin-bottom: 8px; } .mm-how li { gap: 9px; padding: 4px 0; }
  .mm-how canvas { flex-basis: 28px; width: 28px; height: 28px; } .mm-keys { font-size: 12px; }
  .mm-ov-how .mm-btn { min-height: 42px; padding: 7px 12px; }
}
@media (min-width: 760px) { .mm-ov-how .mm-panel { width: min(100%, 700px); } .mm-how { columns: 2; column-gap: 24px; } .mm-how li { break-inside: avoid; } }
