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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

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

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

/* BACKGROUND IMAGE — lobby, room */
#screen-lobby,
#screen-room {
  background-image: url('/images/bg-menu.jpg');
  background-size: cover;
  background-position: 50% 50%;
  background-repeat: no-repeat;
}

/* On portrait mobile the landscape image is wider than the viewport.
   Pan it slowly left↔right so the full artwork is visible over time. */
@keyframes bg-pan-lr {
  from { background-position: 0% 50%; }
  to   { background-position: 100% 50%; }
}

@media (orientation: portrait) and (max-width: 768px) {
  #screen-lobby {
    animation: bg-pan-lr 24s linear infinite alternate;
  }
}

/* Dark overlay for readability */
#screen-lobby::before,
#screen-room::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 26, 0.62);
  z-index: 0;
  pointer-events: none;
}

/* Content must sit above the overlay */
.lobby-container,
.room-container {
  position: relative;
  z-index: 1;
}

/* LOBBY */

.title {
  font-size: 2.4rem;
  color: #ff6b35;
  margin-bottom: 4px;
  letter-spacing: 2px;
}

.subtitle {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 24px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px;
  border: 2px solid #333;
  border-radius: 8px;
  background: #16213e;
  color: #e0e0e0;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: #ff6b35;
}

.btn {
  padding: 14px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  width: 100%;
}

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

.btn-primary {
  background: #ff6b35;
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.4;
}

.btn-secondary {
  background: #2d4059;
  color: #e0e0e0;
}

.lobby-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.separator {
  text-align: center;
  color: #555;
  font-size: 0.85rem;
}

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

.code-input {
  width: 100px !important;
  text-align: center;
  text-transform: uppercase;
  font-size: 1.2rem !important;
  letter-spacing: 4px;
  flex-shrink: 0;
}

.join-row .btn {
  flex: 1;
}

.error-msg {
  color: #ff4757;
  font-size: 0.85rem;
  margin-top: 12px;
  min-height: 20px;
}

/* Create section (room name + vis toggle + create button) */
.create-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.room-name-input {
  width: 100%;
}

.vis-toggle {
  display: flex;
  gap: 8px;
}

.vis-btn {
  flex: 1;
  padding: 9px 8px;
  border: 2px solid #333;
  border-radius: 8px;
  background: #16213e;
  color: #666;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.vis-btn.active {
  border-color: #ff6b35;
  color: #ff6b35;
}

/* Room browser */
.room-browser {
  margin-top: 16px;
  background: #16213e;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #222;
}

.room-browser-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: #0f172a;
  font-size: 0.8rem;
  color: #888;
  letter-spacing: 0.3px;
}

.btn-refresh {
  background: none;
  border: none;
  color: #ff6b35;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.btn-refresh:active { background: rgba(255,107,53,0.15); }

.room-list {
  max-height: 160px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}
.room-list::-webkit-scrollbar { width: 3px; }
.room-list::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.room-list-empty {
  padding: 18px;
  text-align: center;
  color: #444;
  font-size: 0.8rem;
  font-style: italic;
}

.room-entry {
  display: flex;
  align-items: center;
  padding: 9px 14px;
  border-bottom: 1px solid #1c2a44;
  gap: 10px;
}
.room-entry:last-child { border-bottom: none; }

.room-entry-info {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.room-entry-name {
  font-size: 0.86rem;
  font-weight: 600;
  color: #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-entry-count {
  font-size: 0.7rem;
  color: #888;
  margin-top: 2px;
}

.btn-join-room {
  padding: 5px 11px;
  border: 2px solid #4ECDC4;
  border-radius: 6px;
  background: transparent;
  color: #4ECDC4;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.12s;
}
.btn-join-room:active { background: rgba(78,205,196,0.18); }
.btn-join-room:disabled { opacity: 0.35; pointer-events: none; }

/* Lobby container scrollable on small screens */
.lobby-container {
  width: 90%;
  max-width: 360px;
  text-align: center;
  max-height: 100dvh;
  overflow-y: auto;
  padding: 24px 0 16px;
  scrollbar-width: none;
}
.lobby-container::-webkit-scrollbar { display: none; }

/* ROOM */
.room-container {
  width: 90%;
  max-width: 400px;
  text-align: center;
  max-height: 100dvh;
  overflow-y: auto;
  padding: 24px 0 16px;
  scrollbar-width: none;
}
.room-container::-webkit-scrollbar { display: none; }

.room-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}
.room-header h2 {
  font-size: 1.4rem;
  margin-bottom: 0;
}

.room-header h2 span {
  color: #ff6b35;
  font-size: 1.8rem;
  letter-spacing: 6px;
}

.players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #16213e;
  border-radius: 8px;
  border-left: 4px solid;
}
.player-card-addable {
  cursor: pointer;
  transition: background .15s;
}
.player-card-addable:hover { background: #1e2d44; }

.player-card .player-char-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 4px;
  flex-shrink: 0;
}

