/* Menú de movimiento e integración contextual con escenario, panel y lección. */
/* The controller opens over the activity cards, never over the character. */
#movement-menu {
  display: none;
}
@media (max-width: 850px), (pointer: coarse) and (max-width: 1100px) {
  body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]) main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(252px, 1.2fr) 42px minmax(120px, 1fr);
    min-height: 0;
  }

  body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active])
    .playground {
    grid-column: 1;
    grid-row: 1;
    min-height: 252px;
  }

  body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]) .panel {
    grid-column: 1;
    grid-row: 3;
    min-height: 0;
    overflow: hidden;
  }

  #movement-menu {
    display: block;
    position: relative;
    grid-column: 1;
    grid-row: 2;
    z-index: 12;
    min-width: 0;
    height: 42px;
  }

  #movement-menu-toggle {
    display: flex;
    align-items: center;
    gap: 9px;
    width: fit-content;
    height: 42px;
    min-height: 42px;
    padding: 4px 12px;
    border: 2px solid #a9c4ed;
    border-radius: 15px;
    background: linear-gradient(#f8f4ff, #e7dcff);
    color: var(--ad-ink-purple);
    box-shadow: 0 3px 0 #bba4e1;
    font: inherit;
    text-align: left;
    touch-action: manipulation;
  }

  #movement-menu-toggle .control-icon {
    flex: none;
    width: 30px;
    height: 30px;
    font-size: 25px;
    line-height: 30px;
  }

  #movement-menu-toggle strong {
    display: flex;
    align-items: baseline;
    gap: 9px;
    font-size: calc(14px * var(--text-scale, 1));
  }

  #movement-menu-toggle small {
    color: #74648d;
    font-size: calc(11px * var(--text-scale, 1));
    font-weight: 500;
  }

  .movement-menu-chevron {
    margin-left: auto;
    flex: none;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    font-size: 0;
    line-height: 1;
  }

  .movement-menu-chevron::before {
    content: "";
    width: 9px;
    height: 9px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
  }

  #movement-menu:has(#movement-menu-toggle[aria-expanded="true"]) #movement-menu-toggle {
    width: 100%;
    border-color: #bda6e5;
    border-bottom-color: transparent;
    border-radius: 15px 15px 0 0;
    background: #f8f5ff;
    box-shadow: none;
  }

  #movement-menu-toggle[aria-expanded="true"] .movement-menu-chevron {
    transform: rotate(180deg);
  }

  #movement-menu-drawer {
    position: absolute;
    top: calc(100% - 2px);
    z-index: 13;
    padding: 5px;
    border: 2px solid #bda6e5;
    border-top: 0;
    border-radius: 0 0 20px 20px;
    background: #f8f5ff;
    box-shadow: 0 9px 24px #39456d35;
  }

  #movement-menu-drawer[hidden] {
    display: none;
  }

  #movement-menu-drawer .mobile-controls {
    position: static;
    display: grid;
    grid-column: auto;
    grid-row: auto;
    align-self: auto;
    width: 100%;
    margin: 0;
    height: 148px;
    min-height: 148px;
    padding: 8px 7px;
    grid-template-columns: clamp(115px, 36%, 220px) minmax(0, 1fr);
    grid-template-rows: 18px 104px;
    gap: 8px 12px;
    --control-row-height: 48px;
    --control-row-gap: 8px;
    border: 0;
    box-shadow: none;
    background: transparent;
  }

  #movement-menu-drawer .mobile-dpad {
    grid-column: 1;
    grid-row: 2;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, 48px);
    gap: 8px;
  }

  #movement-menu-drawer .mobile-dpad button,
  #movement-menu-drawer .mobile-tools :is(.command, .quick-action) {
    min-height: 48px;
    height: 48px;
  }

  #movement-menu-drawer .mobile-tools {
    grid-column: 2;
    grid-row: 2;
    grid-template-rows: repeat(2, 48px);
    gap: 8px;
  }

  #movement-menu-drawer .touch-label {
    display: block;
    grid-row: 1;
    font-size: calc(11px * var(--text-scale, 1));
    line-height: 18px;
  }

  #movement-menu-drawer .action-controls-label {
    grid-column: 2;
  }

  body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active])
    .lesson-dock {
    grid-column: 1;
    grid-row: 1;
    margin: 0 12px 10px;
    width: calc(100% - 24px);
  }

  body:is(
      .practice-active,
      [data-navigation-area="listen"],
      [data-riddle-active],
      .soccer-world-active,
      .basketball-world-active
    )
    #movement-menu {
    display: none;
  }

  html[data-appearance="dark"] #movement-menu-toggle {
    background: #44395e;
    color: var(--ad-ink-purple);
    border-color: #a18ac5;
    box-shadow: 0 3px 0 #201c32;
  }

  html[data-appearance="dark"] #movement-menu-toggle small {
    color: #d0bfeb;
  }

  html[data-appearance="dark"] #movement-menu-drawer {
    background: #302b43;
    border-color: #9780ba;
  }
}
@media (max-width: 360px) {
  #movement-menu-toggle small {
    display: none;
  }

  #movement-menu-drawer .mobile-controls {
    grid-template-columns: 108px minmax(0, 1fr);
    column-gap: 8px;
    padding: 8px 2px;
  }
}
@media (max-width: 850px) and (orientation: landscape) and (max-height: 500px),
  (pointer: coarse) and (max-width: 1100px) and (orientation: landscape) and (max-height: 500px) {
  body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]) main {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 44%);
    grid-template-rows: 42px minmax(0, 1fr);
  }

  body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active])
    .playground {
    grid-column: 1;
    grid-row: 1/3;
    min-height: 190px;
  }

  #movement-menu {
    grid-column: 2;
    grid-row: 1;
  }

  body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]) .panel {
    grid-column: 2;
    grid-row: 2;
    align-self: stretch;
    height: 100%;
    max-height: 100%;
  }

  body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active])
    .lesson-dock {
    grid-column: 1;
    grid-row: 1/3;
  }

  #movement-menu-toggle small {
    display: none;
  }

  #movement-menu-drawer {
    max-height: calc(100svh - 150px);
    overflow-y: auto;
  }
}
@media (max-width: 850px), (pointer: coarse) and (max-width: 1100px) {
  #movement-menu {
    padding-inline: 0;
  }

  #movement-menu-drawer {
    left: 0;
    right: 0;
  }

  #movement-menu-toggle:focus:not(:focus-visible) {
    outline: none;
  }

  #movement-menu-toggle:focus-visible {
    border-color: #7250ad;
    box-shadow: inset 0 0 0 1px #7250ad;
  }

  html[data-appearance="dark"] #movement-menu-toggle[aria-expanded="true"] {
    background: #302b43;
    border-color: #9780ba;
    border-bottom-color: transparent;
  }
}
/* On taller tablet layouts, let short lists take their natural height. Long
   lists still stop at half the layout and scroll, preserving the scene. */
