/* 게임 결과 오버레이 */
.game-result-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 2500;
  display: flex;
  justify-content: center;
  align-items: center;
}

.result-box {
  background-color: white;
  padding: 20px;
  border-radius: 15px;
  width: 80%;
  max-width: 350px;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  animation: scaleIn 0.5s ease-out;
}

@keyframes scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.result-box h2 {
  font-size: 2.5rem;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.win-title {
  color: #4CAF50;
  animation: winPulse 1.5s infinite alternate;
}

.lose-title {
  color: #f44336;
}

.draw-title {
  color: #2196F3;
}

@keyframes winPulse {
  from { transform: scale(1); }
  to { transform: scale(1.1); text-shadow: 0 0 10px rgba(76, 175, 80, 0.7); }
}

.result-box p {
  font-size: 1rem;
  margin-bottom: 25px;
  color: #333;
}

.button-container {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.result-btn {
  padding: 10px 25px;
  font-size: 1rem;
  font-weight: bold;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.yes-btn {
  background-color: #4CAF50;
  color: white;
}

.yes-btn:hover {
  background-color: #45a049;
  transform: translateY(-2px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

.no-btn {
  background-color: #f44336;
  color: white;
}

.no-btn:hover {
  background-color: #e53935;
  transform: translateY(-2px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

/* 상대방 거절 메시지 오버레이 */
.declined-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 2500;
  display: flex;
  justify-content: center;
  align-items: center;
}

.message-box {
  background-color: white;
  padding: 20px;
  border-radius: 10px;
  width: 80%;
  max-width: 300px;
  text-align: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.message-box p {
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 15px;
}

.close-btn {
  background-color: #2196F3;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
}

.close-btn:hover {
  background-color: #0b7dda;
}/* 애니메이션 효과 */
@keyframes highlightScore {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.highlight-score {
  animation: highlightScore 0.3s ease-in-out;
  color: #FF8E0D !important;
}/* 게임 모드 선택 버튼 스타일 */
.game-mode-section {
  width: 100%;
  margin-bottom: 12px;
}

.mode-container {
  display: flex;
  flex-direction: column; /* 세로 구성으로 변경 */
  width: 100%;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mode-btn {
  flex: 1;
  margin: 1px 0; /* 세로 margin으로 변경 */
  padding: 4px 2px;
  font-size: 0.5rem; /* 폰트 크기 극단적 축소 */
  font-weight: 600;
  background-color: #e0e0e0;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  color: #444;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  width: 100%; /* 전체 너비 사용 */
}

.mode-btn:hover {
  background-color: #d0d0d0;
  transform: translateY(-1px);
}

.mode-btn.selected {
  background-color: #FF8E0D;
  color: white;
  border-color: #FF6F00;
  box-shadow: 0 3px 5px rgba(0,0,0,0.2);
}

/* 게임 모드 선택 버튼 스타일 */
.game-mode-section {
  width: 100%;
  margin-bottom: 12px;
}

.mode-container {
  display: flex;
  flex-direction: column; /* 세로 구성으로 변경 */
  width: 100%;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mode-btn {
  flex: 1;
  margin: 0 2px;
  padding: 8px 4px;
  font-size: 0.8rem;
  font-weight: 600;
  background-color: #e0e0e0;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  color: #444;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.mode-btn:hover {
  background-color: #d0d0d0;
  transform: translateY(-1px);
}

.mode-btn.selected {
  background-color: #FF8E0D;
  color: white;
  border-color: #FF6F00;
  box-shadow: 0 3px 5px rgba(0,0,0,0.2);
}

/* 난이도 버튼 스타일 (새로운 2x2 레이아웃) */
.difficulty-section {
  width: 100%;
  margin-bottom: 12px;
}

.difficulty-container {
  display: flex;
  flex-direction: column; /* 1열 구성으로 변경 */
  width: 100%;
  justify-content: space-between;
  margin-bottom: 2px;
}

/* 그래야만 했는가 */

.difficulty-btn {
  flex: 1;
  margin: 1px 0;
  padding: 3px 2px;
  font-size: 0.45rem; /* 폰트 크기 극단적 축소 */
  font-weight: 600;
  background-color: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  color: #444;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  width: 100%; /* 전체 너비 사용 */
}

.difficulty-btn:hover {
  background-color: #e0e0e0;
  transform: translateY(-1px);
}

.difficulty-btn.selected {
  background-color: #2196F3;
  color: white;
  border-color: #0b7dda;
  box-shadow: 0 3px 5px rgba(0,0,0,0.2);
}
/* --------------------- */
/* 1) 기본 리셋 및 폰트 */
/* --------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Arial', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ---------------------- */
/* 2) 바디 & 컨테이너 등 */
/* ---------------------- */
body {
  background-color: #f0f0f0;
  color: #333;
  width: 100%;
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: manipulation;
  overflow: hidden; /* 스크롤 방지 */
}

.game-container {
  width: 100%;
  max-width: 500px;
  
  /* 아래쪽에 여유 공간 5% (주소창/네비게이션바 등 대응) */
  margin-bottom: 5%;
  
  background-color: white;
  border-radius: 15px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
  padding: 14px;
  
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: center;
  
  /* 보통 95vh로 제한해, 너무 커지지 않도록 */
  max-height: 105vh;
  overflow: visible;
}

h1 {
  display: none; /* 제목 숨김 */
}

/* ------------------- */
/* 3) 게임 영역 스타일 */
/* ------------------- */
.game-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 게임 섹션 - 좌측 컨트롤 + 보드 + 점수 통합 */
.game-section {
  width: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start; /* 상단 정렬로 변경 */
  margin-bottom: 10px;
}

/* 왼쪽 컨트롤 영역 */
.controls-left {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 0 2px;
  width: 80px; /* 너비 축소 */
  gap: 5px; /* 요소 간 간격 축소 */
}

/* 오른쪽 점수 표시부 */
.score-right {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 0 2px;
  height: 100%;
  /* 점수 표시 컨테이너 레이아웃 조정 */
  width: 80px; /* 너비 축소 */
}

/* 수직 점수 표시 아이템 - 박스형 스타일 */
.score-item.vertical {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 3px 0; /* 여백 더 감소 */
  text-align: center;
  font-weight: bold;
  min-width: 60px; /* 너비 축소 */
  background-color: #f8f8f8;
  border-radius: 4px;
  padding: 4px; /* 패딩 더 감소 */
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
  border: 1px solid #eaeaea;
}

.score-item.vertical span:first-child {
  margin-bottom: 2px;
  font-size: 0.5rem; /* 폰트 크기 극단적 축소 */
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.score-item.vertical span:last-child {
  font-size: 0.7rem; /* 폰트 크기 극단적 축소 */
  color: #0066cc;
  font-weight: 700;
}

/* 게임 보드 */
.game-board {
  background-color: #333333;
  padding: 5px;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
#board {
  display: block;
  background-color: #000000;
  width: 100%;
  max-width: 300px;
  height: auto;
  aspect-ratio: 1/2;
  border-radius: 6px;
}

/* 다음 블록 패널 (놀 왼쪽으로 이동) */
.next-panel {
  text-align: center;
  width: 100%;
  margin-top: 10px;
}

/* 액션 버튼 스타일 (왼쪽에 배치) */
#start-button, #pause-button {
  width: 100%;
  height: 28px; /* 높이 축소 */
  font-size: 0.55rem; /* 폰트 크기 극단적 축소 */
  font-weight: 600;
  white-space: nowrap;
  margin: 3px 0;
  border-radius: 4px;
  border: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 3px rgba(0,0,0,0.2);
  letter-spacing: 0.3px;
}

/* 그림자 토글 스타일 */
.toggle-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 5px 0;
  width: 100%;
  background-color: #f0f0f0;
  padding: 8px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  border: 1px solid #e0e0e0;
}
.toggle-label {
  font-size: 0.5rem; /* 폰트 크기 극단적 축소 */
  margin-right: 3px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #444;
}
#ghost-toggle {
  cursor: pointer;
  accent-color: #2196F3;
  transform: scale(1.1);
}
.next-panel p {
  margin-bottom: 3px;
  font-weight: 700;
  font-size: 0.55rem; /* 폰트 크기 극단적 축소 */
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #333;
}
#next-piece-canvas {
  background-color: #222222;
  width: 60px; /* 크기 축소 */
  height: 60px; /* 크기 축소 */
  border-radius: 4px;
  margin: 0 auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  border: 1px solid #444444;
}

/* -------------------- */
/* 4) 모바일 컨트롤 스타일 */
/* -------------------- */
.controls-panel {
  width: 100%;
  margin-top: 8px; /* 전체 여백 조정 */
  padding: 0 2px; /* 양쪽 여백 추가 */
  display: none; /* 기본적으로 숨김 - PC에서는 표시하지 않음 */
}
.mobile-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5px; /* 간격을 1/4로 줄임 (10px → 2.5px) */
  margin-top: 5px;
}
.control-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.middle-row {
  margin: 2px 0; /* 중간 행 여백 줄이기 (8px → 2px) */
}

.action-btn {
  padding: 6px 8px;
  font-size: 0.85rem;
  border: none;
  border-radius: 5px;
  color: white;
  cursor: pointer;
  transition: background-color 0.3s;
  margin-bottom: 5px;
}

/* 시작/일시정지 버튼 */
#start-button {
  background-color: #4CAF50;
  color: white;
}
#start-button:hover {
  background-color: #45a049;
  transform: translateY(-1px);
}
#restart-button {
  background-color: #FF9800;
  color: white;
  margin-bottom: 5px;
}
#restart-button:hover {
  background-color: #F57C00;
  transform: translateY(-1px);
}
#pause-button {
  background-color: #2196F3;
  color: white;
}
#pause-button:hover {
  background-color: #0b7dda;
  transform: translateY(-1px);
}
#pause-button:disabled, 
#start-button:disabled,
#restart-button:disabled {
  background-color: #cccccc;
  color: #777777;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 방향/액션 버튼 */
