* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0a1420;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #eaf6ff;
}

.hidden {
  display: none !important;
}

#back-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 30;
  background: rgba(6, 14, 22, 0.65);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  color: #eaf6ff;
  text-decoration: none;
}

#back-link:hover {
  background: rgba(6, 14, 22, 0.85);
}

#lobby {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(20, 40, 60, 0.6), rgba(4, 10, 16, 0.9));
}

.panel {
  background: rgba(8, 18, 28, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2rem 2.5rem;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  text-align: center;
  max-width: 420px;
  width: min(90vw, 420px);
  max-height: 90vh;
  overflow-y: auto;
}

.panel h1 {
  margin: 0 0 0.5rem;
  background: linear-gradient(90deg, #34e89e, #3b9dff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.panel h3 {
  margin: 1rem 0 0.25rem;
  font-size: 0.85rem;
  color: #a7bdd1;
  text-align: left;
}

.tagline {
  color: #a7bdd1;
  font-size: 0.9rem;
  margin: 0 0 0.75rem;
}

.mode-hint {
  color: #6b8199;
  font-size: 0.85rem;
}

.player-list {
  list-style: none;
  margin: 0.5rem 0 1rem;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.player-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.9rem;
}

.player-list .score {
  color: #a7bdd1;
  font-variant-numeric: tabular-nums;
}

button {
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #34e89e, #3b9dff);
  color: #04121c;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.small-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

#mode-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 0.5rem 0;
}

.mode-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #eaf6ff;
}

.mode-btn.active {
  background: linear-gradient(135deg, #34e89e, #3b9dff);
  color: #04121c;
}

#game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#top-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  padding-left: 9rem;
  background: rgba(6, 14, 22, 0.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

@media (max-width: 480px) {
  #top-bar {
    padding-left: 1rem;
    padding-top: 3rem;
    flex-wrap: wrap;
  }
}

#round-status {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 1rem;
}

#board {
  display: grid;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px;
  border-radius: 12px;
}

#board.mode-tictactoe .cell {
  width: min(24vw, 100px);
  height: min(24vw, 100px);
  font-size: min(10vw, 3rem);
}

#board.mode-connect4 .cell {
  width: min(11vw, 60px);
  height: min(11vw, 60px);
  font-size: min(6vw, 2rem);
}

.cell {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.cell:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
}

#seat-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(6, 14, 22, 0.75);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
