:root {
  --sand-light: #fffdf7;
  --sand-mid: #f3e3c3;
  --sand-border: #d9b982;
  --wood-dark: #2c1e12;
  --wood-soft: #634932;
  --sea-blue: #157a9e;
  --sea-bright: #0ea5e9;
  --coral: #f0542d;
  --coral-dark: #c93814;
  --sun-gold: #f59e0b;
  --success: #16a34a;
  --glass-bg: rgba(255, 251, 240, 0.92);
  --glass-shadow: 0 14px 36px rgba(44, 30, 18, 0.22);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--wood-dark);
  background: #4ea8de;
  touch-action: none;
}

h1, h2, .brand-badge, .phase-pill, .room-code-big, .timer-box, .btn {
  font-family: 'Fredoka', 'Nunito', sans-serif;
}

#site-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

#site-bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  z-index: 1;
  cursor: crosshair;
}

.hidden {
  display: none !important;
}

/* ==================== HUD ==================== */
#hud {
  position: fixed;
  top: 12px;
  left: 16px;
  right: 16px;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  min-height: 44px;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  flex-shrink: 0;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  flex-shrink: 0;
}

.hud-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.pill {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid var(--sand-border);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 12px rgba(44, 30, 18, 0.12);
  color: var(--wood-dark);
}

.pill-btn {
  cursor: pointer;
  transition: transform 0.12s ease;
}

.pill-btn:hover {
  transform: translateY(-1px);
}

