.channel-header__btn--rp {
  margin-top: 0.4rem;
}

@media (max-width: 980px) {
  .channel-header__btn--rp {
    margin-top: 0.2rem;
    padding: 0.28rem 0.45rem;
    font-size: 0.74rem;
  }
}

.rp-map-container {
  height: calc(100vh - 220px);
  min-height: 460px;
  border-top: 1px solid rgba(250, 204, 21, 0.18);
  background: radial-gradient(circle at 20% 10%, rgba(250, 204, 21, 0.08), transparent 45%), rgba(6, 8, 12, 0.92);
  overflow: hidden;
}

.rp-map-root {
  height: 100%;
  display: block;
  position: relative;
}

.rp-map-main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.rp-map-viewport {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 0.75rem;
  position: relative;
  background: #020202;
  cursor: grab;
  min-height: 0;
}

.rp-map-viewport.is-dragging-pan {
  cursor: grabbing;
}

.rp-map-stage {
  width: 100%;
  min-width: 100%;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.rp-map-board {
  position: relative;
  width: var(--rp-board-size, 720px);
  height: var(--rp-board-size, 720px);
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(30, 1fr);
  grid-template-rows: repeat(30, 1fr);
  border: 1px solid rgba(250, 204, 21, 0.22);
}

.rp-map-zoom-actions {
  position: sticky;
  top: 0.65rem;
  left: 0.65rem;
  z-index: 5;
  display: inline-flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
}

.rp-map-action-btn,
.rp-map-zoom-actions .play-zoom-btn {
  min-width: 32px;
  min-height: 32px;
  padding: 0.25rem;
}

.rp-map-action-btn .lucide,
.rp-map-zoom-actions .play-zoom-btn .lucide {
  width: 16px;
  height: 16px;
}

/* Hors du viewport scrollable : sinon flex-end s aligne sur toute la largeur du contenu (carte large) et la carte parait au centre */
.rp-map-inspector-anchor {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 12;
  max-width: min(300px, calc(100% - 1.5rem));
  pointer-events: none;
}

.rp-character-inspector {
  position: relative;
  width: min(300px, 62vw);
  z-index: 1;
  border: 1px solid rgba(250, 204, 21, 0.34);
  background: rgba(3, 8, 18, 0.9);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(2px);
  pointer-events: auto;
}

.rp-character-inspector-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  justify-content: space-between;
  padding: 0.4rem 0.55rem;
  color: #f8fafc;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.rp-character-inspector-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.rp-character-inspector-toggle .lucide {
  width: 15px;
  height: 15px;
  color: rgba(250, 204, 21, 0.92);
}

.rp-character-inspector-body {
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  padding: 0.45rem 0.55rem 0.55rem;
}

.rp-character-inspector-portrait {
  position: relative;
  width: 100%;
  min-height: 128px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(2, 6, 23, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.rp-character-inspector-portrait img {
  width: 100%;
  height: 100%;
  max-height: 260px;
  object-fit: cover;
  display: block;
}

.rp-inspector-portrait-fallback {
  color: rgba(250, 204, 21, 0.92);
}

.rp-inspector-portrait-fallback .rp-provider-icon,
.rp-inspector-portrait-fallback .lucide {
  width: 34px;
  height: 34px;
  stroke-width: 2.1;
}

.rp-character-inspector-hp {
  position: absolute;
  left: 0.45rem;
  bottom: 0.45rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.38rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(2, 6, 23, 0.84);
  color: #fecaca;
  font-size: 0.72rem;
}

.rp-character-inspector-hp .lucide {
  width: 12px;
  height: 12px;
  color: #f87171;
}

.rp-character-inspector.is-collapsed .rp-character-inspector-body {
  display: none;
}

.rp-map-cell {
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(17, 24, 39, 0.74);
  position: relative;
  overflow: visible;
}

.rp-map-cell.is-reachable {
  outline: 1px solid rgba(96, 165, 250, 0.86);
  outline-offset: -1px;
  box-shadow: inset 0 0 0 1px rgba(30, 64, 175, 0.45);
}

.rp-map-cell.t-wall,
.rp-map-cell.t-pnj {
  background:
    repeating-linear-gradient(
      45deg,
      rgba(156, 163, 175, 0.34) 0px,
      rgba(156, 163, 175, 0.34) 3px,
      rgba(75, 85, 99, 0.3) 3px,
      rgba(75, 85, 99, 0.3) 6px
    ),
    rgba(55, 65, 81, 0.36);
}

.rp-map-cell.t-forest,
.rp-map-cell.t-meuble {
  background: rgba(34, 197, 94, 0.26);
}

.rp-map-cell.overlay-meuble::after,
.rp-map-cell.overlay-pnj::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.rp-map-cell.overlay-meuble::after {
  background: rgba(34, 197, 94, 0.08);
}

.rp-map-cell.overlay-pnj::after {
  background: rgba(248, 113, 113, 0.08);
}

.rp-map-cell.overlay-move-block {
  box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.44);
}

.rp-map-cell.overlay-move-slow {
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.36);
}

