/* ==========================================================================
   CSS Design System for Puchees (Indian Pachisi) Web Application
   ========================================================================== */

/* --- Theme Declarations via CSS Variables --- */
:root {
  /* Default (Classic Theme) */
  --bg-primary: #FFF8E7;
  --bg-secondary: #FFE4C4;
  --bg-gradient: linear-gradient(135deg, #FFF8E7 0%, #FFE4C4 50%, #FFDAB9 100%);
  
  --text-primary: #3E2723;
  --text-secondary: #795548;
  --accent: #FF1493;
  --accent-dark: #C71585;
  --accent-light: #FF8A80;
  
  --card-bg: rgba(255, 255, 255, 0.7);
  --border-color: #E0C9A6;
  --button-bg: #FF1493;
  --button-text: #FFFFFF;
  
  --success: #43A047;
  --danger: #E53935;
  --warning: #FFB300;
  
  --board-pink: #FF1493;
  --board-blue: #6EC6FF;
  --board-safe: #FFD700;
  --board-center: #FF69B4;
  --board-center-pat: #C71585;
  --board-border: #8B4513;
  --board-grid: #333333;
  
  --theme-blue: #1E88E5;
}

body[data-theme="royal"] {
  --bg-primary: #1A0033;
  --bg-secondary: #2D004D;
  --bg-gradient: linear-gradient(135deg, #1A0033 0%, #2D004D 50%, #0D001A 100%);
  
  --text-primary: #FFD700;
  --text-secondary: #CE93D8;
  --accent: #FFD700;
  --accent-dark: #FF6F00;
  --accent-light: #FFE082;
  
  --card-bg: rgba(45, 0, 77, 0.75);
  --border-color: #FFD700;
  --button-bg: #FFD700;
  --button-text: #1A0033;
  
  --success: #4CAF50;
  --danger: #F44336;
  --warning: #FFC107;
  
  --board-pink: #7B1FA2;
  --board-blue: #FFD700;
  --board-safe: #FF6F00;
  --board-center: #9C27B0;
  --board-center-pat: #FFD700;
  --board-border: #FFD700;
  --board-grid: #4A148C;
  
  --theme-blue: #2196F3;
}

body[data-theme="temple"] {
  --bg-primary: #EFEBE9;
  --bg-secondary: #D7CCC8;
  --bg-gradient: linear-gradient(135deg, #EFEBE9 0%, #D7CCC8 50%, #BCAAA4 100%);
  
  --text-primary: #3E2723;
  --text-secondary: #5D4037;
  --accent: #BF360C;
  --accent-dark: #8D6E63;
  --accent-light: #FF9E80;
  
  --card-bg: rgba(255, 255, 255, 0.75);
  --border-color: #8D6E63;
  --button-bg: #BF360C;
  --button-text: #FFFFFF;
  
  --success: #00BFA5;
  --danger: #FF3D00;
  --warning: #FFD600;
  
  --board-pink: #FF6F00;
  --board-blue: #00695C;
  --board-safe: #FFD54F;
  --board-center: #BF360C;
  --board-center-pat: #FFD54F;
  --board-border: #8D6E63;
  --board-grid: #3E2723;
  
  --theme-blue: #304FFE;
}

body[data-theme="night"] {
  --bg-primary: #121212;
  --bg-secondary: #1E1E1E;
  --bg-gradient: linear-gradient(135deg, #121212 0%, #1A1A2E 50%, #0A0A0A 100%);
  
  --text-primary: #FFFFFF;
  --text-secondary: #B0BEC5;
  --accent: #FF00FF;
  --accent-dark: #880E4F;
  --accent-light: #FF80AB;
  
  --card-bg: rgba(30, 30, 30, 0.85);
  --border-color: #7C4DFF;
  --button-bg: #FF00FF;
  --button-text: #FFFFFF;
  
  --success: #76FF03;
  --danger: #FF4081;
  --warning: #FFEA00;
  
  --board-pink: #FF00FF;
  --board-blue: #00E5FF;
  --board-safe: #FFEA00;
  --board-center: #880E4F;
  --board-center-pat: #FF00FF;
  --board-border: #4A148C;
  --board-grid: #7C4DFF;
  
  --theme-blue: #00E5FF;
}

/* --- Base Layout & Normalization --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  color: var(--text-primary);
  background: var(--bg-gradient);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px;
  transition: background 0.5s ease, color 0.5s ease;
}

/* --- Ambient Background Glows --- */
.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.2;
  z-index: -1;
  pointer-events: none;
  animation: float-glow 20s infinite alternate ease-in-out;
}

.bg-glow-1 {
  width: 40vw;
  height: 40vw;
  background: var(--accent);
  top: -10%;
  left: -10%;
}

.bg-glow-2 {
  width: 50vw;
  height: 50vw;
  background: var(--theme-blue);
  bottom: -10%;
  right: -10%;
  animation-delay: -10s;
}

@keyframes float-glow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(10%, 10%) scale(1.1); }
}

/* --- App Containers & Header --- */
#app-container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.app-header {
  text-align: center;
  margin-bottom: 25px;
  z-index: 10;
}