.phase-pill {
  background: linear-gradient(135deg, #1d8ab0, #126180);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
}

.spray-pill {
  background: linear-gradient(135deg, #e0f2fe, #bae6fd);
  border-color: #38bdf8;
  color: #0369a1;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.spray-pill.cooldown {
  background: rgba(241, 245, 249, 0.85);
  border-color: #94a3b8;
  color: #64748b;
}

.timer-box {
  background: var(--wood-dark);
  color: var(--sand-light);
  padding: 7px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.18rem;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 6px;
}

.timer-box.urgent {
  background: var(--coral);
  animation: pulse 0.6s infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

/* Tooltip d'information / bannière détachée du header (taille libre, zéro décalage de boutons) */
.banner-msg {
  position: fixed;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  background: rgba(28, 20, 14, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 2px solid rgba(250, 204, 21, 0.85);
  color: #fef08a;
  padding: 6px 20px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 14px rgba(250, 204, 21, 0.25);
  pointer-events: none;
  white-space: nowrap;
  max-width: min(720px, 92vw);
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  transition: top 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease, transform 0.2s ease;
}

.banner-msg.in-battle {
  top: 132px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--sand-border);
  background: var(--glass-bg);
  font-size: 1.15rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(44, 30, 18, 0.1);
}

/* ==================== Galerie miniatures des joueurs ==================== */
.players-strip {
  position: fixed;
  top: 62px;
  left: 16px;
  right: 16px;
  z-index: 9;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  pointer-events: none;
}

.player-card {
  pointer-events: auto;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 2.5px solid var(--sand-border);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: 0 6px 14px rgba(44, 30, 18, 0.12);
  transition: transform 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}

.player-card:hover {
  transform: translateY(-2px);
}

.player-card.active-target {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(240, 84, 45, 0.35);
}

.player-card.active-shooter {
  border-color: var(--sun-gold);
}

.player-card.dead {
  opacity: 0.55;
  filter: grayscale(0.75);
}

.player-thumb {
  width: 60px;
  height: 34px;
  border-radius: 7px;
  background: #bfe4f4;
  border: 1.5px solid rgba(44, 30, 18, 0.15);
  image-rendering: pixelated;
}

.player-meta {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  line-height: 1.25;
}

.player-name {
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 5px;
}

.color-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.player-status {
  color: var(--wood-soft);
  font-size: 0.72rem;
  font-weight: 700;
}

/* ==================== Modales (Lobby & Victoire) ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(16, 42, 62, 0.38);
  backdrop-filter: blur(7px);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--glass-bg);
  border: 3px solid var(--sand-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  padding: 26px;
}

/* Hub d'accueil 2 colonnes : Play & Join à gauche (0 scroll), Tuto GIF à droite */
.lobby-hub-card {
  max-width: 960px;
  max-height: 94vh;
  padding: 24px 28px;
  overflow-y: auto;
}

.lobby-hub-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 22px;
  align-items: start;
}

.lobby-action-column {
  display: flex;
  flex-direction: column;
}

.lobby-tuto-column {
  display: flex;
  flex-direction: column;
}

.lobby-tuto-column .tuto-card {
  margin: 0;
}

.pulse-glow {
  box-shadow: 0 4px 0 #b33210, 0 6px 18px rgba(228, 72, 31, 0.42);
  animation: pulse-cta 2.2s infinite ease-in-out;
}

@keyframes pulse-cta {
  0%, 100% { transform: translateY(0); box-shadow: 0 4px 0 #b33210, 0 6px 18px rgba(228, 72, 31, 0.42); }
  50% { transform: translateY(-2px); box-shadow: 0 6px 0 #b33210, 0 10px 24px rgba(228, 72, 31, 0.65); }
}

@media (max-width: 860px) {
  .lobby-hub-card {
    padding: 18px 16px;
    max-width: 520px;
  }
  .lobby-hub-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .lobby-tuto-column .tuto-card {
    margin-top: 6px;
  }
}

.brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  margin-bottom: 20px;
  text-align: left;
}

.logo-box {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-logo {
  display: block;
  max-width: 150px;
  max-height: 150px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0;
  border-radius: 16px;
  filter: drop-shadow(0 8px 18px rgba(44, 30, 18, 0.28));
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s ease;
  cursor: pointer;
}

.brand-logo:hover {
  transform: scale(1.04) rotate(-1deg);
  filter: drop-shadow(0 10px 22px rgba(44, 30, 18, 0.36));
}

.brand-text-block {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-title {
  font-family: 'Pixelify Sans', cursive, monospace, sans-serif;
  font-size: 2.85rem;
  font-weight: 700;
  line-height: 1.08;
  margin: 0 0 6px 0;
  color: #f59e0b;
  text-shadow:
    2px 0 0 #451a03,
    -1px 0 0 #451a03,
    0 2px 0 #451a03,
    0 -1px 0 #451a03,
    2px 2px 0 #451a03,
    -1px -1px 0 #fef08a,
    3px 4px 0 rgba(69, 26, 3, 0.35);
  letter-spacing: 0.02em;
}

.brand-subtitle {
  font-family: 'Pixelify Sans', cursive, monospace, sans-serif;
  font-size: 1.02rem;
  font-weight: 600;
  color: #78350f;
  margin: 0;
  line-height: 1.35;
  letter-spacing: 0.02em;
  text-shadow: 1px 1px 0 rgba(254, 240, 138, 0.85);
}

@media (max-width: 680px) {
  .brand {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  .brand-logo {
    max-width: 110px;
    max-height: 110px;
  }
  .brand-title {
    font-size: 2.1rem;
  }
  .brand-subtitle {
    font-size: 0.88rem;
  }
}

.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 5px;
  color: var(--wood-soft);
}

.text-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 2px solid var(--sand-border);
  background: #fff;
  font-size: 1rem;
  font-weight: 700;
  color: var(--wood-dark);
  outline: none;
  font-family: inherit;
}

.text-input:focus {
  border-color: var(--sea-blue);
}

.welcome-actions {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--wood-soft);
  font-size: 0.78rem;
  font-weight: 700;
  margin: 2px 0;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1.5px solid var(--sand-border);
}

.divider span {
  padding: 0 10px;
}

.join-row {
  display: flex;
  gap: 8px;
}

.code-input {
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.18em;
  font-weight: 800;
  width: 132px;
  flex-shrink: 0;
}

.rules-chips {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
}

.rule-chip {
  background: rgba(254, 243, 199, 0.95);
  border: 1.5px solid #facc15;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  color: #78350f;
  box-shadow: 0 2px 6px rgba(180, 83, 9, 0.12);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  cursor: default;
}

.rule-chip:hover {
  transform: translateY(-1px) scale(1.02);
  background: #fef08a;
  border-color: #eab308;
}

.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 16px;
  font-size: 0.96rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.btn-lg {
  width: 100%;
  padding: 13px 18px;
  font-size: 1.04rem;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  background: var(--sand-mid);
  color: var(--wood-dark);
  border: 1.5px solid var(--sand-border);
}

.btn-primary {
  background: linear-gradient(135deg, #ff6b42, #e4481f);
  color: #fff;
  box-shadow: 0 4px 0 #b33210, 0 6px 14px rgba(228, 72, 31, 0.32);
}

.btn-secondary {
  background: linear-gradient(135deg, #2191b8, #146c8c);
  color: #fff;
  box-shadow: 0 4px 0 #0e4c63;
}

.btn-accent {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #fff;
  flex: 1;
  box-shadow: 0 4px 0 #92400e;
}

.btn-danger {
  background: linear-gradient(135deg, #ff5e36, #d93814);
  color: #fff;
  padding: 11px 22px;
  box-shadow: 0 4px 0 #9e2408;
}

.error-msg {
  margin-top: 10px;
  color: var(--coral-dark);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

/* Salon d'attente */
.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.72);
  border: 2px solid var(--sand-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.small-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--wood-soft);
  letter-spacing: 0.08em;
}

.room-code-big {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--sea-blue);
}

.qr-box svg {
  width: 88px;
  height: 88px;
  display: block;
}

.join-url {
  font-size: 0.76rem;
  color: var(--wood-soft);
  text-align: center;
  margin: 6px 0 12px;
  user-select: all;
}

.roster-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.roster-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  max-height: 190px;
  overflow-y: auto;
}

.roster-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.78);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--sand-border);
  font-size: 0.92rem;
  font-weight: 700;
}

