* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* === OPTIMISATIONS PERFORMANCE GPU === */
#gameCanvas {
  will-change: transform;
  transform: translate(-50%, -50%) translateZ(0);
  -webkit-transform: translate(-50%, -50%) translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  contain: strict;
}

#menuBackgroundCanvas {
  will-change: transform, opacity;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  contain: strict;
}

.ammo-hud,
.timer,
.connection-status {
  will-change: transform, opacity;
  transform: translateZ(0);
  contain: layout style;
}

.bullet-icon {
  will-change: background-color, border-color;
  contain: layout style paint;
}

.reload-fill {
  will-change: width;
  contain: layout style;
}

:root {
  --color-bg: #fff;
  --color-text: #000;
  --color-border: #000;
  --color-accent: #fff;

  --color-player-fill: #fff;
  --color-player-stroke: #000;
  --color-asteroid-fill: #fff;
  --color-asteroid-stroke: #000;
  --color-pseudo: #000;

  --color-hp-bg: #fff;
  --color-hp-border: #000;

  --app-height: 100vh;
}

html.dark-mode {
  --color-bg: #1a1a1a;
  --color-text: #fff;
  --color-border: #fff;
  --color-accent: #fff;

  --color-player-fill: #000;
  --color-player-stroke: #fff;
  --color-asteroid-fill: #000;
  --color-asteroid-stroke: #fff;
  --color-pseudo: #fff;
  --color-hp-bg: #1a1a1a;
  --color-hp-border: #fff;
}

html {
  height: -webkit-fill-available;
}

body {
  font-family: "Arial", sans-serif;
  background: var(--color-bg);
  overflow: hidden;
  height: 100vh;
  height: var(--app-height);
  min-height: -webkit-fill-available;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
}

html.dark-mode body {
  background: var(--color-bg);
  color: var(--color-text);
}

html.dark-mode .menu-container,
html.dark-mode .code-display,
html.dark-mode .ammo-hud {
  background: #2a2a2a;
  border-color: #fff;
}

html.dark-mode h1,
html.dark-mode .subtitle,
html.dark-mode .pseudo-input label,
html.dark-mode .challenge-input label,
html.dark-mode .code-display p,
html.dark-mode .code-hint,
html.dark-mode .code-value,
html.dark-mode .timer,
html.dark-mode .waiting-message,
html.dark-mode .separator,
html.dark-mode .online-counter,
html.dark-mode #resultTitle,
html.dark-mode #resultText {
  color: #fff;
}

html.dark-mode .pseudo-input input,
html.dark-mode .challenge-input input {
  background: #1a1a1a;
  border-color: #fff;
  color: #fff;
}

html.dark-mode .pseudo-input input:focus,
html.dark-mode .challenge-input input:focus {
  background: #fff;
  color: #000;
}

html.dark-mode .btn-primary {
  background: #fff;
  color: #000;
  border-color: transparent;
}

html.dark-mode .btn-primary:hover {
  background: #000;
  color: #fff;
  border-color: #fff;
}

html.dark-mode .btn-secondary {
  background: #1a1a1a;
  color: #fff;
  border-color: #fff;
}

html.dark-mode .btn-secondary:hover {
  background: #fff;
  color: #000;
}

html.dark-mode .btn-start-bots.voted {
  background: #4caf50;
  color: #fff;
}

html.dark-mode .btn-link {
  color: #fff;
}

html.dark-mode .shop-container {
  background: #111;
  border-color: #fff;
  color: #fff;
}

html.dark-mode .shop-close-btn {
  color: #fff;
}

html.dark-mode .shop-skin-card {
  border-color: #444;
}

html.dark-mode .shop-skin-card:hover {
  border-color: #999;
}

html.dark-mode .shop-skin-card.selected {
  border-color: #fff;
}

html.dark-mode .online-counter {
  background: #2a2a2a;
  border-color: #fff;
}

html.dark-mode .bullet-icon {
  background: #fff;
}

html.dark-mode .bullet-icon.empty {
  background: #1a1a1a;
  border-color: #fff;
}

html.dark-mode .bullet-icon.golden {
  background: #ffd700;
  border: 2px solid #fff;
}