.control-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  border: none;
  color: white;
  font-size: 1.5rem;
  touch-action: manipulation;
  cursor: pointer;
}

/* 기본 버튼 높이 상수 설정 */
:root {
  --base-button-height: 55px;
  --move-button-height: calc(var(--base-button-height) * 1.3); /* 이동 버튼 1.3배 높이 */
}

/* 이동 버튼 (좌/우/하) */
.direction-btn {
  height: var(--move-button-height);
  border-radius: 8px;
  width: 33.3%; /* 세 버튼의 너비를 동일하게 설정 */
}
#left-btn, #right-btn {
  background-color: #9E9E9E; /* 하드드랍보다 더 진한 회색 */
  border: 1px solid #BDBDBD;
  color: #FFFFFF; /* 텍스트를 흰색으로 변경하여 가독성 확보 */
  font-weight: bold;
}
#down-btn {
  background-color: #2196F3; /* 파란색 */
  border: 1px solid #1e88e5;
  color: #FFFFFF;
  font-weight: bold;
}

/* 회전 버튼 */
#rotate-btn {
  width: 100%;
  height: var(--base-button-height);
  background-color: #4CAF50; /* 녹색 */
  font-size: 1rem;
  border-radius: 8px;
  font-weight: bold;
  border: 1px solid #45a049;
  color: #FFFFFF;
}

