: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;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea, .btn, .pill, .tool-btn, .shot-ball {
  touch-action: manipulation;
}

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;
}

.my-castle-pill {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border-color: #7dd3fc;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.my-castle-pill:hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.55);
}

.my-castle-pill.active-return {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #fef08a;
  color: #fff;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.55);
  animation: pulse 0.9s infinite alternate;
}

.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;
}

.mobile-tuto-btn {
  display: none;
}

.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;
}

.room-code-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.copy-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px solid rgba(14, 116, 144, 0.3);
  font-size: 1.25rem;
  color: var(--sea-blue);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
  padding: 0;
  line-height: 1;
}

.copy-icon-btn:hover {
  background: #ffffff;
  border-color: var(--sea-blue);
  transform: translateY(-1px) scale(1.08);
  box-shadow: 0 4px 8px rgba(14, 116, 144, 0.25);
}

.copy-icon-btn:active {
  transform: scale(0.92);
}

.copy-icon-btn.copied {
  background: #16a34a !important;
  color: #fff !important;
}

.spectate-btn-wrap {
  margin: 10px 0 14px;
  padding: 12px;
  background: rgba(56, 189, 248, 0.12);
  border: 2px dashed #0284c7;
  border-radius: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spectate-notice {
  font-size: 0.85rem;
  font-weight: 800;
  color: #0369a1;
  margin: 0;
}

.spectate-btn-wrap button {
  width: 100%;
}

.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;
  margin-bottom: 8px;
  padding: 0 4px;
}

.roster-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--wood-dark, #3e2723);
  letter-spacing: 0.2px;
}

.roster-badge {
  background: rgba(228, 87, 46, 0.15);
  color: #c2410c;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  border: 1px solid rgba(228, 87, 46, 0.3);
}

.add-bot-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(248, 250, 252, 0.85);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1.5px dashed rgba(203, 213, 225, 0.9);
  margin-bottom: 12px;
}

.bot-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.bot-select-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: #475569;
  white-space: nowrap;
}

.add-bot-panel .bot-difficulty-select {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.btn-add-bot {
  white-space: nowrap;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 7px 12px;
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  color: #1e293b;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-add-bot:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.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;
}

/* ====================================================================
   BANDEAU DES JOUEURS SOUS LA ROOM (PC UNIQUEMENT)
   ==================================================================== */
.pc-players-strip {
  position: fixed;
  top: 60px;
  left: 14px;
  z-index: 24;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-width: min(640px, calc(100vw - 320px));
  pointer-events: auto;
  user-select: none;
}

.pc-players-strip.hidden {
  display: none !important;
}

.pc-player-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  border: 2.5px solid var(--p-color, #38bdf8);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35), 0 0 8px var(--p-glow, rgba(56, 189, 248, 0.3));
  color: #f8fafc;
  font-size: 0.78rem;
  font-weight: 800;
  transition: transform 0.15s ease, opacity 0.2s ease;
}

.pc-player-chip.is-dead {
  opacity: 0.62;
  filter: grayscale(0.45);
}

.pc-player-chip.player-disconnected,
.roster-item.player-disconnected {
  animation: pcPlayerDisconnectBlink 0.9s infinite ease-in-out !important;
}

@keyframes pcPlayerDisconnectBlink {
  0%, 100% {
    border-color: var(--p-color, #f59e0b);
    box-shadow: 0 0 6px var(--p-color, #f59e0b);
    background: rgba(15, 23, 42, 0.9);
  }
  50% {
    border-color: #ef4444;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.95), inset 0 0 8px rgba(239, 68, 68, 0.45);
    background: rgba(127, 29, 29, 0.88);
  }
}

.pc-player-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.pc-player-name {
  max-width: 115px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pc-player-kick-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 2px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(248, 113, 113, 0.8);
  background: rgba(220, 38, 38, 0.25);
  color: #fecaca;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pc-player-kick-btn:hover {
  background: #dc2626;
  border-color: #fef2f2;
  color: #ffffff;
  transform: scale(1.12);
}

/* ====================================================================
   ATELIER DE CONSTRUCTION ET MODELAGE TOUT À GAUCHE
   ==================================================================== */
.atelier-sidebar {
  position: fixed;
  top: 102px;
  left: 14px;
  width: 230px;
  max-width: 86vw;
  max-height: calc(100vh - 116px);
  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);
}

.atelier-bucket-canvas {
  width: 44px;
  height: 44px;
  display: block;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: rgba(254, 240, 138, 0.25);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 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;
}

/* ==========================================================================
   Pile cinématique unifiée : Cadre fin en long (Qui combat qui) + Prêts/Partez en dessous
   ========================================================================== */
#pause-modal {
  z-index: 9999 !important;
}

.cinematic-stack {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 58px 14px 20px;
  pointer-events: none;
}

.duel-intro-overlay {
  position: relative;
  width: 100%;
  max-width: 680px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  animation: duelBackdropFadeIn 0.28s ease-out forwards;
}

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

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

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

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

.duel-intro-card.duel-slim-banner {
  position: relative;
  width: 100%;
  max-width: 660px;
  background: linear-gradient(155deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.98));
  border: 2.5px solid #f59e0b;
  border-radius: 18px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.65), 0 0 24px rgba(245, 158, 11, 0.35);
  padding: 10px 18px;
  color: #fff;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: duelCardPop 0.32s cubic-bezier(0.18, 1.25, 0.35, 1) forwards;
}

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

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

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