html.dark-mode .reload-bar {
  background: #1a1a1a;
  border-color: #fff;
}

html.dark-mode .reload-fill {
  background: #fff;
}

html.dark-mode #gameCanvas {
  background: #1a1a1a;
  border-color: #fff;
}

html.dark-mode .timer {
  color: #fff;
  text-shadow: none;
}

html.dark-mode #gameOver .menu-container {
  background: #2a2a2a;
  border-color: #fff;
}

html.dark-mode #gameOver h1,
html.dark-mode #gameOver p {
  color: #fff !important;
}

html.dark-mode .spinner {
  border-color: #fff;
  border-left-color: transparent;
}

html.dark-mode .code-value {
  background: #1a1a1a;
  border-color: #fff;
  color: #fff;
}

html.dark-mode .sudden-death-msg {
  color: #fff;
}

.dark-mode-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  background: #000;
  color: #fff;
  border: 3px solid #000;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.dark-mode-toggle svg {
  width: 24px;
  height: 24px;
}

.dark-mode-toggle:hover {
  transform: scale(1.1);
  background: #333;
}

.dark-mode-toggle:active {
  transform: scale(0.95);
}

html.dark-mode .dark-mode-toggle {
  background: #fff;
  color: #000;
  border-color: #fff;
}

html.dark-mode .dark-mode-toggle:hover {
  background: #ddd;
}

.rotate-message {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-bg);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.rotate-message-content {
  text-align: center;
  padding: 40px;
  color: var(--color-text);
}

.phone-icon {
  position: relative;
  display: inline-block;
  margin-bottom: 30px;
}

.phone-icon svg {
  width: 80px;
  height: 140px;
  stroke: var(--color-text);
  animation: rotatePhone 2s ease-in-out infinite;
}

.rotate-message h2 {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 15px;
  color: var(--color-text);
  letter-spacing: -1px;
}

.rotate-message p {
  font-size: 14px;
  color: var(--color-text);
  opacity: 0.8;
}

@keyframes rotatePhone {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(90deg);
  }
}

.screen {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

#menuBackgroundCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.3;
  transition: opacity 0.5s ease;
}

#menu .menu-container {
  position: relative;
  z-index: 1;
}

.online-counter {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #000;
  padding: 10px 20px;
  border: 3px solid #000;
  background: #fff;
  z-index: 10;
  transition: opacity 0.5s ease;
}

.online-counter span {
  font-size: 18px;
  font-weight: 900;
}

.btn-20bots {
  position: absolute;
  bottom: 20px;
  right: 20px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s, opacity 0.5s ease;
  background-color: transparent;
  outline: none;
  border: none;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  z-index: 10;
}

.btn-20bots:hover {
  text-decoration-thickness: 2px;
}

.btn-watch-background {
  position: absolute;
  bottom: 20px;
  left: 20px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.3s;
  background-color: transparent;
  outline: none;
  border: 2px solid var(--color-border);
  padding: 10px 20px;
  border-radius: 8px;
  z-index: 10;
}

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

.menu-container {
  background: #fff;
  border: 4px solid #000;
  padding: 50px 70px;
  text-align: center;
  position: relative;
  transition: opacity 0.5s ease;
}

h1 {
  font-size: 48px;
  color: #000;
  margin-bottom: 5px;
  font-weight: 900;
  letter-spacing: -2px;
}

.subtitle {
  font-size: 12px;
  color: #000;
  margin-bottom: 40px;
  font-weight: 400;
}

