/* --- Branding / General Layout --- */
body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background-color: #1c2734;
  color: white;
  min-height: 100vh;
}

.container {
  text-align: center;
  padding: 2rem;
}

header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}

.logo {
  font-size: 48px;
  font-weight: bold;
  color: #f5a623;
}

.logo-icon {
  display: inline-block;
  transform: rotate(-20deg);
}

.subtitle {
  font-size: 24px;
  margin: 8px 0 40px;
}

.button,
.actions button,
.auto-queue-btn {
  font-size: 18px;
  font-weight: bold;
  color: black;
  background-color: #f5a623;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.button {
  display: inline-block;
  margin: 20px 0;
  padding: 12px 30px;
}

.button:hover,
.actions button:hover,
.auto-queue-btn:hover {
  background-color: #ffb84d;
}

/* --- Header Buttons for Desktop --- */
.actions {
  margin-top: 1rem;
}

.actions button {
  margin: 0.5rem;
  padding: 0.6rem 1rem;
}
.actions select {
  margin: 0.5rem;
  padding: 0.6rem 1rem;
}
#open-settings {
  font-size: 1.2rem;
}

.settings-modal {
  width: 90%;
  max-width: 400px;
  padding: 1rem;
  border: none;
  border-radius: 12px;
  background-color: #2c2c2c;
  color: white;
  font-family: 'Segoe UI', sans-serif;
}
.settings-modal label {
  display: block;
  margin-top: 0.5rem;
}
.settings-modal select,
.settings-modal input[type="range"] {
  width: 100%;
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
}

/* --- Courts Section --- */
.courts {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.court {
  background-color: #2c2c2c;
  border-radius: 12px;
  width: 140px;
  padding: 0.8rem;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  transition: transform 0.2s;
  position: relative;
}

.court.new-players::after {
  content: "";
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: inherit;
  border: 4px solid #f5a623;
  pointer-events: none;
  animation: court-fade 30s forwards;
}

.court.highlight-target {
  outline: 3px dashed #f5a623;
}

@keyframes court-fade {
  from { opacity: 1; }
  to { opacity: 0; }
}

.court:hover {
  transform: translateY(-4px);
}

.court-number {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.court-players {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.court-players.empty {
  color: #aaa;
  font-style: italic;
}

/* --- Player in Court --- */
.player {
  background-color: #f5a623;
  color: #000;
  border-radius: 6px;
  padding: 0.4rem;
  font-weight: bold;
}

/* --- Auto Queue Button --- */
.auto-queue-container {
  text-align: center;
  margin-bottom: 2rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.auto-queue-btn {
  padding: 0.8rem 2rem;
}

/* --- Queues Section --- */
.queues {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: center;
}

.queue-box {
  background-color: #2c2c2c;
  padding: 1rem;
  border-radius: 12px;
  flex: 1 1 300px;
}

.queue-box h2 {
  margin-top: 0;
  font-size: 1.4rem;
}

.queue-players {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.queue-player {
  background-color: #f5a623;
  color: #000;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}

.queue-player:hover {
  transform: scale(1.05);
}

/* --- Queue Group Styles --- */
.queue-group {
  border: 2px dashed orange;
  border-radius: 10px;
  padding: 6px;
  margin: 8px;
  position: relative;
  min-width: 150px;
  flex: 0 0 calc(50% - 2rem); /* two per row with spacing */
  box-sizing: border-box;
}
.queue-group.selected {
  border-color: #f5a623;
  box-shadow: 0 0 8px 2px rgba(245, 166, 35, 0.7);
}

.group-label {
  position: absolute;
  top: -12px;
  left: -12px;
  background-color: orange;
  color: black;
  font-weight: bold;
  width: 24px;
  height: 24px;
  text-align: center;
  border-radius: 50%;
  line-height: 24px;
  font-size: 0.75rem;
}

.clear-group-icon {
  position: absolute;
  top: -12px;
  right: -12px;
  font-size: 1rem;
  color: red;
  cursor: pointer;
  display: none;
  user-select: none;
}

.queue-group:hover .clear-group-icon {
  display: inline;
}

.group-players {
  min-height: 100px; /* adjust to match your UI */
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: auto;
  gap: 4px;
  align-content: start;
  box-sizing: border-box;
}



/* --- Session Info (Desktop) --- */
.session-info p {
  font-size: 1.2rem;
  margin: 0.5rem 0;
}

/* --- Courts and Player Queue Titles --- */
.courts-display h3,
.queue-display h3 {
  font-size: 1.6rem;
  margin-bottom: 1rem;
}

/* --- Player Selection Modal --- */
.player-modal {
  width: 70%;
  max-width: 675px;
  padding: 1rem;
  box-sizing: border-box;
  border: none;
  border-radius: 12px;
  background-color: #2c2c2c;
  color: white;
}

.player-modal:not([open]) {
  display: none;
}

/* full height layout for the player selection modal */
.player-selection-modal {
  height: 100vh;
}

.player-selection-modal[open] {
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close-btn {
  font-size: 24px;
  background: none;
  color: white;
  border: none;
  cursor: pointer;
}

.player-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 1rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin: 1rem 0;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #444;
  padding: 0.5rem;
  border-radius: 6px;
}

.player-item input[type="checkbox"] {
  transform: scale(1.4);
}

.confirm-button {
  width: 100%;
}

.new-player-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.new-player-form input,
.new-player-form select {
  padding: 0.5rem;
  border-radius: 6px;
  border: none;
}

/* --- Player Card for Selection Modal --- */
.player-card {
  background-color: #444;
  border-radius: 8px;
  padding: 0.5rem;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
}

.player-card:hover {
  transform: scale(1.05);
}

.player-card.selected {
  border-color: #f5a623;
  box-shadow: 0 0 8px 2px rgba(245, 166, 35, 0.7);
}

.player-photo {
  width: 45px;
  height: 45px;
  object-fit: cover;
  border-radius: 50%;
  margin-bottom: 0.5rem;
}

.player-name {
  font-weight: bold;
  font-size: 0.8rem;
}

.player-username {
  font-size: 0.7rem;
  color: #ccc;
}

.player-skill {
  font-size: 0.7rem;
  margin-top: 0.2rem;
  color: #f5a623;
}

.remove-icon {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  line-height: 16px;
  border-radius: 50%;
  background-color: #f44336;
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
  display: none;
}

#waiting .player-card .remove-icon {
  display: block;
}

/* --- Selected Players Display --- */
.selected-count {
  text-align: center;
  margin-bottom: 0.5rem;
  font-weight: bold;
}

.selected-summary {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  text-align: center;
  color: #f5a623;
  font-weight: bold;
}

.player-modal-actions {
  margin-top: auto;
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
}

.player-modal-actions .button {
  margin: 0;
}

.player-modal-actions .confirm-button {
  width: auto;
}

.selected-players-list {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.selected-players-list.empty {
  color: #aaa;
  font-style: italic;
}

.clear-button {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  background-color: #555;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.clear-button:hover {
  background-color: #777;
}

/* --- Small Player Cards Scoped to Desktop Queue --- */
#desktop-queue .player-card {
  width: auto;
  min-width: 60px;
  height: 40px;
  padding: 0 8px;
  background-color: #c09000;
  color: black;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}

/* Hide details inside the card (we’ll show them in tooltip instead) */
#desktop-queue .player-card .player-name,
#desktop-queue .player-card .player-username,
#desktop-queue .player-card .player-skill,
#desktop-queue .player-card img {
  display: none;
}


#player-tooltip {
  background-color: #333;
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  max-width: 220px;
  box-shadow: 0 0 8px rgba(0,0,0,0.5);
  font-size: 0.75rem;
  line-height: 1.3;
  white-space: normal;
  pointer-events: none;
  text-align: center;
}

#player-tooltip .histogram {
  margin-top: 4px;
  text-align: left;
}

#player-tooltip .histogram-title {
  font-size: 0.7rem;
  color: #ddd;
  margin-bottom: 2px;
}

#player-tooltip .histogram-row {
  display: flex;
  align-items: center;
  margin-top: 2px;
  font-size: 0.65rem;
}