.duel-slim-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.duel-badge-top {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(90deg, #d97706, #f59e0b);
  color: #1e1b4b;
  font-weight: 900;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.45);
}

.duel-combatant {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.duel-target {
  justify-content: flex-end;
  text-align: right;
}

.duel-target .combatant-icon-wrapper {
  order: 2;
}

.duel-target .combatant-meta {
  order: 1;
}

.combatant-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.combatant-icon-wrapper {
  position: relative;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.9);
  border: 2.5px solid #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

.duel-shooter .combatant-icon-wrapper {
  border-color: #f59e0b;
}

.duel-target .combatant-icon-wrapper {
  border-color: #e11d48;
}

.combatant-avatar {
  font-size: 1.55rem;
  line-height: 1;
}

.combatant-subicon {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #1e293b;
  border: 1.5px solid #facc15;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
}

.combatant-role {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #94a3b8;
  text-transform: uppercase;
}

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

.duel-vs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 6px;
  flex-shrink: 0;
}

.vs-text {
  font-size: 1.25rem;
  font-weight: 950;
  font-style: italic;
  background: linear-gradient(180deg, #fef08a, #ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.vs-swords {
  font-size: 1rem;
}

.duel-slim-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  border: 1px solid rgba(254, 240, 138, 0.18);
}

.duel-summary {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fef08a;
  line-height: 1.25;
}

.duel-summary strong {
  color: #ffffff;
  font-weight: 900;
}

.duel-subhint {
  font-size: 0.78rem;
  color: #cbd5e1;
  font-weight: 600;
}



/* 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.35;
  filter: grayscale(1);
  transform: scale(0.9);
}

.shot-ball-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
}

.shot-ball.used .shot-ball-img {
  filter: grayscale(1) opacity(0.35);
}

/* 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;
  -webkit-user-select: none;
  -webkit-touch-callout: 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: 8px;
  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.25rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

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

.sand-power-trigger-btn.charging .sand-power-heading {
  font-size: 0.80rem;
  letter-spacing: 0.2px;
}

.sand-power-sub {
  font-size: 0.82rem;
  color: #fef08a;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: right;
}

.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 !") sous le cadre de duel */
.intro-overlay {
  position: relative;
  width: 100%;
  max-width: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.35s ease;
}

.intro-overlay.hidden {
  display: none !important;
  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.94);
  border: 3px solid #d4af37;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.65), 0 0 32px rgba(245, 158, 11, 0.35);
  border-radius: 22px;
  padding: 20px 32px;
  max-width: 440px;
  width: 100%;
  pointer-events: none;
  animation: popIntro 0.32s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

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

.intro-animation-area {
  position: relative;
  width: 110px;
  height: 110px;
  margin-bottom: 8px;
  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;
}

/* Note: Responsive mobile & smartphone styles are unified in the responsive section at the bottom */

/* ==================== 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: 28px;
  height: 28px;
  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: 22px;
  height: 22px;
  border-width: 1.5px;
  opacity: 0.85;
  box-shadow: none;
}

.duel-fighter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid var(--c, #facc15);
  box-shadow: 0 0 8px var(--c, rgba(250, 204, 21, 0.35));
  transition: transform 0.15s ease;
}

.duel-fighter:hover {
  transform: scale(1.05);
}

.duel-fighter-name {
  font-size: 0.82rem;
  font-weight: 800;
  color: #fff;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duel-fighter-badge {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 6px;
  background: #f59e0b;
  color: #000;
  letter-spacing: 0.02em;
}

.duel-fighter-badge.def {
  background: #38bdf8;
  color: #082f49;
}

.duel-next-label {
  font-size: 0.70rem;
  font-weight: 700;
  color: #94a3b8;
  margin-right: 2px;
}

.duel-fighter-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px 1px 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--c, #94a3b8);
  opacity: 0.85;
}

.duel-mini-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: #cbd5e1;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.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;
}

/* ====================================================================
   CENTRE DE NOTIFICATIONS & STATUT (EN HAUT À DROITE)
   ==================================================================== */
.game-chat-dock {
  position: fixed;
  top: 58px;
  bottom: auto;
  right: 14px;
  width: 315px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 76px);
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  box-shadow: 0 10px 32px 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: 175px;
  background: rgba(15, 23, 42, 0.62);
}

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

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  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;
}

.notif-status-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  background: rgba(30, 41, 59, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 3.5px solid #38bdf8;
  font-size: 0.76rem;
  line-height: 1.32;
  color: #f8fafc;
}

.notif-status-banner.status-defense {
  background: rgba(12, 74, 110, 0.72);
  border-left-color: #38bdf8;
}

.notif-status-banner.status-attack {
  background: rgba(120, 53, 15, 0.68);
  border-left-color: #f59e0b;
}

.notif-status-banner.status-danger {
  background: rgba(127, 29, 29, 0.72);
  border-left-color: #ef4444;
}

