@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;900&family=Crimson+Pro:ital,wght@0,400;0,600;1,400&display=swap");

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

:root {
  --bg: #0b1512;
  --felt: #0f1f17;
  --felt2: #122318;
  --felt3: #163020;
  --border: rgba(255, 255, 255, 0.07);
  --border-hi: rgba(255, 255, 255, 0.15);
  --gold: #e8ab2a;
  --gold-glow: rgba(232, 171, 42, 0.22);
  --green: #2ea043;
  --green-glow: rgba(46, 160, 67, 0.22);
  --red: #c93535;
  --red-glow: rgba(201, 53, 53, 0.22);
  --text: #f0e4e4;
  --muted: #e8f9e9;
  --dim: #3a4f3c;
  --card-light: #fffef8;
  --card-warm: #f5f0e4;
  --r-card: 9px;
  --sh-card: 0 6px 24px rgba(0, 0, 0, 0.65), 0 1px 4px rgba(0, 0, 0, 0.4);
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: "Outfit", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.screen.hidden {
  display: none !important;
}

/* ── LOBBY SCREEN ────────────────────────────────────── */

/* Capa de blur + oscurecimiento SIN pointer-events para no bloquear clicks */
#screenLobby::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("./Media/Images/Others/fondo-pantalla-inicial.webp")
    center/cover no-repeat;
  filter: blur(5px) brightness(0.5);
  z-index: 0;
  pointer-events: none;
}
/* El panel verde debe quedar encima de la capa de blur */
.lobby-wrap {
  position: relative;
  z-index: 1;
  width: 90%;
  max-width: 360px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: lab(33.24% -32.48 19.97 / 0.93); /* verde tapete */
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  gap: 12px;
}
.lobby-header {
  text-align: center;
}
.lobby-portada {
  width: 200px;
  height: auto;
  border-radius: 8px;
  margin-bottom: 2px;
  display: block;
  margin-left: auto;
  margin-right: auto;
  object-fit: cover;
}
.ls {
  opacity: 0.75;
}
.ls.oros {
  color: #c9930a;
}
.ls.copas {
  color: #b52828;
}
.ls.espadas {
  color: #a0b4d8;
}
.ls.bastos {
  color: #5a9e3a;
}
h1 {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -1px;
  color: var(--text);
}
h1 .hi {
  color: var(--gold);
}
.lobby-sub {
  font-size: 13px;
  font-weight: 300;
  color: var(--muted);
  margin-top: 4px;
}
.lobby-card {
  display: flex;
  flex-direction: column;
}
.lfield {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
}
.lfield label {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.lfield input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 13px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.lfield input::placeholder {
  color: var(--dim);
}
.lfield input:focus {
  border-color: rgba(232, 171, 42, 0.5);
  box-shadow: 0 0 0 3px rgba(232, 171, 42, 0.1);
}
.lobby-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.lbtn {
  font-family: "Outfit", sans-serif;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition:
    opacity 0.15s,
    transform 0.07s;
}
.lbtn:active {
  transform: translateY(1px);
}
.lbtn-primary {
  background: var(--gold);
  color: #0b1512;
}
.lbtn-primary:hover {
  opacity: 0.9;
}
.lbtn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
}
.lbtn-secondary:hover {
  background: rgba(255, 255, 255, 0.13);
}
.lobby-msg {
  font-size: 13px;
  color: var(--muted);
  min-height: 20px;
  margin-top: 12px;
  text-align: center;
}
.lobby-msg.err {
  color: #ff7070;
}
.lobby-msg.good {
  color: #7ee787;
}
.lobby-debug {
  text-align: center;
}
.chk-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.chk-line input {
  accent-color: var(--gold);
  cursor: pointer;
}

/* ══ HUD ════════════════════════════════ */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  height: 56px;
  background: rgba(18, 52, 42, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.hud-right {
  justify-content: flex-end;
}
.hud-center {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hud-pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-score-num {
  font-family: "Crimson Pro", serif;
  font-size: 40px;
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
  min-width: 30px;
  text-align: center;
}
.hud-score-sep {
  font-size: 28px;
  color: var(--dim);
}
.hud-leave {
  font-family: "Outfit", sans-serif;
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--muted);
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s;
  white-space: nowrap;
}
.hud-leave:hover {
  border-color: rgba(201, 53, 53, 0.5);
  color: #ff8080;
}

/* ══ TURN TIMER BAR ═════════════════════ */
#turnTimerBar {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 49;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
}
#turnTimerFill {
  height: 100%;
  width: 0%;
  background: var(--green);
  transition:
    width 1s linear,
    background 0.3s;
}
#turnTimerFill.urgent {
  background: var(--gold);
}
#turnTimerFill.timer-flash {
  animation: timerFlash 0.4s ease infinite alternate;
}
@keyframes timerFlash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.3;
  }
}

/* ══ TABLE ══════════════════════════════ */
#table {
  position: fixed !important;
  top: 59px !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  padding: 14px 20px 90px !important; /* 90px = espacio para los botones flotantes */
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: space-between !important;
  background: radial-gradient(
    ellipse at 50% 40%,
    #2d6e3a 0%,
    #1e4d28 100%
  ) !important;
  overflow: hidden !important;
}
#table::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 12px,
    rgba(255, 255, 255, 0.007) 12px,
    rgba(255, 255, 255, 0.007) 13px
  );
}