.kick-btn {
  background: none;
  border: none;
  color: var(--coral);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.hint-msg {
  text-align: center;
  font-size: 0.85rem;
  color: var(--wood-soft);
  margin-top: 8px;
  font-weight: 700;
}

/* ==================== Dock & Sidebar de construction / bataille ==================== */
.dock {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 2.5px solid var(--sand-border);
  border-radius: var(--radius-lg);
  padding: 9px 14px;
  box-shadow: var(--glass-shadow);
  max-width: 96vw;
}

/* ====================================================================
   ATELIER DE CONSTRUCTION ET MODELAGE TOUT À GAUCHE
   ==================================================================== */
.atelier-sidebar {
  position: fixed;
  top: 68px;
  left: 14px;
  width: 230px;
  max-width: 86vw;
  max-height: calc(100vh - 82px);
  padding: 12px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 2.5px solid var(--sand-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
  user-select: none;
}

.atelier-sidebar.hidden {
  display: none !important;
}

.atelier-sidebar.collapsed {
  transform: translateX(calc(-100% + 46px));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.atelier-sidebar.collapsed .sidebar-alerts,
.atelier-sidebar.collapsed .sidebar-section-label,
.atelier-sidebar.collapsed .atelier-tools-row,
.atelier-sidebar.collapsed .sidebar-bucket-status,
.atelier-sidebar.collapsed .sidebar-titles {
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1.5px solid var(--sand-border);
}

.sidebar-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.sidebar-titles {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  transition: opacity 0.15s ease;
}

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--wood-dark);
}

.sidebar-badge {
  font-size: 0.65rem;
  font-weight: 800;
  color: #854d0e;
  background: #fef08a;
  padding: 2px 7px;
  border-radius: 999px;
  align-self: flex-start;
  margin-top: 2px;
}

.sidebar-toggle-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid var(--sand-border);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--wood-dark);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
  background: #fff;
  transform: scale(1.08);
}

.sidebar-alerts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  transition: opacity 0.15s ease;
}

.dock-hint {
  font-size: 0.74rem;
  line-height: 1.35;
  background: rgba(245, 158, 11, 0.2);
  color: var(--wood-dark);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.dock-hint.placed {
  background: rgba(22, 163, 74, 0.16);
  color: #166534;
  border-color: rgba(22, 163, 74, 0.3);
}

.dock-hint.danger {
  background: rgba(239, 68, 68, 0.22);
  color: #991b1b;
  border-color: rgba(239, 68, 68, 0.35);
}

.sidebar-section-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--wood-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
  margin-bottom: 2px;
  transition: opacity 0.15s ease;
}

/* Outils de modelage dans l'atelier tout à gauche (Grille 2x2) */
.atelier-sidebar .atelier-tools-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 1px 0;
  margin-bottom: 4px;
}

.atelier-sidebar .atelier-tools-row .tool-btn {
  width: 100%;
  height: 54px;
}

/* Vision du seau dans l'atelier tout à gauche */
.sidebar-bucket-status {
  background: rgba(255, 255, 255, 0.88);
  border: 1.5px solid var(--sand-border);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  box-shadow: 0 2px 4px rgba(120, 53, 15, 0.08);
}

.bucket-status-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.bucket-status-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bucket-status-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--sand-deep);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.bucket-status-bar {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.bucket-status-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #eab308);
  border-radius: 999px;
  transition: width 0.05s linear;
}

/* ====================================================================
   BARRE D'INVENTAIRE EN FOOTER DANS LE SABLE (UNIQUEMENT LES PATRONS)
   ==================================================================== */