@media (min-width: 600px) and (max-width: 850px) and (min-height: 720px),
  (pointer: coarse) and (min-width: 600px) and (max-width: 1100px) and (min-height: 720px) {
  body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
      .soccer-world-active
    ):not(.basketball-world-active)
    main {
    grid-template-rows: minmax(252px, 1fr) 42px fit-content(52%);
  }
}
/* Desktop uses the same explicit controller toggle, opening upwards inside the scene. */
@media (min-width: 851px) and (pointer: fine), (min-width: 1101px) {
  .playground > #movement-menu {
    display: block;
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 12;
    max-width: calc(100% - 32px);
  }

  #movement-menu-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 5px 12px;
    border: 2px solid #a9c4ed;
    border-radius: 15px;
    background: linear-gradient(#f8f4ff, #e7dcff);
    color: var(--ad-ink-purple);
    box-shadow: 0 3px 0 #bba4e1;
    font: inherit;
    text-align: left;
    cursor: pointer;
  }

  #movement-menu-toggle strong {
    font-size: 13px;
  }

  #movement-menu-toggle small {
    display: none;
  }

  #movement-menu-toggle .control-icon {
    display: block;
    flex: none;
    width: 28px;
    height: 28px;
    font-size: 25px;
    line-height: 28px;
  }

  #movement-menu-toggle .movement-menu-chevron {
    display: block;
    font-size: 0;
    width: 16px;
    height: 16px;
    margin-left: 6px;
  }

  #movement-menu-toggle .movement-menu-chevron:before {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translate(2px, 5px) rotate(225deg);
  }

  #movement-menu-toggle[aria-expanded="true"] {
    width: 220px;
    border-top-color: transparent;
    border-radius: 0 0 15px 15px;
    background: #f8f5ff;
  }

  #movement-menu-toggle[aria-expanded="true"] .movement-menu-chevron:before {
    transform: translate(2px, 1px) rotate(45deg);
  }

  #movement-menu-toggle:focus:not(:focus-visible) {
    outline: none;
  }

  #movement-menu-toggle:focus-visible {
    outline: 2px solid #7250ad;
    outline-offset: 2px;
  }

  #movement-menu-drawer {
    position: absolute;
    bottom: calc(100% - 2px);
    right: 0;
    box-sizing: border-box;
    width: 220px;
    padding: 14px;
    border: 2px solid #bda6e5;
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    background: #f8f5ff;
    box-shadow: 0 -5px 18px #39456d20;
  }

  #movement-menu-drawer[hidden] {
    display: none;
  }

  #movement-menu-drawer > .dpad {
    position: static;
    display: grid;
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(2, 44px);
    gap: 8px;
    justify-content: center;
  }

  #movement-menu-drawer > .dpad button {
    width: 48px;
    height: 44px;
    border-radius: 13px;
    font-size: 28px;
  }

  #movement-menu-drawer #desktop-center {
    grid-column: 1;
    grid-row: 1;
    font-size: calc(12px * var(--text-scale, 1));
  }

  #movement-menu-drawer #desktop-clean {
    grid-column: 3;
    grid-row: 1;
    font-size: calc(12px * var(--text-scale, 1));
  }

  #movement-menu-drawer [data-direction="ArrowUp"] {
    grid-column: 2;
    grid-row: 1;
  }

  #movement-menu-drawer [data-direction="ArrowLeft"] {
    grid-column: 1;
    grid-row: 2;
  }

  #movement-menu-drawer [data-direction="ArrowDown"] {
    grid-column: 2;
    grid-row: 2;
  }

  #movement-menu-drawer [data-direction="ArrowRight"] {
    grid-column: 3;
    grid-row: 2;
  }

  .playground:has(#movement-menu-toggle[aria-expanded="true"]) > .hint {
    visibility: hidden;
  }

  body:is(.practice-active, [data-navigation-area="listen"], [data-riddle-active]) #movement-menu {
    display: none;
  }

  html[data-appearance="dark"] #movement-menu-toggle,
  html[data-appearance="dark"] #movement-menu-drawer {
    background: #302b43;
    color: var(--ad-ink-purple);
    border-color: #9780ba;
  }
}
/* Size belongs beside Move on compact screens, outside the character's canvas. */
@media (max-width: 850px), (pointer: coarse) and (max-width: 1100px) {
  #movement-menu > .mobile-zoom {
    display: flex;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 1;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    box-sizing: border-box;
    width: 128px;
    height: 42px;
    min-height: 42px;
    padding: 3px 5px;
    border: 1px solid var(--ad-line);
    border-radius: 14px;
    background: var(--ad-surface);
    box-shadow: 0 2px 0 #c5def2;
  }

  #movement-menu > .mobile-zoom button {
    display: grid;
    place-items: center;
    flex: 0 0 30px;
    width: 30px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    border: 1px solid #94c3e4;
    border-radius: 10px;
    background: linear-gradient(#e0f5ff, #a9ddf4);
    color: #185d89;
    box-shadow: 0 2px 0 #61a6c5;
    font-size: 22px;
  }

  #movement-menu > .mobile-zoom button:disabled {
    opacity: 0.45;
  }

  #movement-menu > .mobile-zoom div {
    flex: 1;
    min-width: 34px;
    text-align: center;
  }

  #movement-menu > .mobile-zoom div > span {
    display: none;
  }

  #movement-menu > .mobile-zoom output {
    color: var(--ad-ink-blue);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
  }

  #movement-menu-toggle {
    position: relative;
    z-index: 2;
    max-width: calc(100% - 138px);
  }

  #movement-menu:has(#movement-menu-toggle[aria-expanded="true"]) #movement-menu-toggle {
    max-width: 100%;
  }

  #movement-menu:has(#movement-menu-toggle[aria-expanded="true"]) > .mobile-zoom {
    visibility: hidden;
  }

  html[data-appearance="dark"] #movement-menu > .mobile-zoom {
    background: var(--ad-surface);
    border-color: #6c91b4;
  }

  html[data-appearance="dark"] #movement-menu > .mobile-zoom output {
    color: var(--ad-ink-blue);
  }
}
@media (max-width: 600px) {
  #movement-menu-toggle small {
    display: none;
  }

  #movement-menu-toggle {
    gap: 6px;
    padding-inline: 8px;
  }
}
@media (max-width: 360px) {
  #movement-menu-toggle strong {
    font-size: 12px;
  }

  #movement-menu-toggle .control-icon {
    width: 24px;
    height: 24px;
    font-size: 23px;
  }

  #movement-menu > .mobile-zoom {
    width: 118px;
    gap: 3px;
  }

  #movement-menu-toggle {
    max-width: calc(100% - 126px);
    padding-inline: 6px;
  }
}
@media (max-width: 850px) and (orientation: landscape) and (max-height: 500px),
  (pointer: coarse) and (max-width: 1100px) and (orientation: landscape) and (max-height: 500px) {
  #movement-menu-toggle .control-icon {
    display: none;
  }

  #movement-menu-toggle strong {
    font-size: 12px;
  }
}
@media (max-width: 850px), (pointer: coarse) and (max-width: 1100px) {
  #movement-menu-drawer {
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #movement-menu[data-open-direction="up"] #movement-menu-drawer {
    top: auto;
    bottom: calc(100% - 2px);
    border-top: 2px solid #bda6e5;
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -9px 24px #39456d35;
  }

  #movement-menu[data-open-direction="up"]:has(#movement-menu-toggle[aria-expanded="true"])
    #movement-menu-toggle {
    border-top-color: transparent;
    border-bottom-color: #bda6e5;
    border-radius: 0 0 15px 15px;
  }
}
/* The menu owns its own slot; play-world.css owns the surrounding game grid. */
@media (max-width: 850px), (pointer: coarse) and (max-width: 1100px) {
  body.play-world-active #movement-menu {
    grid-column: 1;
    grid-row: 2;
  }
}
/* Landscape tablets reserve a permanent controller row outside the canvas. */
body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"] {
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) clamp(390px, 42%, 560px);
  grid-template-rows: minmax(0, 1fr) 176px;
}
body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  .playground {
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
}
body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  #movement-menu {
  display: none;
}
body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  .lesson-dock {
  grid-column: 1;
  grid-row: 1;
}
body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  .panel {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: stretch;
  min-height: 0;
  overflow: hidden;
}
body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  .panel-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  > .dpad {
  position: static;
  display: grid;
  grid-column: 1;
  grid-row: 2;
  grid-template-columns: repeat(3, minmax(80px, 112px));
  grid-template-rows: repeat(2, 80px);
  justify-content: center;
  align-content: center;
  gap: 8px;
  padding: 4px 12px;
  border: 1px solid var(--ad-line);
  border-radius: 23px;
  background: var(--ad-paper);
}
body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  > .dpad
  button {
  width: 100%;
  height: 80px;
  min-height: 80px;
  border-radius: 18px;
  font-size: calc(36px * var(--text-scale, 1));
}
body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  :is(#desktop-center, #desktop-clean) {
  width: 100%;
  height: 80px;
  min-height: 80px;
  font-size: calc(16px * var(--text-scale, 1));
}
body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  #desktop-center {
  grid-column: 1;
  grid-row: 1;
}
body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  #desktop-clean {
  grid-column: 3;
  grid-row: 1;
}

body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  > .dpad
  [data-direction="ArrowUp"] {
  grid-column: 2;
  grid-row: 1;
}

body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  > .dpad
  [data-direction="ArrowLeft"] {
  grid-column: 1;
  grid-row: 2;
}

body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  > .dpad
  [data-direction="ArrowDown"] {
  grid-column: 2;
  grid-row: 2;
}

body:not(.practice-active):not([data-navigation-area="listen"]):not([data-riddle-active]):not(
    .soccer-world-active
  ):not(.basketball-world-active)
  main[data-movement-docked="true"]
  > .dpad
  [data-direction="ArrowRight"] {
  grid-column: 3;
  grid-row: 2;
}

/* Center and Clean are words in the narrowest cells of the panel (about 31-41 px): the size follows the
   screen width, and the text-size setting cannot push them past the button. */
#movement-menu-drawer .mobile-dpad :is(#mobile-center, #mobile-clean) {
  padding-inline: 0;
  font-size: clamp(8.5px, 2.5vw, calc(11px * var(--text-scale, 1)));
  letter-spacing: 0;
}