.pseudo-input {
  margin: 30px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pseudo-input label {
  font-size: 11px;
  color: #000;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1px;
}

.pseudo-input input {
  padding: 14px 20px;
  font-size: 16px;
  font-family: "Arial", sans-serif;
  background: #fff;
  border: 3px solid #000;
  color: #000;
  outline: none;
  text-align: center;
  font-weight: 500;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
}

.btn-primary {
  background: #000;
  color: #fff;
  border: none;
  padding: 16px 50px;
  font-size: 14px;
  font-family: "Arial", sans-serif;
  cursor: pointer;
  transition: all 0.1s;
  border: 3px solid transparent;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.btn-primary:hover {
  background: #fff;
  color: #000;
  border: 3px solid #000;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-secondary {
  background: #fff;
  color: #000;
  border: 3px solid #000;
  padding: 10px 20px;
  font-size: 12px;
  font-family: "Arial", sans-serif;
  cursor: pointer;
  transition: all 0.1s;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  margin: 5px;
}

.btn-secondary:hover {
  background: #000;
  color: #fff;
}

.btn-secondary:active {
  transform: scale(0.97);
}

.shop-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.shop-overlay.hidden {
  display: none;
}

.shop-container {
  background: #fff;
  border: 3px solid #000;
  border-radius: 12px;
  padding: 25px;
  max-width: 520px;
  width: 90%;
}

.shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.shop-header h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 2px;
}

.shop-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  color: #000;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.shop-skin-card {
  border: 2px solid #ccc;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.shop-skin-card:hover {
  border-color: #666;
  transform: scale(1.03);
}

.shop-skin-card.selected {
  border-color: #000;
  border-width: 3px;
}

.skin-preview {
  width: 80px;
  height: 72px;
  display: block;
  margin: 0 auto 4px;
}

.skin-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
}


.btn-shop-floating {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--color-text);
  cursor: pointer;
  background-color: transparent;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 16px;
  transition: all 0.2s;
}

.btn-shop-floating:hover {
  transform: translateY(-50%) scale(1.05);
}

/* Style du dropdown personnalisé pour le mode nombre perso */
.custom-dropdown {
  position: relative;
  display: inline-block;
}

.custom-dropdown-btn {
  background: #000;
  color: #fff;
  border: 3px solid transparent;
  padding: 16px 20px;
  font-size: 14px;
  font-family: "Arial", sans-serif;
  cursor: pointer;
  transition: all 0.1s;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  margin: 0;
}

.custom-dropdown-btn:hover {
  background: #fff;
  color: #000;
  border-color: #000;
}

.dropdown-arrow {
  width: 16px;
  height: 16px;
  transition: transform 0.2s;
}

.custom-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.custom-dropdown-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: #000;
  border: 3px solid #000;
  display: none;
  flex-direction: column;
  z-index: 1000;
  margin-bottom: 5px;
}

.custom-dropdown.open .custom-dropdown-menu {
  display: flex;
}

.custom-dropdown-item {
  padding: 12px 20px;
  cursor: pointer;
  transition: all 0.1s;
  font-size: 14px;
  font-family: "Arial", sans-serif;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  color: #fff;
  background: #000;
}

.custom-dropdown-item:hover {
  background: #fff;
  color: #000;
}

.custom-dropdown-item.selected {
  background: #333;
}

/* Dark mode */
html.dark-mode .custom-dropdown-btn {
  background: #fff;
  color: #000;
  border-color: transparent;
}

html.dark-mode .custom-dropdown-btn:hover {
  background: #000;
  color: #fff;
  border-color: #fff;
}

html.dark-mode .custom-dropdown-menu {
  background: #fff;
  border-color: #fff;
}

html.dark-mode .custom-dropdown-item {
  color: #000;
  background: #fff;
}

html.dark-mode .custom-dropdown-item:hover {
  background: #000;
  color: #fff;
}

html.dark-mode .custom-dropdown-item.selected {
  background: #ddd;
}

.custom-dropdown.disabled {
  pointer-events: none;
  opacity: 0.5;
}