/* 하드드랍 버튼 */
.action-btn.control-btn {
  width: 100%;
  height: var(--base-button-height);
  border-radius: 8px;
  font-size: 1rem;
}
#drop-btn {
  background-color: #2196F3; /* 파란색 */
  font-weight: bold;
  border: 1px solid #1e88e5;
  color: #FFFFFF;
}
#mobile-pause-btn {
  background-color: #f44336;
}

/* --------------------- */
/* 대결 모드 관련 스타일 - 수정됨 */
/* --------------------- */
.opponent-container {
  /* 위치 변경: 절대 위치를 점수 표시 영역으로 이동 */
  position: relative;
  width: 100%;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  padding: 8px;
  margin-bottom: 8px;
  z-index: 100;
}

.opponent-header {
  text-align: center;
  font-weight: bold;
  font-size: 0.5rem; /* 폰트 크기 극단적 축소 */
  margin-bottom: 3px;
  color: #FF0D72;
}

.opponent-board-container {
  background-color: #333;
  padding: 2px;
  border-radius: 5px;
  margin-bottom: 3px;
}

#opponent-board {
  display: block;
  width: 100%;
  height: auto;
  background-color: #000;
}

.opponent-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.45rem; /* 폰트 크기 극단적 축소 */
}

.stat-item {
  background-color: #f0f0f0;
  padding: 3px 5px;
  border-radius: 4px;
  font-weight: bold;
  font-size: 0.45rem; /* 폰트 크기 극단적 축소 */
}

