* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #eee;
  min-height: 100vh;
}

h1, h2, h3 {
  margin-bottom: 1rem;
}

/* Buttons */
button {
  background: linear-gradient(135deg, #4a4ae4 0%, #6a6aff 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(74, 74, 228, 0.3);
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(74, 74, 228, 0.4);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  background: #444;
  cursor: not-allowed;
  box-shadow: none;
}

/* Inputs */
input[type="text"],
input[type="password"] {
  background: #2a2a4e;
  border: 2px solid #444;
  color: #eee;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
  max-width: 300px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: #4a4ae4;
  box-shadow: 0 0 0 3px rgba(74, 74, 228, 0.2);
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  gap: 1rem;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #333;
  border-top-color: #4a4ae4;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Auth Gate */
.auth-gate {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-loading {
  color: #888;
  font-size: 1.2rem;
}

.auth-box {
  background: rgba(30, 30, 60, 0.9);
  padding: 2.5rem;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 100%;
}

.auth-box h1 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.auth-box .auth-emoji {
  font-size: 18rem !important;
  line-height: 1;
  margin-bottom: 1rem;
}

.auth-box p {
  color: #aaa;
  margin-bottom: 1.5rem;
}

.auth-box form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.auth-box input {
  text-align: center;
}

.auth-error {
  color: #ff6b6b;
  margin-top: 1rem;
}

/* Home Page */
.home-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.home-page h1 {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 2rem;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.connection-status {
  text-align: center;
  color: #f0a030;
  margin-bottom: 1rem;
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.error-message {
  background: linear-gradient(135deg, #c0392b 0%, #e74c3c 100%);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.error-message button {
  background: transparent;
  border: 1px solid #fff;
  padding: 0.25rem 0.5rem;
  box-shadow: none;
}

.rejoin-prompt {
  background: linear-gradient(135deg, #2a2a4e 0%, #3a3a5e 100%);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 2rem;
  text-align: center;
  border: 2px solid #4a4ae4;
  animation: fadeIn 0.3s ease;
}

.rejoin-prompt p {
  margin-bottom: 1rem;
}

.rejoin-prompt button {
  margin: 0 0.5rem;
}

.player-setup,
.create-game,
.join-game,
.game-list {
  position: relative;
  background: rgba(42, 42, 78, 0.8);
  backdrop-filter: blur(10px);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.create-game {
  z-index: 10;
  transition: transform 0.2s ease;
}

.player-setup:hover,
.create-game:hover,
.join-game:hover {
  transform: translateY(-2px);
}

.player-setup input,
.create-game input,
.join-game input {
  display: block;
  margin-bottom: 1rem;
}

.create-game label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
}

.game-list h2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-list h2 button {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

.game-list ul {
  list-style: none;
}

.game-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(26, 26, 46, 0.8);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  transition: background 0.2s ease;
}

.game-list li:hover {
  background: rgba(26, 26, 46, 1);
}

/* Game Page */
.game-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.game-header {
  background: rgba(42, 42, 78, 0.95);
  backdrop-filter: blur(10px);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.game-header h1 {
  font-size: 1.5rem;
  margin: 0;
}

.game-phase {
  background: linear-gradient(135deg, #4a4ae4 0%, #6a6aff 100%);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: capitalize;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.pause-button {
  background: transparent;
  border: 2px solid #f0a030;
  color: #f0a030;
  box-shadow: none;
}

.pause-button:hover:not(:disabled) {
  background: #f0a030;
  color: #111;
}

.leave-button {
  background: transparent;
  border: 2px solid #c0392b;
  color: #e74c3c;
  box-shadow: none;
}

.leave-button:hover:not(:disabled) {
  background: #c0392b;
  color: white;
}

.game-content {
  display: flex;
  flex: 1;
}

/* Scoreboard */
.scoreboard {
  width: 280px;
  background: rgba(42, 42, 78, 0.9);
  padding: 1.5rem;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

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

.scoreboard h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

/* Mobile-only scoreboard elements - hidden on desktop */
.scoreboard-title-row {
  display: none;
}

.scoreboard-actions {
  display: none;
}

.scoreboard-toggle {
  display: none;
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
}

.hamburger-icon {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 24px;
}

.hamburger-icon span {
  display: block;
  height: 3px;
  background: #fff;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.scoreboard.expanded .hamburger-icon span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.scoreboard.expanded .hamburger-icon span:nth-child(2) {
  opacity: 0;
}

.scoreboard.expanded .hamburger-icon span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

.player-list {
  list-style: none;
}

.player-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(26, 26, 46, 0.8);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.player-item.disconnected {
  opacity: 0.5;
}

.player-item.card-czar {
  border-color: #f0c040;
  background: rgba(240, 192, 64, 0.1);
}

.player-name {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
}

.host-badge {
  background: #27ae60;
}

.czar-badge {
  background: #f0c040;
  color: #333;
}

.you-badge {
  background: #4a4ae4;
}

.player-score {
  font-weight: bold;
  color: #4a4ae4;
  font-size: 1rem;
}

.submitted-indicator {
  color: #2ecc71;
  font-size: 1.2rem;
}

.disconnected-indicator {
  color: #e74c3c;
  font-size: 1rem;
}

.kick-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: #c0392b;
  box-shadow: none;
}

.game-area {
  flex: 1;
  padding: 2rem;
  animation: fadeIn 0.3s ease;
}

/* Cards */
.black-card {
  background: linear-gradient(135deg, #111 0%, #222 100%);
  color: #fff;
  padding: 1.5rem;
  border-radius: 12px;
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.5;
  min-height: 150px;
  margin-bottom: 2rem;
  max-width: 400px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  border: 3px solid #333;
}

.white-card {
  background: linear-gradient(135deg, #fff 0%, #f5f5f5 100%);
  color: #111;
  padding: 1rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  min-height: 100px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  border: 3px solid transparent;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.white-card.clickable:hover {
  transform: translateY(-6px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.white-card.selected {
  border-color: #4a4ae4;
  transform: translateY(-8px);
  box-shadow: 0 8px 20px rgba(74, 74, 228, 0.3);
}

.white-card.disabled {
  cursor: default;
}

.white-card.disabled:hover {
  transform: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.selection-order {
  position: absolute;
  top: -10px;
  right: -10px;
  background: linear-gradient(135deg, #4a4ae4 0%, #6a6aff 100%);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.875rem;
  box-shadow: 0 2px 8px rgba(74, 74, 228, 0.4);
  animation: pop 0.2s ease;
}

@keyframes pop {
  0% { transform: scale(0); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Hand */
.hand-container {
  margin-top: 1.5rem;
}

.hand {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.submit-button {
  display: block;
  margin: 0 auto;
}

/* Game Lobby */
.game-lobby {
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
}

.lobby-header {
  margin-bottom: 2rem;
}

.game-code {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.game-code code {
  background: rgba(74, 74, 228, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 1.5rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  border: 2px dashed #4a4ae4;
}

.player-count {
  margin-bottom: 1.5rem;
}

.player-count .count {
  font-size: 4rem;
  font-weight: bold;
  display: block;
  color: #4a4ae4;
}

.player-count .label {
  font-size: 1.25rem;
  color: #888;
}

.waiting-message {
  color: #888;
  margin-bottom: 1.5rem;
}

.start-button {
  font-size: 1.25rem;
  padding: 1rem 2rem;
}

.lobby-tips {
  margin-top: 3rem;
  text-align: left;
  background: rgba(26, 26, 46, 0.8);
  padding: 1.5rem;
  border-radius: 12px;
}

.lobby-tips h3 {
  margin-bottom: 1rem;
  color: #888;
}

.lobby-tips ul {
  list-style: none;
}

.lobby-tips li {
  padding: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
  color: #aaa;
}

.lobby-tips li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #4a4ae4;
}

/* Paused Phase */
.paused-phase {
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
  padding: 2rem;
  background: rgba(240, 160, 48, 0.1);
  border: 2px solid #f0a030;
  border-radius: 12px;
  animation: fadeIn 0.3s ease;
}

.paused-phase h2 {
  color: #f0a030;
  margin-bottom: 1rem;
}

.paused-phase .paused-message {
  color: #aaa;
  margin-bottom: 1rem;
}

.paused-phase .player-count {
  font-size: 1.1rem;
  color: #4a4ae4;
  margin-bottom: 1rem;
}

.paused-phase .game-code {
  margin-bottom: 1.5rem;
}

.paused-phase .game-code strong {
  background: rgba(74, 74, 228, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 1.5rem;
  letter-spacing: 0.1em;
  border: 2px dashed #4a4ae4;
  display: inline-block;
  margin-left: 0.5rem;
}

.resume-button {
  font-size: 1.25rem;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #f0a030 0%, #e09020 100%);
}

.resume-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #e09020 0%, #d08010 100%);
}

.min-players-warning {
  color: #e74c3c;
  margin-top: 1rem;
  font-size: 0.9rem;
}

/* Playing Phase */
.playing-phase {
  text-align: center;
}

.playing-phase h2 {
  margin-bottom: 1.5rem;
}

.czar-message,
.wait-message {
  color: #888;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.waiting-section {
  text-align: center;
}

.pending-players {
  color: #e74c3c;
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 1.5rem;
  animation: shake 0.5s ease-in-out infinite;
}

.pending-player {
  display: block;
  margin: 0.5rem 0;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

.force-end-button {
  background: transparent;
  border: 2px solid #f0a030;
  color: #f0a030;
  box-shadow: none;
}

.force-end-button:hover:not(:disabled) {
  background: #f0a030;
  color: #111;
}

/* Answer Selection / Judging */
.answer-selection {
  text-align: center;
}

.answer-selection h2 {
  margin-bottom: 1.5rem;
}

.answer-selection.empty {
  color: #888;
}

.submissions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.submission {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: rgba(42, 42, 78, 0.8);
  border-radius: 12px;
  transition: all 0.2s ease;
  border: 3px solid transparent;
  position: relative;
}

.submission.clickable {
  cursor: pointer;
}

.submission.clickable:hover {
  border-color: rgba(74, 74, 228, 0.5);
  transform: translateY(-4px);
}

.submission.selected {
  border-color: #4a4ae4;
  background: rgba(74, 74, 228, 0.1);
}

.submission-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.submission .white-card {
  cursor: default;
}

.submission .white-card:hover {
  transform: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.selection-indicator {
  position: absolute;
  top: -10px;
  right: -10px;
  background: linear-gradient(135deg, #4a4ae4 0%, #6a6aff 100%);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  animation: pop 0.2s ease;
}

.select-winner-button {
  margin-top: 1rem;
}

/* Card-by-Card View */
.answer-selection.card-view {
  outline: none;
}

.card-navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  margin: 2rem 0;
}

.nav-button {
  background: rgba(42, 42, 78, 0.9);
  border: 2px solid #4a4ae4;
  color: #4a4ae4;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nav-button:hover:not(:disabled) {
  background: #4a4ae4;
  color: white;
  transform: scale(1.1);
}

.nav-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-placeholder {
  width: 60px;
  height: 60px;
}

.current-submission {
  flex: 1;
  max-width: 400px;
}

.submission-cards-display {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(42, 42, 78, 0.8);
  padding: 1.5rem;
  border-radius: 12px;
  border: 2px solid rgba(74, 74, 228, 0.3);
  min-height: 150px;
}

.submission-cards-display .white-card {
  cursor: default;
}

.card-progress {
  text-align: center;
  font-size: 1.1rem;
  color: #888;
  margin-bottom: 1.5rem;
}

.view-actions {
  text-align: center;
  margin-top: 1rem;
}

.view-actions.top {
  margin-top: 0;
  margin-bottom: 1rem;
}

.switch-view-button {
  background: linear-gradient(135deg, #4a4ae4 0%, #6a6af4 100%);
  border: none;
  color: white;
  font-size: 1.1rem;
  padding: 1rem 2rem;
  box-shadow: 0 4px 15px rgba(74, 74, 228, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 15px rgba(74, 74, 228, 0.4); }
  50% { box-shadow: 0 4px 25px rgba(74, 74, 228, 0.7); }
}

.switch-view-button:hover:not(:disabled) {
  background: linear-gradient(135deg, #5a5af4 0%, #7a7aff 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 74, 228, 0.5);
}

/* Czar vs Player styling for judging phase */
.answer-selection.is-czar {
  background: linear-gradient(135deg, rgba(74, 74, 228, 0.15) 0%, rgba(138, 43, 226, 0.1) 100%);
  border-radius: 12px;
  padding: 1.5rem;
  border: 3px solid rgba(74, 74, 228, 0.5);
  box-shadow: 0 0 30px rgba(74, 74, 228, 0.2), inset 0 0 60px rgba(74, 74, 228, 0.05);
}

.answer-selection.is-czar h2 {
  color: #8a8aff;
}

.answer-selection.is-czar::before {
  content: "You are the Card Czar - Pick the winner!";
  display: block;
  background: linear-gradient(135deg, #4a4ae4 0%, #6a3ac4 100%);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: bold;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.answer-selection.is-player {
  background: rgba(40, 40, 50, 0.5);
  border-radius: 12px;
  padding: 1.5rem;
  border: 2px dashed rgba(100, 100, 120, 0.3);
  opacity: 0.85;
}

.answer-selection.is-player h2 {
  color: #666;
}

.answer-selection.is-player::before {
  content: "Waiting for Card Czar to decide...";
  display: block;
  background: rgba(100, 100, 120, 0.3);
  color: #888;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Responsive card navigation */
@media (max-width: 600px) {
  .card-navigation {
    gap: 1rem;
  }

  .nav-button {
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
  }

  .nav-placeholder {
    width: 45px;
    height: 45px;
  }

  .current-submission {
    max-width: none;
  }
}

/* Round Winner */
.round-winner {
  margin-top: 2rem;
  padding: 2rem;
  background: linear-gradient(135deg, rgba(39, 174, 96, 0.2) 0%, rgba(46, 204, 113, 0.2) 100%);
  border: 3px solid #27ae60;
  border-radius: 16px;
  text-align: center;
  animation: winnerPop 0.4s ease;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

@keyframes winnerPop {
  0% { transform: scale(0.9); opacity: 0; }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); opacity: 1; }
}

.round-winner h3 {
  color: #2ecc71;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

.round-winner .black-card {
  margin: 0 auto 1.5rem;
  max-width: 350px;
}

.winning-cards {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.winning-cards .white-card {
  cursor: default;
  max-width: 220px;
  border-color: #27ae60;
  border-width: 3px;
  box-shadow: 0 6px 20px rgba(39, 174, 96, 0.3);
}

.winning-cards .white-card:hover {
  transform: none;
  box-shadow: 0 6px 20px rgba(39, 174, 96, 0.3);
}

/* Round Winner Leaderboard */
.round-winner-leaderboard {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.round-winner-leaderboard h4 {
  color: #fff;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.leaderboard-list {
  list-style: none;
  max-width: 300px;
  margin: 0 auto;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.leaderboard-item.gold {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.3) 0%, rgba(255, 193, 7, 0.2) 100%);
  border: 1px solid #ffd700;
}

.leaderboard-item.silver {
  background: linear-gradient(135deg, rgba(192, 192, 192, 0.3) 0%, rgba(169, 169, 169, 0.2) 100%);
  border: 1px solid #c0c0c0;
}

.leaderboard-item.bronze {
  background: linear-gradient(135deg, rgba(205, 127, 50, 0.3) 0%, rgba(184, 115, 51, 0.2) 100%);
  border: 1px solid #cd7f32;
}

.leaderboard-item.loser {
  background: rgba(100, 50, 50, 0.2);
  border: 1px solid rgba(200, 100, 100, 0.3);
}

.leaderboard-rank {
  font-weight: bold;
  color: #888;
  min-width: 1.5rem;
  font-size: 1rem;
}

.leaderboard-item.gold .leaderboard-rank {
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.leaderboard-item.silver .leaderboard-rank {
  color: #c0c0c0;
  text-shadow: 0 0 10px rgba(192, 192, 192, 0.5);
}

.leaderboard-item.bronze .leaderboard-rank {
  color: #cd7f32;
  text-shadow: 0 0 10px rgba(205, 127, 50, 0.5);
}

.leaderboard-item.loser .leaderboard-rank {
  font-size: 1.2rem;
}

.leaderboard-name {
  flex: 1;
  text-align: left;
}

.leaderboard-score {
  font-weight: bold;
  color: #2ecc71;
}

.leaderboard-item.gold .leaderboard-score {
  color: #ffd700;
}

.leaderboard-item.silver .leaderboard-score {
  color: #c0c0c0;
}

.leaderboard-item.bronze .leaderboard-score {
  color: #cd7f32;
}

.leaderboard-item.loser .leaderboard-score {
  color: #888;
}

/* Name Editor */
.name-editor {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.name-editor input {
  max-width: 150px;
}

.name-editor .edit-btn,
.name-editor .save-btn,
.name-editor .cancel-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.name-editor .cancel-btn {
  background: transparent;
  border: 1px solid #888;
  color: #888;
  box-shadow: none;
}

/* Responsive */
@media (max-width: 768px) {
  .game-content {
    flex-direction: column;
  }

  /* Hide the separate game header on mobile - combined into scoreboard */
  .game-header {
    display: none;
  }

  .scoreboard {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem;
  }

  /* Show mobile-specific elements in scoreboard */
  .scoreboard-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
  }

  .scoreboard-game-title {
    font-size: 1.1rem;
    margin: 0 !important;
    white-space: nowrap;
  }

  .scoreboard-phase {
    background: linear-gradient(135deg, #4a4ae4 0%, #6a6aff 100%);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
  }

  /* Hide Players title when collapsed, show game title instead */
  .scoreboard-players-title {
    display: none;
  }

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

  .scoreboard h2 {
    margin-bottom: 0;
  }

  .scoreboard-toggle {
    display: block;
  }

  .scoreboard.collapsed .scoreboard-content {
    display: none;
  }

  .scoreboard.expanded .scoreboard-content {
    display: block;
    margin-top: 1rem;
  }

  /* Show Players title and actions when expanded */
  .scoreboard.expanded .scoreboard-players-title {
    display: block;
    margin-bottom: 0.5rem;
  }

  .scoreboard.expanded .scoreboard-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
  }

  .scoreboard-actions button {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }

  .hand {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .submissions {
    grid-template-columns: 1fr;
  }

  /* Auth gate responsive */
  .auth-box .auth-emoji {
    font-size: 10rem !important;
  }

  /* Czar/Player banners more compact */
  .answer-selection.is-czar::before,
  .answer-selection.is-player::before {
    font-size: 0.75rem;
    padding: 0.4rem 0.75rem;
  }

  .answer-selection.is-czar,
  .answer-selection.is-player {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .home-page {
    padding: 1rem;
  }

  .home-page h1 {
    font-size: 1.75rem;
  }

  .player-setup,
  .create-game,
  .join-game,
  .game-list {
    padding: 1rem;
  }

  .game-area {
    padding: 0.75rem;
  }

  .black-card {
    font-size: 1rem;
    padding: 1rem;
    min-height: 100px;
    max-width: 100%;
    margin-bottom: 1rem;
  }

  .hand {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .white-card {
    font-size: 0.85rem;
    padding: 0.75rem;
    min-height: 70px;
  }

  /* Scoreboard title even more compact on small screens */
  .scoreboard-game-title {
    font-size: 1rem;
  }

  .scoreboard-phase {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
  }

  /* Auth gate responsive */
  .auth-box .auth-emoji {
    font-size: 8rem !important;
  }

  .auth-box {
    padding: 1.5rem;
  }

  .auth-box p {
    font-size: 0.9rem;
  }

  /* Game list items stack on mobile */
  .game-list li {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .game-list li span {
    font-size: 0.9rem;
  }

  .game-list li button {
    width: 100%;
  }

  /* Playing phase */
  .playing-phase h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
  }

  /* Waiting message */
  .wait-message {
    font-size: 1rem;
  }

  .pending-players {
    font-size: 1rem;
  }

  /* Round winner */
  .round-winner {
    padding: 1rem;
    margin-top: 1rem;
  }

  .round-winner h3 {
    font-size: 1.2rem;
  }

  .round-winner .black-card {
    max-width: 100%;
  }

  .winning-cards .white-card {
    max-width: 100%;
  }

  /* Leaderboard */
  .leaderboard-list {
    max-width: 100%;
  }

  /* Card navigation */
  .card-navigation {
    gap: 0.5rem;
    margin: 1rem 0;
  }

  .nav-button {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .nav-placeholder {
    width: 40px;
    height: 40px;
  }

  .card-progress {
    font-size: 0.95rem;
    margin-bottom: 1rem;
  }

  .switch-view-button {
    font-size: 0.95rem;
    padding: 0.75rem 1.25rem;
  }

  /* Submission cards display */
  .submission-cards-display {
    padding: 1rem;
    min-height: 100px;
  }

  /* Paused phase */
  .paused-phase {
    padding: 1rem;
  }

  .paused-phase h2 {
    font-size: 1.3rem;
  }

  .paused-phase .game-code strong {
    font-size: 1.2rem;
    padding: 0.4rem 0.75rem;
  }

  .resume-button {
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
  }

  /* Lobby */
  .game-lobby {
    padding: 0;
  }

  .player-count .count {
    font-size: 3rem;
  }

  .game-code code {
    font-size: 1.2rem;
    padding: 0.4rem 0.75rem;
  }

  .start-button {
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
  }

  .lobby-tips {
    margin-top: 2rem;
    padding: 1rem;
  }

  /* Buttons general */
  button {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }

  /* Inputs */
  input[type="text"],
  input[type="password"] {
    max-width: 100%;
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #333;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideInRight 0.3s ease-out;
  pointer-events: auto;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast-info {
  background: linear-gradient(135deg, #2196f3, #1976d2);
  border-left: 4px solid #64b5f6;
}

.toast-success {
  background: linear-gradient(135deg, #4caf50, #388e3c);
  border-left: 4px solid #81c784;
}

.toast-warning {
  background: linear-gradient(135deg, #ff9800, #f57c00);
  border-left: 4px solid #ffb74d;
}

.toast-error {
  background: linear-gradient(135deg, #f44336, #d32f2f);
  border-left: 4px solid #e57373;
}

.toast-message {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.4;
}

.toast-dismiss {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}

.toast-dismiss:hover {
  color: white;
}

/* Connection Status */
.connection-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.3);
}

.connection-indicator .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.connection-indicator.connected .status-dot {
  background: #4caf50;
  box-shadow: 0 0 6px #4caf50;
}

.connection-indicator.disconnected .status-dot {
  background: #f44336;
  box-shadow: 0 0 6px #f44336;
}

.connection-indicator.reconnecting .status-dot {
  background: #ff9800;
  box-shadow: 0 0 6px #ff9800;
  animation: pulse 0.5s infinite;
}

/* Disconnected Player */
.player-item.disconnected {
  opacity: 0.5;
}

.player-item .disconnect-badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  background: #f44336;
  color: white;
  border-radius: 3px;
  margin-left: 0.25rem;
}

@media (max-width: 480px) {
  .toast-container {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}

/* Pack Selector */
.pack-selector {
  position: relative;
  isolation: isolate;
  z-index: 100;
  width: 100%;
  max-width: 300px;
  margin-bottom: 1rem;
}

.pack-selector-trigger {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #2a2a4e;
  border: 2px solid #444;
  border-radius: 8px;
  color: #eee;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.pack-selector-trigger:hover {
  border-color: #4a4ae4;
}

.dropdown-arrow {
  font-size: 0.75rem;
  color: #888;
}

.pack-selector-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #2a2a4e;
  border: 2px solid #4a4ae4;
  border-radius: 8px;
  margin-top: 0.25rem;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-height: 350px;
  display: flex;
  flex-direction: column;
}

.pack-selector-search {
  padding: 0.75rem;
  border-bottom: 1px solid #444;
}

.pack-selector-search input {
  width: 100%;
  max-width: none;
  margin: 0;
}

.pack-selector-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #444;
}

.pack-selector-actions button {
  flex: 1;
  padding: 0.5rem;
  font-size: 0.875rem;
  background: rgba(74, 74, 228, 0.2);
  border: 1px solid #4a4ae4;
  color: #4a4ae4;
  box-shadow: none;
}

.pack-selector-actions button:hover {
  background: #4a4ae4;
  color: white;
}

.pack-selector-list {
  overflow-y: auto;
  max-height: 200px;
  padding: 0.5rem;
}

.pack-selector-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.pack-selector-item:hover {
  background: rgba(74, 74, 228, 0.15);
}

.pack-selector-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #4a4ae4;
  cursor: pointer;
}

.pack-selector-item span {
  flex: 1;
  font-size: 0.9rem;
  color: #ddd;
}

.pack-selector-empty {
  padding: 1rem;
  text-align: center;
  color: #888;
}

.pack-selector-info {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid #444;
}

.pack-selector-info small {
  color: #888;
  font-size: 0.8rem;
}