.custom-player-container {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.private-game-links {
  margin-top: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 11px;
}

.btn-link {
  background: none;
  border: none;
  color: #000;
  font-size: 11px;
  font-family: "Arial", sans-serif;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-weight: 400;
  transition: opacity 0.2s;
}

.btn-link:hover {
  opacity: 0.6;
}

.btn-link:active {
  opacity: 0.4;
}

.separator {
  color: #000;
  font-weight: 300;
  opacity: 0.3;
}

hr {
  border: none;
  height: 2px;
  background: #000;
  margin-top: 20px;
  opacity: 0.15;
}

html.dark-mode hr {
  background: #fff;
  opacity: 0.15;
}

.challenge-input {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.challenge-input.hidden {
  display: none;
}

.challenge-input label {
  font-size: 11px;
  color: #000;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1px;
}

.challenge-input input {
  padding: 14px 20px;
  font-size: 16px;
  font-family: "Arial", sans-serif;
  background: #fff;
  border: 3px solid #000;
  color: #000;
  outline: none;
  text-align: center;
  font-weight: 500;
  text-transform: uppercase;
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
}

.challenge-input input:focus {
  background: #000;
  color: #fff;
}

.challenge-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.code-display {
  margin-top: 20px;
  padding: 20px;
  border: 3px solid #000;
  background: #fff;
  text-align: center;
}

.code-display.hidden {
  display: none;
}

.code-display p {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.code-value {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 8px;
  color: #000;
  background: #fff;
  border: 3px solid #000;
  padding: 15px 30px;
  margin: 10px 0;
  font-family: "Courier New", monospace;
}

.code-hint {
  font-size: 10px !important;
  font-weight: 400 !important;
  color: #000;
  margin-top: 10px;
  margin-bottom: 15px;
}

.waiting-message {
  margin-top: 30px;
  color: #000;
}

.waiting-message.hidden {
  display: none;
}

.spinner {
  width: 30px;
  height: 30px;
  margin: 0 auto 15px;
  border: 4px solid #000;
  border-left: 4px solid transparent;
  border-radius: 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.btn-start-bots.voted {
  background: #4caf50;
  color: #fff;
  pointer-events: none;
  opacity: 0.8;
}

.matchmaking-info {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 18px;
  font-weight: bold;
}

.players-count-inline {
  font-weight: bold;
  color: #000;
}

.matchmaking-timer {
  color: #000;
  font-size: 16px;
}

.matchmaking-timer span {
  color: #000;
  font-weight: bold;
}

html.dark-mode .matchmaking-info {
  color: #fff;
}

html.dark-mode .players-count-inline {
  color: #fff;
}

html.dark-mode .matchmaking-timer {
  color: #fff;
}

html.dark-mode .matchmaking-timer span {
  color: #fff;
}

#game {
  flex-direction: column;
  background: var(--color-bg);
  position: relative;
}

.fullscreen-prompt {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 15px 25px;
  border: 3px solid #fff;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  animation: slideDown 0.3s ease-out;
}

.fullscreen-prompt.hidden {
  display: none;
}

.fullscreen-prompt span {
  color: #fff;
}

.prompt-btn {
  background: #fff;
  color: #000;
  border: none;
  padding: 8px 20px;
  font-size: 12px;
  font-family: "Arial", sans-serif;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}

.prompt-btn:hover {
  background: #000;
  color: #fff;
  border: 2px solid #fff;
}

.prompt-btn:active {
  transform: scale(0.95);
}

html.dark-mode .fullscreen-prompt {
  background: rgba(255, 255, 255, 0.95);
  color: #000;
  border-color: #000;
}

html.dark-mode .fullscreen-prompt span {
  color: #000;
}

.countdown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.countdown-overlay.hidden {
  display: none;
}

.countdown-number {
  font-size: 200px;
  font-weight: 900;
  color: #fff;
  animation: countdownPulse 1s ease-out;
  letter-spacing: -5px;
}

@keyframes countdownPulse {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

html.dark-mode .countdown-number {
  color: #fff;
}

html.dark-mode .prompt-btn {
  background: #000;
  color: #fff;
  border: 2px solid #000;
}

html.dark-mode .prompt-btn:hover {
  background: #fff;
  color: #000;
  border: 2px solid #000;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.timer {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 40px;
  font-family: "Arial", sans-serif;
  color: #000;
  z-index: 10;
  pointer-events: none;
  font-weight: 900;
  letter-spacing: -1px;
  text-shadow: -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff,
    2px 2px 0 #fff;
}

.ammo-hud {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 3px solid #000;
  padding: 12px 25px;
  z-index: 10;
  pointer-events: none;
}

.ammo-bullets {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  justify-content: center;
}

.bullet-icon {
  width: 14px;
  height: 14px;
  background: #000;
  border: none;
  transition: opacity 0.2s;
}

.bullet-icon.empty {
  background: #fff;
  border: 2px solid #000;
}

.bullet-icon.golden {
  background: #ffd700;
  border: 2px solid #000;
}

.fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-btn:hover {
  opacity: 0.7;
}

.fullscreen-btn svg {
  width: 24px;
  height: 24px;
  stroke: var(--color-text);
  stroke-width: 2;
  fill: none;
}
.reload-bar {
  width: 130px;
  height: 6px;
  background: #fff;
  border: 2px solid #000;
  overflow: hidden;
}

.reload-fill {
  height: 100%;
  background: #000;
  width: 0%;
  transition: width 0.1s linear;
}

.sudden-death-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 64px;
  font-family: "Arial", sans-serif;
  color: #000;
  animation: pulse 0.5s infinite;
  z-index: 100;
  pointer-events: none;
  font-weight: 900;
  letter-spacing: -2px;
}

.sudden-death-msg.hidden {
  display: none;
}

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

#gameCanvas {
  background: #fff;
  cursor: crosshair;
  position: absolute;
  top: 50%;
  left: 50%;
  border: 4px solid #000;
  /* transform et will-change définis dans les optimisations GPU */
}

#resultTitle {
  font-size: 56px;
  margin-bottom: 15px;
  font-weight: 900;
  letter-spacing: -2px;
}

#resultText {
  font-size: 14px;
  margin-bottom: 40px;
  font-weight: 400;
}