.player-card .player-info {
  flex: 1;
  text-align: left;
}

.player-card .player-name {
  font-weight: 600;
}

.player-card .player-stats {
  font-size: 0.78rem;
  color: #aaa;
  margin-top: 2px;
}

.player-card .host-badge {
  font-size: 0.7rem;
  background: #ff6b35;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
}

/* CHARACTER SELECTION */
.char-section {
  background: #16213e;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.char-section h3 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: #ccc;
  text-align: center;
}
.char-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.char-card {
  background: #0f172a;
  border: 2px solid #2a3a5a;
  border-radius: 8px;
  padding: 8px 4px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.char-card img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 4px;
  transform-origin: bottom center;
  animation: char-breathe 2.2s ease-in-out infinite;
}
/* Non-Bob characters are slightly smaller sprites — scale them up 20% */
.char-card:not([data-char="player"]) img {
  width: 62px;
  height: 62px;
}
/* Stagger each portrait so they don't all breathe in sync */
.char-card:nth-child(1) img { animation-delay:  0.0s; }
.char-card:nth-child(2) img { animation-delay: -0.7s; }
.char-card:nth-child(3) img { animation-delay: -1.4s; }
.char-card:nth-child(4) img { animation-delay: -1.9s; }
.char-card:nth-child(5) img { animation-delay: -0.4s; }
.char-card:nth-child(6) img { animation-delay: -1.1s; }

@keyframes char-breathe {
  0%, 100% { transform: scaleX(1)     scaleY(1);    }
  50%       { transform: scaleX(0.976) scaleY(1.04); }
}
.char-card span {
  font-size: 0.72rem;
  color: #aaa;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.char-card:hover {
  border-color: #4a6a9a;
  background: #1a2a4a;
}
.char-card.selected {
  border-color: #f0c040;
  background: #1a230f;
}
.char-card.selected span {
  color: #f0c040;
}
.char-card.char-locked {
  opacity: 0.45;
  cursor: not-allowed;
  position: relative;
}
.char-card.char-locked:hover {
  border-color: #2a3a5a;
  background: #0f1a2e;
}
.char-card.char-locked::after {
  content: '🔒';
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.75rem;
  line-height: 1;
}

/* Purchasable Mordek card — orange border, 🛒 badge, pointer cursor */
.char-card.char-purchasable {
  opacity: 1;
  cursor: pointer;
  border-color: #d97706;
  background: #1a1200;
}
.char-card.char-purchasable:hover {
  border-color: #f59e0b;
  background: #261a00;
}
.char-card.char-purchasable::after {
  content: '🛒';
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.75rem;
  line-height: 1;
}

/* Mordek purchase modal */
.mordek-modal-panel {
  text-align: center;
  max-width: 340px;
}
.mordek-modal-img {
  width: 90px;
  height: 90px;
  object-fit: contain;
  margin: 0 auto 10px;
  display: block;
  filter: drop-shadow(0 0 12px rgba(217,119,6,0.6));
}
.mordek-modal-title {
  font-size: 1.4rem;
  color: #f59e0b;
  margin: 0 0 8px;
}
.mordek-modal-desc {
  font-size: 0.85rem;
  color: #aaa;
  line-height: 1.5;
  margin: 0 0 14px;
}
.mordek-modal-perks {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  text-align: left;
}
.mordek-modal-perks li {
  font-size: 0.85rem;
  color: #ccc;
  padding: 4px 0;
}
.mordek-buy-btn {
  width: 100%;
  font-size: 1rem;
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #000;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
}
.mordek-buy-btn:hover {
  background: linear-gradient(135deg, #b45309, #d97706);
}
.mordek-buy-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.mordek-modal-legal {
  font-size: 0.7rem;
  color: #666;
  margin: 10px 0 0;
}

.distribution-section {
  background: #16213e;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.distribution-section h3 {
  font-size: 1rem;
  margin-bottom: 14px;
  color: #ccc;
}

.dist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.dist-row label {
  font-size: 0.9rem;
}

.dist-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dist-controls span {
  font-size: 1.4rem;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
  color: #ff6b35;
}

.btn-small {
  width: 36px;
  height: 36px;
  border: 2px solid #444;
  border-radius: 50%;
  background: #2d4059;
  color: #e0e0e0;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-small:active {
  background: #ff6b35;
  border-color: #ff6b35;
}

.obstacle-section {
  background: #16213e;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.obstacle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: #ccc;
  margin-bottom: 10px;
}

.obstacle-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #ff6b35;
  min-width: 28px;
  text-align: right;
}