.logo-text {
  font-family: 'Cinzel Decorative', serif;
  font-size: 3rem;
  letter-spacing: 4px;
  background: linear-gradient(45deg, var(--accent), var(--theme-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 10px rgba(0,0,0,0.15);
  margin-bottom: 5px;
}

.subtitle-text {
  font-size: 1rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 500;
}

/* --- Cards & Glassmorphism --- */
.glass {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.card {
  padding: 30px;
  width: 100%;
  max-width: 480px;
  margin: 15px auto;
}

.card-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

/* --- Forms & Inputs --- */
.input-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  border-radius: 8px;
  border: 1.5px solid var(--border-color);
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-primary);
  font-family: inherit;
  transition: all 0.3s ease;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 10px rgba(255, 20, 147, 0.1);
}

/* --- Buttons --- */
.btn {
  width: 100%;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.25s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:active {
  transform: scale(0.98);
}

.primary-btn {
  background: var(--button-bg);
  color: var(--button-text);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.primary-btn:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.accent-btn {
  background: var(--theme-blue);
  color: #FFFFFF;
}

.accent-btn:hover {
  filter: brightness(1.1);
}

.danger-btn {
  background: var(--danger);
  color: white;
}

.danger-btn:hover {
  filter: brightness(1.1);
}

.success-btn {
  background: var(--success);
  color: white;
}

.success-btn:hover {
  filter: brightness(1.1);
}

.small-btn {
  padding: 6px 12px;
  font-size: 0.8rem;
  width: auto;
  border-radius: 4px;
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.85rem;
  width: auto;
  padding: 8px 16px;
  margin-top: 10px;
}

.logout-btn:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text-primary);
}

/* --- Screen Visibility Control --- */
.screen {
  display: none;
  width: 100%;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

/* --- SCREEN 1: Authentication Tabs --- */
.tab-buttons {
  display: flex;
  width: 100%;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.3s;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
  width: 100%;
}

.tab-content.active {
  display: block;
}

.success-box {
  background: rgba(67, 160, 71, 0.1);
  border: 1.5px dashed var(--success);
  padding: 20px;
  border-radius: 8px;
  margin-top: 15px;
  text-align: center;
}

.success-box p {
  color: var(--success);
  font-weight: 600;
  margin-bottom: 10px;
}

.member-id-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.4);
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
}

.id-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.member-id-display strong {
  font-size: 1.25rem;
  letter-spacing: 1px;
  color: var(--text-primary);
}

.warning-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 15px;
}

.error-text {
  color: var(--danger);
  background: rgba(229, 57, 53, 0.1);
  padding: 10px;
  border-radius: 6px;
  margin-top: 15px;
  text-align: center;
  font-size: 0.9rem;
  border: 1px solid rgba(229, 57, 53, 0.2);
}

/* --- SCREEN 2: Lobby Layout --- */
.player-profile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 25px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto 25px auto;
  flex-wrap: wrap;
  gap: 15px;
}

.profile-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.profile-avatar {
  font-size: 2.2rem;
  background: rgba(255,255,255,0.4);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border-color);
}

.profile-info h3 {
  font-size: 1.2rem;
  font-weight: 600;
}

.profile-id {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.profile-stats {
  display: flex;
  gap: 25px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-lbl {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 3px;
}

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 25px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.lobby-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

.lobby-cards .card {
  max-width: none;
  margin: 0;
}

@media (max-width: 900px) {
  .grid-2col,
  .lobby-cards {
    grid-template-columns: 1fr;
  }
}

.join-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.room-code-input {
  font-size: 2.2rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 6px;
  text-transform: uppercase;
  max-width: 300px;
  margin: 15px auto 25px auto;
  border-bottom: 3px solid var(--accent);
  background: rgba(255,255,255,0.2) !important;
}

/* --- Form Elements in Lobby --- */
.form-group {
  margin-bottom: 25px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.segmented-control {
  display: flex;
  background: rgba(0,0,0,0.05);
  border-radius: 8px;
  padding: 4px;
}

.segment-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.segment-btn.active {
  background: var(--card-bg);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 5px;
  border-radius: 8px;
  border: 1.5px solid var(--border-color);
  background: rgba(255,255,255,0.3);
  cursor: pointer;
  transition: all 0.2s;
}

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

.theme-option.active {
  background: var(--card-bg);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(255,20,147,0.15);
}

.theme-emoji {
  font-size: 1.6rem;
  margin-bottom: 5px;
}

.theme-name {
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
}

/* --- Waiting Room Layout --- */
#waiting-room {
  max-width: 600px;
  margin: 0 auto;
}

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

.room-code-display-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.4);
  padding: 15px 35px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  margin: 20px auto;
}