#player-tooltip .histogram-label {
  width: 60px;
  color: #eee;
}

#player-tooltip .histogram-bar {
  flex-grow: 1;
  height: 6px;
  background-color: #4caf50;
  margin: 0 4px;
  border-radius: 3px;
}

#player-tooltip .histogram-count {
  width: 20px;
  text-align: right;
}


.group-placeholder {
  width: 60px;
  height: 60px;
  border: 2px dashed orange;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: orange;
  font-size: 1.5rem;
}

#waiting {
  min-height: 200px;             /* big enough to always stay visible */
  border: 2px dashed #444;       /* optional: makes the area obvious */
  padding: 0.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 16px;
  align-content: start;          /* ensures items pack to the top */
  box-sizing: border-box;
}

.court-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.end-game-icon {
  font-size: 1.2rem;
  color: red;
  cursor: pointer;
  display: none;
  user-select: none;
}

.court:hover .end-game-icon {
  display: inline;
}

.score-modal {
  width: 90%;
  max-width: 500px;
  padding: 1rem;
  border: none;
  border-radius: 12px;
  background-color: #2c2c2c;
  color: white;
  font-family: 'Segoe UI', sans-serif;
}

.score-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.score-modal .modal-header h2 {
  font-size: 1.4rem;
}

.score-modal .modal-header button {
  font-size: 1.6rem;
  background: none;
  color: white;
  border: none;
  cursor: pointer;
}

.score-modal .pair-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.5rem 0;
}

.score-modal .pair-label {
  flex: 1;
  font-weight: bold;
}

.score-modal .score-controls {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.score-modal input[type="number"] {
  width: 60px;
  padding: 0.4rem;
  border-radius: 8px;
  border: none;
  text-align: center;
  font-size: 1rem;
}

.score-modal .modal-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
}

.score-modal button {
  flex: 1;
  margin: 0 0.5rem;
  padding: 0.6rem;
  font-weight: bold;
  font-size: 1rem;
  background-color: #f5a623;
  color: black;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.score-modal button:hover {
  background-color: #ffb84d;
}

#desktop-queue .player-card {
  position: relative;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 0.75rem;
  padding: 4px;
  text-align: center;
  white-space: normal;
  display: flex;
}

#desktop-queue .player-card .main-name {
  font-weight: bold;
  font-size: 0.8rem;
  color: black;
}

#desktop-queue .player-card .game-badge {
  position: absolute;
  bottom: -4px;
  left: -4px;
  background-color: #2c2c2c;
  color: white;
  font-size: 0.65rem;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #aaa;
  font-weight: bold;
}

