/* ==========================================
   LUDO ROYALE DESIGN SYSTEM & CORE STYLES
   ========================================== */

:root {
  --bg-color: #0c0d14;
  --panel-bg: rgba(20, 22, 37, 0.6);
  --panel-border: rgba(255, 255, 255, 0.08);
  --glass-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --font-primary: 'Outfit', sans-serif;

  /* Vibrant Player Colors */
  --red-color: #ff3366;
  --red-glow: rgba(255, 51, 102, 0.4);
  --green-color: #00e676;
  --green-glow: rgba(0, 230, 118, 0.4);
  --yellow-color: #ffd600;
  --yellow-glow: rgba(255, 214, 0, 0.4);
  --blue-color: #2979ff;
  --blue-glow: rgba(41, 121, 255, 0.4);

  --neutral-cell: rgba(255, 255, 255, 0.03);
  --safe-cell: rgba(255, 255, 255, 0.08);
  --cell-border: rgba(255, 255, 255, 0.05);

  /* Dice Colors */
  --dice-bg: #ffffff;
  --dice-pip: #1e1e2f;

  /* Animations */
  --transition-speed: 0.3s;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html {
  background-color: var(--bg-color);
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-color);
  color: #f3f4f6;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  position: relative;
}

/* Background animated gradient glow */
.bg-glow {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgba(41, 121, 255, 0.15) 0%, rgba(255, 51, 102, 0.1) 40%, transparent 70%);
  z-index: -1;
  pointer-events: none;
  filter: blur(80px);
  animation: bg-pulse 10s infinite alternate;
}

@keyframes bg-pulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
  }

  100% {
    transform: translate(-50%, -50%) scale(1.2);
  }
}

/* Glassmorphism utility card */
.glass-card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: var(--glass-glow);
  padding: 24px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================
   BUTTONS AND INPUTS
   ========================================== */

.btn-primary {
  background: linear-gradient(135deg, var(--blue-color) 0%, #1a237e 100%);
  color: white;
  border: none;
  padding: 14px 28px;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 16px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(41, 121, 255, 0.3);
  transition: all var(--transition-speed);
  letter-spacing: 0.5px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(41, 121, 255, 0.5);
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e5e7eb;
  padding: 10px 20px;
  font-family: var(--font-primary);
  font-weight: 500;
  font-size: 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.btn-toggle {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #9ca3af;
  padding: 8px 16px;
  font-family: var(--font-primary);
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.btn-toggle.active {
  background: var(--blue-color);
  border-color: var(--blue-color);
  color: white;
  box-shadow: 0 0 10px var(--blue-glow);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 18px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
  transition: all var(--transition-speed);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
}

input[type="text"],
select {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  font-family: var(--font-primary);
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition-speed);
}

input[type="text"]:focus,
select:focus {
  border-color: var(--blue-color);
}

/* ==========================================
   APP CONTAINER
   ========================================== */

#app-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  padding: 20px;
  margin: auto;
}

.hidden {
  display: none !important;
}

/* ==========================================
   SETUP SCREEN
   ========================================== */

#setup-screen {
  width: 100%;
  max-width: 800px;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.brand {
  text-align: center;
  margin-bottom: 32px;
}

.logo-crown {
  font-size: 48px;
  margin-bottom: 8px;
  display: inline-block;
  animation: crown-float 3s ease-in-out infinite alternate;
}

@keyframes crown-float {
  0% {
    transform: translateY(0) rotate(0);
  }

  100% {
    transform: translateY(-8px) rotate(5deg);
  }
}

.brand h1 {
  font-weight: 800;
  font-size: 36px;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #ffd600 0%, #ff3366 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.brand .subtitle {
  color: #9ca3af;
  font-size: 14px;
}

.setup-section h2 {
  font-size: 18px;
  margin-bottom: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #e5e7eb;
}

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

@media (max-width: 600px) {
  .players-grid {
    grid-template-columns: 1fr;
  }
}

.player-config-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 16px;
  transition: all var(--transition-speed);
}

.player-config-card.red {
  border-left: 4px solid var(--red-color);
}

.player-config-card.green {
  border-left: 4px solid var(--green-color);
}

.player-config-card.yellow {
  border-left: 4px solid var(--yellow-color);
}