/* Rival */
#rivalZone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1;
  width: 100%;
}
.player-name {
  font-size: 17px !important;
  font-weight: 700 !important;
  color: white;
  text-shadow: 0px 1px 4px rgba(0, 0, 0, 0.8); /* Sombreado para que no se pierda con el fondo */
  white-space: nowrap;
}
.rival-card-slot {
  position: absolute;
  transition:
    transform 0.4s ease,
    opacity 0.4s ease;
}
.rival-card-slot:nth-child(1) {
  transform: translateX(-54px) rotate(-9deg);
}
.rival-card-slot:nth-child(2) {
  transform: translateX(0) rotate(0deg);
  z-index: 2;
}
.rival-card-slot:nth-child(3) {
  transform: translateX(54px) rotate(9deg);
}
.rival-cards[data-count="2"] .rival-card-slot:nth-child(1) {
  transform: translateX(-30px) rotate(-5deg);
}
.rival-cards[data-count="2"] .rival-card-slot:nth-child(2) {
  transform: translateX(30px) rotate(5deg);
}
.rival-cards[data-count="1"] .rival-card-slot:nth-child(1) {
  transform: translateX(0) rotate(0);
}

/* Centro */
#centerZone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 1;
}
.trick-area {
  display: flex;
  align-items: center;
  gap: 16px;
}
.trick-divider {
  width: 1px;
  height: 70px;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(255, 255, 255, 0.12),
    transparent
  );
}
.center-info {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.4px;
  min-height: 18px;
  text-align: center;
}

/* Mi zona */
#myZone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1;
  width: 100%;
  /* Sin padding-bottom artificial */
}

.my-cards {
  display: flex;
  justify-content: center;
  position: relative;
  height: 114px; /* Altura en móvil */
  transition: height 0.3s ease;
}

/* Ajuste para PC (con el nuevo tamaño de 105px) */
@media (min-width: 1024px) {
  /* Bajamos de 195px a 165px para que la mano quede ajustada y elegante */
  .my-cards {
    height: 165px;
  }
}
.my-card-wrap {
  position: relative;
  transition: transform 0.18s ease;
  margin: 0 -8px; /* Móvil */
}

@media (min-width: 768px) {
  .my-card-wrap {
    margin: 0 -15px; /* En PC las separamos un poco más para que luzcan */
  }
}
.my-card-wrap:hover {
  transform: translateY(-12px) scale(1.04);
  z-index: 10;
}
.my-card-wrap.playable {
  cursor: pointer;
}
.my-card-wrap.playable:hover .playing-card {
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.8),
    0 0 0 2px var(--gold);
}

/* ══ PLAYING CARDS ══════════════════════ */
.playing-card {
  width: 86px; /* Un pelín más grande en móvil */
  height: 123px;
  border-radius: var(--r-card);
  background: linear-gradient(
    160deg,
    var(--card-light) 0%,
    var(--card-warm) 100%
  );
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: var(--sh-card);
  padding: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  user-select: none;
  color: #111;
  transition:
    width 0.3s ease,
    height 0.3s ease; /* Para que el cambio sea suave */
}

/* --- TAMAÑO PARA PC --- */
@media (min-width: 768px) {
  .playing-card {
    width: 130px; /* ¡Mucho más grande! */
    height: 195px;
    padding: 10px; /* Más aire por dentro */
  }
}
/* --- Card artwork images (Media/Images/Cards) --- */
.playing-card.use-img {
  padding: 0 !important;
  display: block;
  overflow: hidden;
}
.playing-card.use-img .card-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
  user-select: none;
  pointer-events: none;
}
.pc-top {
  display: flex;
  align-items: center;
  gap: 2px;
}
.pc-rank {
  font-family: "Crimson Pro", serif;
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  color: inherit;
}
.pc-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}
.pc-bot {
  display: flex;
  align-items: center;
  gap: 2px;
  transform: rotate(180deg);
}
.s-oros {
  color: #b07d10;
}
.s-copas {
  color: #b52a2a;
}
.s-espadas {
  color: #1a2540;
}
.s-bastos {
  color: #2a5c17;
}
.card-back {
  width: 76px;
  height: 114px;
  border-radius: var(--r-card);
  background: repeating-linear-gradient(
    135deg,
    #1a3a5c 0px,
    #1a3a5c 8px,
    #0f2438 8px,
    #0f2438 16px
  );
  border: 1px solid rgba(56, 139, 253, 0.18);
  box-shadow: var(--sh-card);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-back::after {
  content: "T";
  font-family: "Crimson Pro", serif;
  font-size: 28px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.12);
  font-style: italic;
}

/* ══ ACTION PANEL ═══════════════════════ */
#actionPanel {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: auto !important;
  min-height: 0 !important;
  background: transparent !important;
  backdrop-filter: none !important;
  border-top: none !important;
  padding: 12px 16px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 6px !important;
  z-index: 50 !important;
}
.offer-msg {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--gold);
  padding: 2px 0;
}
.offer-msg.hidden {
  display: none !important;
}
.action-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.response-area {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.response-area.hidden {
  display: none !important;
}
.status-msg {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}

/* ══ SIDE INFO ══════════════════════════ */
#sideInfo {
  position: fixed;
  right: 12px;
  top: 68px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.si-block {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px !important;
  min-width: 80px !important;
  text-align: right;
}

.si-lbl {
  font-size: 10px !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--dim);
}

