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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  color: #333;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Header */
.game-header {
  text-align: center;
  margin-bottom: 30px;
  color: white;
}

.game-header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.game-info span {
  font-size: 1.2em;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 16px;
  border-radius: 20px;
}

/* Score display */
.score-display {
  background: rgba(255, 255, 255, 0.25);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 1.2em;
  font-weight: 600;
}

/* Rank display */
.rank-display {
  background: rgba(255, 215, 0, 0.3);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 1.2em;
  font-weight: 700;
}

/* Admin Header */
.admin-header {
  text-align: center;
  margin-bottom: 30px;
  color: white;
}

.admin-header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.admin-header .admin-actions {
  margin-top: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
}

.btn-primary {
  background: #4CAF50;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #45a049;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.9);
  color: #667eea;
}

.btn-secondary:hover {
  background: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-danger {
  background: #f44336;
  color: white;
}

.btn-danger:hover {
  background: #da190b;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Grid Container */
.grid-container {
  display: grid;
  gap: 10px;
  max-width: 800px;
  margin: 0 auto 30px;
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.grid-tile {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px;
  background: #f5f5f5;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 0.9em;
  cursor: default;
  transition: all 0.2s ease;
  user-select: none;
}

.grid-tile.disabled {
  cursor: default;
  opacity: 0.9;
}

.grid-tile.tile-clickable {
  cursor: pointer;
}

.grid-tile.tile-clickable:hover {
  transform: scale(1.03);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.grid-tile.tile-validated {
  background: #4CAF50;
  color: white;
  border-color: #45a049;
}

.tile-grid-text {
  font-size: 0.95em;
  margin-bottom: 4px;
}

.rarity-badge {
  font-size: 0.75em;
  opacity: 0.8;
  font-weight: 600;
}

/* Error Message */
.error-message {
  background: #f44336;
  color: white;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  text-align: center;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 40px;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  position: relative;
}

.modal-content h2 {
  margin-bottom: 20px;
  color: #667eea;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 1em;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #667eea;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

/* Leaderboard */
.leaderboard-container {
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 800px;
  margin: 0 auto;
}

.leaderboard-container h2 {
  margin-bottom: 20px;
  color: #667eea;
  text-align: center;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 15px;
  text-align: left;
  border-bottom: 1px solid #ddd;
}

.leaderboard-table th {
  background: #f5f5f5;
  font-weight: 600;
  color: #333;
}

.leaderboard-table tr:hover {
  background: #f9f9f9;
}

.rank-1 { color: #FFD700; font-weight: bold; }
.rank-2 { color: #C0C0C0; font-weight: bold; }
.rank-3 { color: #CD7F32; font-weight: bold; }

.empty-message {
  text-align: center;
  padding: 40px;
  color: #999;
  font-style: italic;
}

.completed-row {
  background: rgba(76, 175, 80, 0.05);
}

.incomplete-row {
  background: rgba(255, 152, 0, 0.05);
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.9em;
  font-weight: 600;
}

.status-badge.completed {
  background: #4CAF50;
  color: white;
}

.status-badge.in-progress {
  background: #FF9800;
  color: white;
}

/* Admin */
.admin-container {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 600px;
  margin: 0 auto;
}

.games-list {
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 1000px;
  margin: 0 auto;
}

.game-item {
  padding: 20px;
  border: 2px solid #ddd;
  border-radius: 8px;
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-item:hover {
  border-color: #667eea;
  background: #f9f9f9;
}

.game-item-info h3 {
  margin-bottom: 8px;
  color: #333;
}

.game-item-info p {
  color: #666;
  font-size: 0.9em;
}

.game-item-actions {
  display: flex;
  gap: 10px;
}

/* Responsive */
@media (max-width: 768px) {
  .game-header h1 {
    font-size: 2em;
  }

  .grid-tile {
    font-size: 0.8em;
    padding: 8px;
  }

  .modal-content {
    padding: 30px 20px;
  }

  .game-info {
    flex-direction: column;
    gap: 10px;
  }

  .game-item {
    flex-direction: column;
    gap: 15px;
  }

  .game-item-actions {
    width: 100%;
    justify-content: stretch;
  }

  .game-item-actions .btn {
    flex: 1;
  }
}

@media (max-width: 480px) {
  .grid-tile {
    font-size: 0.7em;
    padding: 6px;
  }
}

/* Draft Page */
.draft-container {
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 800px;
  margin: 0 auto 20px;
}

.draft-container h2 {
  margin-bottom: 10px;
  color: #667eea;
}

/* Draft info box */
.draft-info-box {
  background: #f0f4ff;
  border: 1px solid #d0d9f0;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 20px;
  font-size: 0.95em;
  color: #444;
  line-height: 1.5;
}

.draft-info-box strong {
  color: #667eea;
}

/* Player Registration */
.player-registration {
  max-width: 400px;
  margin: 0 auto;
}

/* Grayed out state */
.grayed-out {
  opacity: 0.4;
  pointer-events: none;
}

/* Player List */
.player-list {
  margin-bottom: 20px;
}

.player-list h3 {
  color: #667eea;
  margin-bottom: 10px;
}

.player-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 0.95em;
}

.player-ready {
  background: #e8f5e9;
  color: #2E7D32;
}

.player-not-ready {
  background: #f5f5f5;
  color: #666;
}

.ready-badge {
  font-size: 0.8em;
  font-weight: 600;
  background: #4CAF50;
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
}

.add-tile-form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.add-tile-form input {
  flex: 1;
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 1em;
}

.add-tile-form input:focus {
  outline: none;
  border-color: #667eea;
}

.tiles-list {
  list-style: none;
  padding: 0;
}

.tile-item {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  border: 1px solid #eee;
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fafafa;
  transition: background 0.2s;
  gap: 10px;
}

.tile-item:hover {
  background: #f0f0f0;
}

.tile-item.tile-selected {
  background: #e8f5e9;
  border-color: #c8e6c9;
}

.tile-select-checkbox {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

.tile-text {
  flex: 1;
  cursor: pointer;
  padding: 4px 0;
}

.tile-item-actions {
  display: flex;
  gap: 8px;
  margin-left: 10px;
}

.btn-icon {
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85em;
  cursor: pointer;
  color: #667eea;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.btn-icon-danger {
  color: #f44336;
}

.btn-icon-danger:hover {
  background: #f44336;
  color: white;
  border-color: #f44336;
}

.edit-tile-input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid #667eea;
  border-radius: 6px;
  font-size: 1em;
  outline: none;
}

.tile-count-badge {
  background: rgba(255, 255, 255, 0.3);
  padding: 6px 14px;
  border-radius: 16px;
  font-weight: 600;
}

/* Ready Section */
.ready-section {
  text-align: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.ready-button {
  padding: 14px 40px;
  font-size: 1.1em;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

.ready-button:hover {
  background: #5568d6;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.ready-button.ready-active {
  background: #4CAF50;
}

.ready-button.ready-active:hover {
  background: #45a049;
}

.ready-counter {
  margin-top: 10px;
  color: #888;
  font-size: 0.95em;
}

/* Game Layout (grid + sidebar) */
.game-layout {
  display: flex;
  gap: 20px;
  max-width: 1000px;
  margin: 0 auto;
}

.game-layout .grid-container {
  flex: 1;
  margin: 0;
}

.game-sidebar {
  width: 220px;
  flex-shrink: 0;
}

.game-sidebar .player-list {
  background: white;
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  margin-bottom: 15px;
}

.game-sidebar .player-list h3 {
  color: #667eea;
  margin-bottom: 10px;
}

/* Finish Section */
.finish-section {
  text-align: center;
}

.finish-button {
  padding: 14px 40px;
  font-size: 1.1em;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  width: 100%;
}

.finish-button:hover {
  background: #5568d6;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.finish-button.finish-active {
  background: #4CAF50;
}

.finish-button.finish-active:hover {
  background: #45a049;
}

.finish-counter {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.95em;
}

/* Finished player item */
.player-finished-item {
  background: #e8f5e9;
  color: #2E7D32;
}

.finished-badge {
  font-size: 0.8em;
  font-weight: 600;
  background: #4CAF50;
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
}

@media (max-width: 768px) {
  .game-layout {
    flex-direction: column;
  }

  .game-sidebar {
    width: 100%;
  }
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-notification {
  background: white;
  color: #333;
  padding: 14px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  font-size: 0.95em;
  font-weight: 500;
  animation: toastSlideIn 0.3s ease-out;
  pointer-events: auto;
  border-left: 4px solid #4CAF50;
  max-width: 350px;
}

.toast-notification.toast-exit {
  animation: toastSlideOut 0.3s ease-in forwards;
}

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

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

/* Game Status Badges (admin) */
.game-status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 8px;
}

.game-status-draft {
  background: #FFF3E0;
  color: #E65100;
}

.game-status-active {
  background: #E8F5E9;
  color: #2E7D32;
}

.game-status-stopped {
  background: #ECEFF1;
  color: #546E7A;
}

/* Slide-in animation for new tiles */
.tile-slide-in {
  animation: slideIn 0.3s ease-out;
}

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

/* Admin Validation Page */
.validation-container {
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 800px;
  margin: 0 auto;
}

.validation-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #eee;
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fafafa;
  transition: background 0.2s;
}

.validation-tile:hover {
  background: #f0f0f0;
}

.validation-tile.tile-validated {
  background: #e8f5e9;
  border-color: #c8e6c9;
}

.validation-tile input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}

.validation-tile-text {
  flex: 1;
  font-size: 1em;
}

.selection-count-badge {
  font-size: 0.85em;
  color: #888;
  background: #f0f0f0;
  padding: 2px 10px;
  border-radius: 10px;
  white-space: nowrap;
}
