/**
 * Keyboard Beat — 시작 화면·플레이 레이아웃·게스트 모달
 */

/* auto-start 라우트에서도 시작 패널 강제 표시 (활성 패널만) */
body.app-pl-auto-start #playLabPanelKeyboardBeat.is-active #kbSetup,
body.app-pl-auto-start #playLabPanelKeyboardBeat.is-active .kb-setup--start,
body.app-mode.app-pl-auto-start #playLabPanelKeyboardBeat.is-active #kbSetup,
body.app-mode.app-pl-auto-start #playLabPanelKeyboardBeat.is-active .kb-setup--start,
.play-lab-shell[data-play-lab-auto-start="1"] #playLabPanelKeyboardBeat.is-active #kbSetup {
  display: flex !important;
  flex-direction: column;
  visibility: visible !important;
  pointer-events: auto !important;
  opacity: 1 !important;
  min-height: var(--play-game-intro-height-desktop-compact, min(78vh, 760px));
}

#playLabPanelKeyboardBeat.is-active #kbSetup.is-hidden {
  display: none !important;
}

#playLabPanelKeyboardBeat.is-active .kb-campaign-brief {
  margin: 0.35rem 0 0;
  font-size: clamp(0.82rem, 2.6vw, 0.95rem);
  font-weight: 600;
  line-height: 1.45;
  color: rgba(226, 232, 240, 0.92);
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

#playLabPanelKeyboardBeat.is-active .kb-campaign-meta {
  margin: 0.5rem 0 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.65rem;
  font-size: clamp(0.78rem, 2.4vw, 0.9rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #a5f3fc;
}

#playLabPanelKeyboardBeat.is-active #kbCampaignLevel {
  color: #f0abfc;
}

#playLabPanelKeyboardBeat.is-active #kbCampaignGoal {
  color: #fcd34d;
}

#playLabPanelKeyboardBeat.is-active .kb-game-start-btn,
#playLabPanelKeyboardBeat.is-active #kbStartBtn {
  position: relative;
  z-index: 4;
}

#playLabPanelKeyboardBeat.is-active .kb-level-transition {
  z-index: 14;
}

/* -------------------------------------------------------------------------- */
/* 시작 화면 — Race/Word Drop과 동일 높이 (데스크톱, 활성 패널만)                  */
/* 모바일 높이는 keyboard_race.css 풀블리드 히어로 규칙 사용                        */
/* -------------------------------------------------------------------------- */