/* 대기실 오버레이 */
.waiting-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  display: none;
  justify-content: center;
  align-items: center;
}

.waiting-box {
  background-color: white;
  padding: 20px;
  border-radius: 10px;
  width: 80%;
  max-width: 300px;
  text-align: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.waiting-box h2 {
  color: #FF8E0D;
  margin-bottom: 15px;
}

.spinner {
  margin: 20px auto;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: #FF8E0D;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#cancel-matching {
  background-color: #f44336;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  margin-top: 10px;
}

#cancel-matching:hover {
  background-color: #e53935;
}

/* 쓰레기 라인 효과 */
.garbage-effect {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(255, 0, 0, 0.7);
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  font-weight: bold;
  animation: fadeInOut 1.5s forwards;
  z-index: 500;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
  20% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* --------------------- */
/* 대결 모드 관련 스타일 */
/* --------------------- */
.opponent-container {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 160px;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  padding: 10px;
  z-index: 100;
}

.opponent-header {
  text-align: center;
  font-weight: bold;
  font-size: 0.9rem;
  margin-bottom: 5px;
  color: #FF0D72;
}

.opponent-board-container {
  background-color: #333;
  padding: 3px;
  border-radius: 5px;
  margin-bottom: 5px;
}

#opponent-board {
  display: block;
  width: 100%;
  height: auto;
  background-color: #000;
}

.opponent-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.45rem; /* 폰트 크기 극단적 축소 */
}

.stat-item {
  background-color: #f0f0f0;
  padding: 4px 6px;
  border-radius: 4px;
  font-weight: bold;
}

/* 대기실 오버레이 */
.waiting-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  display: none;
  justify-content: center;
  align-items: center;
}

.waiting-box {
  background-color: white;
  padding: 20px;
  border-radius: 10px;
  width: 80%;
  max-width: 300px;
  text-align: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.waiting-box h2 {
  color: #FF8E0D;
  margin-bottom: 15px;
}

.spinner {
  margin: 20px auto;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: #FF8E0D;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#cancel-matching {
  background-color: #f44336;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  margin-top: 10px;
}

#cancel-matching:hover {
  background-color: #e53935;
}

/* 쓰레기 라인 효과 */
.garbage-effect {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(255, 0, 0, 0.7);
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  font-weight: bold;
  animation: fadeInOut 1.5s forwards;
  z-index: 500;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
  20% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* 게임 결과 표시 */
.game-result {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  font-weight: bold;
  padding: 20px 40px;
  border-radius: 10px;
  color: white;
  z-index: 2000;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
  animation: pulseResult 0.5s ease-in-out infinite alternate;
}

.game-result.win {
  background-color: rgba(76, 175, 80, 0.8);
}

.game-result.lose {
  background-color: rgba(244, 67, 54, 0.8);
}

@keyframes pulseResult {
  from { transform: translate(-50%, -50%) scale(1); }
  to { transform: translate(-50%, -50%) scale(1.1); }
}

/* 재대결 타이머 관련 스타일 */
.timer-container {
  background-color: #f0f0f0;
  padding: 8px;
  border-radius: 5px;
  margin: 15px 0;
  text-align: center;
}

#rematch-timer {
  font-weight: bold;
  font-size: 1.2rem;
  color: #FF8E0D;
  transition: color 0.3s;
}

/* 애니메이션 추가 */
@keyframes resultPopup {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 상대방 연결 끊김 메시지 스타일 */
.disconnected-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 2500;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease-in;
}

/* 카운트다운 표시 */
.countdown {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 72px;
  font-weight: bold;
  color: #FF8E0D;
  background-color: rgba(255, 255, 255, 0.8);
  width: 120px;
  height: 120px;
  line-height: 120px;
  text-align: center;
  border-radius: 50%;
  z-index: 2000;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
  animation: pulseCountdown 1s ease-in-out infinite alternate;
}