.player-config-card.blue {
  border-left: 4px solid var(--blue-color);
}

.player-config-card:focus-within {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.card-header {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.player-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 10px;
}

.player-color-dot.red {
  background: var(--red-color);
  box-shadow: 0 0 10px var(--red-glow);
}

.player-color-dot.green {
  background: var(--green-color);
  box-shadow: 0 0 10px var(--green-glow);
}

.player-color-dot.yellow {
  background: var(--yellow-color);
  box-shadow: 0 0 10px var(--yellow-glow);
}

.player-color-dot.blue {
  background: var(--blue-color);
  box-shadow: 0 0 10px var(--blue-glow);
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  flex-grow: 1;
}

/* Switch Toggle Styling */
.switch-container {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.switch-container input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .4s;
  border-radius: 20px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.switch-slider {
  background-color: var(--blue-color);
}

input:checked+.switch-slider:before {
  transform: translateX(20px);
}

.switch-container.active-only input:disabled+.switch-slider {
  opacity: 0.6;
  cursor: not-allowed;
}

.card-body {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
}

.input-group label {
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.setup-settings {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 20px;
  margin-bottom: 24px;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setting-item label {
  font-size: 14px;
  color: #e5e7eb;
}

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

.error-text {
  color: var(--red-color);
  font-size: 13px;
  margin-top: 8px;
  height: 18px;
}

/* ==========================================
   GAMEPLAY SCREEN
   ========================================== */

#game-screen {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.4s ease-out;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo .logo-crown {
  font-size: 24px;
  margin-bottom: 0;
  animation: none;
}

.header-logo h2 {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #ffd600 0%, #ff3366 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.game-layout {
  display: grid;
  grid-template-columns: 280px 1fr 240px;
  gap: 20px;
  align-items: start;
}

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

  .log-sidebar {
    grid-column: 1 / span 2;
  }
}

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

  .game-sidebar {
    order: 2;
  }

  .board-area {
    order: 1;
  }

  .log-sidebar {
    order: 3;
  }
}

/* ==========================================
   SIDEBARS
   ========================================== */

.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.turn-card {
  text-align: center;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.02);
}

.turn-card h3 {
  font-size: 12px;
  color: #9ca3af;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.current-player-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

#turn-instruction {
  font-size: 13px;
  color: #9ca3af;
}

.players-status {
  padding: 16px;
}

.players-status h3,
.log-panel h3 {
  font-size: 12px;
  color: #9ca3af;
  letter-spacing: 1px;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.players-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-status-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  font-size: 14px;
  transition: all var(--transition-speed);
}

.player-status-row.active {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.05);
}

.player-status-row.red.active {
  box-shadow: 0 0 10px var(--red-glow);
  border-color: var(--red-color);
}

.player-status-row.green.active {
  box-shadow: 0 0 10px var(--green-glow);
  border-color: var(--green-color);
}

.player-status-row.yellow.active {
  box-shadow: 0 0 10px var(--yellow-glow);
  border-color: var(--yellow-color);
}

.player-status-row.blue.active {
  box-shadow: 0 0 10px var(--blue-glow);
  border-color: var(--blue-color);
}

.player-status-row.finished {
  opacity: 0.5;
  text-decoration: line-through;
}

.player-status-row .player-info {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.player-status-row .name {
  font-weight: 600;
}

.player-status-row .type-label {
  font-size: 10px;
  color: #9ca3af;
}

.player-status-row .home-count {
  font-size: 18px;
  font-weight: 800;
  margin-left: 8px;
  opacity: 0.8;
}

/* ==========================================
   3D DICE DESIGN
   ========================================== */

.dice-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

.dice-wrapper {
  perspective: 400px;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dice-container {
  width: 60px;
  height: 60px;
  cursor: pointer;
}

.dice {
  width: 60px;
  height: 60px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.25, 1.0);
}

.face {
  position: absolute;
  width: 60px;
  height: 60px;
  background: var(--dice-bg);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.15), 0 0 8px rgba(255, 255, 255, 0.8);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 6px;
  box-sizing: border-box;
}

.pip {
  background: var(--dice-pip);
  border-radius: 50%;
  width: 10px;
  height: 10px;
  align-self: center;
  justify-self: center;
  box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.5);
}

/* Pip position classes */
.pip.top-left {
  grid-area: 1 / 1;
}