.rp-map-cell.t-water {
  background: rgba(59, 130, 246, 0.3);
}

.rp-map-label {
  position: absolute;
  left: 2px;
  top: 1px;
  font-size: 9px;
  color: rgba(248, 250, 252, 0.95);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  white-space: nowrap;
  z-index: 4;
}

.rp-map-tile-icon {
  position: absolute;
  inset: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(245, 158, 11, 0.95);
  pointer-events: none;
}

.rp-map-tile-icon .lucide,
.rp-map-tile-icon .rp-provider-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2.1;
}

.rp-map-token {
  position: absolute;
  inset: 4px;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--rp-token-color, #60a5fa);
  z-index: 2;
}

/* Perso sur une case qui a deja une icone terrain / meuble : fond sombre leger pour separer les deux */
.rp-map-cell.has-token-over-tile-icon .rp-map-token {
  background: rgba(0, 0, 0, 0.42);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.rp-map-cell.has-token-over-tile-icon .rp-map-token.is-selected {
  background: rgba(0, 0, 0, 0.52);
}

.rp-map-token .lucide,
.rp-map-token .rp-provider-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2.3;
}

.rp-map-token.is-selected {
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.95), 0 0 14px rgba(250, 204, 21, 0.45);
}

/* Déplacement optimiste : feedback pendant l attente serveur */
/* Clic valide : depart (perso) + case cible avant fin animation / reponse serveur */
.rp-map-cell.is-move-marker-from {
  box-shadow: inset 0 0 0 2px rgba(250, 204, 21, 0.9);
  outline: 1px solid rgba(250, 204, 21, 0.5);
  outline-offset: -1px;
}

.rp-map-cell.is-move-marker-to {
  box-shadow: inset 0 0 0 2px rgba(52, 211, 153, 0.92);
  outline: 1px solid rgba(16, 185, 129, 0.55);
  outline-offset: -1px;
}

.rp-map-cell.is-pending-confirm {
  box-shadow: inset 0 0 0 2px rgba(96, 165, 250, 0.65);
  animation: rp-cell-pending 0.85s ease-in-out infinite;
}

.rp-map-token.is-pending-move {
  animation: rp-token-pending 0.55s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 6px rgba(96, 165, 250, 0.75));
}

@keyframes rp-cell-pending {
  0%,
  100% {
    box-shadow: inset 0 0 0 2px rgba(96, 165, 250, 0.45);
  }
  50% {
    box-shadow: inset 0 0 0 2px rgba(147, 197, 253, 0.9);
  }
}

@keyframes rp-token-pending {
  0% {
    transform: translateY(0) scale(1);
  }
  100% {
    transform: translateY(-2px) scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rp-map-cell.is-pending-confirm,
  .rp-map-token.is-pending-move {
    animation: none;
  }
}

.rp-map-overlay-modal[hidden] {
  display: none !important;
}

.rp-map-overlay-modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.rp-map-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 4, 9, 0.68);
  backdrop-filter: blur(2px);
}