.sand-inventory-footer {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, rgba(254, 243, 199, 0.95) 0%, rgba(245, 208, 142, 0.98) 100%);
  border: 2.5px solid #b4854e;
  border-radius: 18px;
  padding: 6px 12px;
  box-shadow: 0 8px 24px rgba(120, 53, 15, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  max-width: 96vw;
  overflow-x: auto;
  overflow-y: hidden;
  user-select: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(180, 133, 78, 0.6) transparent;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.sand-inventory-footer::-webkit-scrollbar {
  height: 4px;
}
.sand-inventory-footer::-webkit-scrollbar-thumb {
  background: rgba(180, 133, 78, 0.6);
  border-radius: 999px;
}

.sand-inventory-footer.hidden {
  display: none !important;
}

/* Rangée des patrons et moules disponibles posés dans le sable */
.inventory-moulds-row,
.tool-list,
.atelier-moulds-grid {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Les patrons épuisés ou stock 0 sont masqués pour un inventaire toujours net */
.tool-btn.depleted,
.tool-btn.hidden-depleted {
  display: none !important;
}

/* Boutons des patrons dans la barre d'inventaire : slots agrandis sans texte */
.sand-inventory-footer .tool-btn {
  border: 1.5px solid #d4a373;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 12px;
  padding: 4px;
  min-width: 62px;
  width: 66px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  user-select: none;
  box-shadow: 0 2px 5px rgba(120, 53, 15, 0.12), inset 0 1px 0 #fff;
  flex-shrink: 0;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.sand-inventory-footer .tool-btn canvas {
  width: 52px;
  height: 42px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.sand-inventory-footer .tool-btn .tool-stock {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.65rem;
  font-weight: 900;
  background: #2563eb;
  color: #fff;
  padding: 0 5px;
  min-width: 17px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 999px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.tool-btn {
  border: 1.5px solid #d4a373;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  padding: 4px 4px 2px;
  min-width: 54px;
  width: 58px;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
  position: relative;
  user-select: none;
  box-shadow: 0 2px 4px rgba(120, 53, 15, 0.1), inset 0 1px 0 #fff;
  flex-shrink: 0;
}

.tool-btn:hover {
  transform: translateY(-2px);
  background: #ffffff;
  border-color: #b45309;
}

.tool-btn.active {
  border-color: var(--coral);
  background: #fffbeb;
  box-shadow: 0 0 0 2.5px rgba(240, 84, 45, 0.35), 0 3px 8px rgba(180, 83, 9, 0.2);
  transform: translateY(-2px);
}

.tool-btn.king-tool {
  border-color: var(--sun-gold);
  background: rgba(254, 243, 199, 0.92);
}

.tool-btn.king-tool.active {
  border-color: #d97706;
  box-shadow: 0 0 0 2.5px rgba(245, 158, 11, 0.35);
}

.tool-btn.spray-tool {
  border-color: #38bdf8;
  background: rgba(224, 242, 254, 0.92);
}

.tool-btn.spray-tool.active {
  border-color: #0284c7;
  box-shadow: 0 0 0 2.5px rgba(14, 165, 233, 0.35);
}

.tool-btn.flip-tool {
  border-color: #a855f7;
  background: rgba(243, 232, 255, 0.92);
}

.tool-btn.flip-tool.active {
  border-color: #7e22ce;
  box-shadow: 0 0 0 2.5px rgba(168, 85, 247, 0.35);
}

.tool-btn canvas {
  width: 32px;
  height: 22px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.tool-label {
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--wood-dark);
  text-align: center;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52px;
}

.tool-key {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--wood-soft);
  line-height: 1;
}

/* ====================================================================
   BOUTON CROIX ROUGE POUR ARRÊTER LA PARTIE ET REVENIR AU SALON
   ==================================================================== */
.hud-quit-btn {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%) !important;
  color: #fff !important;
  border: 1.5px solid rgba(254, 202, 202, 0.7) !important;
  box-shadow: 0 4px 14px rgba(185, 28, 28, 0.5), 0 0 10px rgba(239, 68, 68, 0.3) !important;
  font-size: 1.15rem !important;
  font-weight: 900 !important;
  line-height: 1 !important;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease !important;
}
.hud-quit-btn:hover {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%) !important;
  transform: scale(1.1) !important;
  box-shadow: 0 6px 18px rgba(185, 28, 28, 0.7), 0 0 16px rgba(239, 68, 68, 0.5) !important;
}
.hud-quit-btn:active {
  transform: scale(0.92) !important;
}
.hud-quit-btn.hidden {
  display: none !important;
}

/* ====================================================================
   BOUTON ICÔNE IMPOSANT POUR CHANGER DE CATAPULTE
   ==================================================================== */
/* ====================================================================
   ACTIONS DE TIR DIRECTEMENT DANS LE SABLE (SANS FOOTER, SANS CONTOUR)
   ==================================================================== */
.sand-catapult-hud {
  position: fixed;
  bottom: 14px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0;
  user-select: none;
  transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1), right 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.sand-catapult-hud.hidden {
  display: none !important;
}

.sand-catapult-hud > * {
  pointer-events: auto;
}

/* Catapulte GAUCHE : commandes à gauche, bouton tir et boulets à droite de la catapulte */
.sand-catapult-hud.cat-left {
  left: 28px;
  right: auto;
  flex-direction: row;
}

/* Catapulte DROITE : commandes à droite, bouton tir et boulets à gauche de la catapulte */
.sand-catapult-hud.cat-right {
  right: 28px;
  left: auto;
  flex-direction: row-reverse;
}

/* 1. Bouton icône pour changer de catapulte (positionné au centre vertical sur le côté opposé) */
@keyframes catapultSwitchPulse {
  0%, 100% {
    transform: translateY(-50%) scale(1);
    box-shadow: 0 6px 20px rgba(45, 20, 5, 0.5), 0 0 0 0 rgba(250, 204, 21, 0.45);
    border-color: #facc15;
  }
  50% {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 10px 30px rgba(45, 20, 5, 0.65), 0 0 24px 8px rgba(250, 204, 21, 0.7);
    border-color: #fef08a;
  }
}

.catapult-icon-switch-btn {
  position: fixed;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  z-index: 35;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: linear-gradient(145deg, #78350f, #451a03);
  border: 4px solid #facc15;
  box-shadow: 0 8px 24px rgba(45, 20, 5, 0.55), inset 0 2px 0 rgba(255, 255, 255, 0.3);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  animation: catapultSwitchPulse 2.4s ease-in-out infinite;
  transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1), left 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.18s ease, box-shadow 0.18s ease;
  pointer-events: auto;
}

.catapult-icon-switch-btn.pos-right {
  right: 28px;
  left: auto;
}

.catapult-icon-switch-btn.pos-left {
  left: 28px;
  right: auto;
}

.catapult-icon-switch-btn.hidden {
  display: none !important;
}

.catapult-icon-switch-btn:hover {
  animation-play-state: paused;
  transform: translateY(-50%) scale(1.15);
  border-color: #fef08a;
  box-shadow: 0 12px 36px rgba(250, 204, 21, 0.8), 0 0 25px rgba(250, 204, 21, 0.55);
}

.catapult-icon-switch-btn:active {
  transform: translateY(-50%) scale(0.96);
}

.cat-switch-icon {
  font-size: 2.85rem;
}

.cat-switch-tag {
  font-size: 1.05rem;
  font-weight: 900;
  color: #fde047;
  letter-spacing: 0.8px;
  margin-top: 4px;
}

/* ==========================================================================
   Overlay d'introduction cinématique de duel au début de chaque combat
   ========================================================================== */
.duel-intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 15, 29, 0.58);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  pointer-events: auto;
  cursor: pointer;
  animation: duelBackdropFadeIn 0.3s ease-out forwards;
}

