/* Shared mobile layout for both Magische Welt Xylophon variants. */
.mw-mobile-pickers {
  display: none;
}

@media (max-width: 768px),
       (max-height: 480px) and (max-width: 980px) {
  html,
  body {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
  }

  body {
    touch-action: manipulation;
  }

  .wrapper {
    width: 100%;
    max-width: none;
    max-height: none;
    padding: 8px max(8px, env(safe-area-inset-right))
      calc(10px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .game-header {
    gap: 4px;
    margin-bottom: 7px;
  }

  .title-pill {
    min-height: 38px;
    padding: 6px 16px;
    font-size: clamp(18px, 5vw, 21px);
    box-shadow: 0 9px 18px rgba(0, 0, 0, 0.1);
  }

  .subtitle-pill,
  .kb-hint {
    display: none;
  }

  .mw-mobile-pickers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-bottom: 7px;
    position: relative;
    z-index: 30;
  }

  .mw-mobile-picker {
    position: relative;
    min-width: 0;
  }

  .mw-mobile-picker summary {
    list-style: none;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.48);
    border-radius: 15px;
    background: linear-gradient(145deg, rgba(255,255,255,.88), rgba(245,235,250,.7));
    box-shadow: 0 9px 20px rgba(30, 20, 42, 0.13), inset 0 0 14px rgba(255,255,255,.45);
    backdrop-filter: blur(12px) saturate(1.08);
    -webkit-backdrop-filter: blur(12px) saturate(1.08);
    color: #25202d;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
    user-select: none;
  }

  .mw-mobile-picker summary::-webkit-details-marker {
    display: none;
  }

  .mw-mobile-picker summary::after {
    content: "⌄";
    flex: 0 0 auto;
    font-size: 18px;
    line-height: 1;
    transition: transform .16s ease;
  }

  .mw-mobile-picker[open] summary::after {
    transform: rotate(180deg);
  }

  .mw-mobile-menu {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    display: grid;
    gap: 5px;
    padding: 7px;
    border: 1px solid rgba(255,255,255,.52);
    border-radius: 16px;
    background: rgba(247, 240, 250, .94);
    box-shadow: 0 18px 34px rgba(28, 18, 38, .24);
    backdrop-filter: blur(16px) saturate(1.06);
    -webkit-backdrop-filter: blur(16px) saturate(1.06);
  }

  .mw-mobile-option {
    width: 100%;
    min-height: 42px;
    padding: 8px 9px;
    border: 1px solid rgba(80, 55, 100, .13);
    border-radius: 12px;
    background: rgba(255,255,255,.72);
    color: #28202f;
    font: inherit;
    font-size: 13px;
    font-weight: 850;
    text-align: left;
    cursor: pointer;
  }

  .mw-mobile-option:active,
  .mw-mobile-option.is-selected {
    background: linear-gradient(145deg, rgba(162,220,255,.7), rgba(255,190,224,.58));
  }

  .songbar {
    margin: 0 0 7px;
    display: block;
  }

  .songbar > .songbtn {
    display: none !important;
  }

  .songbar-right {
    width: 100%;
    margin: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) auto auto;
    gap: 6px;
    align-items: stretch;
  }

  .songbar-right .mode,
  .songbar-right .toolbtn {
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 7px 8px;
    border-radius: 14px;
    font-size: clamp(11px, 3.25vw, 13px);
    box-shadow: 0 8px 16px rgba(0,0,0,.1);
  }

  #stopSong {
    padding-inline: 11px;
  }

  #muteBtn {
    width: 44px;
    padding: 0;
    font-size: 19px;
  }

  .lane-wrap {
    height: clamp(88px, 18vh, 125px);
    margin: 5px 0 8px;
  }

  .lane {
    border-radius: 16px;
  }

  .lane-line {
    left: 8px;
    right: 8px;
    bottom: 10px;
  }

  .drop {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    font-size: 22px;
  }

  .board {
    width: 100%;
    margin-top: 0;
    padding: 10px 8px 9px;
    border-radius: 18px;
  }

  .walnut-bar {
    height: 13px;
  }

  .keys {
    margin-top: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .key {
    min-width: 0;
    min-height: 72px;
    padding: 7px 0 5px;
    border-radius: 12px;
  }

  .key.c  { height: 112px; }
  .key.d  { height: 108px; }
  .key.e  { height: 104px; }
  .key.f  { height: 100px; }
  .key.g  { height: 96px; }
  .key.a  { height: 92px; }
  .key.h  { height: 88px; }
  .key.c2 { height: 84px; }

  .key::before {
    top: -7px;
    width: 9px;
    height: 9px;
  }

  .key::after {
    top: -17px;
    height: 12px;
  }

  .key .note {
    font-size: 12px;
  }

  .key .icon {
    font-size: clamp(27px, 9vw, 38px);
  }

  .key:hover {
    transform: none;
  }

  .praise {
    padding: 10px;
  }

  .praise-card {
    max-height: calc(100svh - 20px);
    overflow: auto;
  }
}

@media (max-width: 370px) {
  .mw-mobile-pickers {
    grid-template-columns: 1fr;
  }

  .mw-mobile-picker summary {
    min-height: 40px;
  }

  .songbar-right {
    grid-template-columns: 1fr 1fr auto;
  }

  #muteBtn {
    grid-column: 3;
    grid-row: 1;
  }

  #stopSong {
    grid-column: 1 / 4;
    grid-row: 2;
  }
}

@media (max-width: 768px) and (orientation: landscape),
       (max-height: 480px) and (max-width: 980px) {
  .wrapper {
    padding-top: 4px;
  }

  .game-header {
    position: absolute;
    top: 4px;
    left: max(8px, env(safe-area-inset-left));
    z-index: 31;
    margin: 0;
  }

  .title-pill {
    min-height: 34px;
    padding: 4px 12px;
    font-size: 17px;
  }

  .mw-mobile-pickers {
    grid-template-columns: minmax(155px, 1fr) minmax(130px, .82fr);
    width: min(58vw, 470px);
    margin: 0 0 5px auto;
  }

  .mw-mobile-picker summary {
    min-height: 36px;
    padding: 5px 8px;
    font-size: 12px;
  }

  .songbar {
    width: min(62vw, 530px);
    margin: 0 0 5px auto;
  }

  .songbar-right .mode,
  .songbar-right .toolbtn {
    min-height: 36px;
    padding-block: 4px;
    font-size: 11px;
  }

  #muteBtn {
    width: 38px;
  }

  .lane-wrap {
    height: 62px;
    margin: 3px 0 5px;
  }

  .board {
    padding: 7px 7px 6px;
  }

  .walnut-bar {
    height: 10px;
  }

  .keys {
    margin-top: 7px;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 5px;
  }

  .key {
    min-height: 58px;
    padding: 5px 0 3px;
    border-radius: 10px;
  }

  .key.c  { height: 108px; }
  .key.d  { height: 102px; }
  .key.e  { height: 96px; }
  .key.f  { height: 90px; }
  .key.g  { height: 84px; }
  .key.a  { height: 78px; }
  .key.h  { height: 72px; }
  .key.c2 { height: 66px; }

  .key .icon {
    font-size: clamp(24px, 4.6vw, 35px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mw-mobile-picker summary::after {
    transition: none;
  }
}
