/* ============================================
   JANGGI (Korean Chess) - Game-Specific Styles
   Common styles are in ../css/common.css
   ============================================ */

/* Janggi-specific CSS Variables */
:root {
  --board-bg: #dcb35c;
  --board-line: #8b6914;
}

body.theme-light {
  --board-bg: #dcb35c;
  --board-line: #8b6914;
}

/* Game header max-width override for Janggi board */
.game-header {
  max-width: 764px;
}

/* ============================================
   JANGGI BOARD
   ============================================ */

.board-container {
  padding: 22px;
  background: var(--board-bg);
  border-radius: 5px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
  position: relative;
}

.janggi-board {
  display: grid;
  grid-template-columns: repeat(9, 79px);
  grid-template-rows: repeat(10, 65px);
  background: var(--board-bg);
  position: relative;
  border-radius: 5px;
}

/* Board lines SVG - 격자선, 궁성 대각선, 테두리 통합 */
.board-lines {
  position: absolute;
  top: 22px;
  left: 22px;
  width: 711px;
  height: 650px;
  pointer-events: none;
  z-index: 1;
}

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

.cell.valid-move::after {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 128, 0, 0.6);
  border: 2px solid rgba(0, 100, 0, 0.8);
  position: absolute;
}

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

/* Mouse shadow effect */
#mouse-shadow {
  position: absolute;
  width: 46px;
  height: 46px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.15) 40%, rgba(0, 0, 0, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  display: none;
  transform: translate(-50%, -50%);
}

/* ============================================
   JANGGI PIECES
   ============================================ */

.piece {
  width: 59px;
  height: 59px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 30px;
  cursor: pointer;
  position: relative;
  z-index: 2;
  transition: transform 0.15s, filter 0.15s;
  font-family: 'Noto Serif KR', 'Batang', serif;
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
  border: none;
  filter: drop-shadow(2px 3px 3px rgba(0, 0, 0, 0.5));
}

.piece.piece-king {
  width: 58px;
  height: 58px;
  font-size: 31px;
}

.piece.piece-small {
  width: 42px;
  height: 42px;
  font-size: 22px;
}

/* Inner cream area */
.piece::before {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  right: 1px;
  bottom: 1px;
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.9) 0%, transparent 50%),
    linear-gradient(150deg, #f5ecd8 0%, #e8dcc0 40%, #d8c8a0 100%);
  z-index: -1;
}

.piece:hover {
  transform: scale(1.1) translateY(-2px);
  filter: drop-shadow(3px 4px 5px rgba(0, 0, 0, 0.6));
}