.pip.top-right {
  grid-area: 1 / 3;
}

.pip.middle-left {
  grid-area: 2 / 1;
}

.pip.center {
  grid-area: 2 / 2;
}

.pip.middle-right {
  grid-area: 2 / 3;
}

.pip.bottom-left {
  grid-area: 3 / 1;
}

.pip.bottom-right {
  grid-area: 3 / 3;
}

/* 3D transforms for cube sides */
.face.front {
  transform: rotateY(0deg) translateZ(30px);
}

.face.back {
  transform: rotateY(180deg) translateZ(30px);
}

.face.right {
  transform: rotateY(90deg) translateZ(30px);
}

.face.left {
  transform: rotateY(-90deg) translateZ(30px);
}

.face.top {
  transform: rotateX(90deg) translateZ(30px);
}

.face.bottom {
  transform: rotateX(-90deg) translateZ(30px);
}

/* Spin Keyframes */
@keyframes spin-wild {
  0% {
    transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  }

  100% {
    transform: rotateX(1080deg) rotateY(720deg) rotateZ(360deg);
  }
}

.dice.spinning {
  animation: spin-wild 0.6s linear infinite;
}

.dice-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.dice-controls .btn-primary {
  width: 100%;
  padding: 10px 16px;
  font-size: 15px;
}

.roll-result-text {
  font-size: 13px;
  color: #9ca3af;
  height: 18px;
}

/* Sidebar settings row */
.settings-row {
  display: flex;
  gap: 12px;
  width: 100%;
}

.select-wrapper {
  flex-grow: 1;
}

/* ==========================================
   LUDO BOARD AREA
   ========================================== */

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