.room-code-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 2px;
  margin-bottom: 5px;
}

.room-code-display-box strong {
  font-size: 2.2rem;
  letter-spacing: 5px;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.waiting-info {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-bottom: 25px;
  color: var(--text-secondary);
}

.players-list-container {
  margin: 20px 0;
  text-align: left;
}

.players-list-container h3 {
  font-size: 1rem;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  color: var(--text-secondary);
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.player-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  background: rgba(0,0,0,0.03);
  border: 1px solid transparent;
}

.player-slot.occupied {
  background: var(--card-bg);
  border-color: var(--border-color);
}

.slot-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ccc;
  border: 1.5px solid #aaa;
}

.player-slot.occupied .slot-dot.pos-0 { background: #E53935; border-color: #B71C1C; }
.player-slot.occupied .slot-dot.pos-1 { background: #1E88E5; border-color: #0D47A1; }
.player-slot.occupied .slot-dot.pos-2 { background: #43A047; border-color: #1B5E20; }
.player-slot.occupied .slot-dot.pos-3 { background: #FFB300; border-color: #FF6F00; }

.slot-name {
  font-weight: 500;
}

.slot-name .you-tag {
  font-size: 0.75rem;
  background: var(--accent);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 5px;
}

.slot-team {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: auto;
}

/* Waiting Room Pulsing animation */
.pulse-container {
  margin: 25px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pulse-ring {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 var(--accent);
  animation: pulse-ring-anim 1.5s infinite;
}

.waiting-pulse-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

@keyframes pulse-ring-anim {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 20, 147, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 10px rgba(255, 20, 147, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(255, 20, 147, 0);
  }
}

/* --- SCREEN 3: GAMEPLAY LAYOUT --- */
.game-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  width: 100%;
  margin-bottom: 15px;
  gap: 15px;
}

.room-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-indicator strong {
  letter-spacing: 1px;
}

.tag {
  font-size: 0.75rem;
  background: rgba(0,0,0,0.08);
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.game-status-alert {
  font-weight: 500;
  color: var(--accent);
  text-align: center;
  font-size: 0.95rem;
}

.game-grid-layout {
  display: grid;
  grid-template-columns: minmax(400px, 1.2fr) 1fr;
  gap: 20px;
  width: 100%;
  align-items: start;
}

@media (max-width: 900px) {
  .game-grid-layout {
    grid-template-columns: 1fr;
  }
}

.board-wrapper {
  padding: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#board-svg-container {
  width: 100%;
  max-width: 580px;
  aspect-ratio: 1 / 1;
}

#board-svg-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.panel-section {
  padding: 20px;
}

.panel-section h2 {
  font-size: 1rem;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

/* Turn Card & Roll Widget */
.turn-card {
  border-left: 4px solid var(--border-color);
}

.turn-card.active-turn {
  border-left-color: var(--accent);
  box-shadow: 0 0 15px rgba(255, 20, 147, 0.15);
}

.player-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.banner-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ccc;
  display: inline-block;
}

.roll-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
}

.gavvalu-box {
  display: flex;
  justify-content: center;
  gap: 8px;
  background: rgba(0,0,0,0.04);
  padding: 15px;
  border-radius: 8px;
  width: 100%;
  min-height: 80px;
  align-items: center;
}

.roll-btn {
  max-width: 250px;
}

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

.roll-result {
  display: flex;
  align-items: center;
  gap: 10px;
}

.roll-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.5);
  padding: 5px 15px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.roll-bonus-tag {
  font-size: 0.8rem;
  font-weight: 700;
  background: linear-gradient(to right, #FF8A00, #FF005C);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  animation: flash 1s infinite alternate;
}

@keyframes flash {
  0% { opacity: 0.7; }
  100% { opacity: 1; transform: scale(1.05); }
}

/* --- SVG Cowrie Shell CSS Shapes & Animations --- */
.cowrie-shell {
  width: 32px;
  height: 42px;
  position: relative;
  perspective: 1000px;
}

.shell-inner {
  width: 100%;
  height: 100%;
  position: absolute;
  transform-style: preserve-3d;
  transition: transform 0.5s ease-in-out;
}

.shell-inner.rolling {
  animation: spin-shell-anim 1.2s ease-in-out;
}

.shell-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Back of shell (Smooth, facing down / reverse = "down" shell) */
.shell-back {
  background: radial-gradient(circle at 35% 35%, #FFFDD0 0%, #F3E5AB 60%, #C19A6B 100%);
  border: 1px solid #BCAAA4;
  transform: rotateY(0deg);
}

/* Front of shell (Slit opening, facing up / face-up = "up" shell) */
.shell-front {
  background: #FFFDD0;
  border: 1.5px solid #8D6E63;
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Slit decoration */
.shell-front::after {
  content: '';
  width: 4px;
  height: 80%;
  background: #5D4037;
  border-radius: 2px;
  box-shadow: inset 0 0 2px #000;
}

/* Tiny horizontal lines representing shell teeth */
.shell-front-teeth {
  position: absolute;
  width: 12px;
  height: 80%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  pointer-events: none;
}

.shell-front-teeth span {
  width: 100%;
  height: 1px;
  background: #8D6E63;
}

/* CSS states triggered by roll outcome */
.shell-inner.state-down {
  transform: rotateY(0deg);
}

.shell-inner.state-up {
  transform: rotateY(180deg) rotate(15deg);
}

@keyframes spin-shell-anim {
  0% { transform: translateY(0) rotateY(0) rotate(0); }
  30% { transform: translateY(-40px) rotateY(360deg) rotate(120deg) scale(1.2); }
  60% { transform: translateY(-20px) rotateY(720deg) rotate(240deg) scale(1.1); }
  100% { transform: translateY(0) rotateY(1080deg) rotate(360deg) scale(1); }
}

/* --- Player Status Panel --- */
.game-players-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.game-player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(0,0,0,0.03);
  border: 1.5px solid transparent;
}

.game-player-row.active-turn {
  background: var(--card-bg);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(255, 20, 147, 0.1);
}

.game-player-row.pos-0 .slot-dot { background: #E53935; border-color: #B71C1C; }
.game-player-row.pos-1 .slot-dot { background: #1E88E5; border-color: #0D47A1; }
.game-player-row.pos-2 .slot-dot { background: #43A047; border-color: #1B5E20; }
.game-player-row.pos-3 .slot-dot { background: #FFB300; border-color: #FF6F00; }

.player-row-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.player-row-name .me-tag {
  font-size: 0.7rem;
  background: var(--accent);
  color: white;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 4px;
}

.player-row-stats {
  margin-left: auto;
  display: flex;
  gap: 15px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.player-row-stats strong {
  color: var(--text-primary);
}

/* --- Chat Panel --- */
.chat-card {
  display: flex;
  flex-direction: column;
  height: 250px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  background: rgba(0,0,0,0.02);
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.05);
}

.chat-msg {
  font-size: 0.85rem;
  line-height: 1.3;
}

.msg-sender {
  font-weight: 700;
  color: var(--accent-dark);
}

.msg-text {
  color: var(--text-primary);
}

.chat-form {
  display: flex;
  gap: 8px;
}

.chat-form input {
  flex: 1;
  padding: 10px;
  font-size: 0.9rem;
}

.icon-btn {
  width: auto;
  padding: 10px 14px;
  font-size: 1.1rem;
  background: var(--button-bg);
  color: var(--button-text);
}

/* --- Game Over Modal --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  padding: 40px;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  border-color: var(--accent);
}

.victory-crown {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 10px;
  animation: bounce 1.5s infinite;
}

#victory-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 2.2rem;
  color: var(--accent);
  margin-bottom: 8px;
}

#victory-subtitle {
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 25px;
}

.victory-stats-box {
  background: rgba(0,0,0,0.03);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  margin-bottom: 25px;
}

.victory-stats-box h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.modal-stats-table {
  width: 100%;
  border-collapse: collapse;
}

.modal-stats-table th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 6px;
  text-align: center;
}

.modal-stats-table td {
  padding: 8px 6px;
  font-size: 0.9rem;
  font-weight: 500;
}

.modal-stats-table tr:not(:last-child) td {
  border-bottom: 1px dashed var(--border-color);
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* --- SVG Cell & Piece Interactive Animations --- */
.svg-cell {
  cursor: pointer;
}

.svg-cell:hover rect {
  filter: brightness(1.15);
}

.svg-cell-target {
  cursor: pointer;
  animation: pulse-target 1.2s infinite alternate;
}

@keyframes pulse-target {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}

.svg-piece {
  cursor: pointer;
  transition: transform 0.25s ease-out;
}

.svg-piece:hover {
  transform: scale(1.1);
}

.svg-piece-interactive {
  animation: bounce-piece 1.2s infinite alternate ease-in-out;
}

@keyframes bounce-piece {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}

.svg-piece-selected circle.glow-ring {
  animation: rotate-glow 2s infinite linear;
}

@keyframes rotate-glow {
  0% { stroke-dasharray: 4, 4; stroke-dashoffset: 0; }
  100% { stroke-dasharray: 4, 4; stroke-dashoffset: 8; }
}
