/* Add a black background color to the top navigation */
.topnav {
  background-color: #333;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
}

/* Style the links inside the navigation bar */
.topnav a {
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

/* Change the color of links on hover */
.topnav a:hover {
  background-color: #ddd;
  color: black;
}

/* Add a color to the active/current link */
.topnav a.active {
  background-color: #04AA6D;
  color: white;
}

.center-all {
  min-height: 100vh;
  margin: 0;
  display: flex;
  justify-content: center; /* center the main content block */
  padding: 20px;
}

/* Center major titles within the main content area only */
main.center-all h1,
main.center-all h2,
main.center-all h3 {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

/* Generic page title spacing so it doesn't hug the navbar or screen edge */
.page-title {
  margin-top: 16px;
  padding: 0 16px; /* add a little side padding */
}

/* Right aligned nav items */
.topnav .right {
  margin-left: auto;
}

/* Style logout button like a link inside navbar */
.topnav form {
  margin: 0;
}

.topnav button {
  background: none;
  border: none;
  color: #f2f2f2;
  padding: 14px 16px;
  font-size: 17px;
  cursor: pointer;
}

.topnav button:hover {
  background-color: #ddd;
  color: black;
}

/* Home boards grid */
.boards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto; /* center the grid within the page */
}

.board-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  aspect-ratio: 1 / 1; /* make square cards */
  text-decoration: none; /* when used as <a> */
  color: inherit;        /* when used as <a> */
}

.board-card:hover {
  border-color: #bbb;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.board-title {
  font-weight: 600;
  color: #111;
  text-decoration: none;
}

.board-title:hover {
  text-decoration: underline;
}

.players-key {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 8px;
  justify-content: center; /* center the mini legend */
}

.player-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

/* Reusable color dot for players */
.color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #888;
}

/* Board tiles as squares with colored completion overlay */
.tile {
  border: none;
  padding: 6px;
  vertical-align: top;
}

.tile-card {
  position: relative;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  aspect-ratio: 1 / 1; /* square tiles */
  overflow: hidden;
}

.tile-bg {
  position: absolute;
  inset: 0;
  opacity: 0.18; /* low opacity tint so text is readable */
  pointer-events: none;
}

.tile-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.tile-text {
  white-space: pre-wrap;
  flex: 1;
  display: flex;                 /* center the tile label */
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Board view responsive grid */
.board-grid-wrapper {
  /* Make the board scale with the viewport; cap to a sane max per tile */
  /* You can tune --tile-max to control the biggest a tile should get */
  --tile-max: 220px;
  --gap: 10px;
  width: min(
    95vw,
    95vh,
    1100px,
    calc(var(--cols, 5) * var(--tile-max) + (var(--cols, 5) - 1) * var(--gap))
  );
  margin: 0 auto;
}

/* Centered page header helpers */
.page-header {
  text-align: center;
  margin: 10px 0 6px;
}

.page-subtitle {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), 1fr);
  gap: var(--gap, 10px);
}

@media (max-width: 640px) {
  .board-grid {
    gap: 6px;
  }
  .tile-card {
    padding: 6px;
  }
}