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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #0b2340 0, #020817 45%, #020617 100%);
  color: #f9fafb;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 12px;
}

.page {
  width: 100%;
  max-width: 1040px;
}

.card {
  background: rgba(15, 23, 42, 0.96);
  border-radius: 24px;
  padding: 20px 20px 16px;
  box-shadow:
    0 22px 60px rgba(15, 23, 42, 0.9),
    0 0 0 1px rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(8px);
}

/* Titres et textes */

header h1 {
  font-size: 1.8rem;
  text-align: center;
  margin-bottom: 6px;
}

.subtitle {
  text-align: center;
  font-size: 0.95rem;
  color: #cbd5f5;
  margin-bottom: 16px;
}

h2 {
  font-size: 1.3rem;
  margin-bottom: 6px;
}

h3 {
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.hint {
  font-size: 0.9rem;
  color: #9ca3af;
  margin-bottom: 10px;
}

.hint.small {
  font-size: 0.8rem;
}

/* Layout */

.setup-controls,
.battle-wrapper {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.ships-panel {
  flex: 0 0 260px;
  background: linear-gradient(145deg, rgba(30, 64, 175, 0.32), rgba(15, 23, 42, 0.9));
  border-radius: 18px;
  padding: 12px 12px 10px;
  border: 1px solid rgba(129, 140, 248, 0.5);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.7);
}

.grid-wrapper {
  flex: 1;
}

.grid-title {
  text-align: center;
  font-size: 0.9rem;
  color: #e5e7eb;
  margin-bottom: 4px;
}

/* Boutons */

.btn-primary,
.btn-secondary,
.btn-orient {
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 14px;
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease, background 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #e5fdf2;
  justify-content: center;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(34, 197, 94, 0.35);
  opacity: 0.96;
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn-secondary {
  background: rgba(15, 23, 42, 0.92);
  color: #e5e7eb;
  border: 1px solid rgba(148, 163, 184, 0.7);
  justify-content: center;
}

.btn-secondary:hover {
  background: rgba(31, 41, 55, 0.96);
  transform: translateY(-1px);
}

.btn-orient {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: #e5e7eb;
  padding: 6px 10px;
  font-size: 0.8rem;
}

.btn-orient.active {
  background: radial-gradient(circle at top left, #3b82f6, #1d4ed8);
  border-color: rgba(191, 219, 254, 0.9);
  color: #eff6ff;
  box-shadow: 0 5px 15px rgba(59, 130, 246, 0.6);
}

/* Rôles */

.role-buttons {
  display: flex;
  gap: 10px;
  margin: 10px 0 6px;
}

/* Navires */

#ships-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.ship-item {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  padding: 6px 7px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.7);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s, transform 0.1s;
}

.ship-item:hover {
  background: rgba(30, 64, 175, 0.5);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.7);
  transform: translateY(-1px);
}

.ship-item.active {
  background: radial-gradient(circle at top left, #6366f1, #1d4ed8);
  border-color: #c7d2fe;
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.7);
}

.ship-name {
  flex: 1;
  font-size: 0.9rem;
}

.ship-size {
  display: flex;
  gap: 3px;
}

.ship-cell {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, #facc15, #eab308);
  box-shadow: 0 0 5px rgba(250, 204, 21, 0.8);
}

.ship-status {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #a1a1aa;
}

/* Orientation */

.orientation {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: #e5e7eb;
}

/* Grilles */

.grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  background: radial-gradient(circle at top, rgba(59, 130, 246, 0.55), rgba(15, 23, 42, 1));
  padding: 6px;
  border-radius: 16px;
  box-shadow:
    inset 0 0 0 1px rgba(15, 23, 42, 0.8),
    0 14px 30px rgba(15, 23, 42, 0.9);
  position: relative;
}

.grid::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 16px;
  border: 2px solid rgba(148, 163, 184, 0.4);
  pointer-events: none;
}

/* Cases */

.cell {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: radial-gradient(circle at 30% 20%, rgba(248, 250, 252, 0.25), rgba(15, 23, 42, 0.98));
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.85);
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.08s ease,
    box-shadow 0.12s ease,
    opacity 0.1s ease;
  position: relative;
  overflow: hidden;
}

.cell::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, rgba(59, 130, 246, 0.55), transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
}

