/* Universal box-sizing for consistent layout */
* {
  box-sizing: border-box;
}

body {
  font-family: Verdana, Geneva, sans-serif;
  margin: 0;
  padding: 0;
}

nav {
  background-color: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  padding: 0.2rem 0.4rem;
  margin-bottom: 0.5rem;
}

.nav-content {
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.nav-brand {
  font-weight: bold;
  font-size: 1.1rem;
  margin: 0.1rem;
  text-decoration: none;
  color: #333;
  display: flex;
  align-items: center;
}

.nav-icon {
  width: 1.2rem;
  height: 1.2rem;
  margin-left: 0.5rem;
  margin-right: 0.5rem;
  border: 1px solid #333;
  border-radius: 3px;
  padding: 1px;
}

.nav-right {
  display: flex;
  align-items: center;
}

.start-button,
.restart,
.save {
  border-radius: 0.4rem;
  padding: 0.3rem 1rem;
  font-size: 1.2rem;
  font-weight: bold;
  width: 100%;
  background-color: #007bff;
  color: white;
}

.start-button[disabled],
.restart[disabled],
.save[disabled] {
  background-color: #ededed;
  color: grey;
}

.start-button {
  background-color: rgb(152, 217, 178);
  color: black;
}

.start-game {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2em;
  gap: 1.5em;
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  max-width: 30rem;
  margin: 50px auto;
}

.start-button {
  width: 100%;
  padding: 0.8em;
  font-size: 1.2em;
  cursor: pointer;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  text-align: center;
  gap: 1em;
  width: 100%;
  color: #777;
}

.divider::before,
.divider::after {
  content: '';
  border-top: 1px solid #ccc;
}

.join-game {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 0.5em;
}

.join-game label {
  font-weight: bold;
  color: #333;
}

.input-group {
  display: flex;
  gap: 0.5em;
}

.input-group input {
  flex-grow: 1;
  padding: 0.5em;
  font-size: 1em;
  border: 1px solid #ccc;
  border-radius: 4px;
  text-transform: uppercase;
}

.input-group button {
  padding: 0.5em 1em;
  font-size: 1em;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.input-group button:hover {
  background-color: #0056b3;
}

main {
  display: flex;
  justify-content: center;
  align-items: start;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 1em;
}

h1 {
  font-size: 48px;
  margin: 5px;
}

.progress-circle {
  width: 60px;
  height: 60px;
  position: relative;
  margin: 20px auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.progress-circle .number {
  position: absolute;
  font-size: 24px;
  font-weight: bold;
}

.progress-circle .number.small-font {
  font-size: 18px;
}

.progress-circle svg {
  width: 60px;
  height: 60px;
  transform: rotate(-90deg);
}

.progress-circle circle {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
}

.progress-circle .bg {
  stroke: #f0f0f0;
}

.progress-circle .progress {
  stroke: #007bff;
  stroke-dasharray: 157;
  /* Approximately 2 * PI * 25 (radius) */
  stroke-dashoffset: 47.1;
  /* 157 * 0.3 to show 70% progress */
}

.progress-circle.hide {
  display: none;
}

.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.user-info-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.control-gear-icon {
  text-decoration: none;
  font-size: 1rem;
  margin-left: 2px;
}

.game-control-gear-large {
  text-decoration: none;
  font-size: 1.5rem;
}

.game-board {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1em;
  background-color: bisque;
  border: 1px solid black;
  border-radius: 5px;
  gap: 1em;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-radius: 5px;
}

.grid-cell {
  background-color: white;
  border: 1px solid black;
  height: 5rem;
  width: 5rem;
  text-align: center;
  cursor: pointer;
}

.grid-cell[disabled] {
  cursor: not-allowed;
}

.grid-cell[disabled].x:not(.winner),
.grid-cell[disabled].o:not(.winner) {
  background-color: #ededed;
}

.grid-cell.vote-mark {
  position: relative;
}

.grid-cell.vote-mark::before {
  opacity: var(--vote-opacity, 0.2);
  stroke: blue;
}

.vote-count {
  position: absolute;
  bottom: 2px;
  right: 5px;
  font-size: 0.8rem;
  color: blue;
  font-weight: bold;
  pointer-events: none; /* Ensure clicks pass through to the button */
}

.x::before {
  content: url('/tic-tac-toe/x.svg');
}
.o::before {
  content: url('/tic-tac-toe/o.svg');
}

.x::before,
.o::before {
  width: 3rem;
  height: 3rem;
  stroke: black;
}

.player {
  border-radius: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.player.o::before,
.player.x::before {
  opacity: 0.4;
}

.player.turn {
  background-color: rgb(255, 242, 224);
}

.player.winner,
.grid-cell.winner {
  background-color: rgb(152, 217, 178);
}

.player.winner::before {
  opacity: 1;
}

.player.turn::before {
  opacity: 1;
}

.turn-status {
  height: 3rem;
  width: 100%;
  gap: 0.5em; /* Smaller gap for vertical arrangement */
  display: flex;
  flex-direction: row; /* Arrange items vertically */
  justify-content: space-between; /* Center horizontally in the column */
  align-items: center; /* Center horizontally in the column */
  text-align: center; /* Center text within turn-message */
}

.turn-message {
  flex-grow: 0; /* No longer needs to grow */
  max-width: none; /* Remove max-width restriction */
}

.progress-circle {
  margin: 0; /* Remove auto margins when centrally aligned by flexbox */
}

.player {
  /* Ensure players are still horizontally aligned if needed, or adjust based on overall layout */
  flex-direction: row; /* Keep player elements in a row */
  align-items: center;
  justify-content: center;
  gap: 0.5em;
}

.turn-progress {
  display: flex;
  max-width: 7em;
  align-items: center;
  flex-direction: column;
}

#connection-info {
  display: flex;
  justify-content: flex-end;
  gap: 0.5em;
  align-items: center;
}

#message {
  flex-grow: 1;
}

#chat {
  border: 1px solid black;
  padding: 1em;
}

form {
  display: flex;
  gap: 0.5em;
}

.sync {
  padding: 1rem 0.2rem;
  font-size: 0.9rem;
  text-align: center;
}

.settings {
  flex-direction: column;
  padding: 1em;
  border: 1px solid black;
  border-radius: 0.3em;
  background-color: white;
  max-width: 20rem;
}

.settings h2 {
  margin-top: 0.5em;
  margin-bottom: 0.2em;
}

.settings form {
  flex-direction: column;
  gap: 0.5em;
}

.settings label {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}

.settings fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

.settings fieldset legend {
  margin-bottom: 0.3em;
}

.settings .radio-group {
  display: flex;
  gap: 0.5em;
  flex-direction: row;
  margin-top: 0.4em;
}

.settings .radio-group label {
  align-items: center;
  flex-direction: row;
  border: 1px solid black;
  padding: 0.5em;
  border-radius: 0.3em;
  cursor: pointer;
  flex: 1;
  justify-content: center;
}

.settings .radio-group.small label {
  padding-right: 1em;
}

.mode-specific {
  display: none;
}

.settings input[type='number'] {
  font-size: 1em;
  padding: 0.3em;
  text-align: center;
}

.links-panel {
  margin: 1em auto;
  padding: 1em;
  background-color: #f9f9f9;
  border: 1px solid #ccc;
  border-radius: 5px;
  flex-direction: column;
  gap: 0.5em;
  font-size: 0.9em;
  width: fit-content;
  max-width: 100%;
}

.links-panel strong {
  margin-right: 0.5em;
}

.links-panel div {
  display: flex;
  align-items: center;
  min-width: 0;
}

.links-panel div a {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
}

.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2em;
  margin-left: 0.5em;
  padding: 0;
  position: relative;
}