.board-container {
  position: relative;
  width: 90vmin;
  height: 90vmin;
  max-width: 580px;
  max-height: 580px;
  aspect-ratio: 1 / 1;
  background: rgba(20, 22, 37, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 8px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.ludo-board {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  gap: 2px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
}

/* ==========================================
   BOARD COMPONENTS
   ========================================== */

/* Bases (Corner Yards) */
.base-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  position: relative;
  padding: 12px;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.base-container.red {
  background: radial-gradient(circle at center, rgba(255, 51, 102, 0.15) 0%, rgba(255, 51, 102, 0.02) 100%);
  border-color: rgba(255, 51, 102, 0.2);
}

.base-container.green {
  background: radial-gradient(circle at center, rgba(0, 230, 118, 0.15) 0%, rgba(0, 230, 118, 0.02) 100%);
  border-color: rgba(0, 230, 118, 0.2);
}

.base-container.yellow {
  background: radial-gradient(circle at center, rgba(255, 214, 0, 0.15) 0%, rgba(255, 214, 0, 0.02) 100%);
  border-color: rgba(255, 214, 0, 0.2);
}

.base-container.blue {
  background: radial-gradient(circle at center, rgba(41, 121, 255, 0.15) 0%, rgba(41, 121, 255, 0.02) 100%);
  border-color: rgba(41, 121, 255, 0.2);
}

/* Pulsing outline for active player's base */
.base-container.active-turn {
  border-width: 2px;
  animation: base-pulse 1.5s infinite alternate;
}

.base-container.red.active-turn {
  box-shadow: inset 0 0 20px rgba(255, 51, 102, 0.3), 0 0 15px rgba(255, 51, 102, 0.2);
  border-color: var(--red-color);
}

.base-container.green.active-turn {
  box-shadow: inset 0 0 20px rgba(0, 230, 118, 0.3), 0 0 15px rgba(0, 230, 118, 0.2);
  border-color: var(--green-color);
}

.base-container.yellow.active-turn {
  box-shadow: inset 0 0 20px rgba(255, 214, 0, 0.3), 0 0 15px rgba(255, 214, 0, 0.2);
  border-color: var(--yellow-color);
}

.base-container.blue.active-turn {
  box-shadow: inset 0 0 20px rgba(41, 121, 255, 0.3), 0 0 15px rgba(41, 121, 255, 0.2);
  border-color: var(--blue-color);
}

@keyframes base-pulse {
  0% {
    transform: scale(1);
  }

  100% {
    transform: scale(1.01);
  }
}

/* Pockets inside base for tokens */
.pockets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 12px;
}

.pocket {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.base-container.red .pocket {
  border-color: rgba(255, 51, 102, 0.3);
}

.base-container.green .pocket {
  border-color: rgba(0, 230, 118, 0.3);
}

.base-container.yellow .pocket {
  border-color: rgba(255, 214, 0, 0.3);
}

.base-container.blue .pocket {
  border-color: rgba(41, 121, 255, 0.3);
}

/* Center Home */
.center-home {
  position: relative;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

/* Draw triangles in center home */
.center-triangle {
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
}

/* Left Triangle (Red) */
.center-triangle.red {
  top: 0;
  left: 0;
  bottom: 0;
  border-width: 27px 0 27px 27px;
  /* Fallback sizing, JS overrides coordinates based on grid size */
  border-color: transparent transparent transparent rgba(255, 51, 102, 0.25);
  border-left-color: rgba(255, 51, 102, 0.3);
  width: 50%;
  height: 100%;
  clip-path: polygon(0% 0%, 100% 50%, 0% 100%);
  background: linear-gradient(90deg, rgba(255, 51, 102, 0.3) 0%, transparent 100%);
}

/* Top Triangle (Green) */
.center-triangle.green {
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 50%;
  clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
  background: linear-gradient(180deg, rgba(0, 230, 118, 0.3) 0%, transparent 100%);
}

/* Right Triangle (Yellow) */
.center-triangle.yellow {
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  height: 100%;
  left: 50%;
  clip-path: polygon(100% 0%, 100% 100%, 0% 50%);
  background: linear-gradient(-90deg, rgba(255, 214, 0, 0.3) 0%, transparent 100%);
}

/* Bottom Triangle (Blue) */
.center-triangle.blue {
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 50%;
  top: 50%;
  clip-path: polygon(0% 100%, 100% 100%, 50% 0%);
  background: linear-gradient(0deg, rgba(41, 121, 255, 0.3) 0%, transparent 100%);
}

.center-crown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  filter: drop-shadow(0 0 5px rgba(255, 214, 0, 0.8));
}

/* Board Cells */
.cell {
  background: var(--neutral-cell);
  border: 1px solid var(--cell-border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Colored Track Cells */
.cell.red-start {
  background: rgba(255, 51, 102, 0.25) !important;
  border: 2px solid var(--red-color) !important;
  box-shadow: inset 0 0 8px rgba(255, 51, 102, 0.3);
}

.cell.green-start {
  background: rgba(0, 230, 118, 0.25) !important;
  border: 2px solid var(--green-color) !important;
  box-shadow: inset 0 0 8px rgba(0, 230, 118, 0.3);
}

.cell.yellow-start {
  background: rgba(255, 214, 0, 0.25) !important;
  border: 2px solid var(--yellow-color) !important;
  box-shadow: inset 0 0 8px rgba(255, 214, 0, 0.3);
}

.cell.blue-start {
  background: rgba(41, 121, 255, 0.25) !important;
  border: 2px solid var(--blue-color) !important;
  box-shadow: inset 0 0 8px rgba(41, 121, 255, 0.3);
}

/* Home Paths */
.cell.red-path {
  background: linear-gradient(90deg, rgba(255, 51, 102, 0.4) 0%, rgba(255, 51, 102, 0.15) 100%) !important;
  border-color: rgba(255, 51, 102, 0.2);
}

.cell.green-path {
  background: linear-gradient(180deg, rgba(0, 230, 118, 0.4) 0%, rgba(0, 230, 118, 0.15) 100%) !important;
  border-color: rgba(0, 230, 118, 0.2);
}

.cell.yellow-path {
  background: linear-gradient(-90deg, rgba(255, 214, 0, 0.4) 0%, rgba(255, 214, 0, 0.15) 100%) !important;
  border-color: rgba(255, 214, 0, 0.2);
}

.cell.blue-path {
  background: linear-gradient(0deg, rgba(41, 121, 255, 0.4) 0%, rgba(41, 121, 255, 0.15) 100%) !important;
  border-color: rgba(41, 121, 255, 0.2);
}

/* Safe Zone Star Cells */
.cell.star::after {
  content: "★";
  font-size: 14px;
  color: rgba(255, 255, 255, 0.45);
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

.cell.red.star::after {
  color: var(--red-color);
  text-shadow: 0 0 8px var(--red-glow);
}

.cell.green.star::after {
  color: var(--green-color);
  text-shadow: 0 0 8px var(--green-glow);
}

.cell.yellow.star::after {
  color: var(--yellow-color);
  text-shadow: 0 0 8px var(--yellow-glow);
}

.cell.blue.star::after {
  color: var(--blue-color);
  text-shadow: 0 0 8px var(--blue-glow);
}

/* ==========================================
   TOKENS LAYER & INTERACTION
   ========================================== */

.tokens-layer {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  bottom: 8px;
  pointer-events: none;
}

.token-container {
  position: absolute;
  width: 6.666%;
  /* 100% / 15 */
  height: 6.666%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: left 0.2s cubic-bezier(0.25, 0.8, 0.25, 1), top 0.2s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  z-index: 10;
}

.token {
  width: 70%;
  height: 70%;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4), inset 0 2px 2px rgba(255, 255, 255, 0.4), inset 0 -2px 4px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.25);
  transition: transform 0.15s ease, filter 0.15s ease;
}

/* Colored Token Gems */
.token.red {
  background: radial-gradient(circle at 35% 35%, #ff5c8a 0%, var(--red-color) 70%, #990026 100%);
  box-shadow: 0 4px 8px rgba(255, 51, 102, 0.2), inset 0 2px 2px rgba(255, 255, 255, 0.5), inset 0 -2px 4px rgba(0, 0, 0, 0.6);
}

.token.green {
  background: radial-gradient(circle at 35% 35%, #5df2a6 0%, var(--green-color) 70%, #00803d 100%);
  box-shadow: 0 4px 8px rgba(0, 230, 118, 0.2), inset 0 2px 2px rgba(255, 255, 255, 0.5), inset 0 -2px 4px rgba(0, 0, 0, 0.6);
}

.token.yellow {
  background: radial-gradient(circle at 35% 35%, #ffea70 0%, var(--yellow-color) 70%, #b28500 100%);
  box-shadow: 0 4px 8px rgba(255, 214, 0, 0.2), inset 0 2px 2px rgba(255, 255, 255, 0.5), inset 0 -2px 4px rgba(0, 0, 0, 0.6);
}

.token.blue {
  background: radial-gradient(circle at 35% 35%, #70a5ff 0%, var(--blue-color) 70%, #003db3 100%);
  box-shadow: 0 4px 8px rgba(41, 121, 255, 0.2), inset 0 2px 2px rgba(255, 255, 255, 0.5), inset 0 -2px 4px rgba(0, 0, 0, 0.6);
}

/* Inner Shield Ring for Royal Look */
.token::before {
  content: "";
  width: 50%;
  height: 50%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Highlight / Pulsing effect for active tokens that can move */
.token.active-move {
  animation: token-pulse 1s infinite alternate;
  cursor: pointer;
  filter: brightness(1.2);
}

.token.red.active-move {
  border-color: #ffb3c6;
  box-shadow: 0 0 15px #ff3366, inset 0 2px 2px rgba(255, 255, 255, 0.5);
}

.token.green.active-move {
  border-color: #b3ffd9;
  box-shadow: 0 0 15px #00e676, inset 0 2px 2px rgba(255, 255, 255, 0.5);
}

.token.yellow.active-move {
  border-color: #fffae6;
  box-shadow: 0 0 15px #ffd600, inset 0 2px 2px rgba(255, 255, 255, 0.5);
}

.token.blue.active-move {
  border-color: #b3d1ff;
  box-shadow: 0 0 15px #2979ff, inset 0 2px 2px rgba(255, 255, 255, 0.5);
}

@keyframes token-pulse {
  0% {
    transform: scale(1);
    filter: brightness(1.1) drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
  }

  100% {
    transform: scale(1.15);
    filter: brightness(1.3) drop-shadow(0 0 8px rgba(255, 255, 255, 0.6));
  }
}

.token:hover {
  transform: scale(1.2);
  filter: brightness(1.2);
  z-index: 100;
}

/* ==========================================
   GAME LOG CONSOLE
   ========================================== */

.log-sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 250px;
}

.log-panel {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  height: 520px;
  /* Aligns with board height roughly */
  padding: 16px;
}

.log-messages {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  padding-right: 4px;
}

.log-msg {
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.01);
  border-left: 3px solid rgba(255, 255, 255, 0.1);
  line-height: 1.4;
  animation: logFadeIn 0.25s ease-out;
}

@keyframes logFadeIn {
  from {
    opacity: 0;
    transform: translateX(10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.log-msg.system {
  border-left-color: var(--blue-color);
  background: rgba(41, 121, 255, 0.05);
  color: #93c5fd;
}

.log-msg.red {
  border-left-color: var(--red-color);
  background: rgba(255, 51, 102, 0.05);
}

.log-msg.green {
  border-left-color: var(--green-color);
  background: rgba(0, 230, 118, 0.05);
}

.log-msg.yellow {
  border-left-color: var(--yellow-color);
  background: rgba(255, 214, 0, 0.05);
}

.log-msg.blue {
  border-left-color: var(--blue-color);
  background: rgba(41, 121, 255, 0.05);
}

.log-msg.capture {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
  font-weight: 600;
  color: #fef08a;
}

.log-msg.victory {
  border-left-color: #ffd600;
  background: rgba(255, 214, 0, 0.1);
  font-weight: 700;
  color: #fef08a;
}

/* ==========================================
   BOARD OVERLAYS / POPUPS
   ========================================== */

.board-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  z-index: 50;
  animation: fadeIn 0.3s ease-out;
}

.overlay-content {
  text-align: center;
  max-width: 80%;
  width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleUp {
  from {
    transform: scale(0.8);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

#overlay-title {
  font-weight: 800;
  font-size: 24px;
  background: linear-gradient(135deg, #ffd600 0%, #ff9e00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#overlay-text {
  font-size: 15px;
  color: #e5e7eb;
}

/* ==========================================
   MOBILE RESPONSIVENESS AND INTERACTION
   ========================================== */

/* Touch targets & Mobile interaction optimization */
button,
select,
input,
.token,
#dice-click-area {
  touch-action: manipulation;
}

.token.active-move::after {
  content: "";
  position: absolute;
  top: -15px;
  left: -15px;
  right: -15px;
  bottom: -15px;
  border-radius: 50%;
  pointer-events: auto;
  z-index: 5;
}

@media (max-width: 850px) {
  .game-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "turn turn"
      "board board"
      "status status"
      "settings settings"
      "log log";
    gap: 12px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
  }

  .game-sidebar {
    display: contents;
  }

  .turn-card {
    grid-area: turn;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 0;
  }

  .current-player-display {
    font-size: 16px;
    margin-bottom: 0;
  }

  .dice-panel {
    display: none;
  }

  .cell .dice-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.65);
    z-index: 40;
    margin: 0;
    width: 100px;
    height: 100px;
    background: rgba(12, 13, 20, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 10px rgba(255, 255, 255, 0.1);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  /* Glowing borders matching active player's color */
  .cell.red-start .dice-wrapper {
    border: 2px solid var(--red-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 12px var(--red-glow);
  }

  .cell.green-start .dice-wrapper {
    border: 2px solid var(--green-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 12px var(--green-glow);
  }

  .cell.yellow-start .dice-wrapper {
    border: 2px solid var(--yellow-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 12px var(--yellow-glow);
  }

  .cell.blue-start .dice-wrapper {
    border: 2px solid var(--blue-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 12px var(--blue-glow);
  }

  .state-moving .cell .dice-wrapper {
    opacity: 0.05;
    pointer-events: none;
    transform: translate(-50%, -50%) scale(0.45);
  }

  .board-area {
    grid-area: board;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .players-status {
    grid-area: status;
    width: 100%;
    margin: 0;
  }

  .players-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .sidebar-settings {
    grid-area: settings;
    width: 100%;
    margin: 0;
  }

  .log-sidebar {
    grid-area: log;
    width: 100%;
    margin: 0;
  }

  .log-panel {
    height: 180px;
  }
}

@media (max-width: 480px) {
  .game-header h2 {
    font-size: 16px;
  }

  .header-actions .btn-secondary {
    padding: 6px 10px;
    font-size: 12px;
  }

  #app-container {
    padding: 10px;
  }

  .turn-card {
    padding: 8px;
  }

  .dice-panel {
    padding: 8px 12px;
  }
}