.duel-intro-overlay.hidden {
  display: none !important;
}

.duel-intro-overlay.closing {
  animation: duelBackdropFadeOut 0.28s ease-in forwards;
}

@keyframes duelBackdropFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes duelBackdropFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.duel-intro-card {
  position: relative;
  width: 90%;
  max-width: 580px;
  background: linear-gradient(155deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.98));
  border: 3.5px solid #f59e0b;
  border-radius: 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 35px rgba(245, 158, 11, 0.4);
  padding: 24px 30px;
  text-align: center;
  color: #fff;
  user-select: none;
  animation: duelCardPop 0.38s cubic-bezier(0.18, 1.25, 0.35, 1) forwards;
}

.duel-intro-overlay.closing .duel-intro-card {
  animation: duelCardOut 0.28s ease-in forwards;
}

@keyframes duelCardPop {
  0% {
    opacity: 0;
    transform: scale(0.68) translateY(30px);
  }
  70% {
    opacity: 1;
    transform: scale(1.03) translateY(-4px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes duelCardOut {
  0% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.85) translateY(-25px);
  }
}

.duel-badge-top {
  display: inline-block;
  background: linear-gradient(90deg, #d97706, #f59e0b, #d97706);
  color: #1e1b4b;
  font-weight: 900;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 16px;
  border-radius: 999px;
  margin-bottom: 18px;
  box-shadow: 0 3px 10px rgba(245, 158, 11, 0.5);
}

.duel-matchup {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 16px;
  margin-bottom: 18px;
}

.duel-combatant {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.combatant-icon-wrapper {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  border: 3.5px solid #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5), 0 0 16px rgba(56, 189, 248, 0.35);
  margin-bottom: 8px;
  transition: transform 0.2s ease;
}

.duel-shooter .combatant-icon-wrapper {
  border-color: #f59e0b;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5), 0 0 20px rgba(245, 158, 11, 0.45);
}

.duel-target .combatant-icon-wrapper {
  border-color: #e11d48;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5), 0 0 20px rgba(225, 29, 72, 0.45);
}

.combatant-avatar {
  font-size: 3rem;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

.combatant-subicon {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1e293b;
  border: 2px solid #facc15;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.combatant-role {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #94a3b8;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.combatant-name {
  font-size: 1.15rem;
  font-weight: 900;
  color: #f8fafc;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duel-vs {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.vs-text {
  font-size: 1.8rem;
  font-weight: 950;
  font-style: italic;
  background: linear-gradient(180deg, #fef08a, #ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(239, 68, 68, 0.6));
  line-height: 1;
}

.vs-swords {
  font-size: 1.25rem;
  margin-top: 2px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
}

.duel-summary {
  font-size: 1.15rem;
  font-weight: 600;
  color: #fef08a;
  line-height: 1.4;
  margin-bottom: 6px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  border: 1px solid rgba(254, 240, 138, 0.2);
}

.duel-summary strong {
  color: #ffffff;
  font-weight: 900;
  text-shadow: 0 0 10px rgba(250, 204, 21, 0.6);
}

.duel-subhint {
  font-size: 0.85rem;
  color: #cbd5e1;
  font-weight: 500;
  letter-spacing: 0.02em;
}

@media (max-width: 680px) {
  .catapult-icon-switch-btn {
    width: 86px;
    height: 86px;
  }
  .cat-switch-icon {
    font-size: 2rem;
  }
  .cat-switch-tag {
    font-size: 0.78rem;
  }
  .combatant-icon-wrapper {
    width: 70px;
    height: 70px;
  }
  .combatant-avatar {
    font-size: 2.2rem;
  }
  .duel-summary {
    font-size: 0.95rem;
  }
}

/* 2. Râtelier de boulets posé dans le sable */
.sand-ammo-rack {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 50px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(45, 20, 5, 0.82);
  border: 2px solid rgba(245, 158, 11, 0.65);
  box-shadow: 0 4px 14px rgba(40, 20, 5, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
}

.shots-balls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.shot-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.15rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
}

.shot-ball.available {
  border-color: #facc15;
  background: radial-gradient(circle, rgba(250, 204, 21, 0.35), rgba(0, 0, 0, 0.4));
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.45);
  transform: scale(1.05);
}

.shot-ball.used {
  opacity: 0.25;
  filter: grayscale(1);
  transform: scale(0.9);
}

/* 3. Grand bouton de puissance étiré en longueur directement dans le sable */
.sand-power-trigger-btn {
  position: relative;
  height: 50px;
  min-width: 190px;
  max-width: 260px;
  padding: 0 18px;
  border-radius: 999px;
  background: linear-gradient(145deg, #7c2d12, #431407);
  border: 2.5px solid #ea580c;
  box-shadow: 0 5px 16px rgba(45, 20, 5, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  color: #fff;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}

.sand-power-trigger-btn:hover {
  border-color: #f97316;
  box-shadow: 0 6px 18px rgba(234, 88, 12, 0.45);
}

.sand-power-trigger-btn:active {
  transform: scale(0.97);
}

.sand-power-trigger-btn.charging {
  border-color: #facc15;
  box-shadow: 0 0 20px rgba(250, 204, 21, 0.65), 0 6px 18px rgba(234, 88, 12, 0.5);
  animation: trigger-vibrate 0.08s infinite alternate;
}

@keyframes trigger-vibrate {
  from { transform: translateY(0); }
  to { transform: translateY(-1.5px); }
}

.hud-power-progress-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0%;
  background: linear-gradient(90deg, #ca8a04 0%, #ea580c 50%, #ef4444 100%);
  opacity: 0.88;
  pointer-events: none;
  border-radius: 999px;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.8);
  transition: width 0.03s linear;
}

.sand-power-inner {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  pointer-events: none;
  font-family: 'Fredoka', 'Quicksand', sans-serif;
  font-weight: 700;
  white-space: nowrap;
}

.sand-power-inner .power-bolt {
  font-size: 1.35rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.sand-power-heading {
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.sand-power-sub {
  font-size: 0.82rem;
  color: #fef08a;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==================== Bannière Défense & Spectateur Flottante ==================== */
.defender-floating-pill {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  background: rgba(12, 74, 110, 0.88);
  backdrop-filter: blur(12px);
  border: 2px solid #38bdf8;
  border-radius: 999px;
  padding: 8px 22px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 0 16px rgba(56, 189, 248, 0.3);
  color: #fff;
  display: flex;
  align-items: center;
  pointer-events: none;
  max-width: 90vw;
  animation: floatPill 2.5s infinite ease-in-out;
}

.defender-floating-pill.hidden {
  display: none;
}

@keyframes floatPill {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-3px); }
}

.defender-pill-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.defender-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.defender-text {
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.3;
  color: #f0f9ff;
  text-align: center;
}

/* Victoire */
.over-card {
  text-align: center;
}

.crown-icon {
  font-size: 3.4rem;
  margin-bottom: 6px;
}

.over-actions {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Journal discret */
.toast-log {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: none;
  max-width: 320px;
}

.toast-item {
  background: rgba(44, 30, 18, 0.82);
  color: #fff;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  animation: fadeToast 4.5s forwards;
}

@keyframes fadeToast {
  0% { opacity: 0; transform: translateY(6px); }
  10% { opacity: 1; transform: translateY(0); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* Indicateur de remplissage de seau dans la sidebar */
.sidebar-bucket-status {
  background: rgba(255, 255, 255, 0.88);
  border: 1.5px solid var(--sand-border);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.bucket-status-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.bucket-status-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bucket-status-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--sand-deep);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.bucket-status-bar {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.bucket-status-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #eab308);
  border-radius: 999px;
  transition: width 0.05s linear;
}

/* Barre d'indicateur des 3 boules de catapulte */
.shots-indicator-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(26, 20, 14, 0.82);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 12px;
  padding: 6px 14px;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.shots-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: #fae29c;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.shots-balls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shot-ball {
  font-size: 1.15rem;
  transition: transform 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.shot-ball.available {
  opacity: 1;
  transform: scale(1);
  animation: pulseShot 2s infinite ease-in-out;
}

.shot-ball.used {
  opacity: 0.22;
  filter: grayscale(1);
  transform: scale(0.8);
}

@keyframes pulseShot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* Grand Overlay d'intro cinématique ("Prêts ? Feu .. Construisez !") */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease;
}

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

.intro-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: rgba(30, 22, 14, 0.92);
  border: 3px solid #d4af37;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 32px rgba(245, 158, 11, 0.35);
  border-radius: 24px;
  padding: 32px 48px;
  max-width: 440px;
  width: 90%;
  pointer-events: none;
  animation: popIntro 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIntro {
  0% { transform: scale(0.7) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.intro-animation-area {
  position: relative;
  width: 140px;
  height: 140px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.intro-bucket-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45));
}

.intro-catapult-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.intro-catapult-art {
  font-size: 5rem;
  line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(234, 88, 12, 0.5));
  animation: bounceArt 1.2s infinite alternate ease-in-out;
}

.intro-balls-badge {
  background: #ea580c;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 900;
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

@keyframes bounceArt {
  0% { transform: translateY(0) rotate(-4deg); }
  100% { transform: translateY(-8px) rotate(4deg); }
}

.intro-title {
  font-size: 2.4rem;
  font-weight: 900;
  color: #fde047;
  text-shadow: 0 3px 12px rgba(245, 158, 11, 0.6), 0 2px 4px #000;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
  transition: transform 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.intro-title.big-step {
  transform: scale(1.18);
  color: #4ade80;
  text-shadow: 0 3px 16px rgba(34, 197, 94, 0.8), 0 2px 4px #000;
}

.intro-subtitle {
  font-size: 1rem;
  font-weight: 700;
  color: #f8fafc;
  opacity: 0.9;
  margin-bottom: 18px;
}

.intro-progress-bar-wrapper {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  overflow: hidden;
}

.intro-progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #facc15, #22c55e);
  border-radius: 999px;
  transition: width 0.08s linear;
}

@media (max-width: 680px) {
  .banner-msg, .toast-log, .dock-tip {
    display: none;
  }

  .sand-inventory-footer {
    bottom: 6px;
    padding: 4px 6px;
    gap: 4px;
    border-radius: 12px;
  }

  .sand-inventory-footer .tool-btn {
    width: 54px;
    min-width: 48px;
    height: 52px;
    padding: 2px;
  }

  .sand-inventory-footer .tool-btn canvas {
    width: 46px;
    height: 34px;
  }

  .tool-btn {
    width: 48px;
    min-width: 44px;
    height: 48px;
    padding: 2px 2px 1px;
  }

  .tool-btn canvas {
    width: 26px;
    height: 18px;
  }

  .tool-label {
    font-size: 0.54rem;
    max-width: 42px;
  }

  .tool-key {
    font-size: 0.48rem;
  }
}

/* ==================== Timeline de Bataille (Duels d'icônes épurées) ==================== */
.battle-timeline {
  position: fixed;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 12, 8, 0.90);
  border: 1.5px solid rgba(245, 158, 11, 0.65);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 12px;
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.timeline-flow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.king-duels-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.king-duel-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.king-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.5));
  border: 2px solid var(--c, #facc15);
  box-shadow: 0 0 10px var(--c, rgba(250, 204, 21, 0.45));
  transition: transform 0.2s ease;
  user-select: none;
}

.king-badge:hover {
  transform: scale(1.12);
}

.king-badge.next {
  width: 26px;
  height: 26px;
  border-width: 1.5px;
  opacity: 0.8;
  box-shadow: none;
}

.king-crown-icon {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

.duel-swords {
  font-size: 1.05rem;
  line-height: 1;
  user-select: none;
  animation: pulse-swords 1.8s infinite ease-in-out;
}

.duel-swords.next {
  font-size: 0.82rem;
  opacity: 0.65;
  animation: none;
}

.duel-flow-arrow {
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 900;
  opacity: 0.6;
  margin: 0 2px;
  user-select: none;
}

@keyframes pulse-swords {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 2px rgba(250, 204, 21, 0.5)); }
  50% { transform: scale(1.15); filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.85)); }
}

/* ==================== Badges de stock de patrons ==================== */
.tool-stock {
  position: absolute;
  top: 4px;
  right: 6px;
  background: #3b82f6;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 999px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

.tool-stock.depleted {
  background: #ef4444;
}

.tool-btn.depleted {
  opacity: 0.38;
  filter: grayscale(0.85);
  cursor: not-allowed;
  pointer-events: none;
}

/* ==================== Modale choix de cible (Sécheresse) ==================== */
.bonus-choice-card {
  max-width: 420px;
  text-align: center;
  border-color: #f59e0b;
}

.bonus-choice-icon {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: 8px;
}

.target-choice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  max-height: 240px;
  overflow-y: auto;
}

.target-choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}

.target-choice-btn:hover {
  background: rgba(245, 158, 11, 0.3);
  border-color: #facc15;
  transform: translateX(4px);
}

/* ==================== Tuto Animé "GIF" (3 Règles d'Or) ==================== */
.tuto-card {
  margin: 14px 0 16px;
  background: rgba(30, 22, 16, 0.94);
  border: 2px solid rgba(245, 158, 11, 0.7);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color: #fff;
}

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

.tuto-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tuto-badge-step {
  font-size: 0.72rem;
  font-weight: 900;
  color: #1e1b4b;
  background: #facc15;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.5px;
}

.tuto-gif-tag {
  font-size: 0.65rem;
  font-weight: 800;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.12);
  padding: 2px 7px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse-live 1.2s infinite ease-in-out;
}

@keyframes pulse-live {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}

.tuto-nav-buttons {
  display: flex;
  gap: 4px;
}

.tuto-arrow-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fde047;
  border-radius: 8px;
  width: 26px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.12s ease;
}

.tuto-arrow-btn:hover {
  background: rgba(245, 158, 11, 0.35);
  border-color: #facc15;
  transform: scale(1.08);
}

.tuto-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  overflow-x: auto;
}