.copy-btn:hover {
  opacity: 0.7;
}

.copy-popover {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #333;
  color: white;
  padding: 0.3em 0.6em;
  border-radius: 4px;
  font-size: 0.7em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  animation: fadeInOut 2s ease-in-out;
  margin-bottom: 5px;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
    transform: translate(-50%, 5px);
  }
  10% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  90% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -5px);
  }
}

.sync.hide {
  opacity: 0;
  transition: opacity 1s cubic-bezier(0.64, 0, 0.78, 0);
}

.settings label.games-per-round {
  display: none;
}

.share {
  text-align: center;
  padding: 0.5em;
  border: 1px solid black;
  border-radius: 0.3em;
  background-color: white;
  max-width: 20rem;
  margin-bottom: 0.4em;
}

.auth-section {
  width: 100%;
}

.login-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  width: 100%;
}

.login-btn {
  display: block;
  width: 100%;
  padding: 0.8em;
  text-align: center;
  text-decoration: none;
  font-weight: bold;
  color: white;
  border-radius: 0.4rem;
  font-size: 1em;
}

.login-btn.google {
  background-color: #db4437;
}
.login-btn.twitch {
  background-color: #9146ff;
}
.login-btn.linkedin {
  background-color: #0077b5;
}

.login-link {
  color: #007bff;
  text-decoration: none;
  font-size: 0.9rem;
}