.rp-map-overlay-panel {
  position: relative;
  z-index: 1;
  width: min(540px, 94vw);
  max-height: 84vh;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(245, 158, 11, 0.42);
  background: linear-gradient(180deg, rgba(8, 16, 30, 0.98), rgba(5, 12, 22, 0.99));
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(6, 182, 212, 0.18) inset;
}

.rp-map-overlay-panel--wide {
  width: min(760px, 96vw);
}

.rp-map-overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.8rem 0.9rem 0.5rem;
}

.rp-map-overlay-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.4rem 0.9rem 0.9rem;
}

.rp-map-overlay-body .input-cyber {
  width: 100%;
}

.rp-slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}

.rp-slot-pick-card {
  appearance: none;
  cursor: pointer;
  text-align: left;
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid rgba(250, 204, 21, 0.18);
  background: rgba(2, 6, 23, 0.42);
  padding: 0.45rem;
}

.rp-slot-card-btn {
  appearance: none;
  cursor: pointer;
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(2, 6, 23, 0.38);
  padding: 0.45rem;
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 0.45rem;
}

.rp-slot-card-btn.is-filled {
  border-color: rgba(250, 204, 21, 0.45);
}

.rp-slot-index {
  grid-column: 1 / -1;
  font-size: 0.68rem;
  opacity: 0.8;
}

.rp-slot-portrait {
  width: 56px;
  height: 56px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.rp-slot-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rp-slot-portrait-fallback {
  font-size: 0.64rem;
}

.rp-slot-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.rp-slot-meta strong {
  font-size: 0.78rem;
  color: #f8fafc;
  font-family: 'Orbitron', 'JetBrains Mono', monospace;
  letter-spacing: 0.03em;
}

.rp-slot-meta small {
  color: var(--text-secondary);
  font-size: 0.7rem;
}

.rp-participants-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rp-participant-row {
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(2, 6, 23, 0.38);
  padding: 0.45rem 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.rp-participant-name {
  font-weight: 600;
}

.rp-participant-stats {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.rp-participant-presence {
  margin-left: auto;
  font-size: 0.72rem;
  border: 1px solid rgba(148, 163, 184, 0.34);
  padding: 0.08rem 0.4rem;
}

.rp-participant-presence.is-on {
  border-color: rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}

.rp-participant-presence.is-off {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.rp-side-section {
  margin-bottom: 0.75rem;
  border: 1px solid rgba(250, 204, 21, 0.16);
  padding: 0.5rem;
}

.rp-side-section h4 {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
}

.rp-character-pick {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.28rem;
  font-size: 0.78rem;
}

.rp-status-line {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

@media (max-width: 980px) {
  .rp-map-container {
    height: calc(100dvh - 210px);
    min-height: 320px;
  }
  .rp-map-overlay-panel {
    width: min(98vw, 620px);
  }
  .rp-map-action-btn,
  .rp-map-zoom-actions .play-zoom-btn {
    min-width: 28px;
    min-height: 28px;
    padding: 0.2rem;
  }
  .rp-map-action-btn .lucide,
  .rp-map-zoom-actions .play-zoom-btn .lucide {
    width: 14px;
    height: 14px;
  }
  .rp-character-inspector {
    width: min(260px, 68vw);
  }
  .rp-map-board {
    width: var(--rp-board-size, 720px);
    height: var(--rp-board-size, 720px);
  }
}

@media (max-width: 768px) {
  .channel-header__right {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
  }

  .channel-header__right .channel-header__btn {
    display: none;
  }

  .channel-header__right #rpModeToggleBtn {
    display: inline-flex !important;
  }

  #rpModeToggleBtn.channel-header__btn--rp {
    position: fixed;
    right: 10px;
    bottom: calc(var(--rp-mobile-switch-offset, 88px) + env(safe-area-inset-bottom, 0px));
    z-index: 65;
    margin: 0;
    min-width: 36px;
    min-height: 36px;
    padding: 0.3rem 0.5rem;
    border-radius: 10px;
  }

  .rp-map-active .channel-view .messages-container {
    padding-bottom: 0 !important;
    display: none !important;
  }
}