.obstacle-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, #ff6b35 calc(var(--val) / 90 * 100%), #2d4059 calc(var(--val) / 90 * 100%));
  outline: none;
  cursor: pointer;
}

/* Turn-duration slider: range 30–120, so fill = (val-30)/90 */
#turn-duration-slider {
  background: linear-gradient(to right,
    #ff6b35 calc((var(--val) - 30) / 90 * 100%),
    #2d4059 calc((var(--val) - 30) / 90 * 100%));
}

.obstacle-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ff6b35;
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,0.5);
}

.obstacle-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ff6b35;
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,0.5);
}

.obstacle-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: #555;
  margin-top: 5px;
  padding: 0 2px;
}

.waiting-msg {
  color: #888;
  font-size: 0.9rem;
}

.btn-leave {
  margin-top: 18px;
  opacity: 0.75;
  font-size: 0.85rem;
}

/* GAME */
#screen-game {
  flex-direction: column;
  position: relative;
}

/* ── Turn flash border ──────────────────────────────────────────────────── */
#screen-game::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 99;
  box-shadow: inset 0 0 0 4px var(--turn-flash-color, transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
#screen-game.my-turn::before {
  opacity: 1;
  animation: turn-flash-pulse 1.4s ease-in-out infinite;
}
@keyframes turn-flash-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

#screen-game.active {
  justify-content: flex-start;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

#hud-top {
  width: 100%;
  padding: 6px 56px 6px 10px; /* right padding reserves space for the music button */
  background: #0f0f23;
  z-index: 10;
  flex-shrink: 0;
}

#hp-bars {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 8px;
  margin-bottom: 3px;
}

.hp-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 45%;
}

.hp-bar-name {
  font-size: 0.68rem;
  font-weight: 600;
  min-width: 44px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70px;
}

.hp-bar-track {
  flex: 1;
  height: 8px;
  background: #222;
  border-radius: 4px;
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.hp-bar-value {
  font-size: 0.65rem;
  min-width: 24px;
  text-align: right;
}

#turn-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  padding-top: 2px;
}

#turn-timer {
  color: #ff6b35;
  font-weight: 700;
}

#game-canvas {
  flex: 1;
  width: 100%;
  min-height: 0;
  touch-action: none;
  display: block;
}

#hud-bottom {
  width: 100%;
  background: #0f0f23;
  padding: 6px 8px;
  z-index: 10;
  flex-shrink: 0;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}

#resources {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 4px;
  font-size: 0.8rem;
}

.dot-filled {
  color: #ff6b35;
}

.dot-empty {
  color: #333;
}

#spell-bar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#spell-bar::-webkit-scrollbar {
  display: none;
}

.spell-btn {
  flex-shrink: 0;
  padding: 0;
  border: 2px solid #333;
  border-radius: 8px;
  background: #16213e;
  cursor: pointer;
  width: 52px;
  height: 52px;
  overflow: hidden;
  transition: border-color 0.2s, opacity 0.2s;
}

/* 2-row grid on narrow screens (phones) */
@media (max-width: 500px) {
  #spell-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    overflow-x: hidden;
    gap: 3px;
  }
  .spell-btn {
    flex-shrink: unset;
    width: auto;
    height: auto;
    aspect-ratio: 1;
  }
}

.spell-btn.active {
  border-color: #ff6b35;
  background: #2d1810;
}

/* Replaced by .on-cooldown and .disabled:not(.on-cooldown) below */

.spell-icon-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

.spell-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;           /* clicks/touches pass to parent button */
  -webkit-touch-callout: none;    /* iOS: no "save image" callout */
  -webkit-user-select: none;
  user-select: none;
  draggable: false;
}

/* Cooldown overlay: big number centered over the icon */
.spell-cd-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  border-radius: 6px;
  font-size: 1.1rem;
  font-weight: 900;
  color: #ff4757;
  line-height: 1;
  pointer-events: none;
}

/* PA cost badge — small black circle, top-right of icon */
.spell-pa-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
  line-height: 1;
  border: 1px solid rgba(255,255,255,0.15);
}

/* On cooldown: keep visible but clearly locked — overlay carries the info */
.spell-btn.on-cooldown {
  opacity: 0.65;
  pointer-events: none;
}