@keyframes pulseCountdown {
  from { transform: translate(-50%, -50%) scale(1); }
  to { transform: translate(-50%, -50%) scale(1.2); }
}
@media (max-width: 360px) {
  h1 {
    font-size: 1.3rem;
    margin: 2px 0 5px;
  }
  
  .score-item {
    font-size: 0.8rem;
  }
  
  .next-panel p {
    margin-bottom: 2px;
    font-size: 0.9rem;
  }
  
  /* 작은 화면에서도 같은 비율 유지 */
  :root {
    --base-button-height: 45px;
    --move-button-height: calc(var(--base-button-height) * 1.3);
  }
  
  .direction-btn {
    height: var(--move-button-height);
  }
  
  #left-btn {
    width: 45%;
  }
  
  #right-btn {
    width: 45%;
  }
  
  #down-btn {
    width: 10%;
  }
  
  #rotate-btn {
    width: 100%;
    height: var(--base-button-height);
    font-size: 0.9rem;
  }
  
  .action-btn.control-btn {
    width: 100%;
    height: var(--base-button-height);
    font-size: 0.9rem;
  }

  .button-left .action-btn, .button-right .action-btn {
    max-width: 85px;
    height: 35px;
    font-size: 0.8rem;
  }
  
  .toggle-container {
    margin-top: 3px;
  }
  
  .toggle-label {
    font-size: 0.7rem;
  }
  
  .next-piece-container {
    margin: 3px 0;
  }
  
  .mobile-controls {
    gap: 2px; /* 간격 더 줄임 */
  }
  
  .middle-row {
    margin: 1px 0; /* 중간 행 여백 더 줄임 */
  }
}

/* 모바일 기기에서는 컨트롤 패널 표시 */
@media (max-width: 768px), (pointer: coarse) {
  .controls-panel {
    display: block; /* 모바일에서는 표시 */
  }
  
  /* 모바일에서 양쪽 컨트롤 영역 더 축소 */
  .controls-left, .score-right {
    width: 65px; /* 모바일에서 더 축소 */
    padding: 0 1px;
  }
  
  /* 모바일에서 폰트 크기 추가 축소 */
  .mode-btn {
    font-size: 0.45rem;
    padding: 3px 1px;
  }
  
  .difficulty-btn {
    font-size: 0.4rem;
    padding: 2px 1px;
  }
  
  .toggle-label {
    font-size: 0.45rem;
  }
  
  #start-button, #pause-button {
    font-size: 0.5rem;
    height: 25px;
  }
  
  .next-panel p {
    font-size: 0.5rem;
  }
  
  #next-piece-canvas {
    width: 50px;
    height: 50px;
  }
  
  .score-item.vertical {
    min-width: 50px;
    padding: 3px;
  }
  
  .score-item.vertical span:first-child {
    font-size: 0.45rem;
  }
  
  .score-item.vertical span:last-child {
    font-size: 0.6rem;
  }
  
  /* 게임 보드 크기 최대화 */
  .game-board {
    flex: 1;
    max-width: 100%;
  }
  
  #board {
    max-width: 100%;
    width: 100%;
  }
  
  /* Ranking, Logout 버튼 모바일 폰트 크기 */
  #ranking-button, #logout-button {
    font-size: 0.45rem !important;
    padding: 3px !important;
  }
  
  /* 대결 모드 상대방 통계 모바일 폰트 크기 */
  .opponent-stats {
    font-size: 0.4rem;
  }
  
  .stat-item {
    font-size: 0.4rem;
    padding: 2px 3px;
  }
}

/* PC 전용 스타일 - 화면 최대화 */
@media (min-width: 769px) and (pointer: fine) {
  .game-container {
    max-width: 100%; /* 최대 너비 제한 없음 */
    margin: 0; /* 여백 없음 */
    padding: 5px; /* 패딩 최소화 */
    height: 100vh; /* 화면 높이 최대화 */
    max-height: 100vh; /* 최대 높이 제한 없음 */
    border-radius: 0; /* 모서리 둥글게 없음 */
    box-shadow: none; /* 그림자 없음 */
    justify-content: center; /* 수직 중앙 정렬 */
  }
  
  /* 게임 보드 크기 확대 */
  .game-board {
    padding: 2px;
  }
  
  #board {
    max-width: none; /* 최대 너비 제한 없음 */
    width: auto; /* 자동 너비 */
    height: 85vh; /* 최대 화면 높이의 85% */
  }
  
  /* 좌우 영역 너비 맞춤 */
  .controls-left, .score-right {
    padding: 0 10px;
  }
}

