/* ============================================
   OMOK (오목) GAME - SPECIFIC STYLES
   Common styles are in ../css/common.css
   ============================================ */

/* Omok-specific CSS Variables */
:root {
  --board-bg: #dcb35c;
  --board-line: #5a4510;
}

body.theme-light {
  --board-bg: #dcb35c;
  --board-line: #5a4510;
}

/* ============================================
   PLAYER CARD (Game-specific layout)
   ============================================ */

.player-card {
  background: var(--bg-card);
  padding: 8px 12px;
  border-radius: 8px;
  min-width: 160px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player-card.active {
  border: 2px solid var(--accent);
}

.player-card .player-row-1 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-card .player-row-2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.player-card .stone-indicator {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-card .stone-indicator.black {
  background: #111;
  border: 1px solid #333;
}

.player-card .stone-indicator.white {
  background: #fff;
  border: 1px solid #ccc;
}

.player-card .name {
  font-weight: bold;
  font-size: 14px;
}

.player-card .rating {
  font-size: 13px;
  color: var(--warning);
  font-weight: bold;
}

.player-card .timer {
  font-family: monospace;
  font-size: 14px;
  font-weight: bold;
}

.vs-text {
  font-size: 18px;
  font-weight: bold;
  color: var(--text-secondary);
}

/* ============================================
   GAME BOARD - Intersection-based (15x15 Grid)
   ============================================ */

.board-container {
  position: relative;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(15, 44px);
  grid-template-rows: repeat(15, 44px);
  background: var(--board-bg);
  padding: 22px;
  border-radius: 5px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
  position: relative;
}

/* Draw grid lines through intersection points */
.game-board::before {
  content: '';
  position: absolute;
  top: 44px;
  left: 44px;
  right: 44px;
  bottom: 44px;
  background-image:
    linear-gradient(var(--board-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--board-line) 1px, transparent 1px);
  background-size: 44px 44px;
  background-position: 0 0;
  pointer-events: none;
}

/* Border lines */
.game-board::after {
  content: '';
  position: absolute;
  top: 44px;
  left: 44px;
  width: calc(44px * 14 + 1px);
  height: calc(44px * 14 + 1px);
  border: 1px solid var(--board-line);
  pointer-events: none;
}

.cell {
  width: 44px;
  height: 44px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.cell:hover::after {
  content: '';
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  position: absolute;
}

/* Hover shadow for white's turn */
.game-board.white-turn .cell:hover::after {
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

/* Hover shadow for black's turn */
.game-board.black-turn .cell:hover::after {
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

.cell.disabled {
  cursor: not-allowed;
}

.cell.disabled:hover::after {
  display: none;
}

/* ============================================
   STONES
   ============================================ */

.stone {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  position: relative;
  z-index: 2;
}

.stone.black {
  background: radial-gradient(circle at 30% 30%, #444, #111);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.stone.white {
  background: radial-gradient(circle at 30% 30%, #fff, #ccc);
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.stone.last-move::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

/* Star points (화점) */
.cell.star-point::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--board-line);
  position: absolute;
  z-index: 0;
}

/* ============================================
   EVALUATION BAR
   ============================================ */

.eval-bar-container {
  width: 100%;
  max-width: 600px;
  margin-bottom: 10px;
}

.eval-bar {
  height: 20px;
  background: linear-gradient(to right, #111 50%, #fff 50%);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.eval-fill {
  height: 100%;
  background: #111;
  transition: width 0.5s ease;
  position: relative;
}

.eval-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
}

.eval-text {
  text-align: center;
  font-size: 12px;
  margin-top: 5px;
  color: var(--text-secondary);
}

/* ============================================
   MOVE NUMBERS ON STONES
   ============================================ */

.stone .move-number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: bold;
  z-index: 3;
}

.stone.black .move-number {
  color: #fff;
}

.stone.white .move-number {
  color: #000;
}

/* ============================================
   HINT INDICATOR
   ============================================ */

.hint-indicator {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px dashed var(--success);
  animation: hint-pulse 1s infinite;
  pointer-events: none;
  z-index: 100;
}

@keyframes hint-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.5; }
}

/* ============================================
   MOVE LIST
   ============================================ */

.move-list-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px;
  min-height: 0;
  background: transparent;
  border-radius: 0;
}

.move-list-header {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.move-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
  overflow-y: auto;
  align-content: flex-start;
}

.move-item {
  padding: 4px 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
}

.move-item.black {
  border-left: 3px solid #333;
}

.move-item.white {
  border-left: 3px solid #ccc;
}

/* ============================================
   STONE ANIMATIONS
   ============================================ */

@keyframes stone-place {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.stone.animated {
  animation: stone-place 0.3s ease-out;
}

/* Win Line Animation */
@keyframes win-glow {
  0%, 100% { box-shadow: 0 0 10px var(--success); }
  50% { box-shadow: 0 0 25px var(--success), 0 0 50px var(--success); }
}

.stone.winning {
  animation: win-glow 1s infinite;
}

/* ============================================
   BOARD STYLE VARIATIONS
   ============================================ */

.game-board.style-wooden {
  background: linear-gradient(135deg, #deb887 0%, #c9a66b 50%, #b8956d 100%);
}

.game-board.style-green {
  --board-bg: #2d5016;
  --board-line: #1a3009;
  background: #2d5016;
}

/* ============================================
   COORDINATES
   ============================================ */

.board-coordinates {
  position: absolute;
  font-size: 12px;
  color: var(--board-line);
  font-weight: bold;
}

.coord-top, .coord-bottom {
  display: flex;
  justify-content: space-around;
  width: calc(36px * 15);
  left: 18px;
}

.coord-top {
  top: 0;
}

.coord-bottom {
  bottom: 0;
}

.coord-left, .coord-right {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  height: calc(36px * 15);
  top: 18px;
}

.coord-left {
  left: 0;
}

.coord-right {
  right: 0;
}

/* ============================================
   ANALYSIS MODAL (Game-specific)
   ============================================ */

.analysis-content {
  max-height: 500px;
  overflow-y: auto;
}

.analysis-summary {
  background: var(--bg-card);
  padding: 20px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.analysis-stat {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.analysis-moves {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.analysis-move {
  display: flex;
  align-items: center;
  padding: 10px;
  background: var(--bg-card);
  border-radius: 8px;
}

.analysis-move.good {
  border-left: 4px solid var(--success);
}

.analysis-move.bad {
  border-left: 4px solid var(--accent);
}

.analysis-move.neutral {
  border-left: 4px solid var(--text-secondary);
}

.analysis-move-number {
  width: 40px;
  font-weight: bold;
}

.analysis-move-text {
  flex: 1;
}

.analysis-move-eval {
  font-weight: bold;
}

/* ============================================
   TUTORIAL MODAL (Game-specific)
   ============================================ */

.tutorial-content {
  min-height: 300px;
  padding: 20px;
}

.tutorial-step {
  text-align: center;
}

.tutorial-step h3 {
  font-size: 24px;
  margin-bottom: 20px;
  color: var(--accent);
}

.tutorial-step p {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.tutorial-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 20px auto;
  padding: 15px;
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.tutorial-image canvas {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.tutorial-caption {
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
  text-align: center;
  padding: 8px 16px;
  background: rgba(108, 92, 231, 0.1);
  border-radius: 20px;
  border: 1px solid rgba(108, 92, 231, 0.3);
}

.tutorial-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  border-top: 1px solid var(--bg-card);
}

.tutorial-progress {
  color: var(--text-secondary);
}

/* ============================================
   RESPONSIVE - Game-specific adjustments
   ============================================ */

/* 1040px: 보드 0.9배 (44px → 40px) */
@media (max-width: 1040px) {
  .game-board {
    grid-template-columns: repeat(15, 40px);
    grid-template-rows: repeat(15, 40px);
    padding: 20px;
  }

  .game-board::before {
    top: 40px;
    left: 40px;
    right: 40px;
    bottom: 40px;
    background-size: 40px 40px;
  }

  .game-board::after {
    top: 40px;
    left: 40px;
    width: calc(40px * 14 + 1px);
    height: calc(40px * 14 + 1px);
  }

  .cell {
    width: 40px;
    height: 40px;
  }

  .stone {
    width: 36px;
    height: 36px;
  }
}

/* 970px: 보드 0.89배 (40px → 35px) */
@media (max-width: 970px) {
  .game-board {
    grid-template-columns: repeat(15, 35px);
    grid-template-rows: repeat(15, 35px);
    padding: 18px;
  }

  .game-board::before {
    top: 35px;
    left: 35px;
    right: 35px;
    bottom: 35px;
    background-size: 35px 35px;
  }

  .game-board::after {
    top: 35px;
    left: 35px;
    width: calc(35px * 14 + 1px);
    height: calc(35px * 14 + 1px);
  }

  .cell {
    width: 35px;
    height: 35px;
  }

  .stone {
    width: 31px;
    height: 31px;
  }
}

/* 900px: 보드 0.85배 (35px → 29px) */
@media (max-width: 900px) and (min-width: 821px) {
  .game-board {
    grid-template-columns: repeat(15, 29px);
    grid-template-rows: repeat(15, 29px);
    padding: 15px;
  }

  .game-board::before {
    top: 29px;
    left: 29px;
    right: 29px;
    bottom: 29px;
    background-size: 29px 29px;
  }

  .game-board::after {
    top: 29px;
    left: 29px;
    width: calc(29px * 14 + 1px);
    height: calc(29px * 14 + 1px);
  }

  .cell {
    width: 29px;
    height: 29px;
  }

  .stone {
    width: 25px;
    height: 25px;
  }
}

/* 820px 이하: 게임판 화면 너비 꽉 차게 */
@media (max-width: 820px) {
  .board-container {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 0 6px;
    box-sizing: border-box;
  }

  .game-board {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    grid-template-rows: repeat(15, 1fr);
    padding: 3%;
    box-sizing: border-box;
  }

  .game-board::before {
    top: calc(100% / 15 / 2 + 3%);
    left: calc(100% / 15 / 2 + 3%);
    right: calc(100% / 15 / 2 + 3%);
    bottom: calc(100% / 15 / 2 + 3%);
    background-size: calc(100% / 14) calc(100% / 14);
  }

  .game-board::after {
    top: calc(100% / 15 / 2 + 3%);
    left: calc(100% / 15 / 2 + 3%);
    width: calc(100% - 100% / 15 - 6%);
    height: calc(100% - 100% / 15 - 6%);
  }

  .cell {
    width: 100%;
    height: 100%;
  }

  .stone {
    width: 85%;
    height: 85%;
  }

  .cell.star-point::before {
    width: 20%;
    height: 20%;
  }
}

/* 600px 이하: 기타 모바일 조정 (게임판은 820px 규칙 사용) */
@media (max-width: 600px) {
  /* Hide move list on mobile */
  .move-list-container {
    display: none !important;
  }
}

/* ============================================
   RECONNECT OVERLAY
   ============================================ */

#reconnect-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

#reconnect-overlay.active {
  display: flex;
}

.reconnect-content {
  text-align: center;
  color: white;
  padding: 30px;
  background: rgba(50, 50, 50, 0.9);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.reconnect-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #6c5ce7;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

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

.reconnect-text {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 10px;
}

.reconnect-attempt {
  font-size: 14px;
  color: #aaa;
  margin-bottom: 15px;
}

.reconnect-refresh {
  display: none;
  padding: 12px 24px;
  font-size: 16px;
  background: #6c5ce7;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.reconnect-refresh:hover {
  background: #5b4cdb;
}

/* ============================================
   SPECTATOR MODE STYLES
   ============================================ */

/* Room List - Live Game Styling */
.room-item.room-live {
  border: 2px solid #e74c3c;
  background: linear-gradient(135deg, rgba(231, 76, 60, 0.1), rgba(192, 57, 43, 0.05));
  cursor: default;
}

.room-item.room-live:hover {
  transform: none;
  border-color: #c0392b;
}

.room-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-badge {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  animation: live-pulse 1.5s infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

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