#sideInfo .si-block > div:last-child {
  font-size: 14px !important;
  font-weight: 700 !important;
}

.si-block > div:last-child {
  color: var(--text);
  margin-top: 1px;
}

/* ══ LOG PANEL (Ajustado: más bajo y más pequeño) ══ */
#logPanel {
  position: fixed;
  right: 12px;
  top: 180px; /* <--- Aumentado de 165 a 180 para separarlo de Ronda */
  z-index: 40;
  width: 160px; /* <--- Un poco más estrecho (antes 190) */
  text-align: right;
}

.log-toggle {
  font-size: 10px; /* <--- Bajado 1px */
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.4px;
  padding: 4px 0;
  user-select: none;
}

.log-toggle:hover {
  color: var(--text);
}

.log-body {
  background: rgba(
    0,
    0,
    0,
    0.65
  ); /* Un pelín más oscuro para leer mejor la letra pequeña */
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  max-height: 130px; /* <--- Reducido de 160 a 130 para que sea más discreto */
  overflow-y: auto;
  margin-top: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.log-body.hidden {
  display: none !important;
}

#logArea {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-entry {
  font-size: 10px; /* <--- Letra más pequeña (antes 11) */
  color: var(--muted);
  line-height: 1.3;
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  text-align: right;
}

/* ══ CHAT ═══════════════════════════════ */
#chatPanel {
  position: fixed;
  bottom: 134px;
  right: 12px;
  z-index: 60;
  width: 240px;
}
.chat-toggle {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
  transition:
    border-color 0.15s,
    color 0.15s;
  margin-left: auto;
  width: fit-content;
}
.chat-toggle:hover {
  color: var(--text);
  border-color: var(--border-hi);
}
.chat-badge {
  background: var(--gold);
  color: #0b1512;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  padding: 1px 5px;
  line-height: 1.4;
}
.chat-badge.hidden {
  display: none !important;
}
.chat-box {
  background: rgba(11, 21, 18, 0.96);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}
.chat-box.hidden {
  display: none !important;
}
.chat-messages {
  height: 200px;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.chat-msg {
  font-size: 13px;
  line-height: 1.4;
}
.chat-msg .chat-author {
  font-weight: 700;
  margin-right: 4px;
}
.chat-msg.mine .chat-author {
  color: var(--gold);
}
.chat-msg.theirs .chat-author {
  color: #7ee787;
}
.chat-msg .chat-text {
  color: var(--text);
}
.chat-msg .chat-time {
  font-size: 10px;
  color: var(--dim);
  margin-left: 4px;
}
.chat-input-row {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--border);
}
#chatInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
}
#chatInput::placeholder {
  color: var(--dim);
}
.chat-send {
  background: var(--gold);
  color: #0b1512;
  border: none;
  padding: 0 14px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: opacity 0.15s;
}
.chat-send:hover {
  opacity: 0.85;
}

/* ══ OVERLAYS ═══════════════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
}
/* ── WAITING OVERLAY: mismo fondo pero como overlay ── */
#waitingOverlay {
  background:
    url("./Media/Images/Others/fondo-pantalla-inicial.webp") center/cover
      no-repeat,
    var(--bg);
}
#waitingOverlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  z-index: 0;
}

.overlay.hidden {
  display: none !important;
}

/* Countdown entre manos: flotante, semitransparente, no tapa el tablero */
#countdownOverlay {
  background: transparent !important;
  backdrop-filter: none !important;
  pointer-events: none;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 150px;
}
#countdownOverlay .overlay-card {
  background: rgba(8, 16, 11, 0.82);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(232, 171, 42, 0.25);
  padding: 16px 28px;
  gap: 4px;
  max-width: 360px;
  width: 90vw;
}
.overlay-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 52px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: ovIn 0.35s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
@keyframes ovIn {
  from {
    opacity: 0;
    transform: scale(0.88);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.ov-suits {
  font-size: 20px;
  letter-spacing: 10px;
  margin-bottom: 4px;
}
.ov-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}
.ov-num {
  font-family: "Crimson Pro", serif;
  font-size: 110px;
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
  text-shadow: 0 0 80px rgba(232, 171, 42, 0.45);
  animation: numPulse 0.9s ease-in-out infinite;
}
@keyframes numPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}
.ov-label {
  font-size: 14px;
  font-weight: 300;
  color: var(--muted);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* Waiting overlay */
.waiting-code {
  font-family: "Crimson Pro", serif;
  font-size: 56px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 8px;
}
.waiting-status {
  font-size: 14px;
  color: var(--muted);
  min-height: 20px;
}
.waiting-note {
  font-size: 11px;
  color: var(--dim);
  margin-top: 4px;
}

/* Game over */
.go-winner {
  font-family: "Crimson Pro", serif;
  font-size: 36px;
  font-weight: 600;
  color: var(--gold);
}
.go-score {
  font-size: 22px;
  color: var(--muted);
}

/* ══ ANIMATIONS ═════════════════════════ */
@keyframes dealIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.88);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.deal-anim {
  animation: dealIn 0.28s ease both;
}
.deal-anim:nth-child(2) {
  animation-delay: 0.08s;
}
.deal-anim:nth-child(3) {
  animation-delay: 0.16s;
}