@media (min-width: 901px) {
  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) {
    min-height: var(--play-game-intro-height-desktop-compact, min(78vh, 760px));
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .kb-shell {
    min-height: var(--play-game-intro-height-desktop-compact, min(78vh, 760px)) !important;
    max-height: var(--play-game-intro-height-desktop-compact, min(78vh, 760px)) !important;
    height: auto !important;
    overflow: hidden !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .kb-layout,
  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .kb-main,
  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) #kbSetup:not(.is-hidden),
  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .kb-setup--start {
    min-height: inherit !important;
    height: 100% !important;
    display: block;
    overflow: hidden !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .kb-menu-screen.play-lab-hero {
    position: absolute;
    inset: 0;
    width: 100%;
    min-height: 100% !important;
    height: 100% !important;
    overflow: hidden;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .kb-menu-screen__bg-image {
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
  }

  /* 시작하기 CTA — keyboard_race.css 공통 playlab-hero__actions 규칙과 동일 (하단 중앙) */
  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .playlab-hero__actions,
  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .play-lab-mobile-actions.playlab-hero__actions {
    position: absolute !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: calc(clamp(28px, 4.5vh, 36px) + env(safe-area-inset-bottom, 0px)) !important;
    transform: translateX(-50%) !important;
    z-index: 5 !important;
    display: block !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    pointer-events: none !important;
    background: none !important;
    border: none !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .playlab-hero__actions > .playlab-start-btn,
  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) #kbStartBtn.playlab-start-btn {
    position: absolute !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: 0 !important;
    transform: translateX(-50%) !important;
    z-index: 6 !important;
    pointer-events: auto !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    width: clamp(260px, 30vw, 320px) !important;
    min-width: 260px !important;
    max-width: 320px !important;
    height: 56px !important;
    min-height: 56px !important;
    margin: 0 !important;
    padding: 0 20px !important;
  }
}

@media (max-width: 900px) {
  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .kb-header {
    display: none !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .kb-menu-screen__bg-image {
    background-size: cover !important;
    background-position: center top !important;
    background-repeat: no-repeat !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .playlab-hero__actions,
  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .play-lab-mobile-actions.playlab-hero__actions {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    bottom: var(--kr-intro-cta-inset, max(28px, calc(24px + env(safe-area-inset-bottom, 0px)))) !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) #kbStartBtn.playlab-start-btn,
  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) .playlab-hero__actions > .playlab-start-btn {
    width: min(78vw, 320px) !important;
    min-width: 220px !important;
    max-width: calc(100% - 32px) !important;
    height: 52px !important;
    min-height: 52px !important;
    transform: translateX(-50%) !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame.is-hidden) #kbStartBtn.playlab-start-btn:active {
    transform: translateX(-50%) scale(0.98) !important;
  }
}

/* -------------------------------------------------------------------------- */
/* 플레이 중: #kbGame 표시 시에만 flex 레이아웃 (시작 화면과 분리)               */
/* -------------------------------------------------------------------------- */

body.kb-beat-playing.pl-game-focus-mode,
body.kb-beat-playing.app-mode.app-game-mode {
  overflow: hidden;
}

/* PLAY LAB 탭(/keyboard-race#keyboard-beat) — PC */
@media (min-width: 901px) {
  .play-lab-page.keyboard-race-page:not(.app-play-lab-solo).kb-beat-playing,
  .play-lab-page.keyboard-race-page:not(.app-play-lab-solo):has(
      #playLabPanelKeyboardBeat.is-active #kbGame:not(.is-hidden)
    ) {
    overflow: hidden;
  }

  .play-lab-page.keyboard-race-page:not(.app-play-lab-solo):has(
      #playLabPanelKeyboardBeat.is-active #kbGame:not(.is-hidden)
    )
    .play-lab-shell {
    align-items: stretch;
    min-height: calc(var(--app-height, 100dvh) - 96px);
    max-height: calc(var(--app-height, 100dvh) - 96px);
  }

  .play-lab-page.keyboard-race-page:not(.app-play-lab-solo):has(
      #playLabPanelKeyboardBeat.is-active #kbGame:not(.is-hidden)
    )
    .play-lab-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
}

#playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
}

#playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-shell {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0;
  padding: 6px 8px 8px;
  box-sizing: border-box;
}

#playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-layout,
#playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-header {
  flex-shrink: 0;
}

/* 게임 카드: 고정 min(62vh) 제거 → 남는 세로 공간 전부 사용 */
#playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-game {
  flex: 1 1 auto;
  min-height: 0 !important;
  max-height: none !important;
  height: auto !important;
  margin-top: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

#playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-game-stack {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 4px 6px 4px !important;
  gap: 0 !important;
  box-sizing: border-box !important;
}

#playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-board {
  flex: 1 1 auto !important;
  min-height: 280px !important;
  height: 100% !important;
  position: relative !important;
  display: block !important;
  overflow: hidden !important;
}

#playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-lane-wrap {
  position: absolute !important;
  inset: 0 !important;
  z-index: 1;
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 0 !important;
  overflow: hidden !important;
}

#playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-lane {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
}

/* 노트 낙하 구간 — 레이블은 하단 오버레이로 분리해 stage 높이 확보 */
#playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-lane__stage {
  flex: 1 1 auto !important;
  min-height: 200px !important;
  height: 100% !important;
  max-height: none !important;
}

#playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-lane__labels {
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 4;
  flex: 0 0 auto !important;
  pointer-events: none;
  padding-bottom: max(2px, env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent 0%, rgba(2, 6, 16, 0.72) 42%, rgba(2, 6, 16, 0.9) 100%);
}

/* 레인 수(--kb-n-lanes)에 따라 하단 키 라벨·터치패드와 겹치지 않게 판정선 위치 */
#playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-lane__line {
  bottom: max(
    12%,
    calc(28px + (var(--kb-n-lanes, 4) - 1) * 4px)
  ) !important;
}

@media (max-width: 900px) {
  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-lane__line {
    bottom: max(
      14%,
      calc(36px + (var(--kb-n-lanes, 4) - 1) * 5px)
    ) !important;
  }
}