/* Other disabled reasons (not enough PA, not your turn…): more faded */
.spell-btn.disabled:not(.on-cooldown) {
  opacity: 0.3;
  pointer-events: none;
}

/* SPELL TOOLTIP */
#spell-tooltip {
  position: fixed;
  z-index: 600;
  display: none;
  max-width: 220px;
  min-width: 130px;
  background: rgba(10, 10, 26, 0.96);
  border: 1.5px solid #ff6b35;
  border-radius: 10px;
  padding: 8px 12px;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  text-align: center;
}

/* Arrow pointing down (tooltip above the button) */
#spell-tooltip[data-arrow-side="bottom"]::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: #ff6b35;
  border-bottom: none;
}
#spell-tooltip[data-arrow-side="bottom"]::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(10, 10, 26, 0.96);
  border-bottom: none;
  z-index: 1;
}

/* Arrow pointing up (tooltip below the button) */
#spell-tooltip[data-arrow-side="top"]::after {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-bottom-color: #ff6b35;
  border-top: none;
}
#spell-tooltip[data-arrow-side="top"]::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: rgba(10, 10, 26, 0.96);
  border-top: none;
  z-index: 1;
}

.tt-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #ff6b35;
  margin-bottom: 5px;
}

.tt-desc {
  font-size: 0.76rem;
  color: #ccc;
  line-height: 1.5;
}

/* GAME OVER OVERLAY */
#gameover-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background 2s ease;
}
#gameover-overlay.visible {
  background: rgba(0, 0, 0, 0.82);
  pointer-events: auto;
}

.gameover-panel {
  background: rgba(16, 26, 48, 0.96);
  border: 2px solid #2d4059;
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  width: 90%;
  max-width: 360px;
  opacity: 0;
  transform: scale(0.88) translateY(16px);
  transition: opacity 0.8s ease 1.2s, transform 0.8s ease 1.2s;
}
#gameover-overlay.visible .gameover-panel {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.replay-votes-msg {
  font-size: 0.78rem;
  color: #aaa;
  font-style: italic;
  margin-bottom: 10px;
  min-height: 1.1em;
  line-height: 1.4;
}

.gameover-panel h2 {
  font-size: 1.8rem;
  color: #ff6b35;
  margin-bottom: 20px;
}

#final-stats {
  margin-bottom: 24px;
  width: 100%;
}

