body {
  font-family: Arial, sans-serif;
  background-color: #f5f5f5;
  margin: 0;
  padding: 20px;
}

.welcome-container {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  background: #fff;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.welcome-container h1 {
  font-size: 3em;
  margin-bottom: 20px;
  color: #333;
}

.welcome-container p {
  font-size: 1.5em;
  color: #555;
}

.welcome-container ul {
  list-style: none;
  padding: 0;
  font-size: 1.3em;
}

.welcome-container li {
  margin: 10px 0;
}

.welcome-container a {
  text-decoration: none;
  color: #0066cc;
  font-weight: bold;
}

.welcome-container a:hover {
  color: #004999;
}

/* Player count picker on the welcome page */
.player-count {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.player-count button {
  font-size: 1.3em;
  width: 50px;
  height: 50px;
  border: 2px solid #0066cc;
  border-radius: 8px;
  background: #fff;
  color: #0066cc;
  cursor: pointer;
}

.player-count button.selected {
  background: #0066cc;
  color: #fff;
}

/* Game code form on the welcome page */
.code-form {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 20px 0;
}

.code-form input {
  font-size: 1.3em;
  width: 220px;
  padding: 8px 12px;
  border: 2px solid #0066cc;
  border-radius: 8px;
}

.code-form button {
  font-size: 1.3em;
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  background: #0066cc;
  color: #fff;
  cursor: pointer;
}

/* Lobby: name, player count, colors, and a small map before the game starts */
.lobby {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
  background: #fff;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.lobby [hidden] {
  display: none !important;
}

.lobby h1 {
  margin-top: 0;
  color: #333;
}

.game-code {
  font-family: monospace;
  background: #f0f0f0;
  padding: 2px 10px;
  border-radius: 6px;
}

.lobby-status {
  color: #555;
  font-size: 1.1em;
}

.lobby-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  justify-content: center;
  margin: 20px 0;
  text-align: left;
}

.lobby-panel {
  flex: 1 1 360px;
  max-width: 420px;
}

.lobby-panel h2 {
  font-size: 1.1em;
  color: #333;
  margin: 18px 0 8px;
}

.lobby-name {
  display: block;
  font-weight: bold;
  color: #333;
}

.lobby-name input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  font-size: 1em;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.lobby .player-count {
  justify-content: flex-start;
}

.team-slots {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* One row per color: the color button, and the bot select while the color is free */
.team-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 8px;
  border: 2px solid transparent;
  border-radius: 8px;
}

.team-row:hover {
  border-color: #999;
}

.team-row.current-player-team {
  border-color: #333;
}

.team-slot {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 12px;
  font-size: 1em;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

.bot-select {
  flex: none;
  font-size: 0.9em;
  padding: 3px 4px;
  border: 1px solid #999;
  border-radius: 4px;
  background: #fff;
}

.team-swatch {
  flex: none;
  width: 18px;
  height: 18px;
  border: 1px solid #333;
  border-radius: 4px;
}

.team-label {
  flex: none;
  width: 70px;
  font-weight: bold;
}

.team-members {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #333;
}

.unassigned {
  color: #777;
}

.mini-map {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 320px;
}

/* The small map only shows the layout: no troop counts, no hover */
.mini-map .board-shape {
  position: static;
}

.mini-map text {
  display: none;
}

.mini-map .cell {
  cursor: default;
}

.mini-map .cell:hover polygon {
  fill-opacity: 1;
}

.lobby-button {
  font-size: 1.1em;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  background: #0066cc;
  color: #fff;
  cursor: pointer;
}

.lobby-button:disabled {
  background: #aaa;
  cursor: not-allowed;
}

#regenerate-button {
  display: block;
  margin: 12px auto 0;
}

.start-button {
  font-size: 1.4em;
  padding: 12px 40px;
  background: #4CAF50;
}

/* Board container wrapping board and overlay; main.js sets its size to fit the board */
#board-container {
  position: relative;
  margin: 20px auto;
}

/* Game board styling */
#game-board {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

/* Board SVG: the board polygon, then the cells on top of it */
.board-shape {
  position: absolute;
  top: 0;
  left: 0;
}

.board-outline {
  fill: #333;
}

/* Individual cell styling: an SVG group with the cell polygon and the troop count */
.cell {
  cursor: pointer;
}

