/* Mock keyboard dedicated layout. Loaded after the main app bundle CSS. */
.game-shell:has(.keyboard-panel) {
  width: 100%;
  min-height: 100dvh;
  margin: 0;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(76px, calc(env(safe-area-inset-bottom) + 76px)) max(10px, env(safe-area-inset-left));
  border: 0;
  border-radius: 0;
  background: linear-gradient(180deg, #f9fbff 0%, #eef4ff 54%, #dfeafd 100%);
  box-shadow: none;
}

.game-shell:has(.keyboard-panel) .game-header,
.game-shell:has(.keyboard-panel) .game-topbar,
.game-shell:has(.keyboard-panel) .switcher {
  display: none;
}

.game-shell:has(.keyboard-panel) .keyboard-panel {
  display: grid;
  grid-template-rows: minmax(150px, auto) minmax(0, 1fr);
  gap: 0;
  width: min(100%, 1560px);
  min-height: calc(100dvh - 98px);
  margin: 0 auto;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.game-shell:has(.keyboard-panel) .note-display {
  position: relative;
  display: block;
  justify-self: center;
  width: 100%;
  aspect-ratio: 2172 / 724;
  min-height: 150px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: url("/assets/brand/mock-keyboard-console-gloss-v1.webp") center / 100% 100% no-repeat;
  box-shadow: 0 24px 48px rgba(32, 45, 74, .18);
  overflow: visible;
}

.game-shell:has(.keyboard-panel) .note-display:before,
.game-shell:has(.keyboard-panel) .note-display:after {
  display: none;
}

.game-shell:has(.keyboard-panel) .note-readout {
  position: absolute;
  left: 71.7%;
  top: 28.7%;
  width: 15.3%;
  height: 26.8%;
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 3% 4%;
  background: transparent;
  box-shadow: none;
  color: #18324a;
  text-align: center;
  gap: 2%;
}

.game-shell:has(.keyboard-panel) .note-display strong {
  color: #18324a;
  font-size: clamp(17px, 2.7vw, 40px);
  line-height: 1;
}

.game-shell:has(.keyboard-panel) .note-display span {
  color: rgba(24, 50, 74, .68);
  font-size: clamp(8px, .95vw, 14px);
  font-weight: 950;
}

.game-shell:has(.keyboard-panel) .note-visual {
  position: absolute;
  left: 13.6%;
  top: 27.4%;
  display: block;
  width: 51.8%;
  height: 29.4%;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.game-shell:has(.keyboard-panel) .note-visual:before {
  display: none;
}

.game-shell:has(.keyboard-panel) .note-png-wrap {
  position: absolute;
  inset: 9% 7%;
  display: grid;
  place-items: center;
  overflow: visible;
}

.game-shell:has(.keyboard-panel) .note-png {
  display: block;
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  object-position: center !important;
}

.game-shell:has(.keyboard-panel) .note-display .note-accidental {
  position: absolute;
  top: 8px;
  right: 10px;
  display: grid !important;
  place-items: center;
  width: clamp(26px, 4vw, 38px);
  height: clamp(26px, 4vw, 38px);
  border-radius: 999px;
  color: #fff;
  background: #17233f;
  font-size: clamp(18px, 2.8vw, 27px);
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 6px 12px rgba(23, 35, 63, .22);
}

.game-shell:has(.keyboard-panel) .note-display .note-placeholder {
  position: absolute;
  inset: 0;
  display: grid !important;
  place-items: center;
  color: rgba(22, 35, 63, .38);
  font-size: 30px;
  font-weight: 950;
}

.game-shell:has(.keyboard-panel) .app-dock {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: max(8px, env(safe-area-inset-bottom));
  width: min(calc(100% - 16px), 380px);
  transform: translateX(-50%);
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 14px 36px rgba(31, 49, 86, .16);
  backdrop-filter: blur(16px);
}

@media (orientation: landscape), (min-width: 721px) {
  .game-shell:has(.keyboard-panel) .keyboard-panel {
    grid-template-rows: minmax(160px, auto) minmax(0, 1fr);
  }

  .game-shell:has(.keyboard-panel) .note-display {
    width: 100%;
    min-height: 160px;
    padding: 0;
  }

  .game-shell:has(.keyboard-panel) .keyboard {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: min(54vh, 420px);
    min-height: 280px;
    overflow-x: auto;
    margin-top: -28px;
    padding: 30px 14px 14px;
    border-radius: 0 0 20px 20px;
    background:
      linear-gradient(180deg, rgba(255,255,255,.18) 0, rgba(255,255,255,.04) 10px, transparent 34px),
      linear-gradient(90deg, #07090f 0%, #242b3d 4%, #101622 16%, #060911 50%, #101622 84%, #242b3d 96%, #07090f 100%);
    box-shadow:
      inset 0 18px 28px rgba(255,255,255,.08),
      inset 0 -24px 34px rgba(0,0,0,.45),
      0 24px 44px rgba(20, 31, 54, .20);
  }

  .game-shell:has(.keyboard-panel) .white-key {
    z-index: 1;
    height: 100% !important;
    min-width: clamp(46px, 4.6vw, 74px);
  }

  .game-shell:has(.keyboard-panel) .black-key {
    position: absolute;
    z-index: 3;
    top: 10px;
    left: calc(((var(--white-index) + 1) * 100%) / 21);
    display: grid;
    place-items: center;
    width: clamp(30px, 3.4vw, 50px);
    height: 64%;
    border: 0;
    border-radius: 0 0 9px 9px;
    color: #f9fbff;
    background: linear-gradient(180deg, #303b57 0%, #0a1021 72%, #02040b 100%);
    box-shadow: 0 12px 20px rgba(2, 7, 18, .34);
    transform: translateX(-50%);
    touch-action: manipulation;
  }

  .game-shell:has(.keyboard-panel) .black-key small {
    display: none;
  }
}

@media (orientation: portrait) and (max-width: 720px) {
  .game-shell:has(.keyboard-panel) {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(72px, calc(env(safe-area-inset-bottom) + 72px)) max(8px, env(safe-area-inset-left));
  }

  .keyboard-panel,
  .game-shell:has(.keyboard-panel) .keyboard-panel {
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
    width: 100%;
    min-height: calc(100dvh - 88px);
    padding: 0;
  }

  .game-shell:has(.keyboard-panel) .note-display {
    display: none;
  }

  .keyboard {
    position: relative;
    display: flex;
    flex-direction: column-reverse;
    gap: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    min-height: calc(100dvh - 150px);
    max-height: none;
    justify-self: center;
    overflow-x: hidden;
    overflow-y: auto;
    margin-top: 0;
    padding: 12px 0 8px 8px;
    scroll-snap-type: y proximity;
    border-radius: 0 0 18px 18px;
    background:
      linear-gradient(90deg, #07090f 0%, #1e2638 4%, #111827 14%, #f8fbff 14.5%, #f8fbff 100%);
    box-shadow:
      inset 16px 0 26px rgba(255,255,255,.08),
      inset 0 -20px 28px rgba(0,0,0,.32),
      0 18px 36px rgba(28, 43, 74, .18);
  }

  .white-key {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(46px, 64px) 1fr minmax(38px, 52px);
    align-items: center;
    justify-items: center;
    flex: 1 0 clamp(42px, 6vh, 58px);
    min-width: 0;
    width: 100%;
    min-height: 38px;
    height: auto !important;
    margin: 0 0 -1px;
    border-radius: 0 9px 9px 0;
    padding: 0 42px 0 14px;
    scroll-snap-align: center;
    background: linear-gradient(90deg, #ffffff 0%, #f8fbff 76%, #dbe7ff 100%);
    box-shadow: inset 12px 0 20px rgba(22, 32, 54, .09);
  }

  .white-key:before {
    display: none;
  }

  .black-key {
    position: absolute;
    z-index: 5;
    top: calc(((20 - var(--white-index)) * 100%) / 21);
    right: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    justify-items: center;
    width: min(62%, 188px);
    height: clamp(42px, 6.2vh, 66px);
    min-height: 40px;
    padding: 0 12px 0 22px;
    border: 0;
    border-radius: 12px 0 0 12px;
    color: #f9fbff;
    background: linear-gradient(90deg, #303b57 0%, #11182b 34%, #050814 100%);
    box-shadow: -10px 0 16px rgba(0, 0, 0, .36);
    transform: translateY(-50%);
    touch-action: manipulation;
  }

  .black-key:active {
    background: linear-gradient(90deg, #44557d 0%, #1b294a 44%, #0a1021 100%);
    transform: translateY(-50%) translateX(-2px);
  }

  .black-key span,
  .black-key small {
    justify-self: center;
    color: #f9fbff;
    font-weight: 950;
    line-height: 1;
    transform: rotate(90deg);
    transform-origin: center;
  }

  .black-key span {
    font-size: clamp(14px, 4vw, 18px);
  }

  .black-key small {
    color: #c8d4ef;
    font-size: clamp(11px, 3vw, 14px);
  }

  .white-key .jp,
  .white-key span {
    justify-self: center;
    color: #17233f;
    font-size: clamp(17px, 5vw, 24px);
    font-weight: 950;
    line-height: 1;
    transform: rotate(90deg);
    transform-origin: center;
  }

  .white-key .en,
  .white-key small {
    justify-self: center;
    margin: 0;
    color: #65738f;
    font-size: clamp(12px, 3.2vw, 15px);
    font-weight: 950;
    line-height: 1;
    transform: rotate(90deg);
    transform-origin: center;
  }

  .surface-webview .keyboard {
    min-height: calc(100dvh - 140px);
  }

  .surface-webview .keyboard-panel {
    min-height: calc(100dvh - 82px);
  }
}