@keyframes flyToCenter {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) scale(0.72) rotate(var(--rot));
  }
}
.card-flying {
  animation: flyToCenter 0.32s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes landOnTable {
  from {
    opacity: 0;
    transform: scale(0.72) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.land-anim {
  animation: landOnTable 0.22s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

/* ══ RESPONSIVE ═════════════════════════ */
@media (max-width: 520px) {
  #sideInfo {
    display: none;
  }
  #logPanel {
    display: none;
  }
  #chatPanel {
    width: 200px;
  }
  .playing-card,
  .card-back {
    width: 64px;
    height: 96px;
  }
  .overlay-card {
    padding: 28px 24px;
  }
  .waiting-code {
    font-size: 42px;
  }
}

#countdownOverlay .ov-num {
  font-size: 56px;
  animation: none;
}
#countdownOverlay .ov-label {
  font-size: 12px;
  letter-spacing: 1px;
}

/* Summary label in between-hands overlay */
.cd-summary {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  text-align: center;
  min-height: 20px;
}

/* lobby z-index managed in main block */

/* ── RIVAL TURN INDICATOR ── */
.rival-header {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

/* ── MY TURN INDICATOR on action panel ── */
#statusMsg.my-turn {
  color: var(--gold);
  font-weight: 700;
}

/* ── GAME OVER ── */
.go-rematch-status {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  min-height: 16px;
  margin-top: 4px;
}
#gameOverOverlay .overlay-card {
  background: rgba(10, 18, 14, 0.95) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
}
#goTitle {
  font-size: 22px;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: -0.5px;
}

/* ── RIVAL CARDS FAN (absolute positioned) ── */
.rival-cards {
  position: relative !important;
  height: 96px !important;
  width: 180px !important;
  margin: 0 auto;
}
.rival-card-slot {
  position: absolute !important;
  top: 0;
  left: 50%;
  margin-left: -38px; /* half card width */
  transform-origin: bottom center;
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

/* ── LOBBY: full bleed background, no black bar ── */
/* green lobby panel handled in main block */
/* Also for waitingOverlay card */
#waitingOverlay .overlay-card {
  background: rgba(20, 90, 45, 0.94) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

/* ── TRICK AREA: side by side layout ── */
.trick-slot {
  width: auto !important;
  min-width: 76px !important;
  max-width: 280px !important;
  min-height: 114px !important;
  position: relative !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-end !important;
  justify-content: center !important;
  gap: 5px !important;
}

/* ── LOBBY TAGLINE ── */
.lobby-tagline {
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
  padding-top: 4px;
}
/* ── LOBBY: fondo con blur ── */
#screenLobby {
  background: var(--bg);
  overflow-y: auto;
}

/* ── EL RECUADRO (El div de dentro) ── */
#screenLobby > div {
  /* EL TRUCO: Margen 'auto' a los lados para centrar, 
     y 60px fijos arriba y abajo para que NUNCA toque el borde */
  margin: 60px auto !important;

  height: auto !important;
  max-width: 450px;
  width: 90%; /* Para que en móvil no pegue a los lados */

  position: relative;
  z-index: 1;

  /* Esto asegura que el navegador lo trate como un bloque centrado */
  flex-shrink: 0;
}

/* ── LOBBY: smaller on mobile, show bg top+bottom ── */
@media (max-height: 700px), (max-width: 480px) {
  .lobby-wrap {
    max-height: 88vh;
    overflow-y: auto;
    padding: 18px 18px;
    gap: 14px;
  }
  .lobby-portada {
    width: 140px;
  }
  h1 {
    font-size: 26px;
  }
}

/* ── FELT TEXTURE on green panels ── */
.lobby-wrap,
#waitingOverlay .overlay-card,
#waitingOverlay .waiting-card {
  background-image:
    repeating-linear-gradient(
      45deg,
      rgba(0, 0, 0, 0.04) 0px,
      rgba(0, 0, 0, 0.04) 1px,
      transparent 1px,
      transparent 4px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(0, 0, 0, 0.03) 0px,
      rgba(0, 0, 0, 0.03) 1px,
      transparent 1px,
      transparent 4px
    ) !important;
}

/* ── WAITING OVERLAY updates ── */
.waiting-portada {
  width: 90px;
  height: auto;
  border-radius: 8px;
  display: block;
  margin: 0 auto 10px;
}
.waiting-code-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  justify-content: center;
  margin: 4px 0;
}
.waiting-code-lbl {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.6);
}
.waiting-code {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--gold);
}

/* ── SCORE SUMMARY in countdown overlay ── */
.summary-events {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}
.sum-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.sum-label {
  color: var(--text);
  text-align: left;
}
.sum-pts {
  color: #7ee787;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.sum-result {
  margin-top: 10px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 8px;
}
.sum-score {
  color: var(--gold);
  font-size: 20px;
}

/* ── TURN RING PULSE when it's your turn ── */
#myTimerRing:not(.hidden) {
  filter: drop-shadow(0 0 6px rgba(46, 160, 67, 0.9));
  animation: ringPulse 1.4s ease-in-out infinite;
}
@keyframes ringPulse {
  0%,
  100% {
    filter: drop-shadow(0 0 4px rgba(46, 160, 67, 0.7));
  }
  50% {
    filter: drop-shadow(0 0 10px rgba(46, 160, 67, 1));
  }
}