.spectator-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.spectator-overlay.hidden {
  display: none;
}

.spectator-card {
  background: #fff;
  border: 4px solid #000;
  padding: 60px 80px;
  text-align: center;
}

.spectator-card h1 {
  font-size: 120px;
  color: #000;
  margin-bottom: 20px;
  font-weight: 900;
  letter-spacing: -4px;
}

.spectator-card p {
  font-size: 16px;
  color: #000;
  margin-bottom: 30px;
  font-weight: 500;
}

html.dark-mode .spectator-card {
  background: #2a2a2a;
  border-color: #fff;
}

html.dark-mode .spectator-card h1,
html.dark-mode .spectator-card p {
  color: #fff;
}

.spectator-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
}

.spectator-return-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 60;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  border: 2px solid #fff;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 4px;
}

.spectator-return-btn:hover {
  background: rgba(0, 0, 0, 0.95);
  transform: translateX(-4px);
}

.spectator-return-btn.hidden {
  display: none;
}

html.dark-mode .spectator-return-btn {
  background: rgba(255, 255, 255, 0.15);
  border-color: #fff;
  color: #fff;
}

html.dark-mode .spectator-return-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.music-toggle {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  z-index: 1000;
}

.music-icon {
  width: 100%;
  height: 100%;
  color: white;
  position: absolute;
  top: 0;
  left: 0;
  transition: opacity 0.2s ease;
}

.music-icon.hidden {
  opacity: 0;
  pointer-events: none;
}

html:not(.dark-mode) .music-icon {
  color: #333;
}

.music-toggle.playing .music-icon {
  animation: pulse 2s ease-in-out infinite;
}

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

  50% {
    opacity: 0.7;
  }
}