/* Cho (Red) pieces */
.piece.cho {
  background: linear-gradient(145deg, #d42040 0%, #a01830 50%, #801020 100%);
  color: #a01525;
  text-shadow: 0.5px 0.5px 0 rgba(255,255,255,0.8), -0.5px -0.5px 0 rgba(255,255,255,0.5);
}

/* Han (Green) pieces */
.piece.han {
  background: linear-gradient(145deg, #2a8a2a 0%, #1a6a1a 50%, #0a4a0a 100%);
  color: #1a5a1a;
  text-shadow: 0.5px 0.5px 0 rgba(255,255,255,0.8), -0.5px -0.5px 0 rgba(255,255,255,0.5);
}

/* Selected piece */
.piece.selected {
  transform: scale(1.15) translateY(-3px);
}

.piece.cho.selected {
  animation: selected-pulse-cho 0.8s ease-in-out infinite alternate;
}

.piece.han.selected {
  animation: selected-pulse-han 0.8s ease-in-out infinite alternate;
}

@keyframes selected-pulse-cho {
  from {
    transform: scale(1.15) translateY(-3px);
    filter: drop-shadow(0 0 8px rgba(255, 50, 50, 0.9)) drop-shadow(0 0 15px rgba(255, 50, 50, 0.6));
  }
  to {
    transform: scale(1.2) translateY(-5px);
    filter: drop-shadow(0 0 12px rgba(255, 50, 50, 1)) drop-shadow(0 0 25px rgba(255, 50, 50, 0.8)) drop-shadow(0 0 40px rgba(255, 50, 50, 0.5));
  }
}

@keyframes selected-pulse-han {
  from {
    transform: scale(1.15) translateY(-3px);
    filter: drop-shadow(0 0 8px rgba(50, 255, 50, 0.9)) drop-shadow(0 0 15px rgba(50, 255, 50, 0.6));
  }
  to {
    transform: scale(1.2) translateY(-5px);
    filter: drop-shadow(0 0 12px rgba(50, 255, 50, 1)) drop-shadow(0 0 25px rgba(50, 255, 50, 0.8)) drop-shadow(0 0 40px rgba(50, 255, 50, 0.5));
  }
}

/* Last move highlight */
.cell.last-move-cell-cho {
  background: radial-gradient(circle, rgba(255, 0, 0, 0.5) 0%, rgba(255, 0, 0, 0.2) 50%, transparent 70%) !important;
  animation: last-move-glow-cho 0.8s ease-in-out infinite alternate;
}

.cell.last-move-cell-han {
  background: radial-gradient(circle, rgba(0, 255, 0, 0.5) 0%, rgba(0, 255, 0, 0.2) 50%, transparent 70%) !important;
  animation: last-move-glow-han 0.8s ease-in-out infinite alternate;
}

@keyframes last-move-glow-cho {
  0% { background: radial-gradient(circle, rgba(255, 0, 0, 0.3) 0%, rgba(255, 0, 0, 0.1) 50%, transparent 70%); }
  100% { background: radial-gradient(circle, rgba(255, 0, 0, 0.6) 0%, rgba(255, 0, 0, 0.3) 50%, transparent 70%); }
}

@keyframes last-move-glow-han {
  0% { background: radial-gradient(circle, rgba(0, 255, 0, 0.3) 0%, rgba(0, 255, 0, 0.1) 50%, transparent 70%); }
  100% { background: radial-gradient(circle, rgba(0, 255, 0, 0.6) 0%, rgba(0, 255, 0, 0.3) 50%, transparent 70%); }
}

/* Piece indicator for player cards */
.piece-indicator {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 14px;
  font-weight: bold;
  flex-shrink: 0;
  font-family: 'Noto Serif KR', serif;
}

.piece-indicator.cho {
  background: #f5e6c8;
  border: 3px solid #c41e3a;
  color: #c41e3a;
}

.piece-indicator.han {
  background: #f5e6c8;
  border: 3px solid #228b22;
  color: #228b22;
}

/* ============================================
   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;
  max-height: 80px;
}

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

.move-item.cho {
  border-left: 3px solid #c00;
}

.move-item.han {
  border-left: 3px solid #00c;
}

/* ============================================
   FORMATION MODAL
   ============================================ */

#formation-modal .modal {
  max-width: 500px;
  text-align: center;
}

.formation-timer {
  font-size: 18px;
  color: var(--warning);
  margin: 15px 0;
  padding: 10px;
  background: rgba(251, 191, 36, 0.1);
  border-radius: 8px;
}

#formation-timer-count {
  font-size: 24px;
  font-weight: bold;
  color: var(--accent);
  margin: 0 5px;
}

.formation-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin: 20px 0;
}

