/* 3D Golf Game CSS */
:root {
  --primary: #e94560;
  --primary-dark: #de3d63;
}

.board-container {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  /* 가로:세로 = 4:3, 위 플레이어 카드 아래로 남는 세로 높이를 꽉 채움 */
  --board-avail-h: calc(100vh - 200px);
  width: 100%;
  max-width: calc(var(--board-avail-h) * 4 / 3);
  max-height: var(--board-avail-h);
  aspect-ratio: 4 / 3;
  background-color: #1a1a2e;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  border: 1px solid var(--border);
}

.game-board {
  width: 100%;
  height: 100%;
  cursor: crosshair;
  position: relative;
  overflow: hidden;
}

/* 3D 캔버스가 컨테이너보다 크게 그려져도 넘쳐 잘리지 않도록 강제로 맞춤 */
.game-board > canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#golf-ui-overlay {
  user-select: none;
  -webkit-user-select: none;
}

#golf-power-gauge-container {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  animation: pulse-border 1.5s infinite alternate;
}

@keyframes pulse-border {
  from {
    border-color: #ffffff;
  }
  to {
    border-color: var(--primary);
  }
}

/* 3D 캔버스 반응형 처리 — 모바일: 고정 비율 해제하고 남는 높이를 꽉 채움 */
@media (max-width: 820px) {
  /* 4:3 고정 해제 — 높이는 JS(fitBoardToScreen)가 기기별로 정확히 계산 */
  .board-container {
    max-width: 100%;
    aspect-ratio: auto;
    width: 100%;
    max-height: none;
    min-height: 280px;   /* JS 적용 전 폴백 */
    flex: 0 0 auto;
  }
  .game-board {
    width: 100%;
    height: 100%;
  }
  .game-controls-mobile,
  .ad-mobile-fixed { flex-shrink: 0; }
  /* 광고 컨테이너 높이 고정(50px) 해제 — 큰(네이티브) 광고가 잘리지 않게 */
  .ad-mobile-fixed:not(.hidden) {
    height: auto !important;
    min-height: 50px;
    overflow: visible;
    margin: 6px auto 10px;
  }
}

/* ============================================
   SIDEBAR TAB (탭 기반 통합 사이드바)
   ============================================ */
.sidebar {
  padding: 1px;
  gap: 1px;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1px;
  flex-shrink: 0;
}

.sidebar-tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.sidebar-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-tab.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  margin-bottom: -1px;
}

.sidebar-tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  min-height: 0;
}

#sidebar-chat-content .chat-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: var(--bg-card);
  border-radius: 1px;
  overflow: hidden;
  min-height: 0;
}

#sidebar-chat-content .chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

#sidebar-chat-content .chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1px;
  min-height: 150px;
}

#sidebar-chat-content .game-controls {
  padding: 10px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

#sidebar-chat-content .game-controls .btn {
  flex: 1;
  min-width: 80px;
}

.sidebar .ad-sidebar {
  flex-shrink: 0;
  margin-top: auto;
  display: flex;
  justify-content: center;
}

@media (max-width: 820px) {
  .sidebar-tabs {
    display: none;
  }
}

/* ============================================
   CHAT TABS & PARTICIPANT LIST
   ============================================ */
.chat-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0;
}
.chat-tab {
  flex: 1;
  padding: 10px 15px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.chat-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.chat-tab.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  font-weight: 500;
}
.participant-count {
  background: var(--accent);
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#chat-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}
#chat-content .chat-messages {
  flex: 1;
}
/* Participants List */
.participants-list {
  padding: 10px;
  overflow-y: auto;
  height: 100%;
}
.participant-section {
  margin-bottom: 15px;
}
.participant-section-header {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-color);
}
.participant-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.participant-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border-radius: 8px;
  font-size: 13px;
}
.participant-item.player {
  border-left: 3px solid var(--accent);
}
.participant-item.host {
  border-left: 3px solid #f1c40f;
}
.participant-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.participant-info {
  flex: 1;
}
.participant-name {
  font-weight: 500;
  color: var(--text-primary);
}
.participant-role {
  font-size: 11px;
  color: var(--text-secondary);
}
.participant-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.participant-badge.host {
  background: #f1c40f;
  color: #000;
}
.participant-badge.black {
  background: #2c3e50;
  color: #fff;
}
.participant-badge.white {
  background: #ecf0f1;
  color: #2c3e50;
}
.empty-participants {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
  font-size: 13px;
}