@media screen and (max-width: 768px) {
  body {
    font-size: 14px;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }

  .menu-container {
    padding: 30px 20px;
    border: 3px solid #000;
    max-width: 90%;
    margin: 0 auto;
  }

  h1 {
    font-size: 32px;
    letter-spacing: -1px;
    margin-bottom: 10px;
  }

  .subtitle {
    font-size: 11px;
    margin-bottom: 20px;
  }

  .pseudo-input {
    margin: 20px 0;
  }

  .pseudo-input label {
    font-size: 10px;
  }

  .pseudo-input input {
    padding: 12px 15px;
    font-size: 14px;
  }

  .btn-primary {
    padding: 14px 30px;
    font-size: 12px;
    width: 100%;
  }

  .btn-secondary {
    padding: 10px 18px;
    font-size: 11px;
  }

  .fullscreen-btn {
    top: 5px;
    right: 5px;
    width: 35px;
    height: 35px;
  }

  .fullscreen-btn svg {
    width: 20px;
    height: 20px;
  }

  .online-counter {
    top: 10px;
    right: 10px;
    font-size: 10px;
    padding: 8px 12px;
  }

  .online-counter span {
    font-size: 14px;
  }

  .btn-20bots {
    bottom: 10px;
    right: 10px;
    font-size: 11px;
  }

  .btn-shop-floating {
    right: 10px;
    font-size: 11px;
    padding: 8px 12px;
  }

  .shop-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .shop-container {
    padding: 15px;
  }

  .dark-mode-toggle {
    top: 10px;
    left: 10px;
    width: 40px;
    height: 40px;
    border: 2px solid #000;
  }

  .dark-mode-toggle svg {
    width: 20px;
    height: 20px;
  }

  .music-toggle {
    top: 10px;
    left: 10px;
    width: 25px;
    height: 25px;
  }

  .private-game-links {
    margin-top: 15px;
    flex-wrap: wrap;
    font-size: 10px;
  }

  .btn-link {
    font-size: 10px;
  }

  .code-display {
    padding: 15px;
  }

  .code-value {
    font-size: 24px;
    letter-spacing: 4px;
    padding: 12px 20px;
  }

  .code-hint {
    font-size: 9px !important;
  }

  .challenge-input label {
    font-size: 10px;
  }

  .challenge-input input {
    padding: 12px 15px;
    font-size: 14px;
  }

  .challenge-buttons {
    flex-direction: column;
    gap: 8px;
  }

  .challenge-buttons .btn-secondary {
    width: 100%;
  }

  .waiting-message {
    margin-top: 20px;
    font-size: 13px;
  }

  .spinner {
    width: 25px;
    height: 25px;
    border: 3px solid #000;
    border-left: 3px solid transparent;
  }

  .matchmaking-info {
    font-size: 14px;
  }

  .matchmaking-timer {
    font-size: 14px;
  }

  .timer {
    top: 50px;
    font-size: 28px;
    letter-spacing: 0;
  }

  .ammo-hud {
    bottom: 20px;
    padding: 10px 20px;
    border: 2px solid #000;
  }

  .ammo-bullets {
    gap: 8px;
    margin-bottom: 6px;
  }

  .bullet-icon {
    width: 12px;
    height: 12px;
  }

  .reload-bar {
    width: 100px;
    height: 5px;
  }

  .fullscreen-prompt {
    display: none !important;
  }

  .prompt-btn {
    padding: 6px 16px;
    font-size: 11px;
  }

  .sudden-death-msg {
    font-size: 36px;
    letter-spacing: -1px;
  }

  #gameCanvas {
    border: 3px solid #000;
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
    object-fit: contain;
  }

  #gameOver .menu-container {
    padding: 40px 25px;
  }

  #resultTitle {
    font-size: 36px;
    margin-bottom: 10px;
  }

  #resultText {
    font-size: 12px;
    margin-bottom: 25px;
  }

  .spectator-card {
    padding: 40px 30px;
    border: 3px solid #000;
    max-width: 90%;
  }

  .spectator-card h1 {
    font-size: 72px;
    letter-spacing: -2px;
    margin-bottom: 15px;
  }

  .spectator-card p {
    font-size: 14px;
    margin-bottom: 20px;
  }

  .spectator-buttons {
    flex-direction: column;
    gap: 10px;
  }

  .spectator-buttons .btn-primary,
  .spectator-buttons .btn-secondary {
    width: 100%;
  }

  .spectator-return-btn {
    top: 10px;
    left: 10px;
    padding: 10px 18px;
    font-size: 14px;
  }
}

@media screen and (max-width: 480px) {
  .menu-container {
    padding: 20px 15px;
  }

  h1 {
    font-size: 28px;
  }

  .btn-primary {
    padding: 12px 25px;
    font-size: 11px;
  }

  .code-value {
    font-size: 20px;
    letter-spacing: 3px;
    padding: 10px 15px;
  }

  .timer {
    top: 40px;
    font-size: 24px;
  }

  .ammo-hud {
    bottom: 15px;
    padding: 8px 15px;
  }

  .spectator-card h1 {
    font-size: 56px;
  }

  #resultTitle {
    font-size: 32px;
  }

  .sudden-death-msg {
    font-size: 28px;
  }
}