.notif-status-banner.status-inspect {
  background: rgba(8, 145, 178, 0.68);
  border-left-color: #22d3ee;
}

.notif-status-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
  line-height: 1;
}

.notif-status-text {
  flex: 1;
  font-weight: 700;
}

.notif-status-text strong {
  color: #fde047;
  font-weight: 900;
}

.chat-messages {
  max-height: 175px;
  min-height: 95px;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  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.22);
  border-radius: 4px;
}

.chat-msg {
  display: flex;
  align-items: center;
  gap: 7px;
  word-break: break-word;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid #64748b;
  animation: notifSlideIn 0.22s ease-out;
}

@keyframes notifSlideIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

.chat-msg.system {
  color: #e2e8f0;
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.05);
  border-left-color: #38bdf8;
}

.chat-msg.combat {
  color: #fed7aa;
  background: rgba(234, 88, 12, 0.16);
  border-left-color: #f97316;
}

.chat-msg.defense {
  color: #bae6fd;
  background: rgba(2, 132, 199, 0.2);
  border-left-color: #38bdf8;
}

.chat-msg.bonus {
  color: #fef08a;
  background: rgba(234, 179, 8, 0.18);
  border-left-color: #facc15;
}

.chat-msg.danger {
  color: #fecaca;
  background: rgba(220, 38, 38, 0.22);
  border-left-color: #ef4444;
}

.notif-badge-icon {
  font-size: 0.92rem;
  flex-shrink: 0;
  line-height: 1;
}

.chat-msg-time {
  font-size: 0.62rem;
  color: #94a3b8;
  opacity: 0.85;
  flex-shrink: 0;
}

.chat-msg-text {
  color: #f8fafc;
  font-weight: 700;
  flex: 1;
}

/* 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);
}

/* ==================== Ligne Partie Rapide + S'entraîner ==================== */
.quick-play-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.quick-play-row .btn {
  padding-left: 12px;
  padding-right: 12px;
  font-size: 0.96rem;
  white-space: nowrap;
}

.btn-train {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #ffffff;
  border: 2px solid #7dd3fc;
  box-shadow: 0 4px 0 #0369a1, 0 6px 14px rgba(2, 132, 199, 0.35);
}