/* Stats table (game over) */
.stats-table-header,
.stats-table-row {
  display: grid;
  grid-template-columns: 1fr repeat(5, 36px);
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 6px;
}
.stats-table-header {
  font-size: 0.7rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-bottom: 4px;
}
.stats-table-row {
  background: rgba(22, 33, 62, 0.85);
  margin-bottom: 5px;
  font-size: 0.82rem;
}
.stats-col-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stats-col {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* PLAYER COLORS */
.pcolor-0 { color: #4ECDC4; }
.pcolor-1 { color: #FF6B6B; }
.pcolor-2 { color: #FFE66D; }
.pcolor-3 { color: #A78BFA; }

.pbg-0 { background-color: #4ECDC4; }
.pbg-1 { background-color: #FF6B6B; }
.pbg-2 { background-color: #FFE66D; }
.pbg-3 { background-color: #A78BFA; }

.pborder-0 { border-color: #4ECDC4; }
.pborder-1 { border-color: #FF6B6B; }
.pborder-2 { border-color: #FFE66D; }
.pborder-3 { border-color: #A78BFA; }

/* MUSIC BUTTON */
#btn-music {
  position: fixed;
  z-index: 200;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #4ECDC4;
  background: #1a1a2e;
  color: #4ECDC4;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6);
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
#btn-music:active {
  background: #0d2a2a;
}
#btn-music.dragging {
  cursor: grabbing;
  box-shadow: 0 4px 16px rgba(78,205,196,0.4);
  background: #0d2a2a;
  transition: none;
}
/* Muted state: dim the button and show a strikethrough overlay */
#btn-music.muted {
  color: #666;
  border-color: #555;
  opacity: 0.75;
}
#btn-music.muted::after {
  content: '';
  position: absolute;
  width: 2px;
  height: 26px;
  background: #888;
  transform: rotate(45deg);
  border-radius: 1px;
}

/* HELP BUTTON */
#btn-help {
  position: fixed;
  z-index: 200;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #ff6b35;
  background: #1a1a2e;
  color: #ff6b35;
  font-size: 1rem;
  font-weight: 700;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
#btn-help.dragging {
  cursor: grabbing;
  box-shadow: 0 4px 16px rgba(255,107,53,0.4);
  background: #2d1810;
}

/* HELP MODAL */
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.help-overlay.hidden {
  display: none;
}

.help-modal {
  position: relative;
  background: #16213e;
  border: 2px solid #2d4059;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.help-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  z-index: 1;
}
.help-close:active { color: #fff; }

.help-content {
  overflow-y: auto;
  padding: 20px 18px 24px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}
.help-content::-webkit-scrollbar { width: 4px; }
.help-content::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.help-title {
  font-size: 1.2rem;
  color: #ff6b35;
  letter-spacing: 1px;
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid #2d4059;
}

.help-section {
  margin-bottom: 16px;
}
.help-section h3 {
  font-size: 0.85rem;
  color: #4ECDC4;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.help-section ul {
  padding-left: 16px;
}
.help-section li {
  font-size: 0.82rem;
  color: #ccc;
  line-height: 1.5;
  margin-bottom: 4px;
}
.help-section li b {
  color: #e0e0e0;
}

/* SPELL LIST */
.spell-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.spell-entry {
  background: #0f1a30;
  border-radius: 8px;
  padding: 10px 12px;
  border-left: 3px solid #ff6b35;
}
.spell-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
  gap: 8px;
}
.spell-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
}
.spell-meta {
  font-size: 0.7rem;
  color: #ff6b35;
  white-space: nowrap;
  flex-shrink: 0;
}
.spell-entry p {
  font-size: 0.8rem;
  color: #bbb;
  line-height: 1.5;
  margin-bottom: 4px;
}
.spell-entry ul {
  padding-left: 14px;
  margin-top: 4px;
}
.spell-entry li {
  font-size: 0.78rem;
  color: #aaa;
  line-height: 1.5;
}
.spell-entry li b {
  color: #ddd;
}

/* Help spell icon */
.spell-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.help-spell-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  flex-shrink: 0;
  background: #1a1a2e;
  object-fit: contain;
  image-rendering: pixelated;
}

/* BONUS LIST */
.bonus-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bonus-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #0f1a30;
  border-radius: 8px;
  padding: 10px 12px;
  border-left: 3px solid #ffd700;
}
.help-bonus-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: 6px;
  background: #1a1a2e;
}
.bonus-entry-body {
  min-width: 0;
}
.bonus-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #ffd700;
  margin-bottom: 3px;
}
.bonus-entry p {
  font-size: 0.78rem;
  color: #bbb;
  line-height: 1.45;
  margin: 0;
}

/* ── In-progress room badge ─────────────────────────────────────────────── */
.badge-inprogress {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  background: #e67e22;
  color: #fff;
  vertical-align: middle;
  margin-left: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Rejoin modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay.hidden {
  display: none;
}
.modal-panel {
  background: #1e2a3a;
  border: 1px solid #3a4a5a;
  border-radius: 16px;
  padding: 28px 24px 20px;
  max-width: 340px;
  width: 90%;
  text-align: center;
  color: #e0e0e0;
}
.modal-panel h2 {
  font-size: 1.15rem;
  color: #ffd700;
  margin-bottom: 8px;
}
.modal-panel p {
  font-size: 0.88rem;
  color: #aaa;
  margin-bottom: 16px;
}
.rejoin-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.rejoin-card {
  background: #253545;
  border: 2px solid #3a4a5a;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 90px;
  transition: border-color 0.15s, background 0.15s;
  color: #e0e0e0;
}
.rejoin-card:hover, .rejoin-card:active {
  border-color: #ffd700;
  background: #2e4060;
}
.rejoin-card img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
}
.rejoin-card-name {
  font-size: 0.85rem;
  font-weight: 700;
}
.rejoin-card-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Game paused overlay ────────────────────────────────────────────────── */
.paused-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.paused-overlay.hidden {
  display: none;
}
.paused-panel {
  background: rgba(20, 30, 48, 0.95);
  border: 1px solid #3a4a5a;
  border-radius: 16px;
  padding: 28px 32px;
  text-align: center;
  color: #e0e0e0;
}
.paused-icon {
  font-size: 2.4rem;
  margin-bottom: 8px;
}
.paused-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffd700;
  margin-bottom: 6px;
}
.paused-sub {
  font-size: 0.82rem;
  color: #aaa;
}

/* ── Toast notification ─────────────────────────────────────────────────── */
#ui-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 30, 48, 0.92);
  border: 1px solid #3a4a5a;
  color: #e0e0e0;
  font-size: 0.82rem;
  padding: 8px 16px;
  border-radius: 20px;
  z-index: 600;
  pointer-events: none;
  transition: opacity 0.3s;
  white-space: nowrap;
}
#ui-toast.toast-visible {
  opacity: 1;
}
#ui-toast.toast-hidden {
  opacity: 0;
}

