#rhythmContainer {
  position: absolute; 
  top: 0; left: 0; 
  width: 100%; height: 100%; 
  z-index: 25; /* omok is 20 */
  display: none; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  background: #000;
  overflow: hidden;
}

#rhythmContainer.rhythm-expanded {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
}

#rhythmMinimizeBtn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10000;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  display: none;
  backdrop-filter: blur(6px);
}

#rhythmExtFsBtn {
  background: rgba(233,30,99,0.15);
  color: #e91e63;
  border: 1px solid #e91e63;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 900;
  font-size: 13px;
  cursor: pointer;
  display: none;
  margin-top: 5px;
  transition: background 0.2s;
}
#rhythmExtFsBtn:hover { background: rgba(233,30,99,0.3); }

#rhythmPlayer {
  position: absolute; 
  top: 50%; left: 50%; 
  width: 100%; height: 100%; 
  transform: translate(-50%, -50%);
  z-index: 1; 
  pointer-events: none; 
  /* opacity를 걸지 않는다(불투명 1): 알파 블렌딩으로 인한 컴포지터 부하 제거.
     어두운 효과는 아래 #rhythmDim이 전담한다 (2026-08-06). */
}

/* 영상 어두운 효과 전담 정적 레이어 (2026-08-06)
   영상을 opacity<1로 두면 브라우저가 매 프레임 풀스크린으로
   영상·배경·캔버스 3층을 알파 블렌딩해야 해서, 내장 GPU·고해상도 모니터에서
   컴포지터 병목이 되어 캔버스(노트)만 덜컹일 수 있다. 영상은 불투명하게 두고
   이 정적 레이어(컴포지터가 캐시)만 얹는다. z 순서: 영상(1) < dim(1.5) < 캔버스(2). */
#rhythmDim {
  position: absolute;
  inset: 0;
  z-index: 1.5;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.5);
}

#rhythmCanvas {
  position: relative; 
  z-index: 2; 
  width: 100%; height: 100%;
}

