html, body {
  margin: 0;
  font-family: sans-serif;
  height: 100vh;
  overflow: hidden;
}

/* 전체 페이지 레이아웃을 Flexbox로 설정 */
.site-container {
  display: flex;
  height: 100%;
}

#sidebar {
  width: 220px;
  flex-shrink: 0; /* 사이드바 너비가 줄어들지 않도록 고정 */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px;
  background: #f0f0f0;
  box-sizing: border-box;
}

/* 메인 콘텐츠와 하단 광고를 감싸는 영역 */
#content-area {
  flex-grow: 1; /* 남은 공간을 모두 차지 */
  display: flex;
  flex-direction: column; /* 컨텐츠와 광고를 세로로 배치 */
  height: 100vh;
}

#main {
  flex-grow: 1; /* 남은 세로 공간을 모두 차지 */
  min-height: 0; /* 높이가 넘치는 것을 방지 */
}

/* 하단 광고 영역 스타일 */
#bottom-ad {
  height: 90px; /* 광고 영역 높이 고정 */
  flex-shrink: 0; /* 광고 영역 높이가 줄어들지 않도록 고정 */
  background: #ddd;
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

iframe#gameFrame {
  width: 100%;
  height: 100%;
  border: none;
}

.category-list {
  flex-grow: 1;
}

.game-link {
  cursor: pointer;
  margin: 5px 0;
  display: block;
  color: #333;
}

.ad-box {
  background: #ddd;
  padding: 10px;
}

#language-selector {
  margin-bottom: 20px;
}

/* 화면 너비가 768px 이하일 때 적용될 스타일 */
@media (max-width: 768px) {
  html, body {
    overflow: auto;
  }
  
  .site-container {
    flex-direction: column;
    height: auto;
  }

  /* 모바일용 상단 헤더 스타일 */
  #sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;       /* 내부 아이템을 가로로 배치 */
    justify-content: space-between; /* 양쪽 끝으로 아이템을 분산 배치 */
    align-items: center;       /* 세로 중앙 정렬 */
    padding: 10px 15px;        /* 내부 여백 조정 */
    border-bottom: 2px solid #ccc;
    box-sizing: border-box;
  }

  /* 모바일에서는 불필요한 제목들을 숨깁니다. */
  #sidebar h3, #sidebar strong {
    display: none;
  }

  /* 왼쪽 메뉴 영역 (언어 선택 + 게임 링크) */
  #sidebar .category-list {
    display: flex;
    align-items: center;
    gap: 15px; /* 아이템 사이 간격 */
    flex-grow: 0; /* 불필요한 공간 차지를 막음 */
  }

  /* 언어 선택 드롭다운의 여백 제거 */
  #language-selector {
    margin-bottom: 0;
  }
  
  /* 광고 상자 스타일 조정 */
  #sidebar .ad-box {
     padding: 5px 8px; /* 광고 상자 크기 줄임 */
     flex-shrink: 0; /* 찌그러지지 않게 함 */
  }
  /* 광고 상자 안의 p 태그 여백 제거 */
  #sidebar .ad-box p {
    margin: 0;
    font-size: 0.8em;
  }

  #content-area {
    height: auto;
    min-height: calc(100vh - 70px); /* 화면 높이에서 헤더 높이만큼 빼서 최소 높이 확보 */
  }
}