.formation-btn {
  background: var(--bg-secondary);
  border: 2px solid var(--bg-card);
  border-radius: 12px;
  padding: 15px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.formation-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.formation-btn.selected {
  border-color: var(--accent);
  background: rgba(233, 69, 96, 0.1);
  box-shadow: 0 0 15px rgba(233, 69, 96, 0.3);
}

.formation-name {
  font-size: 18px;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.formation-preview {
  font-family: 'Noto Serif KR', serif;
  font-size: 20px;
  color: var(--accent);
  letter-spacing: 2px;
}

.formation-default {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 5px;
}

.formation-confirm {
  width: 100%;
  margin-top: 10px;
  padding: 15px;
  font-size: 16px;
}

/* ============================================
   SPEECH BUBBLE (Janggun/Munggun)
   ============================================ */

.speech-bubble-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2000;
  pointer-events: none;
  display: none;
}

.speech-bubble-container.active {
  display: block;
  animation: bubble-appear 0.3s ease-out forwards;
}

.speech-bubble {
  position: relative;
  background: #fff;
  border: 4px solid #333;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  padding: 25px 40px;
  font-size: 32px;
  font-weight: bold;
  color: #333;
  text-align: center;
  box-shadow: 4px 4px 0 #333, 8px 8px 15px rgba(0, 0, 0, 0.3);
  font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  min-width: 150px;
}

.speech-bubble::before {
  content: '';
  position: absolute;
  top: -15px;
  left: 20%;
  width: 30px;
  height: 30px;
  background: #fff;
  border: 4px solid #333;
  border-radius: 50%;
  border-bottom: none;
  z-index: -1;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  top: -10px;
  right: 25%;
  width: 25px;
  height: 25px;
  background: #fff;
  border: 4px solid #333;
  border-radius: 50%;
  border-bottom: none;
  z-index: -1;
}

.speech-bubble .cloud-bump-1 {
  position: absolute;
  top: -12px;
  left: 45%;
  width: 35px;
  height: 35px;
  background: #fff;
  border: 4px solid #333;
  border-radius: 50%;
  border-bottom: none;
  z-index: -1;
}

.speech-bubble .cloud-bump-2 {
  position: absolute;
  bottom: -8px;
  left: 30%;
  width: 20px;
  height: 20px;
  background: #fff;
  border: 4px solid #333;
  border-radius: 50%;
  border-top: none;
}

.speech-bubble .cloud-bump-3 {
  position: absolute;
  bottom: -10px;
  right: 35%;
  width: 25px;
  height: 25px;
  background: #fff;
  border: 4px solid #333;
  border-radius: 50%;
  border-top: none;
}

/* Janggun - Red */
.speech-bubble.janggun {
  background: linear-gradient(135deg, #fff5f5 0%, #ffe0e0 100%);
  border-color: #c41e3a;
  color: #c41e3a;
  box-shadow: 4px 4px 0 #c41e3a, 8px 8px 20px rgba(196, 30, 58, 0.4);
}

.speech-bubble.janggun::before,
.speech-bubble.janggun::after,
.speech-bubble.janggun .cloud-bump-1,
.speech-bubble.janggun .cloud-bump-2,
.speech-bubble.janggun .cloud-bump-3 {
  background: linear-gradient(135deg, #fff5f5 0%, #ffe0e0 100%);
  border-color: #c41e3a;
}

/* Munggun - Green */
.speech-bubble.munggun {
  background: linear-gradient(135deg, #f0fff0 0%, #d0f0d0 100%);
  border-color: #228b22;
  color: #228b22;
  box-shadow: 4px 4px 0 #228b22, 8px 8px 20px rgba(34, 139, 34, 0.4);
}

.speech-bubble.munggun::before,
.speech-bubble.munggun::after,
.speech-bubble.munggun .cloud-bump-1,
.speech-bubble.munggun .cloud-bump-2,
.speech-bubble.munggun .cloud-bump-3 {
  background: linear-gradient(135deg, #f0fff0 0%, #d0f0d0 100%);
  border-color: #228b22;
}

/* Warning - Yellow */
.speech-bubble.warning {
  background: linear-gradient(135deg, #fffff0 0%, #fff8dc 100%);
  border-color: #daa520;
  color: #b8860b;
  box-shadow: 4px 4px 0 #daa520, 8px 8px 20px rgba(218, 165, 32, 0.4);
}

.speech-bubble.warning::before,
.speech-bubble.warning::after,
.speech-bubble.warning .cloud-bump-1,
.speech-bubble.warning .cloud-bump-2,
.speech-bubble.warning .cloud-bump-3 {
  background: linear-gradient(135deg, #fffff0 0%, #fff8dc 100%);
  border-color: #daa520;
}

@keyframes bubble-appear {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1.2); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes bubble-shake {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
  25% { transform: translate(-50%, -50%) rotate(-3deg); }
  75% { transform: translate(-50%, -50%) rotate(3deg); }
}

.speech-bubble-container.shake {
  animation: bubble-appear 0.3s ease-out, bubble-shake 0.15s ease-in-out 0.3s 3;
}

/* ============================================
   HINT HIGHLIGHT
   ============================================ */

.cell.hint-from::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  transform: translate(-50%, -50%);
  border: 4px solid #3b82f6;
  border-radius: 50%;
  animation: hint-pulse-from 0.8s ease-in-out infinite;
  pointer-events: none;
  z-index: 50;
}

.cell.hint-to::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  transform: translate(-50%, -50%);
  border: 4px dashed #fbbf24;
  border-radius: 50%;
  animation: hint-pulse-to 0.8s ease-in-out infinite;
  pointer-events: none;
  z-index: 50;
}

@keyframes hint-pulse-from {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; box-shadow: 0 0 10px rgba(59, 130, 246, 0.8); }
  50% { transform: translate(-50%, -50%) scale(1.1); opacity: 0.7; box-shadow: 0 0 20px rgba(59, 130, 246, 1); }
}

@keyframes hint-pulse-to {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; box-shadow: 0 0 10px rgba(251, 191, 36, 0.8); }
  50% { transform: translate(-50%, -50%) scale(1.15); opacity: 0.7; box-shadow: 0 0 25px rgba(251, 191, 36, 1); }
}

/* ============================================
   RESPONSIVE - 1090px (0.9배: 79px → 71px)
   ============================================ */

@media (max-width: 1090px) {
  .board-container {
    padding: 20px;
  }

  .janggi-board {
    grid-template-columns: repeat(9, 71px);
    grid-template-rows: repeat(10, 59px);
  }

  .board-lines {
    top: 20px;
    left: 20px;
    width: 639px;
    height: 590px;
  }

  .cell {
    width: 71px;
    height: 59px;
  }

  .piece {
    width: 53px;
    height: 53px;
    font-size: 27px;
  }

  .piece.piece-king {
    width: 52px;
    height: 52px;
    font-size: 28px;
  }

  .piece.piece-small {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }
}

/* ============================================
   RESPONSIVE - 1010px (0.83배: 71px → 59px)
   ============================================ */

@media (max-width: 1010px) {
  .board-container {
    padding: 16px;
  }

  .janggi-board {
    grid-template-columns: repeat(9, 59px);
    grid-template-rows: repeat(10, 49px);
  }

  .board-lines {
    top: 16px;
    left: 16px;
    width: 531px;
    height: 490px;
  }

  .cell {
    width: 59px;
    height: 49px;
  }

  .piece {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }

  .piece.piece-king {
    width: 43px;
    height: 43px;
    font-size: 23px;
  }

  .piece.piece-small {
    width: 31px;
    height: 31px;
    font-size: 16px;
  }
}

/* ============================================
   RESPONSIVE - Tablet (900px) (0.9배: 60px → 54px)
   ============================================ */

@media (max-width: 900px) {
  .board-container {
    padding: 15px;
  }

  .janggi-board {
    grid-template-columns: repeat(9, 54px);
    grid-template-rows: repeat(10, 45px);
  }

  .board-lines {
    top: 15px;
    left: 15px;
    width: 486px;
    height: 450px;
  }

  .cell {
    width: 54px;
    height: 45px;
  }

  .piece {
    width: 41px;
    height: 41px;
    font-size: 20px;
  }

  .piece.piece-king {
    width: 40px;
    height: 40px;
    font-size: 21px;
  }

  .piece.piece-small {
    width: 29px;
    height: 29px;
    font-size: 15px;
  }

  .cell.hint-from::before,
  .cell.hint-to::before {
    width: 52px;
    height: 52px;
    border-width: 3px;
  }
}

/* ============================================
   RESPONSIVE - 847px (0.95배: 54px → 51px)
   ============================================ */

@media (max-width: 847px) {
  .board-container {
    padding: 14px;
  }

  .janggi-board {
    grid-template-columns: repeat(9, 51px);
    grid-template-rows: repeat(10, 43px);
  }

  .board-lines {
    top: 14px;
    left: 14px;
    width: 459px;
    height: 430px;
  }

  .cell {
    width: 51px;
    height: 43px;
  }

  .piece {
    width: 39px;
    height: 39px;
    font-size: 19px;
  }

  .piece.piece-king {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }

  .piece.piece-small {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
}

/* ============================================
   RESPONSIVE - Mobile (600px)
   ============================================ */

@media (max-width: 600px) {
  .board-container {
    padding: 8px;
  }

  .janggi-board {
    grid-template-columns: repeat(9, 42px);
    grid-template-rows: repeat(10, 36px);
  }

  .janggi-board::before {
    top: 18px;
    left: 21px;
    width: calc(42px * 8);
    height: calc(36px * 9);
    background-size: 42px 36px;
  }

  .janggi-board::after {
    top: 17px;
    left: 20px;
    width: calc(42px * 8);
    height: calc(36px * 9);
  }

  .board-lines {
    top: 8px;
    left: 8px;
    width: 378px;
    height: 360px;
  }

  .cell {
    width: 42px;
    height: 36px;
  }

  .piece {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .piece.piece-king {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }

  .piece.piece-small {
    width: 27px;
    height: 27px;
    font-size: 13px;
  }

  .game-controls {
    max-width: 394px;
  }

  .move-list-container {
    display: none !important;
  }

  .speech-bubble {
    font-size: 24px;
    padding: 18px 30px;
    min-width: 120px;
  }

  .speech-bubble::before {
    width: 22px;
    height: 22px;
    top: -10px;
  }

  .speech-bubble::after {
    width: 18px;
    height: 18px;
    top: -8px;
  }

  .cell.hint-from::before,
  .cell.hint-to::before {
    width: 36px;
    height: 36px;
    border-width: 2px;
  }
}

/* ============================================
   RESPONSIVE - Small Mobile (400px)
   ============================================ */

@media (max-width: 400px) {
  .board-container {
    padding: 5px;
  }

  .janggi-board {
    grid-template-columns: repeat(9, 38px);
    grid-template-rows: repeat(10, 32px);
  }

  .janggi-board::before {
    top: 16px;
    left: 19px;
    width: calc(38px * 8);
    height: calc(32px * 9);
    background-size: 38px 32px;
  }

  .janggi-board::after {
    top: 15px;
    left: 18px;
    width: calc(38px * 8);
    height: calc(32px * 9);
  }

  .board-lines {
    top: 5px;
    left: 5px;
    width: 342px;
    height: 320px;
  }

  .cell {
    width: 38px;
    height: 32px;
  }

  .piece {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .piece.piece-king {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }

  .piece.piece-small {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .game-controls {
    max-width: 352px;
  }

  .cell.hint-from::before,
  .cell.hint-to::before {
    width: 32px;
    height: 32px;
    border-width: 2px;
  }
}

/* ============================================
   820px 이하: 모바일 레이아웃 (게임판 100% 너비)
   SVG viewBox는 720x660, 격자는 80x66 간격
   격자 교차점: col*80+40, row*66+33
   셀 중심과 격자 교차점 일치를 위해 SVG 오프셋 필요
   ============================================ */
@media (max-width: 820px) {
  .board-container {
    width: 100%;
    padding: 0 !important;
    box-sizing: border-box;
    position: relative;
  }

  .janggi-board {
    width: 100%;
    /* SVG viewBox 비율: 720:660 */
    aspect-ratio: 720 / 660;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(10, 1fr);
    position: relative;
  }

  .board-lines {
    position: absolute !important;
    /* .board-container(=.janggi-board)와 정확히 일치 */
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    /* SVG viewBox(720x660)와 그리드(9x10)가 정확히 대응
       셀 크기: 80x66 (viewBox 기준)
       격자 교차점: (40+col*80, 33+row*66) = 셀 중심 */
  }

  .cell {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  /* 장기말 크기: 왕 > 일반 > 졸/병 */
  /* 일반 말 (車, 馬, 象, 士, 包) - 중간 크기 */
  .piece {
    width: calc((100vw - 12px) * 0.075);
    height: calc((100vw - 12px) * 0.075);
    font-size: calc((100vw - 12px) * 0.038);
  }

  /* 왕 (楚/漢) - 제일 큼 */
  .piece.piece-king {
    width: calc((100vw - 12px) * 0.09);
    height: calc((100vw - 12px) * 0.09);
    font-size: calc((100vw - 12px) * 0.048);
  }

  /* 졸/병 - 제일 작음 */
  .piece.piece-small {
    width: calc((100vw - 12px) * 0.058);
    height: calc((100vw - 12px) * 0.058);
    font-size: calc((100vw - 12px) * 0.028);
  }

  .cell.hint-from::before,
  .cell.hint-to::before {
    width: calc((100vw - 12px) * 0.09);
    height: calc((100vw - 12px) * 0.09);
  }
}

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

/* ============================================
   TUTORIAL MODAL
   ============================================ */
.modal-tutorial {
  max-width: 520px;
  width: 95%;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid #3a3a5c;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.modal-tutorial h2 {
  text-align: center;
  margin-bottom: 20px;
  font-size: 1.5rem;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.tutorial-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tutorial-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#tutorial-canvas {
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), inset 0 0 30px rgba(0, 0, 0, 0.3);
  background: #dcb35c;
}

.tutorial-caption {
  font-size: 0.85rem;
  color: #a0a0c0;
  text-align: center;
  font-style: italic;
}

.tutorial-text {
  padding: 0 10px;
  text-align: center;
}

.tutorial-text h3 {
  font-size: 1.2rem;
  color: #fff;
  margin-bottom: 10px;
}

.tutorial-text p {
  font-size: 0.95rem;
  color: #c0c0d0;
  line-height: 1.6;
}

.tutorial-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.tutorial-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.progress-dots {
  display: flex;
  gap: 6px;
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3a3a5c;
  transition: all 0.3s ease;
}

.progress-dot.active {
  background: #ffd700;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.progress-dot.completed {
  background: #4ade80;
}

.tutorial-progress span {
  font-size: 0.8rem;
  color: #808090;
}

.tutorial-navigation .btn {
  min-width: 90px;
}

.tutorial-navigation .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Light theme */
body.theme-light .modal-tutorial {
  background: linear-gradient(180deg, #f5f5f5 0%, #e8e8e8 100%);
  border-color: #ccc;
}

body.theme-light .modal-tutorial h2 {
  color: #b8860b;
  text-shadow: none;
}

body.theme-light .tutorial-caption {
  color: #666;
}

body.theme-light .tutorial-text h3 {
  color: #333;
}

body.theme-light .tutorial-text p {
  color: #555;
}

body.theme-light .progress-dot {
  background: #ccc;
}

body.theme-light .progress-dot.active {
  background: #b8860b;
  box-shadow: 0 0 8px rgba(184, 134, 11, 0.5);
}

body.theme-light .tutorial-progress span {
  color: #888;
}

/* ============================================
   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.cho {
  background: #c41e3a;
  color: #fff;
}

.participant-badge.han {
  background: #228b22;
  color: #fff;
}

.empty-participants {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
  font-size: 13px;
}