.rhythm-lobby-container {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  background: rgba(15, 15, 20, 0.95);
  border: 1px solid #e91e63;
  border-radius: 16px;
  color: white;
  width: 94%; max-width: 920px;
  height: 90%; max-height: 700px;
  display: flex; flex-direction: column;
  box-shadow: 0 0 40px rgba(233, 30, 99, 0.4);
  overflow: hidden;
}
.rhythm-lobby-header {
  padding: 10px 20px;
  background: linear-gradient(90deg, #e91e63, #9c27b0);
  text-align: center;
  flex-shrink: 0;
}
.rhythm-lobby-header h2 { margin: 0; font-size: 18px; font-weight: 900; letter-spacing: 1px; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.rhythm-lobby-content {
  display: flex; flex: 1; overflow: hidden; min-height: 0;
}
.rhythm-song-list-wrapper {
  flex: 2; border-right: 1px solid rgba(255,255,255,0.1); padding: 15px; display: flex; flex-direction: column; overflow: hidden; min-height: 0;
}
.rhythm-song-search {
  width: 100%; padding: 12px; background: rgba(0,0,0,0.5); border: 1px solid #555; color: white; border-radius: 8px; margin-bottom: 15px; outline: none; font-size: 16px; transition: border-color 0.2s;
}
.rhythm-song-search:focus { border-color: #e91e63; }
.rhythm-lobby-players {
  flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; min-height: 0;
}
.rhythm-player-card {
  display: flex; align-items: center; gap: 15px; background: rgba(255,255,255,0.05); padding: 15px; border-radius: 12px; border-left: 4px solid #555; transition: all 0.2s;
}
.rhythm-player-card.ready { border-left-color: #4caf50; background: rgba(76, 175, 80, 0.1); }
.rhythm-player-avatar { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; }
.rhythm-player-info { flex: 1; text-align: left; }
.rhythm-player-name { font-weight: bold; font-size: 18px; }
.rhythm-player-status { font-size: 14px; font-weight: bold; color: #aaa; margin-top: 5px; }
.rhythm-player-card.ready .rhythm-player-status { color: #4caf50; }
.rhythm-keybind-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    color: #ccc;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    width: fit-content;
}
.rhythm-keybind-btn:hover {
    background: rgba(233,30,99,0.2);
    border-color: #e91e63;
    color: #e91e63;
}
.rhythm-speed-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid #444;
    color: #aaa;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.rhythm-speed-btn:hover {
    border-color: #2196F3;
    color: #fff;
}
.rhythm-speed-drop div:hover {
    background: rgba(33,150,243,0.2) !important;
    color: #fff !important;
}
.rhythm-lobby-footer {
  padding: 10px 15px;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.rhythm-btn-footer {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  word-break: keep-all;
  transition: all 0.2s ease;
  border: 1px solid rgba(255,255,255,0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.rhythm-btn-large {
  background: #e91e63;
  color: white;
  border: none;
  padding: 6px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  word-break: keep-all;
  transition: all 0.2s;
  box-shadow: 0 4px 10px rgba(233, 30, 99, 0.4);
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex-shrink: 0;
}
.rhythm-btn-large:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(233, 30, 99, 0.6); }
.rhythm-btn-large.ready { background: #4caf50; box-shadow: 0 4px 10px rgba(76, 175, 80, 0.4); }

.rhythm-song-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
  padding: 5px;
  min-height: 0;
}

.rhythm-song-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  background: #222;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 8px;
  flex-shrink: 0;
}
.rhythm-song-item:hover { transform: translateX(5px); background: #2a2a2a; }
.rhythm-song-item.selected { 
  border-color: #e91e63; 
  background: rgba(233, 30, 99, 0.15); 
  box-shadow: 0 0 10px rgba(233, 30, 99, 0.4); 
}
.rhythm-song-thumb {
  width: 90px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.rhythm-song-info {
  flex: 1;
  text-align: left;
  min-width: 0;
}
.rhythm-song-title { font-weight: bold; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.rhythm-song-diff { font-size: 12px; color: #ffeb3b; margin-top: 4px; font-weight: bold; }
.rhythm-song-right {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
}
.rhythm-song-duration {
  font-size: 13px;
  font-weight: 700;
  color: #bbb;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.rhythm-song-selected-badge {
  color: #e91e63;
  font-weight: 900;
  font-size: 13px;
  white-space: nowrap;
}

.rhythm-btn {
  background: #2196F3;
  color: white; border: none; padding: 10px 20px; border-radius: 6px;
  font-weight: bold; cursor: pointer; margin: 5px;
}
.rhythm-btn:disabled { background: #555; cursor: not-allowed; }

#rhythmMobileControls {
  position: absolute;
  top: 78%; left: 50%; transform: translateX(-50%);
  width: 90%; max-width: 288px;
  height: 22%;
  z-index: 5;
  display: none;
  pointer-events: auto;
  border-top: 2px solid rgba(255,255,255,0.6);
  touch-action: none;
}
#rhythmMobileControls.active {
  display: flex; /* Fallback if no media query */
}
@media (min-width: 769px) {
  #rhythmMobileControls.active {
    display: none; /* Hide virtual keys on PC */
  }
}
.rhythm-key {
  flex: 1;
  box-sizing: border-box;
  border: 1px solid rgba(255,255,255,0.1);
  border-bottom: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0.1) 100%);
  color: rgba(255,255,255,0.3);
  font-size: 20px; font-weight: 900;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 20px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
/* White keys: D, K */
.rhythm-key[data-key="0"], .rhythm-key[data-key="3"] {
  background: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0.15) 100%);
  color: rgba(255,255,255,0.8);
}
/* Blue keys: F, J */
.rhythm-key[data-key="1"], .rhythm-key[data-key="2"] {
  background: linear-gradient(180deg, rgba(3,169,244,0.02) 0%, rgba(3,169,244,0.3) 100%);
  color: rgba(3,169,244,0.9);
  border-color: rgba(3,169,244,0.2);
}

.rhythm-key:active {
  transition: all 0.05s;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
}

/* Active White Keys (D, K) */
.rhythm-key[data-key="0"].active, .rhythm-key[data-key="3"].active { 
  background: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.8) 100%);
  color: #000;
  box-shadow: 0 0 20px rgba(255,255,255,0.6), inset 0 0 10px rgba(255,255,255,0.8);
  padding-bottom: 15px;
}
/* Active Blue Keys (F, J) */
.rhythm-key[data-key="1"].active, .rhythm-key[data-key="2"].active {
  background: linear-gradient(180deg, rgba(3,169,244,0.4) 0%, rgba(3,169,244,0.9) 100%);
  color: #fff;
  box-shadow: 0 0 20px rgba(3,169,244,0.6), inset 0 0 10px rgba(255,255,255,0.5);
}

#rhythmCountdown {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 80px; font-weight: 800; color: white;
  text-shadow: 0 0 20px #000;
  z-index: 20;
  pointer-events: none;
}

@media (max-width: 600px) {
  .rhythm-lobby-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    max-width: none; max-height: none;
    border-radius: 0;
    overflow-y: auto;
  }
  .rhythm-lobby-header { padding: 5px 10px; }
  .rhythm-lobby-header h2 { font-size: 13px; }
  .rhythm-lobby-content { flex-direction: column; gap: 0; }
  .rhythm-song-list-wrapper {
    flex: 0 1 auto; min-height: 0;
    max-height: 55%;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding: 5px 8px;
    overflow-y: auto;
  }
  .rhythm-lobby-players {
    flex: 0 1 auto;
    padding: 5px 8px;
    gap: 4px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    overflow-y: auto;
    max-height: 22%;
  }
  .rhythm-player-card {
    padding: 4px 6px; gap: 4px;
    flex: 0 0 auto;
    border-left-width: 3px;
  }
  .rhythm-player-avatar { width: 24px; height: 24px; }
  .rhythm-player-name { font-size: 11px; }
  .rhythm-player-status { font-size: 10px; margin-top: 0; }
  .rhythm-song-item { padding: 3px 5px; gap: 5px; }
  .rhythm-song-thumb { width: 40px; height: 24px; }
  .rhythm-song-title { font-size: 11px; }
  .rhythm-song-diff { font-size: 9px; margin-top: 1px; }
  .rhythm-song-duration { font-size: 10px; }
  .rhythm-song-selected-badge { font-size: 10px; }
  .rhythm-song-search { padding: 5px 8px; font-size: 12px; margin-bottom: 4px; }
  .rhythm-song-list { gap: 3px; }
  .rhythm-btn-large { padding: 7px 12px; font-size: 12px; }
  .rhythm-lobby-footer { padding: 5px 8px; gap: 5px; flex-shrink: 0; }
}


