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

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, rgb(102, 126, 234) 0%, #764ba2 100%);
  color: #333;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

.navbar {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding: 1rem 0;
}

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

.nav-brand h1 {
  color: white;
  font-size: 1.8rem;
  font-weight: bold;
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 2rem;
}

.nav-link {
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  transition: background-color 0.3s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.nav-dropdown {
  position: relative;
}

.dropdown-toggle {
  cursor: pointer;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  min-width: 120px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  z-index: 1000;
}

.nav-dropdown:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu li {
  list-style: none;
}

.dropdown-menu .nav-link {
  display: block;
  padding: 0.5rem 1rem;
  color: white;
  text-decoration: none;
  transition: background-color 0.3s ease;
}

.dropdown-menu .nav-link:hover {
  background: rgba(76, 175, 80, 0.2);
  color: #4caf50;
}

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.hero-section {
  text-align: center;
  padding: 4rem 0;
  color: white;
}

.hero-section h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.hero-section p {
  font-size: 1.2rem;
  margin-bottom: 2rem;
  opacity: 0.9;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 5px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  min-height: 44px;
  min-width: 44px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

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

.btn-primary:hover {
  background: #45a049;
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.btn-success {
  background: rgba(40, 167, 69, 0.8);
  color: white;
}

.btn-success:hover {
  background: rgba(40, 167, 69, 1);
}

.features-section {
  margin-top: 4rem;
  color: white;
}

.features-section h2 {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 2rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.feature-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 2rem;
  border-radius: 10px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.feature-card h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.game-container {
  text-align: center;
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.auth-required-message {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 3rem;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-width: 500px;
  margin: 2rem auto;
  text-align: center;
}

.auth-required-message h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: white;
}

.auth-required-message p {
  font-size: 1.2rem;
  margin-bottom: 2rem;
  color: rgba(255, 255, 255, 0.9);
}

.auth-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.game-container h1 {
  font-size: 2.5rem;
  margin-bottom: 0;
}

.game-score-top {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 1rem 2rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  min-width: 300px;
}

.game-score-top .score-display {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.score-display .player-left {
  color: #f44336;
  font-size: 2.5rem;
  text-shadow: 0 0 10px rgba(244, 67, 54, 0.5);
}

.score-display .player-right {
  color: #2196f3;
  font-size: 2.5rem;
  text-shadow: 0 0 10px rgba(33, 150, 243, 0.5);
}

.score-display .score-separator {
  color: white;
  font-size: 2rem;
  opacity: 0.7;
}

.game-score-top .game-status {
  font-size: 1rem;
  color: #ffc107;
  opacity: 0.9;
}

#gameCanvas {
  border: 2px solid white;
  border-radius: 10px;
  background: #000;
  margin: 0 auto;
  display: block;
  max-width: 100%;
  height: auto;
}

.game-controls-bottom {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.2rem;
  min-width: 120px;
  font-weight: bold;
}

.game-controls-info {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1rem;
  width: 100%;
  max-width: 600px;
}

.mode-selection {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 2rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  text-align: center;
  max-width: 700px;
  margin: 2rem auto;
}

.mode-selection h2 {
  font-size: 2rem;
  margin-bottom: 2rem;
}

.mode-buttons {
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 2rem;
  min-width: 250px;
  background: rgba(76, 175, 80, 0.2);
  border: 2px solid #4caf50;
  transition: all 0.3s ease;
}

.mode-btn:hover {
  background: rgba(76, 175, 80, 0.4);
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.mode-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: white;
}

.mode-description {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.8);
}

.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.game-mode-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-wrap: wrap;
}

.game-mode-info span {
  font-size: 1.1rem;
  color: #4caf50;
  font-weight: bold;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  min-width: auto;
}

.game-instructions {
  width: 100%;
  max-width: 1000px;
  margin: 0.5rem 0;
  display: flex;
  justify-content: center;
}

.player-1-solo {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
  max-width: 300px;
  margin: 0 auto;
  border-left: 3px solid #4caf50;
}

.player-1-solo .player-label {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: #4caf50;
}

.player-1-solo .controls-text {
  font-size: 0.9rem;
  color: white;
  opacity: 0.9;
  margin-bottom: 0.2rem;
}

.player-1-solo .key {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: bold;
  margin-left: 0.3rem;
}

.player-controls {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
  flex: 1;
}

.player-label {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.controls-text {
  font-size: 0.9rem;
  color: white;
  opacity: 0.9;
  margin-bottom: 0.2rem;
}

.controls-text .key {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: bold;
  margin-left: 0.3rem;
}

.player-1 {
  border-left: 3px solid #f44336;
}

.player-1 .player-label {
  color: #f44336;
}

.player-2 {
  border-right: 3px solid #2196f3;
}

.player-2 .player-label {
  color: #2196f3;
}

.player-controls-inline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
}

.player-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.controls-inline {
  font-size: 0.9rem;
  color: white;
  opacity: 0.9;
}

.controls-inline .key {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-weight: bold;
  margin: 0 0.1rem;
}

.online-info {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 1rem 2rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f44336;
  animation: pulse 2s infinite;
}

.status-indicator.online {
  background: #4caf50;
  animation: none;
}

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

.room-info {
  text-align: right;
}

.room-info p {
  margin: 0.2rem 0;
  font-size: 0.9rem;
}

.room-info span {
  font-weight: bold;
  color: #4caf50;
}

.online-instructions {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 1.5rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin-top: 1rem;
  text-align: left;
  max-width: 600px;
}

.online-instructions h3 {
  color: #4caf50;
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.online-instructions ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.online-instructions li {
  margin-bottom: 0.5rem;
  color: white;
  opacity: 0.9;
}

.online-instructions .note {
  font-style: italic;
  opacity: 0.7;
  font-size: 0.9rem;
  margin: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding-top: 1rem;
}

.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.auth-form {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 2rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 100%;
  max-width: 400px;
  color: white;
}

.auth-form h1 {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 2rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 1rem;
  min-height: 44px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.form-group input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.form-group input:focus {
  outline: none;
  border-color: #4caf50;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.auth-form .btn {
  width: 100%;
  margin-top: 1rem;
}

.auth-form p {
  text-align: center;
  margin-top: 1rem;
  opacity: 0.8;
}

.auth-form a {
  color: #4caf50;
  text-decoration: none;
}

.auth-form a:hover {
  text-decoration: underline;
}

.profile-container {
  color: white;
}

.profile-container h1 {
  font-size: 2.5rem;
  margin-bottom: 2rem;
  text-align: center;
}

.profile-info {
  display: flex;
  gap: 2rem;
  margin-bottom: 3rem;
  align-items: center;
  flex-wrap: wrap;
}

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

.avatar-placeholder {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.7);
}

.avatar-placeholder::before {
  content: "👤";
  opacity: 0.5;
}

.avatar-placeholder[style*="background-image"]::before {
  content: "";
  opacity: 0;
}

.user-details h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.user-details p {
  margin-bottom: 0.5rem;
  opacity: 0.8;
}

.stats-section h3,
.match-history h3 {
  font-size: 1.8rem;
  margin-bottom: 1rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 3rem;
}

.stat-card {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 1.5rem;
  border-radius: 10px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-card h4 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  opacity: 0.8;
}

.stat-number {
  font-size: 2rem;
  font-weight: bold;
  color: #4caf50;
}

.match-history {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 2rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

@media (max-width: 480px) {
  .nav-container {
    padding: 0 1rem;
    flex-direction: column;
    gap: 0.5rem;
  }

  .nav-brand h1 {
    font-size: 1.5rem;
  }

  .nav-menu {
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }

  .nav-link {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
  }

  .main-content {
    padding: 0.5rem;
  }

  .hero-section {
    padding: 2rem 0;
  }

  .hero-section h1 {
    font-size: 1.8rem;
    margin-bottom: 0.8rem;
  }

  .hero-section p {
    font-size: 1rem;
    margin-bottom: 1.5rem;
  }

  .hero-buttons {
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
  }

  .btn {
    width: 100%;
    max-width: 280px;
    padding: 0.8rem 1rem;
  }

  .features-section {
    margin-top: 2rem;
  }

  .features-section h2 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
  }

  .features-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .feature-card {
    padding: 1.5rem;
  }

  .game-container h1 {
    font-size: 1.8rem;
  }

  .game-score-top {
    min-width: auto;
    width: 100%;
    max-width: 350px;
    padding: 0.8rem 1rem;
  }

  .game-score-top .score-display {
    font-size: 1.5rem;
    gap: 0.5rem;
  }

  .score-display .player-left,
  .score-display .player-right {
    font-size: 2rem;
  }

  .score-display .score-separator {
    font-size: 1.5rem;
  }

  .game-controls-bottom {
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    max-width: 350px;
  }

  .btn-large {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
  }

  #gameCanvas {
    width: 100%;
    max-width: 100vw;
    height: auto;
  }

  .game-controls-info {
    flex-direction: column;
    gap: 1rem;
    max-width: 350px;
  }

  .player-controls {
    padding: 0.8rem;
  }

  .player-label {
    font-size: 1rem;
  }

  .controls-text {
    font-size: 0.8rem;
  }

  .auth-form {
    margin: 0 1rem;
    padding: 1.5rem;
  }

  .auth-form h1 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
  }

  .profile-container h1 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
  }

  .profile-info {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }

  .avatar-placeholder {
    width: 100px;
    height: 100px;
    font-size: 2.5rem;
  }

  .user-details h2 {
    font-size: 1.5rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-number {
    font-size: 1.5rem;
  }

  .match-history {
    padding: 1.5rem;
  }

  .stats-section h3,
  .match-history h3 {
    font-size: 1.5rem;
  }

  .mode-selection {
    padding: 1.5rem 1rem;
    margin: 1rem;
  }

  .mode-selection h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
  }

  .mode-buttons {
    flex-direction: column;
    gap: 1rem;
  }

  .mode-btn {
    min-width: auto;
    width: 100%;
    max-width: 350px;
    padding: 1.5rem;
  }

  .mode-title {
    font-size: 1.2rem;
  }

  .mode-description {
    font-size: 0.9rem;
  }

  .game-mode-info {
    padding: 0.5rem 1rem;
    width: 100%;
    max-width: 350px;
  }

  .game-mode-info span {
    font-size: 0.9rem;
  }

  .btn-small {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  .game-instructions {
    max-width: 350px;
  }

  .player-1-solo {
    max-width: 100%;
    padding: 0.8rem;
  }

  .player-1-solo .player-label {
    font-size: 1rem;
  }

  .player-1-solo .controls-text {
    font-size: 0.85rem;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .nav-container {
    padding: 0 1.5rem;
  }

  .hero-section h1 {
    font-size: 2.2rem;
  }

  .hero-buttons {
    gap: 1rem;
  }

  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .profile-info {
    flex-direction: column;
    text-align: center;
    gap: 1.5rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .game-score-top {
    max-width: 500px;
  }

  .game-controls-bottom {
    max-width: 500px;
  }

  .btn-large {
    min-width: 140px;
  }

  #gameCanvas {
    width: 100%;
    max-width: 100vw;
  }

  .game-controls-info {
    max-width: 500px;
    gap: 1.5rem;
  }

  .mode-selection {
    padding: 1.5rem;
    max-width: 600px;
  }

  .mode-buttons {
    gap: 1.5rem;
  }

  .mode-btn {
    min-width: 220px;
    padding: 1.5rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .nav-container {
    padding: 0 2rem;
  }

  .main-content {
    padding: 1.5rem;
  }

  .features-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .btn-large {
    font-size: 1rem;
    padding: 0.8rem 1.5rem;
    min-width: 100px;
  }

  .online-info {
    flex-direction: column;
    text-align: center;
    padding: 1rem;
  }

  .room-info {
    text-align: center;
  }

  .online-instructions {
    padding: 1rem;
    margin-top: 1rem;
  }

  .online-instructions ol {
    margin-left: 1rem;
  }
}

/* Global loader overlay */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none; /* toggled to flex in JS */
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  z-index: 10000;
  pointer-events: all;
  touch-action: none;
}

.loader-spinner {
  width: 64px;
  height: 64px;
  border: 6px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: loader-spin 0.9s linear infinite;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
}

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

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10001;
  pointer-events: none; /* allow clicks through except on toasts */
}

.toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: 360px;
  color: #fff;
  background: rgba(0, 0, 0, 0.8);
  border-left: 4px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(-10px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.hiding {
  opacity: 0;
  transform: translateY(-10px);
}

.toast-success {
  background: rgba(46, 204, 113, 0.9);
  border-left-color: #2ecc71;
}

.toast-error {
  background: rgba(231, 76, 60, 0.9);
  border-left-color: #e74c3c;
}

.toast-info {
  background: rgba(52, 152, 219, 0.9);
  border-left-color: #3498db;
}
@media (min-width: 481px) and (max-width: 768px) {
  .nav-container {
    padding: 0 1.5rem;
  }

  .hero-section h1 {
    font-size: 2.2rem;
  }

  .hero-buttons {
    gap: 1rem;
  }

  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .profile-info {
    flex-direction: column;
    text-align: center;
    gap: 1.5rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .game-score-top {
    max-width: 500px;
  }

  .game-controls-bottom {
    max-width: 500px;
  }

  .btn-large {
    min-width: 140px;
  }

  #gameCanvas {
    width: 100%;
    max-width: 100vw;
  }

  .game-controls-info {
    max-width: 500px;
    gap: 1.5rem;
  }

  .mode-selection {
    padding: 1.5rem;
    max-width: 600px;
  }

  .mode-buttons {
    gap: 1.5rem;
  }

  .mode-btn {
    min-width: 220px;
    padding: 1.5rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .nav-container {
    padding: 0 2rem;
  }

  .main-content {
    padding: 1.5rem;
  }

  .features-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .btn-large {
    font-size: 1rem;
    padding: 0.8rem 1.5rem;
    min-width: 100px;
  }

  .online-info {
    flex-direction: column;
    text-align: center;
    padding: 1rem;
  }

  .room-info {
    text-align: center;
  }

  .online-instructions {
    padding: 1rem;
    margin-top: 1rem;
  }

  .online-instructions ol {
    margin-left: 1rem;
  }
}

/* Global loader overlay */
.loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none; /* toggled to flex in JS */
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  z-index: 10000;
  pointer-events: all;
  touch-action: none;
}

.loader-spinner {
  width: 64px;
  height: 64px;
  border: 6px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: loader-spin 0.9s linear infinite;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
}

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