/* ============================================
   TERRITORY (땅따먹기) STYLES
   ============================================ */

/* Game Canvas */
#game-canvas {
  display: block;
  margin: 0 auto;
  border-radius: 8px;
  background: #1a1a2e;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  cursor: crosshair;
  touch-action: none;
}

/* Board Container */
.board-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 10px;
  background: linear-gradient(145deg, #16213e, #0f0f23);
  border-radius: 12px;
  margin: 10px 0;
  box-sizing: border-box;
}

/* Game Timer */
.game-timer {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  padding: 8px 20px;
  border-radius: 20px;
  font-family: monospace;
  font-size: 24px;
  font-weight: bold;
  color: #27ae60;
  z-index: 5;
  border: 2px solid #27ae60;
}

.game-timer.warning {
  color: #f39c12;
  border-color: #f39c12;
  animation: pulse 0.5s ease-in-out infinite alternate;
}

.game-timer.danger {
  color: #e74c3c;
  border-color: #e74c3c;
  animation: pulse 0.3s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 1; }
  to { opacity: 0.6; }
}

/* ============================================
   PLAYER CARD - Territory-specific styles only
   Base styles inherited from common.css
   ============================================ */
/* Color indicator for Territory */
.player-card .color-indicator {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-card .color-indicator.player1-color {
  background: linear-gradient(135deg, #27ae60, #1e8449);
  border: 1px solid #1e8449;
}

.player-card .color-indicator.player2-color {
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  border: 1px solid #8e44ad;
}

/* Territory percentage display */
.player-card .territory-percent {
  font-family: monospace;
  font-size: 16px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.3);
}

#player1-card .territory-percent {
  color: #27ae60;
}

#player2-card .territory-percent {
  color: #9b59b6;
}

/* ============================================
   MOBILE DIRECTION CONTROLS
   ============================================ */
.mobile-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
}

.mobile-control-row {
  display: flex;
  gap: 5px;
}

.mobile-btn {
  width: 60px;
  height: 60px;
  font-size: 24px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.mobile-btn:active {
  background: var(--accent);
  transform: scale(0.95);
}

/* Show mobile controls only on mobile during game */
@media (max-width: 768px) {
  .game-room.active .mobile-controls {
    display: flex;
  }
}

/* Time display in create room modal */
.time-display {
  display: inline-block;
  margin-left: 10px;
  padding: 4px 12px;
  background: var(--bg-secondary);
  border-radius: 4px;
  font-size: 14px;
  color: var(--accent);
  font-weight: bold;
}

/* Chat Tabs */
.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;
  margin-left: 4px;
}

/* Tab Content */
.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.green {
  background: #27ae60;
  color: #fff;
}
.participant-badge.purple {
  background: #9b59b6;
  color: #fff;
}
.empty-participants {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
  font-size: 13px;
}

/* Final Score in Game Over Modal */
.final-score {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.territory-breakdown {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin: 15px 0;
}

.territory-stat {
  text-align: center;
}

.territory-stat .label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.territory-stat .value {
  font-size: 24px;
  font-weight: bold;
}

.territory-stat.player1 .value {
  color: #27ae60;
}

.territory-stat.player2 .value {
  color: #9b59b6;
}

/* AI Badge */
.ai-badge {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 8px;
}

/* Waiting Overlay */
.waiting-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 12px;
  z-index: 10;
}

.waiting-overlay.active {
  display: flex;
}

.waiting-overlay h3 {
  margin-top: 20px;
  color: var(--text-primary);
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--surface);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Drawing indicator */
.drawing-indicator {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(39, 174, 96, 0.9);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: bold;
  display: none;
  z-index: 5;
}

.drawing-indicator.active {
  display: block;
  animation: fadeInOut 0.3s ease-in-out;
}

@keyframes fadeInOut {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Responsive - 820px and below */
@media (max-width: 820px) {
  .board-container {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
  }

  .game-timer {
    font-size: 18px;
    padding: 6px 14px;
  }
}

@media (max-width: 480px) {
  .player-card {
    min-width: 140px;
    padding: 8px 10px;
  }

  .player-card .name {
    font-size: 13px;
  }

  .player-card .territory-percent {
    font-size: 14px;
  }

  .player-card .color-indicator {
    width: 16px;
    height: 16px;
  }

  .board-container {
    padding: 4px;
  }

  .game-timer {
    font-size: 16px;
    padding: 4px 12px;
    top: 5px;
  }
}

/* Light Theme Adjustments */
.theme-light .board-container {
  background: linear-gradient(145deg, #e8e8e8, #f5f5f5);
}

.theme-light #game-canvas {
  background: #f0f0f0;
}

.theme-light .player-card {
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.theme-light .game-timer {
  background: rgba(255, 255, 255, 0.95);
  color: #27ae60;
}

/* Responsive Ads */
@media (max-width: 768px) {
  .ad-pc-only { display: none !important; }
}
@media (min-width: 769px) {
  .ad-mobile-only { display: none !important; }
}

/* ============================================
   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;
  }
}