.tuto-tab-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  border-radius: 8px;
  padding: 5px 6px;
  font-size: 0.73rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  font-family: inherit;
}

.tuto-tab-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.tuto-tab-btn.active {
  background: rgba(245, 158, 11, 0.3);
  border-color: #facc15;
  color: #fde047;
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.25);
}

.tuto-screen {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid rgba(245, 158, 11, 0.4);
  line-height: 0;
}

.tuto-canvas {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
}

.tuto-progress-track {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.5);
}

.tuto-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b, #facc15);
  transition: width 0.08s linear;
}

.tuto-caption {
  margin-top: 8px;
  padding: 4px 2px;
}

.tuto-caption-title {
  font-size: 0.86rem;
  font-weight: 900;
  color: #fde047;
  margin-bottom: 3px;
}

.tuto-caption-text {
  font-size: 0.77rem;
  color: #e2e8f0;
  line-height: 1.4;
  margin: 0;
}

/* ====================================================================
   PANNEAU TRANSLUCIDE CHAT & HISTORIQUE DE COMBAT
   ==================================================================== */
.game-chat-dock {
  position: fixed;
  top: 56px;
  bottom: auto;
  right: 14px;
  width: 290px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 72px);
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  color: #f1f5f9;
  z-index: 45;
  font-family: system-ui, -apple-system, sans-serif;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.game-chat-dock.collapsed {
  width: auto;
  min-width: 170px;
  background: rgba(15, 23, 42, 0.55);
}