/* ── TABLE MSG (button action displayed in center) ── */
.table-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  opacity: 0;
  z-index: 30;
}
/* --- NUEVOS BOCADILLOS POSICIONALES --- */
/* --- TEXTO FLOTANTE (Sin recuadros) --- */
.table-msg-bubble {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  background: none !important; /* Sin fondo */
  border: none !important; /* Sin bordes */
  box-shadow: none !important; /* Sin sombras */
  color: var(--gold, gold);
  font-size: 38px; /* Más grande para compensar que no hay cuadro */
  font-weight: 900;
  text-transform: uppercase;
  z-index: 1000;
  pointer-events: none;
  text-shadow:
    2px 2px 4px rgba(0, 0, 0, 0.8),
    0 0 10px rgba(212, 175, 55, 0.5);
  animation: bubblePop 1.8s ease-out forwards;
}

.msg-mine {
  bottom: 30%;
}
.msg-rival {
  top: 30%;
}

@keyframes bubblePop {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translateX(-50%) scale(1.3);
  }
  80% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-40px) scale(1.1);
  }
}
.table-msg-anim {
  animation: tableMsgShow 2.5s ease forwards;
}
@keyframes tableMsgShow {
  0% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.7);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }
  40% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ── TURN ACTIVE ZONES ── */
#myZone.turn-active .player-name {
  color: var(--gold);
  animation: namePulse 1.2s ease-in-out infinite;
}
#rivalZone.turn-active .player-name {
  color: #f0a0a0;
  animation: namePulse 1.2s ease-in-out infinite;
}
@keyframes namePulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ── GAME OVER OVERLAY — transparent over board ── */
#gameOverOverlay {
  background: rgba(0, 0, 0, 0.65) !important;
  backdrop-filter: blur(3px) !important;
  -webkit-backdrop-filter: blur(3px) !important;
}
#gameOverOverlay .overlay-card {
  background: rgba(12, 22, 16, 0.88) !important;
}

/* ── TABLE: lighter felt ── */
#table {
  background: radial-gradient(
    ellipse at 50% 40%,
    #2d6e3a 0%,
    #1e4d28 100%
  ) !important;
}
#table::before {
  background: none !important;
}

/* ── BAZA TEXT: EMPAT in gold ── */
.baza-empat {
  color: #f0b429 !important;
  font-weight: 700;
}

/* ── REUBICACIÓN DE AVATARES (Posición final) ── */
.rival-header {
  position: absolute !important;
  top: 25px !important; /* Un poco más separado del borde superior */
  left: 50px !important;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 50;
}

.my-zone-header {
  position: absolute !important;
  /* Bajamos el avatar: si antes tenías 85px, 20px lo dejará casi pegado a la barra */
  bottom: 20px !important;
  left: 50px !important;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 50;
}

/* ── 6. Absence notification ── */
.absence-notif {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(218, 54, 51, 0.92);
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(4px);
}
.absence-notif.hidden {
  display: none !important;
}

/* ── 8. Countdown in center ── */
.table-cd-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 25;
  opacity: 0;
}
.table-cd-anim {
  animation: cdShow 1.1s ease forwards;
}
@keyframes cdShow {
  0% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.6);
  }
  20% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1);
  }
  75% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}
.cd-subtitle {
  font-size: 18px;
  color: rgb(255, 255, 255);
  letter-spacing: 1px;
}
.cd-number {
  font-size: 72px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(232, 171, 42, 0.8);
  line-height: 1;
}

/* ── 9. Avatar styles (Versión Cuadrícula 4x4) ── */
.avatar-pick {
  text-align: center;
  margin-bottom: 20px;
}
.avatar-pick-lbl {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.951);
  margin-bottom: 18px;
}

/* El contenedor: Ahora es una rejilla */
.avatar-options {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 15px 10px !important;
  justify-items: center !important;
  max-width: 320px; /* Ajuste para que los 4 queden bien centrados en móvil */
  margin: 0 auto !important;
}

/* El círculo del avatar: ¡Más grande! */
.av-opt {
  width: 70px !important;
  height: 70px !important;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.907);
  cursor: pointer;
  transition:
    border-color 0.2s,
    transform 0.2s;
  background: #222;
}

.av-opt:hover {
  transform: scale(1.1);
  border-color: gold;
}

/* Importante: He visto que tu clase de selección se llama 'av-selected' */
.av-opt.av-selected {
  border: 4px solid gold !important;
  box-shadow: 0 0 15px rgba(232, 171, 42, 0.6) !important;
  transform: scale(1.05);
}

/* Mantenemos los avatares pequeños de la mesa igual */
.player-av-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}
/* ── FIX 3: Avatares centrados y anillo de tiempo perfecto ── */

/* 1. El contenedor principal (el que manda) */
.player-avatar-wrap {
  position: relative !important;
  overflow: visible !important; /* CRUCIAL: Para que el menú no se quede dentro del círculo */
  cursor: pointer;
}

/* 2. El círculo del Avatar (El de dentro) */
.player-av-sm {
  width: 44px !important; /* Tamaño fijo del avatar */
  height: 44px !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  position: relative !important;
  z-index: 1;
  border: 2px solid rgba(255, 255, 255, 0.1); /* Un borde fino para separar */
}

.player-av-sm img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
}