/* ── Speech bubbles ─────────────────────────────────────────────────────── */
#bubble-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 55;
  overflow: visible;
}

.speech-bubble {
  position: fixed;
  background: #fffef0;
  border: 2.5px solid #1a1a1a;
  border-radius: 12px;
  padding: 6px 11px 7px;
  min-width: 52px;
  max-width: 175px;
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive, sans-serif;
  font-size: 0.78rem;
  line-height: 1.35;
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.28);
  pointer-events: auto;
  cursor: pointer;
  text-align: center;
  white-space: normal;
  word-break: break-word;
  /* Centred above anchor point, with a small gap */
  transform: translate(-50%, calc(-100% - 10px));
  animation: bubble-in 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Tail outer (border colour) */
.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -11px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border: 10px solid transparent;
  border-top: 11px solid #1a1a1a;
  border-bottom: none;
}

/* Tail inner (fill colour, layered on top) */
.speech-bubble::before {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border: 8px solid transparent;
  border-top: 8px solid #fffef0;
  border-bottom: none;
  z-index: 1;
}

.bubble-name {
  display: block;
  font-weight: 900;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}

.bubble-text {
  display: block;
  color: #1a1a1a;
}

/* Dismiss animation */
.speech-bubble.bubble-out {
  animation: bubble-out 0.3s ease-out forwards !important;
}

@keyframes bubble-in {
  0%   { opacity: 0; transform: translate(-50%, calc(-100% - 10px)) scale(0.45); }
  100% { opacity: 1; transform: translate(-50%, calc(-100% - 10px)) scale(1); }
}

@keyframes bubble-out {
  0%   { opacity: 1; transform: translate(-50%, calc(-100% - 10px)) scale(1); }
  100% { opacity: 0; transform: translate(-50%, calc(-115% - 10px)) scale(0.8); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   EMOJI REACTIONS
   ═══════════════════════════════════════════════════════════════════════════ */

#emote-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 56;
  overflow: visible;
}

.floating-emote {
  position: fixed;
  font-size: 2rem;
  line-height: 1;
  /*
   * Anchor = horizontal centre + top of the cell (character head).
   * Shift up by 100% of own height + a small gap so the emoji sits
   * just above the character's head.
   */
  transform: translate(-50%, calc(-100% - 6px));
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.55));
  animation: emote-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.floating-emote.emote-out {
  animation: emote-out 0.38s ease-out forwards !important;
}

@keyframes emote-in {
  0%   { opacity: 0; transform: translate(-50%, calc(-100% + 10px)) scale(0.3); }
  100% { opacity: 1; transform: translate(-50%, calc(-100% - 6px))  scale(1); }
}

@keyframes emote-out {
  0%   { opacity: 1; transform: translate(-50%, calc(-100% - 6px))  scale(1); }
  100% { opacity: 0; transform: translate(-50%, calc(-100% - 28px)) scale(0.7); }
}

/* EMOTE BUTTON (inside #screen-game, so auto-hides with the screen) */
#btn-emote {
  position: fixed;
  z-index: 205;
  /* Default position — overridden by localStorage via JS */
  left: 12px;
  bottom: 140px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #f5a623;
  background: #1a1a2e;
  font-size: 1.25rem;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s, box-shadow 0.15s;
}
#btn-emote.dragging {
  cursor: grabbing;
  box-shadow: 0 4px 16px rgba(245,166,35,0.4);
  background: #2e2200;
}
#btn-emote:not(.dragging):active {
  background: #2e2200;
}

/* EMOTE PICKER PANEL — position set dynamically by JS */
#emote-picker {
  position: fixed;
  z-index: 210;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px;
  background: rgba(20, 20, 46, 0.96);
  border: 2px solid #f5a623;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.7);
  /* Hidden by default */
  opacity: 0;
  transform: translateY(10px) scale(0.92);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#emote-picker.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.emote-pick-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.07);
  font-size: 1.35rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.1s;
  touch-action: manipulation;
}
.emote-pick-btn:hover {
  background: rgba(245, 166, 35, 0.25);
}
.emote-pick-btn:active {
  background: rgba(245, 166, 35, 0.4);
  transform: scale(0.88);
}