@media screen and (max-height: 500px) and (orientation: landscape) {
  .menu-container {
    padding: 20px 30px;
    max-height: 90vh;
    overflow-y: auto;
  }

  h1 {
    font-size: 28px;
    margin-bottom: 5px;
  }

  .pseudo-input {
    margin: 15px 0;
  }

  .btn-primary {
    padding: 10px 25px;
  }

  .timer {
    top: 10px;
    font-size: 20px;
  }

  .ammo-hud {
    bottom: 5px;
    padding: 6px 12px;
  }

  #gameCanvas {
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
    object-fit: contain;
  }
}

@media screen and (max-width: 768px) and (orientation: portrait) {
  .rotate-message {
    display: flex !important;
  }
}

/* Notification de statut de connexion */
.connection-status {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  padding: 15px 25px;
  border-radius: 10px;
  font-weight: bold;
  font-size: 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  animation: slideDown 0.3s ease-out;
  pointer-events: none;
}

.connection-status.offline {
  background: #ff4444;
  color: white;
  border: 2px solid #cc0000;
}

.connection-status.reconnecting {
  background: #ffaa00;
  color: white;
  border: 2px solid #cc8800;
}

.connection-status.reconnected {
  background: #44ff44;
  color: #000;
  border: 2px solid #00cc00;
}

.connection-status.weak {
  background: #ffaa00;
  color: white;
  border: 2px solid #cc8800;
}

.connection-status.hidden {
  display: none;
}

@keyframes slideDown {
  from {
    transform: translateX(-50%) translateY(-100px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
  to {
    transform: translateX(-50%) translateY(-100px);
    opacity: 0;
  }
}

/* Overlay de chargement */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-bg);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease-out;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-container {
  text-align: center;
  padding: 40px;
  max-width: 400px;
  width: 90%;
}

.loading-container h2 {
  font-size: 32px;
  margin-bottom: 30px;
  color: var(--color-text);
  font-weight: bold;
  letter-spacing: 3px;
}

.loading-bar {
  width: 100%;
  height: 15px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 0px;
  overflow: hidden;
  margin-bottom: 20px;
  border: 2px solid var(--color-border);
}

html.dark-mode .loading-bar {
  background: rgba(255, 255, 255, 0.1);
}

.loading-progress {
  height: 100%;
  background: var(--color-text);
  width: 0%;
  transition: width 0.3s ease-out;
}

.loading-text {
  color: var(--color-text);
  font-size: 14px;
  opacity: 0.7;
  margin-top: 10px;
}

/* Barre de switch spectateur en mode multi */
.spectator-switch-bar {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  border: 2px solid #fff;
  border-radius: 12px;
  padding: 10px 15px;
  display: flex;
  align-items: center;
  gap: 15px;
  z-index: 60;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.spectator-switch-bar.hidden {
  display: none;
}

.spectator-switch-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

.spectator-switch-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: #fff;
  transform: scale(1.1);
}

.spectator-switch-btn:active {
  transform: scale(0.95);
}

.spectator-switch-btn svg {
  width: 20px;
  height: 20px;
  color: #fff;
}

.spectator-current-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
}

#spectatorCurrentName {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.spectator-hp {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 2px;
}

/* Dark mode adjustments */
html.dark-mode .spectator-switch-bar {
  background: rgba(40, 40, 40, 0.9);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Mobile responsiveness */
@media screen and (max-width: 768px) {
  .spectator-switch-bar {
    bottom: 80px;
    padding: 8px 12px;
    gap: 10px;
  }

  .spectator-switch-btn {
    width: 35px;
    height: 35px;
  }

  .spectator-switch-btn svg {
    width: 18px;
    height: 18px;
  }

  .spectator-current-player {
    min-width: 100px;
  }

  #spectatorCurrentName {
    font-size: 14px;
  }

  .spectator-hp {
    font-size: 11px;
  }
}