/* 3. El Anillo de Tiempo (El de fuera) */
.av-ring {
  position: absolute !important;
  /* Centrado quirúrgico */
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) rotate(-90deg) !important;

  /* El anillo es un poco más grande que el avatar para rodearlo */
  width: 52px !important;
  height: 52px !important;

  pointer-events: none !important;
  z-index: 2;
}

/* 4. Estilos del dibujo del anillo */
.av-ring .timer-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 3;
}

.av-ring .timer-ring-arc {
  fill: none;
  stroke: #2ea043;
  stroke-width: 3;
  stroke-linecap: round;
  /* El dasharray depende del radio del círculo en tu HTML, lo mantenemos */
  stroke-dasharray: 119.4 119.4;
  transition:
    stroke-dasharray 0.9s linear,
    stroke 0.3s ease;
}

/* ── FIX 4: Fixed countdown (no re-animation) ── */
.table-cd-fixed {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 25;
  transition: opacity 0.3s;
}
.table-cd-fixed.hidden {
  opacity: 0;
  pointer-events: none;
}
.table-cd-fixed .cd-subtitle {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.table-cd-fixed .cd-number {
  font-size: 80px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(232, 171, 42, 0.9);
  line-height: 1;
}

/* ── Fix avatar options: remove onclick attr warning ── */
.av-opt {
  cursor: pointer;
}
/* Avatar taken by rival */
.av-opt.av-taken {
  opacity: 0.35;
  filter: grayscale(0.8);
  cursor: not-allowed;
  border-color: rgba(218, 54, 51, 0.5) !important;
}
.av-opt.av-taken::after {
  content: "✗";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: rgba(218, 54, 51, 0.9);
  font-weight: 900;
}
.av-opt {
  position: relative;
}

/* -- Room list in lobby -- */
.lobby-rooms {
  width: 100%;
}
.rl-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 8px;
}
.room-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 24px;
}
.rl-loading,
.rl-empty {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
  padding: 6px;
}
.rl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 8px 12px;
  gap: 10px;
}
.rl-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rl-code {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 2px;
}
.rl-host {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
}
.rl-join {
  padding: 6px 14px !important;
  font-size: 13px !important;
  flex-shrink: 0;
}

/* -- Quick join panel -- */
.quick-join-panel {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(232, 171, 42, 0.35);
  border-radius: 14px;
  padding: 16px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeSlideIn 0.25s ease;
}
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.qj-title {
  font-size: 14px;
  color: var(--text);
  text-align: center;
}
.qj-title b {
  color: var(--gold);
}
.qj-av-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.485);
  text-align: center;
}
.qj-avs {
  justify-content: center;
}
.qj-btns {
  display: flex;
  gap: 8px;
}
.qj-btns .lbtn {
  flex: 1;
  padding: 10px !important;
  font-size: 14px !important;
}

/* -- Quick join centered modal -- */
.qj-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.qj-hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  margin-bottom: 8px;
  font-style: italic;
}

/* -- Game over overlay: very transparent so cards show through -- */
#gameOverOverlay {
  background: rgba(0, 0, 0, 0.25) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  pointer-events: auto;
}
#gameOverOverlay .overlay-card {
  background: rgba(8, 16, 12, 0.78) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7) !important;
}
/* --- Nueva Mesa de Juego (Estilo Enfrentado) --- */

.trick-grid {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px; /* Espacio entre la baza 1, 2 y 3 */
  min-height: 250px;
  width: 100%;
}

.trick-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  transition: background 0.3s;
}

/* Resaltado suave si la baza es empate */
.trick-draw {
  background: rgba(255, 215, 0, 0.05);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.1);
}

.trick-cell-rival,
.trick-cell-mine {
  /* Mantengo tus medidas y ajustes */
  width: 82px;
  height: 123px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;

  /* --- EFECTO 3D (LO NUEVO) --- */
  /* El perspective crea la sensación de profundidad */
  perspective: 500px;
}

/* Aplicamos la inclinación a la carta que esté dentro de la celda */
.trick-cell-rival img,
.trick-cell-mine img,
.trick-cell-rival .playing-card,
.trick-cell-mine .playing-card {
  /* rotateX(25deg) hace que la parte de arriba se aleje de ti */
  /* scale(1.05) la agranda un pelín para compensar que al inclinarla parece más pequeña */
  transform: rotateX(25deg) scale(1.05);

  /* Una sombra suave hacia abajo para que parezca que "flota" un milímetro sobre el tapete */
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);

  border-radius: 6px;
  transition: transform 0.3s ease;
}

/* --- TAMAÑO PARA PC (Equilibrado) --- */
@media (min-width: 1024px) {
  /* Bajamos de 130px a 105px para que no se dispare el tamaño */
  .playing-card,
  .trick-cell-rival,
  .trick-cell-mine {
    width: 90px;
    aspect-ratio: 105 / 153;
    height: auto;
  }
}
/* Contenedores de la mesa */
.trick-cell-rival,
.trick-cell-mine {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  /* El 'perspective' es clave para el 3D */
  perspective: 400px;
}

/* LA REGLA MAESTRA: Cualquier carta o imagen dentro de la mesa */
.trick-cell-rival .playing-card,
.trick-cell-mine .playing-card,
.trick-cell-rival img,
.trick-cell-mine img {
  /* Forzamos la inclinación inmediatamente */
  transform: rotateX(25deg) !important;

  /* Sombra para que parezca apoyada */
  box-shadow: 0 18px 25px rgba(0, 0, 0, 0.4) !important;

  /* Aseguramos que ocupe todo el hueco */
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;

  border-radius: 8px;
}