/* ── Auth button (lobby) ──────────────────────────────────────────────────── */
.btn-auth-lobby {
  display: block;
  margin: 18px auto 0;
  padding: 8px 18px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  color: rgba(255,255,255,0.65);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-auth-lobby:hover {
  border-color: rgba(255,255,255,0.6);
  color: #fff;
}
.btn-auth-lobby.logged-in {
  border-color: #4ECDC4;
  color: #4ECDC4;
}

/* ── Lobby footer (legal links) ──────────────────────────────────────────── */
.lobby-footer {
  text-align: center;
  margin-top: 24px;
  padding-bottom: 12px;
}
.lobby-footer a {
  color: rgba(255,255,255,0.3);
  text-decoration: none;
  font-size: 0.72rem;
  transition: color 0.2s;
}
.lobby-footer a:hover {
  color: rgba(255,255,255,0.65);
}
.footer-sep {
  color: rgba(255,255,255,0.15);
  font-size: 0.72rem;
  margin: 0 6px;
}

/* ── Auth modal ───────────────────────────────────────────────────────────── */
.auth-modal-panel {
  width: min(360px, 90vw);
  padding: 36px 24px 24px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: #ff6b35;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
}
.modal-close:hover {
  background: rgba(255, 107, 53, 0.15);
}
.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}
.auth-tab.active {
  background: #4ECDC4;
  border-color: #4ECDC4;
  color: #1a1a2e;
  font-weight: 600;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-form.hidden {
  display: none;
}
.auth-form .form-group label small {
  font-size: 0.7rem;
  opacity: 0.6;
  margin-left: 4px;
}
.auth-error {
  background: rgba(255, 80, 80, 0.15);
  border: 1px solid rgba(255, 80, 80, 0.4);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  color: #ff8080;
}
.auth-error.hidden { display: none; }

/* Rang badge dans la liste joueurs */
.rank-badge {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-left: 4px;
}

/* ── Écran profil ────────────────────────────────────────────────────────── */
#screen-profile {
  background-image: url('/images/bg-menu.jpg');
  background-size: cover;
  background-position: 50% 50%;
  background-repeat: no-repeat;
  /* override .screen.active justify-content so the container starts at top */
  justify-content: flex-start;
  align-items: center;
  overflow-y: auto;
}

.profile-container {
  width: min(480px, 94vw);
  padding: 24px 0 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-sizing: border-box;
  min-height: 100%;
}

/* Header */
.profile-header {
  background: rgba(14, 22, 36, 0.93);
  border: 1px solid #3a4a5a;
  border-radius: 14px;
  padding: 20px 22px 16px;
  text-align: center;
}

.profile-username {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 14px;
}

.profile-rank-section { display: flex; flex-direction: column; gap: 5px; }

.profile-rank-label { font-size: 0.85rem; color: #aaa; }
.profile-rank-label strong { color: #ff8c00; font-size: 1rem; }

.profile-rank-bar {
  background: #1e2d3e;
  border-radius: 6px;
  height: 9px;
  overflow: hidden;
}
.profile-rank-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b00, #ffaa00);
  border-radius: 6px;
  transition: width 0.5s ease;
  min-width: 3px;
}
.profile-rank-pts {
  font-size: 0.72rem;
  color: #777;
}

/* Tabs */
.profile-tabs {
  display: flex;
  gap: 8px;
  background: rgba(14, 22, 36, 0.88);
  border-radius: 10px;
  padding: 6px;
}
.profile-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: #aaa;
  padding: 9px 6px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
}
.profile-tab.active { background: #ff6b00; color: #fff; font-weight: 600; }

/* Tab content */
.profile-tab-content {
  background: rgba(14, 22, 36, 0.93);
  border: 1px solid #3a4a5a;
  border-radius: 14px;
  padding: 16px;
  min-height: 200px;
}
.profile-tab-content.hidden { display: none; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid #2e3e50;
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
}
.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: #ff8c00;
}
.stat-label {
  font-size: 0.72rem;
  color: #999;
  margin-top: 3px;
}
.stat-sub {
  font-size: 0.65rem;
  color: #666;
  margin-top: 1px;
}

/* History */
.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid #253444;
  border-radius: 10px;
  padding: 10px 12px;
}
.history-entry.result-win {
  border-color: rgba(255, 140, 0, 0.55);
  background: rgba(255, 140, 0, 0.07);
}
.history-entry.result-last { opacity: 0.55; }

.history-rank { font-size: 1.5rem; min-width: 34px; text-align: center; }