.cell:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.9);
}

.cell:hover::after {
  opacity: 0.6;
}

.cell.ship {
  background: linear-gradient(135deg, #10b981, #16a34a);
  box-shadow:
    inset 0 0 0 1px rgba(15, 23, 42, 0.8),
    0 4px 10px rgba(16, 185, 129, 0.7);
}

.cell.miss {
  background: radial-gradient(circle at 30% 15%, rgba(248, 250, 252, 0.2), rgba(15, 23, 42, 1));
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.8);
}

.cell.miss::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 999px;
  border: 2px solid rgba(148, 163, 184, 0.8);
}

.cell.hit {
  background: radial-gradient(circle at center, #f97316 0, #b91c1c 40%, #111827 100%);
  box-shadow:
    0 0 16px rgba(248, 113, 113, 0.9),
    inset 0 0 0 1px rgba(15, 23, 42, 0.9);
}

.cell.hit::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at center, #fed7aa 0, transparent 70%);
  opacity: 0.9;
}

.cell.sunk {
  background: linear-gradient(145deg, #7c2d12, #1f2937);
  box-shadow:
    inset 0 0 0 1px rgba(15, 23, 42, 1),
    0 0 12px rgba(248, 113, 113, 0.9);
}

.cell.target-selected {
  box-shadow:
    0 0 0 2px #e5e7eb,
    0 0 15px rgba(251, 191, 36, 0.9);
  transform: translateY(-1px) scale(1.03);
}

/* Bouton TIR */

.fire-panel {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.btn-fire {
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 12px 22px;
  background: radial-gradient(circle at top left, #ef4444, #b91c1c);
  color: #fee2e2;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  box-shadow:
    0 14px 28px rgba(239, 68, 68, 0.5),
    0 0 0 2px rgba(248, 250, 252, 0.15);
  transition: transform 0.08s ease, box-shadow 0.1s ease, opacity 0.1s;
}

.btn-fire:disabled {
  opacity: 0.35;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-fire:not(:disabled):hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow:
    0 18px 35px rgba(239, 68, 68, 0.7),
    0 0 0 2px rgba(248, 250, 252, 0.3);
}

.btn-fire:not(:disabled):active {
  transform: translateY(1px) scale(0.99);
  box-shadow: none;
}

/* Sonar en haut au milieu */

.sonar-top-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 8px 0 14px;
}

.sonar-wrapper {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  background: radial-gradient(circle at center, #022c43, #020617 65%);
  border: 2px solid rgba(96, 165, 250, 0.9);
  box-shadow:
    0 0 22px rgba(59, 130, 246, 0.9),
    0 0 0 4px rgba(15, 23, 42, 0.95);
}

.sonar-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* halo sonar */
.sonar-wrapper::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(191, 219, 254, 0.8);
  opacity: 0;
  animation: sonar-pulse 1.8s infinite;
}

@keyframes sonar-pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.7;
  }
  100% {
    transform: scale(1.3);
    opacity: 0;
  }
}

/* Log et footer */

.log {
  margin-top: 8px;
  padding: 8px 10px;
  min-height: 40px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.4);
  font-size: 0.85rem;
  color: #e5e7eb;
}

.winner-text {
  text-align: center;
  margin: 10px 0 8px;
  font-size: 1rem;
}

.footer {
  margin-top: 12px;
  text-align: center;
  font-size: 0.78rem;
  color: #9ca3af;
}

.reset-link {
  color: #93c5fd;
  text-decoration: underline;
}

.reset-link:hover {
  color: #bfdbfe;
}

/* Utilitaires */

.hidden {
  display: none;
}

@media (max-width: 880px) {
  .battle-wrapper,
  .setup-controls {
    flex-direction: column;
  }

  .ships-panel {
    width: 100%;
  }

  .grid {
    margin-inline: auto;
  }

  .cell {
    width: 24px;
    height: 24px;
  }

  .sonar-wrapper {
    width: 160px;
    height: 160px;
  }
}

@media (max-width: 520px) {
  .card {
    padding-inline: 14px;
  }

  .cell {
    width: 22px;
    height: 22px;
  }

  header h1 {
    font-size: 1.4rem;
  }

  .sonar-wrapper {
    width: 130px;
    height: 130px;
  }
}