.game-chat-dock.collapsed .chat-body {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  user-select: none;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #fde047;
  letter-spacing: 0.3px;
}

.chat-icon {
  font-size: 0.9rem;
}

.chat-unread-badge {
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 999px;
  line-height: 1.2;
}

.chat-header-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #cbd5e1;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.chat-body {
  display: flex;
  flex-direction: column;
}

.chat-messages {
  height: 145px;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.74rem;
  line-height: 1.35;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.chat-msg {
  display: flex;
  align-items: baseline;
  gap: 5px;
  word-break: break-word;
}

.chat-msg.system {
  color: #cbd5e1;
  font-style: italic;
  font-size: 0.71rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 3px 6px;
  border-radius: 6px;
  border-left: 2px solid #38bdf8;
}

.chat-msg.bonus {
  color: #fef08a;
  background: rgba(234, 179, 8, 0.12);
  padding: 3px 6px;
  border-radius: 6px;
  border-left: 2px solid #facc15;
}

.chat-msg-time {
  font-size: 0.62rem;
  color: #94a3b8;
  opacity: 0.7;
}

.chat-msg-name {
  font-weight: 800;
}

.chat-msg-text {
  color: #f8fafc;
}

.chat-form {
  display: flex;
  padding: 6px 8px;
  gap: 6px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 4px 8px;
  color: #fff;
  font-size: 0.75rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.chat-input:focus {
  border-color: #38bdf8;
  background: rgba(255, 255, 255, 0.14);
}

.chat-send-btn {
  background: #0284c7;
  border: none;
  color: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-send-btn:hover {
  background: #0369a1;
}

/* Sélecteur de catapulte balistique (Gauche / Droite) */
.catapult-side-picker {
  display: flex;
  gap: 6px;
  margin: 6px 0 8px 0;
  width: 100%;
}

.side-btn {
  flex: 1;
  background: rgba(30, 22, 14, 0.7);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 8px;
  color: #cbd5e1;
  padding: 6px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.side-btn:hover {
  background: rgba(45, 32, 20, 0.9);
  border-color: rgba(212, 175, 55, 0.7);
  color: #fff;
}

.side-btn.active {
  background: linear-gradient(135deg, #d97706, #b45309);
  border-color: #fde047;
  color: #fff;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
}