.history-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.history-char { font-size: 0.88rem; font-weight: 600; color: #e0e0e0; }
.history-players { font-size: 0.72rem; color: #888; }

.history-stats {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.72rem;
  color: #aaa;
  text-align: right;
}
.history-date { font-size: 0.68rem; color: #666; min-width: 46px; text-align: right; }

/* Footer */
.profile-footer {
  display: flex;
  gap: 10px;
  align-items: center;
}
.profile-footer .btn { flex: 1; }

.btn-danger-small {
  background: rgba(180, 40, 40, 0.28);
  border: 1px solid rgba(200, 60, 60, 0.45);
  color: #f99;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 0.84rem;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-danger-small:hover { background: rgba(180, 40, 40, 0.5); }

.profile-loading, .profile-empty {
  text-align: center;
  color: #777;
  padding: 28px;
  font-size: 0.9rem;
}
.profile-error {
  text-align: center;
  color: #f88;
  padding: 28px;
  font-size: 0.9rem;
}

/* ── Friends tab ─────────────────────────────────────────────────────────── */
.friends-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #777;
  margin: 14px 0 6px;
}
.friends-section-title:first-child { margin-top: 0; }

.friend-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid #253444;
  border-radius: 9px;
  padding: 9px 12px;
  margin-bottom: 6px;
}
.friend-dot { font-size: 0.9rem; flex-shrink: 0; }
.friend-info {
  flex: 1;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px;
}
.friend-name { font-weight: 600; font-size: 0.9rem; color: #e0e0e0; }
.friend-status-txt { font-size: 0.72rem; color: #888; }

.friend-btns { display: flex; gap: 6px; }
.btn-friend-accept, .btn-friend-decline, .btn-friend-remove {
  background: rgba(255,255,255,0.07);
  border: 1px solid #3a4a5a;
  color: #ccc;
  border-radius: 6px;
  width: 30px; height: 30px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.btn-friend-accept { color: #6f6; border-color: rgba(100,200,100,.4); }
.btn-friend-accept:hover { background: rgba(100,200,100,.2); }
.btn-friend-decline, .btn-friend-remove { color: #f88; border-color: rgba(200,80,80,.4); }
.btn-friend-decline:hover, .btn-friend-remove:hover { background: rgba(200,80,80,.2); }

.friend-add-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.friend-add-row input {
  flex: 1;
  background: #0e1624;
  border: 1px solid #3a4a5a;
  border-radius: 8px;
  color: #e0e0e0;
  padding: 9px 12px;
  font-size: 0.88rem;
}
.friend-add-row input:focus { outline: none; border-color: #ff6b00; }
#btn-friend-send {
  background: #ff6b00;
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}
#btn-friend-send:hover { background: #e05e00; }

.friend-add-msg {
  font-size: 0.8rem;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 6px;
}
.friend-add-msg.hidden { display: none; }
.friend-add-msg.ok  { background: rgba(100,200,100,.15); color: #8f8; }
.friend-add-msg.err { background: rgba(200,80,80,.15);  color: #f88; }

/* ── Invite friends button in room header ────────────────────────────────── */
.btn-invite-friends {
  background: rgba(255,255,255,0.1);
  border: 1px solid #3a4a5a;
  border-radius: 8px;
  color: #e0e0e0;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  transition: background .15s;
  margin-left: auto;
}
.btn-invite-friends:hover { background: rgba(255,255,255,0.18); }
.btn-invite-friends.hidden { display: none; }

/* Invite modal friend rows */
.invite-friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #253444;
  gap: 10px;
}
.invite-friend-row:last-child { border-bottom: none; }
.btn-invite-send {
  background: #ff6b00;
  border: none;
  border-radius: 7px;
  color: #fff;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.82rem;
  flex-shrink: 0;
  transition: background .15s;
}
.btn-invite-send:hover:not(:disabled) { background: #e05e00; }
.btn-invite-send:disabled { background: #555; cursor: default; }

/* ── Room invite banner ───────────────────────────────────────────────────── */
.invite-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a2636;
  border: 1px solid #ff6b00;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 3000;
  box-shadow: 0 6px 24px rgba(0,0,0,.6);
  max-width: min(420px, 92vw);
  font-size: 0.88rem;
  color: #e0e0e0;
  animation: slideUp .25s ease;
}
.invite-banner.hidden { display: none; }
.invite-banner-btns { display: flex; gap: 8px; flex-shrink: 0; }
#btn-invite-join {
  background: #ff6b00;
  border: none;
  border-radius: 7px;
  color: #fff;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 0.82rem;
  white-space: nowrap;
}
#btn-invite-join:hover { background: #e05e00; }
#btn-invite-dismiss {
  background: transparent;
  border: 1px solid #555;
  border-radius: 7px;
  color: #999;
  width: 30px; height: 30px;
  cursor: pointer;
  font-size: 0.82rem;
  display: flex; align-items: center; justify-content: center;
}
#btn-invite-dismiss:hover { background: rgba(255,255,255,.08); }

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