/* PC: 온스크린 키패드 숨김 (물리 키보드) */
@media (min-width: 901px) {
  #playLabPanelKeyboardBeat.is-active .kb-touch-row {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-game-stack {
    padding-bottom: 4px !important;
  }
}

/* 모바일: 터치 키패드 표시 — 보드 위·키패드 아래 flex 분할 (immersive는 keyboard_race.css) */
@media (max-width: 900px) {
  .play-lab-page.keyboard-race-page:has(#playLabPanelKeyboardBeat.is-active #kbGame:not(.is-hidden)) {
    --kb-mobile-site-header: 84px;
    --kb-mobile-touch-stack: clamp(112px, 22vw, 148px);
    --kb-mobile-play-board-min: max(
      320px,
      calc(var(--app-height, 100svh) - var(--kb-mobile-site-header) - var(--kb-mobile-touch-stack) - 24px)
    );
  }

  body.kb-mobile-playing.play-lab-page.keyboard-race-page,
  body.kb-beat-playing.play-lab-page.keyboard-race-page:has(
      #playLabPanelKeyboardBeat.is-active #kbGame:not(.is-hidden)
    ) {
    padding: 0 !important;
    min-height: var(--app-height, 100svh) !important;
    height: var(--app-height, 100svh);
    overflow: hidden !important;
    box-sizing: border-box;
  }

  body.kb-mobile-playing .play-lab-shell,
  body.kb-beat-playing:has(#playLabPanelKeyboardBeat.is-active #kbGame:not(.is-hidden)) .play-lab-shell {
    min-height: 0 !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.kb-mobile-playing .play-lab-main,
  body.kb-beat-playing:has(#playLabPanelKeyboardBeat.is-active #kbGame:not(.is-hidden)) .play-lab-main {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  body.kb-beat-playing:not(.kb-mobile-playing)
    #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: calc(
      var(--app-height, 100svh) - var(--kb-mobile-site-header, 84px) - env(safe-area-inset-bottom, 0px)
    ) !important;
    max-height: calc(
      var(--app-height, 100svh) - var(--kb-mobile-site-header, 84px) - env(safe-area-inset-bottom, 0px)
    ) !important;
    height: calc(
      var(--app-height, 100svh) - var(--kb-mobile-site-header, 84px) - env(safe-area-inset-bottom, 0px)
    ) !important;
    border-radius: 0 !important;
    overflow: hidden !important;
  }

  body:not(.kb-mobile-playing)
    #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden))
    .kb-shell {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 4px 6px 6px !important;
    box-sizing: border-box !important;
  }

  body:not(.kb-mobile-playing)
    #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden))
    .kb-layout,
  body:not(.kb-mobile-playing)
    #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden))
    .kb-main,
  body:not(.kb-mobile-playing)
    #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden))
    .kb-game {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    max-height: none !important;
    margin-top: 0 !important;
  }

  body:not(.kb-mobile-playing)
    #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden))
    .kb-header {
    display: none !important;
  }

  body:not(.kb-mobile-playing)
    #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden))
    .kb-game-stack {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 4px 6px 0 !important;
    gap: 4px !important;
  }

  body:not(.kb-mobile-playing)
    #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden))
    .kb-lane-wrap {
    position: relative !important;
    inset: auto !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
  }

  body:not(.kb-mobile-playing)
    #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden))
    .kb-board {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: var(--kb-mobile-play-board-min, 320px) !important;
    height: auto !important;
    max-height: none !important;
  }

  body:not(.kb-mobile-playing)
    #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden))
    .kb-lane__stage {
    flex: 1 1 auto !important;
    min-height: max(260px, calc(var(--kb-mobile-play-board-min, 320px) - 48px)) !important;
    height: 100% !important;
    max-height: none !important;
  }

  #playLabPanelKeyboardBeat.is-active .kb-touch-row:not(.is-hidden) {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    margin-top: 0 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
}

/* 앱 게임 전용 solo — shell 패딩 최소화 */
body.app-mode.app-game-mode.app-pl-solo--keyboard-beat
  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden))
  .kb-shell {
  padding: 0 max(4px, env(safe-area-inset-right, 0px)) max(4px, env(safe-area-inset-bottom, 0px))
    max(4px, env(safe-area-inset-left, 0px)) !important;
}