.login-link:hover {
  text-decoration: underline;
}

dialog {
  border: none;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 0;
  max-width: 90vw;
  width: 300px;
}

dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

.login-dialog-content {
  position: relative;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-dialog-content h3 {
  margin: 0;
  text-align: center;
}

.close-dialog-x {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 0.2rem;
}

.close-dialog-x:hover {
  color: #333;
}

.login-btn.linkedin {
  background-color: #0077b5;
}

.logout-link {
  display: inline-block;
  color: #007bff;
  text-decoration: none;
  font-size: 0.75rem;
  margin-left: 2px;
}

.logout-link:hover {
  text-decoration: underline;
}

.user-avatar-container {
  position: relative;
  width: 1.3rem;
  height: 1.3rem;
}

.user-avatar-container img.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar-container img.provider-icon {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
  padding: 1px;
}

#user-name {
  font-size: 0.9rem;
  font-weight: bold;
  margin-right: 0.5rem;
}

@media (max-width: 25rem) {
  #user-name {
    display: none;
  }
  .logout-link span {
    display: none;
  }
  .logout-link::after {
    content: '➜]';
  }
  .nav-right {
    gap: 0.5rem;
  }
}

/* Dialog Styling */
#confirm-move-dialog {
  padding: 0;
  border: none;
  border-radius: 8px;
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.1),
    0 1px 3px rgba(0, 0, 0, 0.08);
  max-width: 400px;
  width: 90%;
  font-family: inherit;
}

#confirm-move-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.dialog-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
}

.dialog-content h3 {
  margin: 0;
  font-size: 1.25rem;
  color: #333;
}

.dialog-content p {
  margin: 0;
  color: #666;
  line-height: 1.5;
}

.dialog-buttons {
  display: flex;
  gap: 1rem;
  width: 100%;
  margin-top: 0.5rem;
}

.dialog-buttons button {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.btn-primary {
  background-color: #007bff;
  color: white;
}

.btn-primary:hover {
  background-color: #0056b3;
}

.btn-secondary {
  background-color: #e9ecef;
  color: #333;
}

.btn-secondary:hover {
  background-color: #dde2e6;
}

.games-list {
  display: grid;
  grid-template-columns: 1fr 40px 40px minmax(max-content, 1.5fr) 40px 40px;
  list-style: none;
  padding: 0;
  width: 100%;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 5px;
}

.game-item {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / 7;
  border-bottom: 1px solid #eee;
  align-items: center;
}

.game-item:last-child {
  border-bottom: none;
}

.game-link {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / 5;
  text-decoration: none;
  color: #333;
  transition: background-color 0.2s;
  height: 100%;
  align-items: center;
  padding: 0.8em 0;
}

.game-item:hover {
  background-color: #f8f9fa;
}

.game-id {
  font-family: monospace;
  font-weight: bold;
  text-align: left;
  padding-left: 0.8rem;
}

.game-type {
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-type-icon {
  width: 1.2rem;
  height: 1.2rem;
  object-fit: contain;
}

.game-type {
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-type-icon {
  width: 1.2rem;
  height: 1.2rem;
  object-fit: contain;
}

.game-role {
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-date {
  font-size: 0.8rem;
  color: #777;
  text-align: left;
  padding-left: 0.8rem;
  white-space: nowrap;
}

.control-game-btn {
  text-decoration: none;
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity 0.2s;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-game-btn:hover {
  opacity: 1;
}

.delete-game-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  opacity: 0.6;
  transition: opacity 0.2s;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-game-btn:hover {
  opacity: 1;
}

.control-game-placeholder,
.delete-game-placeholder {
  width: 100%;
}

.recent-games {
  width: 100%;
}

/* Game Chooser Styles */
.game-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
  width: 100%;
  margin-top: 1rem;
}

.game-option-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.game-option-btn:hover {
  border-color: #007bff;
  background-color: #f8f9fa;
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.game-option-icon-wrapper {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  border-radius: 6px;
  flex-shrink: 0;
}

.game-option-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.game-option-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.game-option-info strong {
  font-size: 1.1rem;
  color: #333;
}

.game-option-info p {
  margin: 0;
  font-size: 0.85rem;
  color: #666;
  line-height: 1.3;
}