/* Separador invisible o línea sutil entre cartas */
.trick-row-sep {
  height: 2px;
  width: 40px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* Borde dorado para la carta ganadora */
.trick-winner {
  outline: 2px solid #ffd700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
  border-radius: 2px;
}

/* --- 1. ARREGLO GLOBAL PARA AVATARES --- */
/* (Esto hace que las fotos de los avatares se vean bien) */
.player-av img,
.av-opt img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 50%;
  display: block;
}

/* ══ BOTONES DE ACCIÓN (base, todas las pantallas) ══════════════════════════ */
.abtn {
  font-family: "Outfit", sans-serif;
  font-size: 17px;
  font-weight: 800;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 13px 22px;
  cursor: pointer;
  min-width: 110px;
  transition:
    opacity 0.15s,
    transform 0.07s,
    filter 0.15s;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.6),
    0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Colores sólidos por tipo de botón (PC y móvil) */
.abtn-green {
  background: #1e7a34;
  border-color: #4caf65;
  color: #e8ffe8;
}
.abtn-gold {
  background: #8a5e00;
  border-color: #e8ab2a;
  color: #fff3cc;
}
.abtn-red {
  background: #7a1f1f;
  border-color: #e05555;
  color: #ffe8e8;
}

/* ══ AJUSTES EXCLUSIVOS PARA MÓVIL ══════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Contenedor de botones: fila compacta */
  #actionBtns {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 4px !important;
    width: 100% !important;
    height: 40px !important;
    padding: 0 4px !important;
  }

  /* Botones: tamaño reducido para pantalla pequeña */
  .abtn {
    flex: 1 1 0;
    height: 40px;
    font-size: 15px;
    font-weight: 800;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Texto de estado y oferta: sin fondo, flota sobre la mesa */
  #statusMsg,
  #offerMsg {
    font-size: 11px !important;
    margin: 0 !important;
    padding: 2px 0 !important;
    background: transparent !important;
    width: 100% !important;
  }

  /* Ocultar panel de acciones en el lobby */
  #screenLobby #actionPanel,
  .hidden {
    display: none !important;
  }
}

/* Ocultar el panel de acciones cuando el juego no está activo */
#screenGame.hidden ~ #actionPanel,
#screenLobby:not(.hidden) ~ * #actionPanel {
  display: none !important;
}
/* Asegura que el modal no se vea si tiene la clase hidden */
.hidden {
  display: none !important;
}

/* Contenedor de las salas con posición relativa para que el modal se pegue a él */
.lobby-rooms {
  position: relative;
  min-height: 120px;
}

/* Modal compacto y centrado solo en el área de salas */
/* El modal ahora se alinea arriba (flex-start) para que no lo tape el teclado */
.qj-modal {
  position: fixed; /* ← fixed en lugar de absolute */
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center; /* ← centra verticalmente */
  justify-content: center; /* ← centra horizontalmente */
  z-index: 500;
  border-radius: 0; /* quita el border-radius que tenía del contenedor pequeño */
}

/* El recuadro ahora es verde y más compacto */
.qj-content {
  background: #1e4d2b; /* Verde tipo mesa de Truc/Casino */
  padding: 15px;
  border: 2px solid white; /* Un poco más de borde para que resalte */
  border-radius: 12px;
  width: 85%;
  max-width: 240px;
  text-align: center;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
  animation: slideIn 0.3s ease-out; /* Animación de entrada rápida */
}

/* Animación opcional para que aparezca "cayendo" desde arriba */
@keyframes slideIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.qj-content h3 {
  font-size: 15px;
  color: gold;
  margin: 0 0 10px 0;
  text-shadow: 1px 1px 2px black;
}
.qj-content p {
  font-size: 12px;
  margin-bottom: 10px;
  color: #eee;
}

#qj-name-input {
  width: 100%;
  padding: 10px;
  margin-bottom: 15px;
  background: rgba(0, 0, 0, 0.3); /* Fondo oscuro semitransparente */
  border: 1px solid rgb(255, 255, 255);
  border-radius: 6px;
  color: white;
  text-align: center;
  font-size: 16px; /* Tamaño ideal para que no haga zoom el iPhone */
}

.qj-buttons {
  display: flex;
  gap: 8px;
}
.btn-qj-confirm {
  background: gold;
  color: black;
  flex: 2;
  padding: 10px;
  border-radius: 6px;
  font-weight: bold;
  border: none;
  cursor: pointer;
}
.btn-qj-cancel {
  background: #8b0000;
  color: white;
  flex: 1;
  padding: 10px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
}

/* Los hijos vuelven a flujo normal (NO fixed) */
.action-btns,
.response-area {
  position: static !important;
  width: 100% !important;
  height: auto !important;
  background: transparent !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  padding: 0 !important;
  flex-wrap: wrap !important;
}

.action-btn {
  /* Cambio clave: flex-grow a 0 para que no se estiren innecesariamente */
  flex: 0 1 auto;

  /* Un ancho mínimo para que no se vean ridículos, pero sin forzar el máximo */
  min-width: 80px;
  max-width: 150px;

  font-size: clamp(12px, 2.5vw, 15px);
  padding: 10px 12px;
  white-space: nowrap;
  border-radius: 8px; /* Por si quieres que se vean más modernos */

  /* Si el texto no cabe, que ponga puntos suspensivos */
  overflow: hidden;
  text-overflow: ellipsis;
}