/* -------------------------------------------------------------------------- */
/* 게스트 로그인 / 무료 체험 종료 모달 — 대비 개선 (패널 밖 fixed 모달)          */
/* -------------------------------------------------------------------------- */

.pl-guest-login-modal .pl-guest-login-modal__buttons .kb-btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.pl-guest-login-modal .pl-guest-login-modal__buttons .kb-btn--primary {
  border: 1px solid rgba(34, 211, 238, 0.65);
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  color: #042f2e;
  box-shadow: 0 4px 14px rgba(34, 211, 238, 0.35);
}

.pl-guest-login-modal .pl-guest-login-modal__buttons .kb-btn--primary:hover {
  filter: brightness(1.06);
  color: #022c22;
}

.pl-guest-login-modal .pl-guest-login-modal__buttons .kb-btn--secondary {
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(51, 65, 85, 0.95);
  color: #f1f5f9;
}

.pl-guest-login-modal .pl-guest-login-modal__buttons .kb-btn--ghost {
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(30, 41, 59, 0.92);
  color: #f8fafc;
}

.pl-guest-login-modal .pl-guest-login-modal__buttons .kb-btn--ghost:hover {
  border-color: rgba(203, 213, 225, 0.55);
  background: rgba(51, 65, 85, 0.98);
  color: #ffffff;
}

.pl-guest-login-modal.pl-guest-login-modal--daily-limit .pl-guest-login-modal__buttons {
  gap: 10px;
}

@media (max-width: 900px) {
  .pl-guest-login-modal .pl-guest-login-modal__buttons .kb-btn {
    min-height: 48px;
    font-size: 16px;
  }
}

/* -------------------------------------------------------------------------- */
/* PC 넓은 화면(≥1200px) — 게임 보드 가로·세로 확대 (모바일 규칙 유지)            */
/* -------------------------------------------------------------------------- */

@media (min-width: 1200px) {
  .play-lab-page.keyboard-race-page:not(.app-play-lab-solo):has(
      #playLabPanelKeyboardBeat.is-active #kbGame:not(.is-hidden)
    )
    .play-lab-shell {
    align-items: stretch;
    min-height: calc(100dvh - 88px);
    max-height: calc(100dvh - 88px);
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    min-height: var(--play-game-stage-h, clamp(580px, calc(100vh - 108px), 860px));
    height: var(--play-game-stage-h, clamp(580px, calc(100vh - 108px), 860px));
    border-radius: 14px;
    overflow: hidden;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-shell {
    width: 100%;
    max-width: none;
    min-height: 100% !important;
    height: 100% !important;
    padding: 4px 10px 10px !important;
    margin: 0;
    box-sizing: border-box;
  }

  /* 패널 헤더 숨김 → 레인 영역 세로 확보 (설정/랭킹은 플레이 HUD·사이드 메뉴) */
  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-header {
    display: none !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-layout,
  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-main {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    width: 100%;
    max-width: none;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-game {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    width: 100%;
    max-width: none;
    margin-top: 0 !important;
    border-radius: 12px;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-game-stack {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: 100% !important;
    width: 100%;
    max-width: none;
    padding: 2px 6px 6px !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-board {
    flex: 1 1 auto !important;
    min-height: var(--play-game-board-min-h, clamp(560px, calc(100vh - 128px), 820px)) !important;
    height: 100% !important;
    width: 100%;
    max-width: none;
    display: block !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-lane-wrap {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-lane {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-lane__stage {
    flex: 1 1 auto !important;
    min-height: var(--play-game-board-min-h, clamp(540px, calc(100vh - 148px), 800px)) !important;
    height: 100% !important;
    width: 100% !important;
    max-height: none !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-lanes-bg,
  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-notes-layer {
    width: 100%;
    height: 100%;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-play-hud--overlay {
    left: 12px;
    right: 12px;
    top: 10px;
  }
}

/* 901–1199px: 중간 해상도에서도 보드 최소 높이 완화 */
@media (min-width: 901px) and (max-width: 1199px) {
  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-board {
    min-height: clamp(480px, 62vh, 640px) !important;
  }

  #playLabPanelKeyboardBeat.is-active:has(#kbGame:not(.is-hidden)) .kb-lane__stage {
    min-height: clamp(440px, 58vh, 600px) !important;
  }
}