/* Arcade visual layer */
#rhythmContainer {
  background:
    radial-gradient(circle at 50% 22%, rgba(27, 76, 125, 0.3), transparent 42%),
    linear-gradient(145deg, #03050c 0%, #09031a 52%, #020812 100%);
}
/* #rhythmPlayer는 불투명 유지 — 어두운 효과는 #rhythmDim(위 기본 섹션)이 담당 (2026-08-06).
   opacity<1 재도입 금지: 매 프레임 풀스크린 알파 블렌딩으로 컴포지터 병목 재발. */
/* Avoid full-frame CSS filters on the video/canvas during 60fps gameplay. */

.rhythm-lobby-container {
  background:
    linear-gradient(145deg, rgba(10, 16, 31, 0.97), rgba(23, 8, 34, 0.96)),
    rgba(7, 10, 20, 0.96);
  border: 1px solid rgba(95, 224, 255, 0.72);
  box-shadow: 0 0 0 1px rgba(255, 63, 172, 0.22), 0 0 48px rgba(0, 197, 255, 0.24), 0 24px 70px rgba(0, 0, 0, 0.72);
}
.rhythm-lobby-header {
  background: linear-gradient(100deg, #7b2cff 0%, #e62f9d 48%, #00bce8 100%);
  border-bottom: 1px solid rgba(255,255,255,0.35);
}
.rhythm-lobby-header h2 { text-shadow: 0 2px 5px rgba(0,0,0,0.55), 0 0 14px rgba(255,255,255,0.36); }
.rhythm-song-search {
  background: rgba(2, 7, 18, 0.72);
  border-color: rgba(110, 194, 255, 0.35);
}
.rhythm-song-search:focus {
  border-color: #42dfff;
  box-shadow: 0 0 0 2px rgba(66, 223, 255, 0.12), 0 0 18px rgba(66, 223, 255, 0.14);
}
.rhythm-song-item {
  background: linear-gradient(100deg, rgba(20, 28, 48, 0.92), rgba(25, 15, 39, 0.9));
  border-color: rgba(130, 190, 255, 0.1);
}
.rhythm-song-item:hover {
  background: linear-gradient(100deg, rgba(28, 45, 72, 0.96), rgba(48, 19, 61, 0.94));
  border-color: rgba(77, 217, 255, 0.42);
}
.rhythm-song-item.selected {
  border-color: #51dfff;
  background: linear-gradient(100deg, rgba(0, 177, 225, 0.18), rgba(224, 44, 158, 0.2));
  box-shadow: inset 3px 0 #ff4eac, 0 0 18px rgba(40, 210, 255, 0.3);
}
.rhythm-player-card { background: linear-gradient(110deg, rgba(255,255,255,0.06), rgba(100,180,255,0.025)); }
.rhythm-player-card.ready { border-left-color: #52f0bc; background: rgba(55, 232, 172, 0.1); box-shadow: inset 0 0 18px rgba(55,232,172,0.05); }
.rhythm-btn-large {
  background: linear-gradient(105deg, #df2c91, #7b36f2);
  box-shadow: 0 5px 18px rgba(197, 44, 190, 0.38);
}
.rhythm-btn-large.ready { background: linear-gradient(105deg, #22c98b, #19a9ce); box-shadow: 0 5px 18px rgba(31, 210, 173, 0.34); }
#rhythmCountdown {
  font-family: "Arial Black", "Inter", sans-serif;
  font-style: italic;
  letter-spacing: -3px;
  text-shadow: 0 0 8px #fff, 0 0 24px #23cfff, 0 4px 0 rgba(92, 28, 145, 0.75), 0 12px 35px #000;
}
#rhythmMobileControls {
  background: linear-gradient(180deg, rgba(4, 10, 24, 0.15), rgba(4, 8, 20, 0.72));
  border-top-color: rgba(95, 224, 255, 0.72);
  box-shadow: 0 -8px 24px rgba(0, 198, 255, 0.1);
}
.rhythm-key.active { transform: translateY(2px); }


#rhythmSoloEndBtn {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: none;
  padding: 9px 18px;
  border: 1px solid rgba(255, 100, 120, 0.75);
  border-radius: 9px;
  background: rgba(120, 12, 30, 0.78);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(255, 45, 85, 0.24);
}
#rhythmSoloEndBtn:hover { background: rgba(175, 20, 45, 0.9); }
#rhythmSoloEndBtn:disabled { opacity: 0.55; cursor: wait; }
@media (max-width: 768px) {
  #rhythmSoloEndBtn {
    right: 10px;
    bottom: calc(22% + 10px);
    padding: 7px 13px;
    font-size: 12px;
  }
}