/* En móviles muy pequeños, bajamos un poco el min-width */
@media (max-width: 400px) {
  .action-btn {
    min-width: 60px;
    padding: 8px 6px;
    gap: 4px;
  }
}
/* Animación de los puntos suspensivos */
.dots::after {
  content: "";
  animation: dots-anim 1.5s steps(4, end) infinite;
}

@keyframes dots-anim {
  0%,
  20% {
    content: "";
  }
  40% {
    content: ".";
  }
  60% {
    content: "..";
  }
  80%,
  100% {
    content: "...";
  }
}

/* Estilo para el botón de volver */
/* El botón de volver, un poco más separado */
.btn-volver {
  margin-top: 30px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ccc;
  padding: 5px 15px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.2s;
}

.btn-volver:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}
/* Estilo para cuando el botón de inicio está bloqueado */
#startBtn:disabled {
  background-color: #666 !important;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}
/* --- MENÚ RADIAL EN ABANICO --- */
/* --- OPCIONES DEL MENÚ MÁS PEQUEÑAS --- */
.radial-option {
  position: absolute;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 4px 10px; /* Más estrechas */
  border: 1px solid var(--gold);
  border-radius: 12px;
  font-size: 11px !important; /* Letra pequeña */
  white-space: nowrap;
  z-index: 10000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  transition: transform 0.1s ease;
  pointer-events: auto !important;
}

.radial-option:hover {
  background: var(--gold);
  color: black;
  transform: scale(1.1);
}

/* Menú radial: oculto por defecto, visible al activar */
.radial-menu {
  visibility: hidden;
  pointer-events: none;
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 9999;
}
.radial-menu.active {
  visibility: visible;
  pointer-events: auto;
}
/* --- BOCADILLO DE TEXTO (Speech Bubble) --- */
.speech-bubble {
  position: absolute;
  bottom: 60px; /* Encima del avatar */
  left: 20px;
  background: white;
  color: #333;
  padding: 8px 15px;
  border-radius: 15px;
  font-weight: bold;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  min-width: 100px;
  text-align: center;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 20px;
  border-width: 8px 8px 0;
  border-style: solid;
  border-color: white transparent transparent;
}

@keyframes popIn {
  from {
    transform: scale(0) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

/* Estado bloqueado del avatar */
.av-frozen {
  filter: grayscale(0.8);
  opacity: 0.7;
  cursor: not-allowed !important;
}
/* ── CONFIG BUTTON ── */
.config-btn {
  position: fixed;
  right: 12px;
  top: 310px; /* ajusta si el registro ocupa más o menos */
  z-index: 40;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.5;
  transition:
    opacity 0.2s,
    transform 0.3s;
  user-select: none;
  line-height: 1;
}
.config-btn:hover {
  opacity: 1;
  transform: rotate(45deg);
}

/* ── CONFIG PANEL ── */
.config-panel {
  position: fixed;
  right: 12px;
  top: 340px;
  z-index: 200;
  width: 220px;
  background: rgba(8, 18, 12, 0.97);
  border: 1px solid var(--border-hi);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: ovIn 0.2s ease both;
}
.config-panel.hidden {
  display: none !important;
}

.cfg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cfg-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold);
}
.cfg-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition:
    color 0.15s,
    background 0.15s;
}
.cfg-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.cfg-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cfg-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}
.cfg-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cfg-opt {
  font-family: "Outfit", sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}
.cfg-opt:hover {
  border-color: var(--border-hi);
  color: var(--text);
}
.cfg-opt.active {
  background: var(--gold-glow);
  border-color: var(--gold);
  color: var(--gold);
}

/* ── TABLE BACKGROUNDS ── */
/* ── MESA: Fondo 2 (Color Sòlid - Ja funciona) ── */
#table.bg-bg2 {
  background: radial-gradient(
    ellipse at 50% 40%,
    #1a2a4a 0%,
    #0d1525 100%
  ) !important;
}

/* ── MESA: Fondo 3 (Imatge de BAR amb Blur - El que fallava) ── */
#table.bg-bg3 {
  position: relative;
  overflow: hidden;
  background-color: #000 !important; /* Fons negre mentre carrega */
  background-image: none !important; /* ELIMINA EL TAPETE VERDE */
}

#table.bg-bg3::before {
  content: "";
  position: absolute;
  /* El inset -10px i el scale 1.1 són per a evitar vores blanques pel blur */
  inset: -10px;
  background:
    linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.55)),
    url("./Media/Images/Others/fondo-mesa-juego-bar.webp") center/cover
      no-repeat;
  filter: blur(12px) saturate(0.85);
  transform: scale(1.1);
  z-index: 0;
  pointer-events: none;
}

/* Això fa que les cartes i el xat es vegen per sobre de la imatge borrosa */
#table.bg-bg3 > * {
  position: relative;
  z-index: 1;
}
/* ── BUTTON SIZE: large mode ── */
body.btn-large .abtn {
  font-size: 20px !important;
  padding: 16px 26px !important;
  min-width: 130px !important;
}
body.btn-large #actionBtns {
  height: 56px !important;
}
@keyframes ovIn {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