/* 로그인 오버레이 스타일 */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0,0,0,0.5);
  z-index: 2000; /* 게임화면보다 위에 오도록 */
  display: none; /* 처음에는 감춤 */
  justify-content: center;
  align-items: center;
}

.login-box {
  background-color: #fff;
  padding: 20px;
  border-radius: 10px;
  min-width: 250px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 로그인 폼 안쪽 텍스트/버튼 스타일 */
.login-box h2 {
  margin-bottom: 10px;
  font-size: 1rem;
}
.login-box label {
  font-size: 0.75rem;
  font-weight: 600;
}
.login-box input {
  font-size: 0.75rem;
  padding: 5px;
  border: 1px solid #ccc;
  border-radius: 5px;
}
.login-box button {
  font-size: 0.75rem;
  padding: 8px;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  background-color: #2196F3;
  color: white;
  font-weight: 600;
}
.login-box button:hover {
  background-color: #0b7dda;
}

/* 랭킹 오버레이 */
.ranking-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.7);
  z-index: 1500;
  display: none;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #333;
}

.ranking-box {
  background-color: #ffffff;
  width: 70%;
  max-width: 300px;
  margin: 0 auto;
  padding: 20px;
  border: 2px solid #FF0D72;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.ranking-box h2 {
  font-size: 1rem;
  color: #FF0D72;
  margin-bottom: 10px;
}

/* 랭킹 목록 */
.ranking-list {
  list-style: none;
  padding: 0;
  margin: 10px 0;
  font-size: 0.75rem;
}
.ranking-list li {
  margin: 4px 0;
}

/* 닫기 버튼 */
#close-ranking {
  margin-top: 10px;
  font-size: 0.75rem;
  padding: 6px;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  background-color: #2196F3;
  color: white;
  font-weight: 600;
}
#close-ranking:hover {
  background-color: #0071EB;
}

#left-btn:active, #right-btn:active, #down-btn:active, #rotate-btn:active, #drop-btn:active {
  transform: translateY(4px) scale(0.95);
  filter: brightness(0.9);
}

#left-btn:active, #right-btn:active {
  transform: translateY(4px) scale(0.95);
  background-color: #757575; /* 더 진한 회색으로 변경 */
  color: #FFFFFF;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

#down-btn:active {
  transform: translateY(4px) scale(0.95);
  background-color: #E0E0E0; /* 중간 톤 실버로 변경 */
  color: #424242;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

#rotate-btn:active {
  transform: translateY(4px) scale(0.95);
  background-color: #45a049; /* 더 어두운 녹색 */
  color: #FFFFFF;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

#drop-btn:active {
  transform: translateY(4px) scale(0.95);
  background-color: #1e88e5; /* 더 어두운 파란색 */
  color: #FFFFFF;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* 미니맵 컨테이너 스타일 - 수정됨 */
.minimap-container {
  width: 100%;
  display: none; /* 기본적으로 숨김 */
}

.minimap-container h3 {
  font-size: 0.5rem; /* 폰트 크기 극단적 축소 */
  color: #444;
  margin-bottom: 3px;
  text-align: center;
}

.minimap-container canvas {
  width: 100%;
  height: auto;
  max-height: 160px; /* 최대 높이 제한 */
  background-color: #000;
  border: 1px solid #444;
  border-radius: 4px;
  margin-top: 3px;
}

/* 미니맵 컨테이너가 숨겨져 있을 때 */
.minimap-container.hidden {
  display: none;
}

/* Ranking, Logout 버튼 스타일 */
#ranking-button, #logout-button {
  font-size: 0.5rem !important; /* 폰트 크기 극단적 축소 */
  padding: 4px !important;
  height: auto !important;
  cursor: pointer;
}