.cell polygon {
  fill: #eee;
  stroke: #333;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.cell text {
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  user-select: none;
}

/* Style for white cells (non-spawn cells with no owner) */
.cell.empty {
  cursor: not-allowed;
}

.cell.empty polygon {
  fill: #e2e2e2;
}

.cell.red polygon {
  fill: #ffaaaa;
}

.cell.blue polygon {
  fill: #aaaaff;
}

.cell.green polygon {
  fill: #aaffaa;
}

.cell.yellow polygon {
  fill: #ffc935;
}

.cell.purple polygon {
  fill: #d9b3ff;
}

.cell.cyan polygon {
  fill: #a0eeee;
}

.cell.neutral polygon {
  fill: #eee;
}

/* Spawn styling */
.cell.spawn polygon {
  stroke: #000;
  stroke-width: 2;
}

.cell.inactive-spawn polygon {
  fill: #555;
}

/* A player's base: losing it gives all the player's cells to the attacker */
.cell.base polygon {
  stroke-width: 4;
}

/* Overlay canvas positioned relative to board-container */
#overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 10;
}

/* Game controls */
.game-controls {
  max-width: 1100px;
  margin: 20px auto;
  text-align: center;
  display: flex;
  gap: 10px;
  justify-content: center;
}

#pause-button, #finish-button {
  font-size: 1.2em;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  color: white;
  cursor: pointer;
  transition: background-color 0.3s;
}

#pause-button {
  background-color: #4CAF50;
}

#finish-button {
  background-color: #f44336;
}

#pause-button:hover {
  background-color: #45a049;
}

#finish-button:hover {
  background-color: #da190b;
}

#pause-button.paused {
  background-color: #f44336;
}

#pause-button.paused:hover {
  background-color: #da190b;
}

/* Update leaderboard styles */
#leaderboard {
  max-width: 800px;
  margin: 20px auto;
  font-size: 1.2em;
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  overflow: hidden;
}

#leaderboard table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

#leaderboard td {
  padding: 12px;
  border-bottom: 1px solid #eee;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* First row (header) styling */
#leaderboard tr:first-child td {
  background-color: #f8f9fa;
  font-weight: bold;
  color: #333;
}

/* Column widths and alignments */
.team-name { 
  width: 15%; 
  text-align: left;
}

.player-names { 
  width: 35%; 
  text-align: left;
  padding-left: 20px;
}

.stat-value { 
  width: 15%; 
  text-align: center;
}

/* Team row colors in leaderboard */
.red-row {
  background-color: rgba(255, 0, 0, 0.1);
}

.blue-row {
  background-color: rgba(0, 0, 255, 0.1);
}

.green-row {
  background-color: rgba(0, 255, 0, 0.1);
}

.yellow-row {
  background-color: rgba(255, 201, 53, 0.1);
}

.purple-row {
  background-color: rgba(155, 48, 255, 0.1);
}

.cyan-row {
  background-color: rgba(0, 160, 160, 0.1);
}

/* Current player's team highlighting */
tr.current-player-team {
  position: relative;
  font-weight: bold;
}

/* Specific colors for current player's team */
tr.red-row.current-player-team {
  background-color: rgba(255, 0, 0, 0.2);
}

tr.blue-row.current-player-team {
  background-color: rgba(0, 0, 255, 0.2);
}

tr.green-row.current-player-team {
  background-color: rgba(0, 255, 0, 0.2);
}

tr.yellow-row.current-player-team {
  background-color: rgba(255, 201, 53, 0.2);
}

tr.purple-row.current-player-team {
  background-color: rgba(155, 48, 255, 0.2);
}

tr.cyan-row.current-player-team {
  background-color: rgba(0, 160, 160, 0.2);
}

/* Cell hover effect */
.cell:hover polygon {
  fill-opacity: 0.85;
}

/* Selected cell: enlarged, with a pulsing outline and glow */
.cell.selected {
  transform: scale(1.1);
  transform-box: fill-box;
  transform-origin: center;
  filter: drop-shadow(0 0 6px #ffc935);
}

.cell.selected polygon {
  stroke: #ffc935;
  stroke-width: 5;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { stroke: rgba(255, 201, 53, 1); }
  50% { stroke: rgba(255, 201, 53, 0.5); }
  100% { stroke: rgba(255, 201, 53, 1); }
}