.btn-train:hover {
  background: linear-gradient(135deg, #38bdf8, #0369a1);
  transform: translateY(-2px);
}

/* ==================== Modale de choix d'entraînement ==================== */
.training-choice-card {
  max-width: 580px;
  text-align: center;
  background: var(--glass-bg, rgba(255, 251, 240, 0.96));
  border: 3px solid var(--sand-border, #d9b982);
  border-radius: var(--radius-lg, 22px);
  box-shadow: var(--glass-shadow, 0 14px 36px rgba(44, 30, 18, 0.22));
  color: var(--wood-dark, #2c1e12);
}

.training-choice-card h2 {
  color: var(--wood-dark, #2c1e12);
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 1.55rem;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.training-modes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.training-mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-radius: var(--radius-md, 16px);
  background: #ffffff;
  border: 2.5px solid var(--sand-border, #d9b982);
  color: var(--wood-dark, #2c1e12);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 12px rgba(44, 30, 18, 0.08);
  font-family: inherit;
}

.training-mode-card:hover {
  background: #fffdf7;
  border-color: #f59e0b;
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.28), 0 4px 0 #d97706;
}

.training-mode-icon {
  font-size: 2.3rem;
  line-height: 1.1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.training-mode-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--wood-dark, #2c1e12);
  font-family: 'Fredoka', 'Nunito', sans-serif;
}

.training-mode-desc {
  font-size: 0.82rem;
  color: var(--wood-soft, #634932);
  line-height: 1.4;
  font-weight: 600;
}

/* ==================== Contrôles d'entraînement dans le HUD ==================== */
.train-hud-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.train-action-pill {
  background: linear-gradient(135deg, #ea580c, #c2410c) !important;
  color: #fff !important;
  border: 1.5px solid #fde047 !important;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(234, 88, 12, 0.45);
}

.train-action-pill:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.train-switch-pill {
  background: rgba(2, 132, 199, 0.88) !important;
  color: #fff !important;
  border: 1.5px solid #7dd3fc !important;
  font-weight: 800;
  cursor: pointer;
}

/* ==================== Boutons de sélection de boulet par type sous la catapulte ==================== */
.shot-ball.ammo-type-btn {
  position: relative;
  width: auto;
  min-width: 54px;
  height: 38px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  gap: 5px;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transform: translateY(0);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  user-select: none;
}

.shot-ball.ammo-type-btn:hover {
  border-color: #fde047;
  background: rgba(250, 204, 21, 0.28);
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.5);
  transform: translateY(-2px);
}

.shot-ball.ammo-type-btn:active {
  transform: translateY(0) scale(0.96);
}

.shot-ball.ammo-type-btn.selected {
  border-color: #facc15;
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.45), rgba(234, 88, 12, 0.5));
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transform: scale(1.06);
}

.ammo-count-badge {
  font-size: 0.78rem;
  font-weight: 900;
  color: #fef08a;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  font-family: 'Fredoka', 'Nunito', sans-serif;
  line-height: 1;
}

/* ==================== Sélecteurs de difficulté de l'IA (Âge) ==================== */
.add-bot-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bot-difficulty-select {
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 800;
  border-radius: 8px;
  background: #ffffff;
  color: var(--wood-dark, #2c1e12);
  border: 1.5px solid var(--sand-border, #d9b982);
  cursor: pointer;
  outline: none;
  box-shadow: 0 1px 4px rgba(44, 30, 18, 0.08);
  transition: all 0.15s ease;
}
.bot-difficulty-select:hover,
.bot-difficulty-select:focus {
  border-color: #f59e0b;
}
.bot-difficulty-select option {
  background: #ffffff;
  color: var(--wood-dark, #2c1e12);
  font-weight: 700;
}

.training-difficulty-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 16px 0;
  padding: 10px 16px;
  background: rgba(243, 227, 195, 0.45);
  border-radius: var(--radius-sm, 12px);
  border: 1.5px solid var(--sand-border, #d9b982);
}

.training-difficulty-label {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--wood-dark, #2c1e12);
}

.train-difficulty-select {
  padding: 6px 12px;
  font-size: 0.88rem;
  font-weight: 800;
  border-radius: 8px;
  background: #ffffff;
  color: var(--wood-dark, #2c1e12);
  border: 2px solid var(--sand-border, #d9b982);
  cursor: pointer;
  outline: none;
  box-shadow: 0 2px 6px rgba(44, 30, 18, 0.08);
  transition: all 0.15s ease;
}

.train-difficulty-select:hover,
.train-difficulty-select:focus {
  border-color: #f59e0b;
}

.train-difficulty-select option {
  background: #ffffff;
  color: var(--wood-dark, #2c1e12);
  font-weight: 700;
}

/* ==================== Bouton Rejoindre la salle précédente ==================== */
.btn-rejoin {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
  border: 2px solid #38bdf8;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  font-weight: 800;
  width: 100%;
  padding: 12px 18px;
  cursor: pointer;
}

.btn-rejoin:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
  border-color: #7dd3fc;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.55);
}

.btn-rejoin strong {
  color: #fef08a;
  letter-spacing: 1px;
}

/* ==================== Modale Menu Pause ==================== */
.pause-modal-card {
  max-width: 440px;
  text-align: center;
  background: var(--glass-bg, rgba(255, 251, 240, 0.96));
  border: 3.5px solid var(--sand-border, #d9b982);
  border-radius: var(--radius-lg, 22px);
  box-shadow: 0 16px 42px rgba(44, 30, 18, 0.35);
  padding: 28px 24px;
  animation: pause-pop 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pause-pop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.pause-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.pause-modal-card h2 {
  font-size: 1.8rem;
  letter-spacing: 1px;
  color: var(--wood-dark, #2c1e12);
  margin-bottom: 4px;
}

.pause-subtitle {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--wood-soft, #634932);
  margin-bottom: 20px;
}

.pause-actions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.pause-actions-list .btn {
  width: 100%;
  padding: 13px 18px;
  font-size: 1rem;
  font-weight: 800;
  border-radius: var(--radius-md, 14px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #ffffff;
  border: 2px solid #f87171;
  box-shadow: 0 4px 0 #b91c1c, 0 6px 14px rgba(220, 38, 38, 0.35);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #f87171, #dc2626);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #b91c1c, 0 8px 18px rgba(220, 38, 38, 0.45);
}

/* ==================== Éléments strictement réservés au Mobile (masqués sur PC) ==================== */
.sand-catapult-top-row,
.mobile-chat-btn,
.mobile-tuto-btn,
.chat-backdrop {
  display: none;
}

/* Structure interne de la bannière Défense & Château sur PC */
.defender-floating-pill.inspect-mode {
  border-color: #38bdf8;
  box-shadow: 0 8px 28px rgba(14, 165, 233, 0.35);
}

.defender-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.defender-actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.defender-spray-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(2, 132, 199, 0.28);
  border: 1.5px solid #38bdf8;
  color: #e0f2fe;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.defender-return-btn {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

/* ==========================================================================
   ADAPTATION RESPONSIVE SMARTPHONE & MOBILE COMPLÈTE
   (Préserve 100% de l'expérience PC tout en offrant une ergonomie tactile parfaite)
   ========================================================================== */

/* 1. Écrans Tablettes & Petits Ordinateurs (max 860px) */
@media (max-width: 860px) {
  .lobby-hub-card {
    padding: 20px 16px;
    max-width: 540px;
    width: 95vw;
  }
  .lobby-hub-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .lobby-tuto-column .tuto-card {
    margin-top: 4px;
  }
}

/* 2. Smartphones & Écrans Tactiles Mobiles (max 768px) */
@media (max-width: 768px) {
  /* Safe area & espacements généraux */
  body {
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
  }

  /* Modale Backdrop avec padding sûr */
  .modal-backdrop {
    padding: max(10px, env(safe-area-inset-top, 0)) max(10px, env(safe-area-inset-right, 0)) max(10px, env(safe-area-inset-bottom, 0)) max(10px, env(safe-area-inset-left, 0));
  }

  .modal-card {
    padding: 18px 14px;
    border-radius: var(--radius-md, 16px);
    max-width: 96vw;
    width: 96vw;
    max-height: 92vh;
  }

  /* Bandeau Supérieur (HUD) Mobile : 1 seule ligne ultra-propre sans wrap */
  #hud {
    top: max(6px, env(safe-area-inset-top, 0));
    left: max(6px, env(safe-area-inset-left, 0));
    right: max(6px, env(safe-area-inset-right, 0));
    height: 38px;
    min-height: 38px;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    z-index: 35;
  }

  .hud-left {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
  }

  /* Sur mobile, ces boutons d'action sont relocalisés dans le dock bas pour ne pas écraser le HUD */
  #my-castle-btn,
  #spray-quick-btn {
    display: none !important;
  }

  .hud-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    flex-shrink: 0;
  }

  .hud-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0 2px;
  }

  .pill {
    padding: 4px 7px;
    font-size: 0.70rem;
    border-radius: 999px;
    border-width: 1.5px;
    white-space: nowrap;
  }

  #room-pill {
    font-weight: 800;
    letter-spacing: 0.5px;
  }

  #phase-pill {
    font-size: 0.68rem;
    padding: 4px 6px;
  }

  .wind-pill {
    max-width: 75px;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 3px 5px;
    font-size: 0.65rem;
  }

  .icon-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 0.88rem;
    border-width: 1.5px;
    border-radius: 9px;
  }

  .mobile-chat-btn {
    display: inline-flex !important;
    position: relative;
    align-items: center;
    justify-content: center;
  }

  .chat-badge-mini {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #ffffff;
    font-size: 0.58rem;
    font-weight: 900;
    border-radius: 999px;
    padding: 1px 4px;
    line-height: 1.1;
    border: 1.5px solid #ffffff;
  }

  .timer-box {
    padding: 2px 7px;
    font-size: 0.84rem;
    height: 30px;
    border-radius: 10px;
  }

  .banner-msg {
    display: none !important;
  }

  /* Timeline de bataille Mobile : positionnée sous le HUD à 44px */
  .battle-timeline {
    top: max(46px, calc(env(safe-area-inset-top, 0) + 44px));
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 8px;
    max-width: 95vw;
    height: 30px;
    border-radius: 999px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    z-index: 34;
  }
  .battle-timeline::-webkit-scrollbar {
    display: none;
  }

  .king-duels-bar {
    gap: 4px;
    align-items: center;
  }

  .king-badge {
    width: 22px;
    height: 22px;
    font-size: 0.85rem;
  }
  .king-badge.next {
    width: 16px;
    height: 16px;
  }

  .duel-fighter-badge {
    display: none !important;
  }

  .duel-fighter-name {
    max-width: 65px;
    font-size: 0.70rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .duel-next-label {
    display: none !important;
  }

  /* Miniatures des joueurs */
  .players-strip {
    top: max(48px, calc(env(safe-area-inset-top, 0) + 42px));
    left: 8px;
    right: 8px;
    gap: 6px;
    max-height: 70px;
    overflow-x: auto;
    scrollbar-width: none;
    flex-wrap: nowrap;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
  }
  .players-strip::-webkit-scrollbar {
    display: none;
  }
  .player-card {
    padding: 4px 7px;
    gap: 6px;
    flex-shrink: 0;
  }
  .player-thumb {
    width: 44px;
    height: 25px;
  }
  .player-name {
    font-size: 0.74rem;
  }
  .player-status {
    font-size: 0.65rem;
  }

  /* ==================== Salon d'accueil & Salle d'attente (Hors-jeu sur Smartphone) ==================== */
  .lobby-hub-card {
    padding: 16px 14px max(14px, env(safe-area-inset-bottom, 14px));
    max-width: 410px;
    width: min(94vw, 410px);
    max-height: calc(100dvh - max(24px, env(safe-area-inset-top, 12px) + env(safe-area-inset-bottom, 12px)));
    border-radius: 22px;
    border-width: 2.5px;
    box-shadow: 0 16px 44px rgba(44, 30, 18, 0.38);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* En-tête de marque compact horizontal sur smartphone (prend 56px de haut au lieu de 160px) */
  .brand {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    text-align: left;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1.5px solid rgba(217, 185, 130, 0.45);
  }

  .brand-logo {
    width: 52px;
    height: 52px;
    max-width: 52px;
    max-height: 52px;
    border-radius: 12px;
    filter: drop-shadow(0 4px 10px rgba(44, 30, 18, 0.25));
  }

  .brand-text-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .brand-title {
    font-size: 1.75rem;
    line-height: 1.05;
    margin: 0 0 2px;
    word-break: normal;
  }

  .brand-subtitle {
    font-size: 0.72rem;
    line-height: 1.2;
    color: #78350f;
  }

  /* Écran d'accueil (Welcome-view) */
  .field-block {
    margin-bottom: 10px;
  }

  .field-label {
    font-size: 0.76rem;
    font-weight: 800;
    color: #634932;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
  }

  #name-input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    font-size: 16px !important; /* CRUCIAL IOS SAFARI : EMPÊCHE LE ZOOM FORCÉ */
    font-weight: 800;
    text-align: center;
    border-radius: 12px;
    border: 2px solid var(--sand-border);
    background: #ffffff;
    color: var(--wood-dark);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
  }

  .welcome-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .quick-play-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .quick-play-row .btn {
    height: 48px;
    min-height: 48px;
    padding: 0 8px;
    font-size: 0.90rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
  }

  #create-btn {
    width: 100%;
    height: 46px;
    min-height: 46px;
    font-size: 0.92rem;
    border-radius: 12px;
  }

  .divider {
    margin: 4px 0;
    font-size: 0.72rem;
    color: var(--wood-soft);
  }

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

  #code-input {
    width: 105px;
    height: 46px;
    font-size: 16px !important;
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-align: center;
    border-radius: 12px;
  }

  #join-btn {
    flex: 1;
    height: 46px;
    min-height: 46px;
    font-size: 0.92rem;
    border-radius: 12px;
  }

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

  .rule-chip {
    font-size: 0.68rem;
    padding: 3px 7px;
    border-radius: 6px;
  }

  /* Bouton accordéon pour déplier le tutoriel uniquement sur mobile si souhaité */
  .mobile-tuto-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font-size: 0.80rem;
    font-weight: 800;
    color: #78350f;
    background: rgba(243, 227, 195, 0.65);
    border: 1.5px solid var(--sand-border);
    border-radius: 12px;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.15s ease;
  }

  .mobile-tuto-btn:active {
    background: rgba(243, 227, 195, 0.95);
    transform: scale(0.98);
  }

  /* Salle d'attente (Room-view) sur Smartphone */
  .room-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.92);
    border: 2px solid var(--sand-border);
    border-radius: 14px;
    margin-bottom: 10px;
  }

  .room-code-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .room-code-big {
    font-size: 1.95rem;
    letter-spacing: 3px;
    color: var(--sea-blue);
    line-height: 1;
  }

  /* Le QR-code est masqué sur mobile (inutile de scanner son propre écran) */
  .qr-box {
    display: none !important;
  }

  .copy-icon-btn {
    width: 38px;
    height: 38px;
    font-size: 1.2rem;
    border-radius: 10px;
  }

  .roster-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    padding: 0 2px;
  }

  .roster-title {
    font-size: 0.88rem;
    font-weight: 800;
  }

  .roster-badge {
    font-size: 0.78rem;
    padding: 2px 8px;
  }

  .add-bot-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 10px;
    margin-bottom: 10px;
    border-radius: 10px;
    background: rgba(248, 250, 252, 0.9);
  }

  .bot-select-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
  }

  .bot-select-label {
    font-size: 0.76rem;
    font-weight: 800;
  }

  .bot-difficulty-select {
    font-size: 0.78rem;
    height: 36px;
    padding: 4px 6px;
    border-radius: 8px;
    flex: 1;
  }

  .btn-add-bot {
    height: 36px;
    padding: 0 10px;
    font-size: 0.78rem;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .roster-list {
    max-height: 160px;
    overflow-y: auto;
    margin-bottom: 12px;
    gap: 5px;
  }

  .roster-item {
    padding: 7px 10px;
    font-size: 0.85rem;
    border-radius: 10px;
  }

  .lobby-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  #start-btn {
    width: 100%;
    height: 52px;
    min-height: 52px;
    font-size: 1.15rem;
    font-weight: 900;
    letter-spacing: 0.5px;
    border-radius: 14px;
  }

  #leave-room-btn {
    width: 100%;
    height: 38px;
    min-height: 38px;
    font-size: 0.84rem;
    border-radius: 10px;
    margin-top: 0 !important;
  }

  /* Gestion du Tutoriel GIF sur Smartphone */
  .lobby-tuto-column {
    display: none;
    margin-top: 10px;
  }

  .lobby-tuto-column.open-mobile {
    display: flex !important;
  }

  /* Quand on est dans la room, le tuto est strictement masqué sur mobile */
  #room-view:not(.hidden) ~ .lobby-tuto-column,
  .lobby-action-column:has(#room-view:not(.hidden)) ~ .lobby-tuto-column {
    display: none !important;
  }

  .tuto-card {
    padding: 10px 10px 12px;
  }

  .tuto-screen {
    width: 100%;
    max-width: 100%;
    border-radius: 10px;
    overflow: hidden;
  }

  .tuto-canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    aspect-ratio: 480 / 175;
    display: block;
  }

  .tuto-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
    padding-bottom: 2px;
  }
  .tuto-tabs::-webkit-scrollbar {
    display: none;
  }

  .tuto-tab-btn {
    white-space: nowrap;
    font-size: 0.72rem;
    padding: 4px 8px;
    flex-shrink: 0;
  }

  .tuto-caption-title {
    font-size: 0.88rem;
  }

  .tuto-caption-text {
    font-size: 0.76rem;
    line-height: 1.35;
  }

  /* Séparation stricte PC / Téléphone : masquer toute l'interface de jeu PC sur téléphone */
  .pc-only-ui {
    display: none !important;
  }

  /* ==================== INTERFACE DE JEU DÉDIÉE TÉLÉPHONE (#mobile-game-dock) ==================== */
  .mobile-game-dock:not(.hidden) {
    position: fixed;
    bottom: max(6px, env(safe-area-inset-bottom, 0));
    left: 6px;
    right: 6px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: auto;
    user-select: none;
  }

  /* Barre d'actions Entraînement sur mobile */
  .mob-train-bar:not(.hidden) {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
  }

  .mob-train-btn {
    flex: 1;
    height: 34px;
    border-radius: 10px;
    font-size: 0.76rem;
    font-weight: 800;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  }

  .mob-train-primary {
    background: linear-gradient(135deg, #ea580c, #d97706);
    border-color: #fde047;
  }

  .mob-train-secondary {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    border-color: #7dd3fc;
  }

  /* Panneau générique du dock mobile */
  .mob-dock-panel:not(.hidden) {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border-radius: 18px;
    background: rgba(28, 21, 14, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid var(--sand-border);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    width: 100%;
  }

  /* 1. PANNEAU CONSTRUCTION MOBILE */
  .mob-tools-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
  }

  .mob-tools-row .tool-btn {
    width: 100%;
    height: 44px;
    min-width: 0;
    border-radius: 11px;
    padding: 3px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .mob-tools-row .tool-key {
    display: none !important;
  }

  .mob-tools-row .tool-label {
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1.05;
    margin-top: 2px;
  }

  .mob-moulds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 6px;
    max-height: 116px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 2px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    -webkit-overflow-scrolling: touch;
  }

  .mob-moulds-grid .tool-btn {
    width: 100%;
    min-width: 48px;
    height: 50px;
    border-radius: 10px;
    padding: 2px;
    flex-shrink: 0;
  }

  .mob-moulds-grid .tool-btn canvas {
    width: 40px;
    height: 30px;
  }

  .mob-moulds-grid .tool-btn .tool-stock {
    font-size: 0.62rem;
    min-width: 16px;
    height: 14px;
    line-height: 14px;
    top: 2px;
    right: 2px;
    padding: 0 3px;
  }

  /* 2. PANNEAU ATTAQUE / CATAPULTE MOBILE */
  .mob-attack-top-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .mob-action-pill {
    height: 40px;
    border-radius: 11px;
    font-size: 0.78rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 8px;
    cursor: pointer;
    white-space: nowrap;
  }

  .mob-cat-pill {
    background: linear-gradient(135deg, rgba(250, 204, 21, 0.25), rgba(217, 119, 6, 0.38));
    border: 1.5px solid #facc15;
    color: #fef08a;
  }

  .mob-castle-pill {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.32), rgba(2, 132, 199, 0.48));
    border: 1.5px solid #38bdf8;
    color: #e0f2fe;
  }

  .mob-ammo-rack {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 46px;
    padding: 0 6px;
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    overflow-x: auto;
  }

  .mob-ammo-rack .shot-ball.ammo-type-btn {
    flex: 1;
    min-width: 56px;
    height: 36px;
    padding: 0 6px;
    gap: 4px;
    border-radius: 9px;
    justify-content: center;
  }

  .mob-fire-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
  }

  .mob-fire-trigger-btn {
    position: relative;
    flex: 1;
    height: 52px;
    border-radius: 14px;
    border: 2.5px solid #fde047;
    background: linear-gradient(135deg, #ea580c, #dc2626);
    color: #fff;
    font-family: var(--font-title);
    font-size: 0.98rem;
    font-weight: 900;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.45);
    touch-action: none;
  }

  .mob-power-progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: linear-gradient(90deg, rgba(250, 204, 21, 0.55), rgba(34, 197, 94, 0.75));
    pointer-events: none;
    transition: width 0.04s linear;
  }

  .mob-fire-inner {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 100%;
    padding: 0 12px;
  }

  .mob-fire-heading {
    letter-spacing: 0.03em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
  }

  .mob-fire-pct {
    background: rgba(0, 0, 0, 0.35);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.84rem;
  }

  .mob-cancel-fire-btn:not(.hidden) {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: 14px;
    border: 2px solid #fca5a5;
    background: rgba(153, 27, 27, 0.92);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  /* 3. PANNEAU DÉFENSE / CHÂTEAU / SPECTATEUR MOBILE */
  #mob-panel-defend:not(.hidden) {
    background: rgba(15, 23, 42, 0.96);
    border-color: #38bdf8;
    box-shadow: 0 8px 26px rgba(2, 132, 199, 0.38);
    padding: 12px;
    gap: 10px;
  }

  .mob-defend-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
  }

  .mob-defend-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
  }

  .mob-defend-text {
    font-size: 0.82rem;
    line-height: 1.32;
    color: #f1f5f9;
    flex: 1;
    text-align: left;
  }

  .mob-defend-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
  }

  .mob-defend-spray-badge:not(.hidden) {
    flex: 1;
    height: 40px;
    padding: 0 10px;
    border-radius: 11px;
    background: rgba(14, 165, 233, 0.22);
    border: 1.5px solid rgba(56, 189, 248, 0.6);
    color: #bae6fd;
    font-size: 0.78rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }

  .mob-defend-action-btn:not(.hidden) {
    flex: 1.15;
    height: 40px;
    padding: 0 12px;
    border-radius: 11px;
    border: 1.5px solid #fde047;
    background: linear-gradient(135deg, #ea580c, #d97706);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
  }

  /* Tiroir mobile de Notifications & Statut (Bottom Sheet drawer) */
  .game-chat-dock:not(.mobile-open) {
    display: none !important;
  }

  .game-chat-dock.mobile-open {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 52vh !important;
    max-height: 52vh !important;
    border-radius: 20px 20px 0 0 !important;
    z-index: 100 !important;
    background: rgba(15, 23, 42, 0.97) !important;
    backdrop-filter: blur(14px) !important;
    border: 2px solid var(--sand-border) !important;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.6) !important;
    flex-direction: column !important;
    animation: slideUpMobile 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  @keyframes slideUpMobile {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .chat-backdrop:not(.hidden) {
    display: block !important;
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.52) !important;
    z-index: 99 !important;
    backdrop-filter: blur(2px) !important;
  }

  .chat-header {
    padding: 10px 14px;
    border-bottom: 1.5px solid rgba(255,255,255,0.1);
  }

  .chat-title-text {
    font-size: 0.88rem;
    font-weight: 800;
  }

  .chat-body {
    flex: 1;
    max-height: none;
    overflow-y: auto;
    padding: 8px 12px;
  }

  .chat-messages {
    max-height: none;
    font-size: 0.82rem;
  }

  /* Modale Camp d'entraînement */
  .training-choice-card {
    padding: 16px 12px;
    max-width: 94vw;
  }

  .training-choice-card h2 {
    font-size: 1.35rem;
  }

  .training-difficulty-box {
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    margin-bottom: 12px;
  }

  .training-difficulty-label {
    font-size: 0.82rem;
  }

  .train-difficulty-select {
    width: 100%;
    padding: 6px 10px;
    font-size: 0.82rem;
  }

  .training-modes-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 10px;
  }

  .training-mode-card {
    padding: 12px 10px;
    gap: 4px;
  }

  .training-mode-icon {
    font-size: 1.8rem;
  }

  .training-mode-title {
    font-size: 0.92rem;
  }

  .training-mode-desc {
    font-size: 0.76rem;
    line-height: 1.35;
  }

  /* Modale Menu Pause */
  .pause-modal-card {
    padding: 18px 14px;
    max-width: 92vw;
  }

  .pause-icon {
    font-size: 2.2rem;
  }

  .pause-modal-card h2 {
    font-size: 1.45rem;
  }

  .pause-subtitle {
    font-size: 0.85rem;
    margin-bottom: 14px;
  }

  .pause-actions-list .btn {
    padding: 11px 14px;
    font-size: 0.92rem;
    min-height: 44px;
  }

  /* Modale Victoire */
  .over-card {
    padding: 18px 14px;
    max-width: 92vw;
  }

  .crown-icon {
    font-size: 2.5rem;
  }

  #winner-title {
    font-size: 1.55rem;
  }

  #winner-subtitle {
    font-size: 0.88rem;
  }

  .over-actions .btn {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 0.92rem;
  }

  .bonus-choice-card {
    padding: 18px 14px;
    max-width: 94vw;
  }

  /* Pile cinématique sur mobile */
  .cinematic-stack {
    padding: 46px 10px 16px;
    gap: 10px;
  }

  .duel-intro-card.duel-slim-banner {
    padding: 8px 12px;
    border-radius: 14px;
    gap: 6px;
  }

  .duel-badge-top {
    font-size: 0.64rem;
    padding: 3px 8px;
  }

  .combatant-icon-wrapper {
    width: 38px;
    height: 38px;
  }

  .combatant-avatar {
    font-size: 1.25rem;
  }

  .combatant-role {
    font-size: 0.56rem;
  }

  .combatant-name {
    font-size: 0.80rem;
    max-width: 85px;
  }

  .vs-text {
    font-size: 1rem;
  }

  .duel-slim-bottom-row {
    padding: 5px 8px;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .duel-summary {
    font-size: 0.78rem;
  }

  .duel-subhint {
    font-size: 0.68rem;
  }

  /* Overlay intro */
  .intro-card {
    padding: 14px 12px;
    max-width: 92vw;
  }

  .intro-animation-area {
    width: 76px;
    height: 76px;
    margin-bottom: 6px;
  }

  .intro-title {
    font-size: 1.35rem;
  }

  .intro-subtitle {
    font-size: 0.78rem;
  }
}

/* Masquer l'interface mobile dédiée sur PC (> 768px) */
@media (min-width: 769px) {
  .mobile-only-ui {
    display: none !important;
  }
}

/* 3. Très petits smartphones (iPhone SE, Galaxy A, écrans <= 480px) */
@media (max-width: 480px) {
  #room-pill {
    max-width: 95px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 4px 6px;
  }

  .mob-fire-heading {
    font-size: 0.84rem;
  }
}

/* RÈGLE ABSOLUE EN FIN DE FEUILLE : .hidden doit toujours l'emporter sur toutes les règles media queries */
.hidden,
[hidden] {
  display: none !important;
}

