/* ==================================================================
   COLOR MEMORY — Casino Online 1vs1
   Sistema visual premium (estilo Crown Sequence) adaptado a colores.
   Responsive: desktop-first con adaptación a tablet y móvil.
   ================================================================== */

:root {
  --gold: #ffd76a;
  --gold-deep: #e8a013;
  --gold-soft: #ffe9a8;
  --ink: #07060e;
  --paper: #f3ead8;
  --muted: #b9a98a;
  --dim: #8d8168;
  --c-blue: #3b82f6;
  --c-red: #ef4444;
  --c-yellow: #facc15;
  --c-green: #22c55e;
  --c-purple: #a855f7;
  /* acentos de los 4 estilos de juego */
  --m-pairs: #FFD700;
  --m-sequence: #40C4FF;
  --m-sums: #00E676;
  --m-subtract: #FF9100;
}

* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--ink);
  color: var(--paper);
  font-family: 'Outfit', system-ui, sans-serif;
  overflow: hidden; /* pantalla completa: sin scroll del navegador */
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.font-display, .logo-title, .room-code-big, .result-money, .pot-v, .stat-v, h2 { font-family: 'Cinzel', serif; }

/* ---------- selector de estilo de juego (4 modos) ---------- */
.style-panel { padding: 12px 16px; }
.style-grid { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.style-chip {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px;
  border-radius: 12px; cursor: pointer; text-align: left;
  background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.12);
  color: var(--paper); transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.style-chip:active { transform: scale(0.97); }
.style-ic { font-size: 19px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
.style-tx { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.style-tx b { font-size: 11.5px; font-weight: 800; letter-spacing: 0.09em; }
.style-tx i {
  font-style: normal; font-size: 9px; font-weight: 600; color: var(--dim);
  line-height: 1.3; white-space: normal;
}
.style-chip.on {
  border-color: var(--sc);
  background: linear-gradient(160deg, color-mix(in srgb, var(--sc) 17%, rgba(0,0,0,0.45)), rgba(0,0,0,0.45));
  box-shadow: 0 0 16px color-mix(in srgb, var(--sc) 32%, transparent), inset 0 1px 0 rgba(255,255,255,0.07);
}
.style-chip.on .style-tx b { color: var(--sc); }
.style-chip.on .style-tx i { color: #cbbf9f; }

/* ---------- textos premium ---------- */
.gold-text {
  background: linear-gradient(180deg, #fff6d8 0%, #ffd76a 38%, #c9861a 72%, #ffe9a8 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.shimmer-text {
  background: linear-gradient(100deg, #c9861a 20%, #fff6d8 40%, #ffd76a 50%, #c9861a 65%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: kf-shimmer 3.2s linear infinite;
}

/* ---------- fondo de escenario ---------- */
.stage-bg {
  background:
    linear-gradient(180deg, rgba(7,6,14,0.62) 0%, rgba(7,6,14,0.40) 38%, rgba(7,6,14,0.84) 100%),
    url('/games/number-memory/static/assets/bg-numbers.jpg') center / cover no-repeat fixed,
    #07060e;
}
.vignette::after {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(115% 100% at 50% 45%, rgba(0,0,0,0) 52%, rgba(0,0,0,0.58) 100%);
}

/* polvo dorado ambiental */
.ambient-dust { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.ambient-dust span {
  position: absolute; border-radius: 50%;
  width: 3px; height: 3px; background: #ffd76a; opacity: 0;
  animation: kf-drift linear infinite;
}

/* ---------- canvas FX global ---------- */
.fx-canvas { position: fixed; inset: 0; z-index: 90; pointer-events: none; width: 100%; height: 100%; }

/* ---------- pantallas ---------- */
.screen { display: none; }
.screen.active { display: block; }
.screen-inner {
  position: relative;
  height: 100dvh;
  overflow: hidden;
  display: flex; flex-direction: column;
  padding: clamp(12px, 2vw, 28px) clamp(14px, 3vw, 44px);
}
.screen-inner.center { align-items: center; justify-content: center; text-align: center; }

/* ---------- paneles y botones ---------- */
.panel {
  background: linear-gradient(160deg, rgba(38,32,66,0.72), rgba(14,12,28,0.85));
  border: 1px solid rgba(255,215,106,0.16);
  box-shadow: 0 18px 40px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
  border-radius: 18px;
}
.btn-gold {
  background: linear-gradient(180deg, #ffe9a8 0%, #f6b73c 45%, #c9861a 100%);
  color: #3a2503; border: 0; cursor: pointer; border-radius: 14px;
  font-family: 'Cinzel', serif; font-weight: 900; letter-spacing: 0.06em;
  box-shadow: 0 6px 18px rgba(232,160,19,0.35), inset 0 1px 0 rgba(255,255,255,0.65), inset 0 -2px 0 rgba(120,70,5,0.45);
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
}
.btn-gold:hover { filter: brightness(1.06); box-shadow: 0 8px 26px rgba(232,160,19,0.5), inset 0 1px 0 rgba(255,255,255,0.65), inset 0 -2px 0 rgba(120,70,5,0.45); }
.btn-gold:active { transform: translateY(2px) scale(0.98); }
.btn-block { display: block; width: 100%; padding: 13px 18px; font-size: 15px; }
.btn-ghost {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.14);
  color: #d8ccb2; border-radius: 12px; cursor: pointer;
  transition: background .15s ease, transform .12s ease;
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); }
.btn-ghost:active { transform: scale(0.97); }
.btn-icon { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }

.txt-input {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.15); background: rgba(0,0,0,0.4);
  color: var(--gold-soft); font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 15px;
  outline: none; text-align: center;
}
.txt-input:focus { border-color: rgba(255,215,106,0.6); }
.txt-input::placeholder { color: #5c543f; }

.lbl { display: block; font-size: 11px; font-weight: 800; letter-spacing: 0.18em; color: var(--muted); margin-bottom: 8px; }

/* ---------- orbes / dígitos del logo ---------- */
.logo-orbs { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; }
.orb { width: 20px; height: 20px; border-radius: 50%; display: inline-block; }
/* dígitos LED dorados (temática de números) */
.d-orb {
  width: 30px; height: 30px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-weight: 900; font-size: 17px;
  color: #ffe9a8; text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  background: linear-gradient(165deg, #2a3149 0%, #161b2e 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.14),
    inset 0 -3px 6px rgba(0,0,0,0.5),
    0 0 14px rgba(255,215,106,0.35),
    0 0 0 1.5px rgba(255,215,106,0.45);
}
.result-orbs .d-orb { width: 34px; height: 34px; font-size: 19px; }
.o-blue   { background: radial-gradient(circle at 32% 28%, #bcd7ff, var(--c-blue) 60%, #17265e); box-shadow: 0 0 16px rgba(59,130,246,0.75); }
.o-red    { background: radial-gradient(circle at 32% 28%, #ffc4c4, var(--c-red) 60%, #6e1414); box-shadow: 0 0 16px rgba(239,68,68,0.75); }
.o-yellow { background: radial-gradient(circle at 32% 28%, #fff3b0, var(--c-yellow) 60%, #7a5b06); box-shadow: 0 0 16px rgba(250,204,21,0.75); }
.o-green  { background: radial-gradient(circle at 32% 28%, #b6f5cd, var(--c-green) 60%, #0b5a2b); box-shadow: 0 0 16px rgba(34,197,94,0.75); }
.o-purple { background: radial-gradient(circle at 32% 28%, #e6c8ff, var(--c-purple) 60%, #4c1d95); box-shadow: 0 0 16px rgba(168,85,247,0.75); }
.anim-orbs .orb, .anim-orbs .d-orb { animation: kf-orb-bob 3.4s ease-in-out infinite; }
.anim-orbs .orb:nth-child(2), .anim-orbs .d-orb:nth-child(2) { animation-delay: .25s; }
.anim-orbs .orb:nth-child(3), .anim-orbs .d-orb:nth-child(3) { animation-delay: .5s; }
.anim-orbs .orb:nth-child(4), .anim-orbs .d-orb:nth-child(4) { animation-delay: .75s; }
.anim-orbs .orb:nth-child(5), .anim-orbs .d-orb:nth-child(5) { animation-delay: 1s; }
@keyframes kf-orb-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

.logo-title {
  margin: 0; text-align: center; font-weight: 900;
  font-size: clamp(40px, 6.5vw, 74px); line-height: 0.98; letter-spacing: 0.04em;
}
.logo-tag {
  margin: 10px 0 0; text-align: center;
  font-size: clamp(10px, 1.2vw, 13px); font-weight: 700; letter-spacing: 0.22em; color: var(--muted);
}

/* ==================================================================
   LOGIN
   ================================================================== */
#screen-login .screen-inner { align-items: center; justify-content: center; }
.login-wrap { position: relative; z-index: 2; width: min(420px, 92vw); display: flex; flex-direction: column; gap: 22px; }
.login-panel { padding: 22px; }
.login-panel .txt-input { margin-bottom: 14px; }
.login-note { margin: 12px 0 0; text-align: center; font-size: 11px; color: var(--dim); line-height: 1.5; }
.login-note b { color: var(--gold-soft); }

/* ==================================================================
   LOBBY
   ================================================================== */
.lobby-topbar {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.badge-pvp {
  border-radius: 999px; background: rgba(0,0,0,0.4); padding: 6px 12px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.2em; color: var(--muted);
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.balance-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 8px 14px;
  background: linear-gradient(180deg, rgba(80,58,14,0.5), rgba(30,22,8,0.65));
  border: 1px solid rgba(255,215,106,0.35);
  color: var(--gold-soft); font-size: 14px; font-weight: 800;
}
.balance-chip i { color: var(--gold); }

.lobby-body {
  position: relative; z-index: 2; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  gap: clamp(24px, 5vw, 72px);
  padding: 18px 0;
  /* seguridad en pantallas muy bajas: scroll interno sin barra visible */
  overflow-y: auto; scrollbar-width: none;
}
.lobby-body::-webkit-scrollbar { display: none; }
.lobby-hero { display: flex; flex-direction: column; align-items: center; }
.lobby-hero .orb { width: 26px; height: 26px; }
.lobby-hero .d-orb { width: 34px; height: 34px; font-size: 19px; border-radius: 10px; }

.lobby-side { width: min(430px, 94vw); display: flex; flex-direction: column; gap: 14px; }

.bet-panel { padding: 14px 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-lbl { font-size: 10px; font-weight: 800; letter-spacing: 0.18em; color: var(--muted); }
.panel-sub { font-size: 10px; font-weight: 600; color: var(--dim); }

.bet-grid { margin-top: 10px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.chip-bet {
  border-radius: 10px; border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05); color: #e8dcc0;
  padding: 10px 0; font-size: 13px; font-weight: 800; cursor: pointer;
  transition: all .15s ease; font-family: 'Outfit', sans-serif;
}
.chip-bet:hover { border-color: rgba(255,215,106,0.5); }
.chip-bet.on {
  background: linear-gradient(180deg, #ffe9a8, #e8a013);
  color: #3a2503; border-color: #ffe9a8;
  box-shadow: 0 4px 14px rgba(232,160,19,0.45);
  transform: scale(1.06);
}

/* apuesta manual (otro valor) */
.custom-bet-row { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.custom-bet-lbl { font-size: 9px; font-weight: 800; letter-spacing: 0.16em; color: var(--muted); white-space: nowrap; }
.custom-bet-box {
  flex: 1; display: flex; align-items: center; gap: 6px;
  border: 1px solid rgba(255,255,255,0.15); background: rgba(0,0,0,0.4);
  border-radius: 12px; padding: 0 12px;
  transition: border-color .15s ease;
}
.custom-bet-box:focus-within { border-color: rgba(255,215,106,0.6); }
.custom-bet-sign { color: var(--gold); font-weight: 900; font-size: 14px; }
#input-custom-bet {
  flex: 1; min-width: 0; padding: 10px 0;
  background: none; border: 0; outline: none;
  color: var(--gold-soft); font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 15px;
}
#input-custom-bet::placeholder { color: #5c543f; font-weight: 600; }
#input-custom-bet::-webkit-outer-spin-button, #input-custom-bet::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#input-custom-bet[type=number] { -moz-appearance: textfield; appearance: textfield; }

.pot-grid { margin-top: 10px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; border-radius: 12px; background: rgba(0,0,0,0.3); padding: 10px 6px; }
.pot-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pot-ic { height: 22px; display: flex; align-items: center; color: var(--gold); font-size: 15px; }
.pot-pct { font-weight: 900; color: var(--dim); }
.pot-l { font-size: 8px; font-weight: 700; letter-spacing: 0.1em; color: var(--dim); text-align: center; }
.pot-v { font-size: 14px; font-weight: 700; color: var(--gold-soft); }

.modes { display: flex; flex-direction: column; gap: 10px; }
.mode-btn {
  display: flex; align-items: center; gap: 14px; padding: 15px 16px;
  cursor: pointer; text-align: left; color: var(--paper);
  transition: transform .15s ease, border-color .2s ease, box-shadow .25s ease;
}
.mode-btn:hover { transform: translateY(-2px); border-color: rgba(255,215,106,0.55); box-shadow: 0 10px 30px rgba(232,160,19,0.18); }
.mode-btn:active { transform: translateY(0) scale(0.98); }
.mode-ic {
  width: 46px; height: 46px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; background: rgba(255,215,106,0.1);
  font-size: 20px; color: var(--gold);
}
.mode-tx { flex: 1; display: flex; flex-direction: column; }
.mode-t1 { font-family: 'Cinzel', serif; font-size: 15px; font-weight: 900; letter-spacing: 0.04em; color: var(--gold-soft); }
.mode-t2 { font-size: 11px; color: var(--muted); margin-top: 2px; }
.mode-arrow { color: var(--gold); }

.join-panel { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.join-row { display: flex; gap: 8px; }
.code-input {
  flex: 1; min-width: 0;
  font-family: 'Cinzel', serif; font-size: 17px; font-weight: 900; letter-spacing: 0.3em;
  text-transform: uppercase;
}
.btn-join { padding: 0 18px; font-weight: 800; font-size: 13px; color: var(--gold-soft); white-space: nowrap; }

.lobby-foot {
  position: relative; z-index: 2; margin: 0; padding-top: 10px;
  text-align: center; font-size: 10px; letter-spacing: 0.12em; color: #5c543f;
}

/* ==================================================================
   SALA DE ESPERA
   ================================================================== */
.wait-lbl { font-size: 11px; font-weight: 800; letter-spacing: 0.22em; color: var(--muted); margin: 0 0 12px; }
.code-card { padding: 20px 34px; }
.room-code-big {
  font-size: clamp(34px, 5vw, 46px); font-weight: 900; letter-spacing: 0.28em; color: var(--gold-soft);
  text-shadow: 0 0 24px rgba(255,190,60,0.4);
}
.wait-copy { max-width: 320px; margin-top: 18px; }
.wait-copy + .wait-copy { margin-top: 10px; }
.wait-link { margin: 12px 0 0; max-width: 420px; font-size: 11px; color: var(--dim); word-break: break-all; }
.wait-status { margin-top: 22px; display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: #e8dcc0; }
.wait-status b { color: var(--gold-soft); }
.spin-slow {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,215,106,0.3); border-top-color: var(--gold);
  animation: kf-spin 1.2s linear infinite; display: inline-block;
}
.wait-cancel { margin-top: 26px; padding: 11px 22px; font-size: 13px; font-weight: 700; }

/* ==================================================================
   JUEGO
   ================================================================== */
/* Pantalla completa: el juego usa TODO el ancho de la ventana (no una columna angosta) */
#screen-game .screen-inner { gap: 12px; width: 100%; max-width: none; margin: 0; }

.game-topbar { position: relative; z-index: 5; display: flex; align-items: center; gap: 12px; }
.stats-bar { flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px 12px; }
.stat-cell { display: flex; align-items: center; justify-content: center; gap: 8px; }
.stat-ic { color: var(--gold); font-size: 16px; }
.stat-cell > div { display: flex; flex-direction: column; }
.stat-l { font-size: 8px; font-weight: 700; letter-spacing: 0.14em; color: var(--muted); }
.stat-v { font-size: 16px; font-weight: 700; line-height: 1.1; }

.players-row { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; }
.player-panel {
  flex: 1; display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  transition: all .3s ease; border-radius: 16px;
}
.player-panel.active-turn { animation: kf-turn-glow 1.4s ease-in-out infinite; border-color: var(--gold); }
.player-panel.eliminated { opacity: 0.45; filter: grayscale(0.7); }
.avatar {
  width: 46px; height: 46px; flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 19px; color: #fff;
  background: radial-gradient(circle at 35% 30%, #2a2f4e, #0a0c18);
}
.av-blue { box-shadow: inset 0 0 0 2.5px #3fa9f5, 0 0 14px rgba(63,169,245,0.5); }
.av-pink { box-shadow: inset 0 0 0 2.5px #ff4d5e, 0 0 14px rgba(255,77,94,0.5); }
.av-bot  { box-shadow: inset 0 0 0 2.5px #a855f7, 0 0 14px rgba(168,85,247,0.55); }
.pp-info { min-width: 0; flex: 1; }
.pp-info.right { text-align: right; }
.pp-name-row { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.pp-info.right .pp-name-row { justify-content: flex-end; }
.pp-tag {
  border-radius: 999px; padding: 2px 7px;
  font-size: 8px; font-weight: 800; letter-spacing: 0.12em;
  background: var(--gold); color: #3a2503;
}
.pp-dots { margin-top: 5px; display: flex; gap: 3px; flex-wrap: wrap; }
.pp-info.right .pp-dots { justify-content: flex-end; }
.pp-dots i {
  width: 9px; height: 9px; border-radius: 50%; display: inline-block;
  background: rgba(255,255,255,0.06); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
}
.pp-dots i.on { background: var(--gold); box-shadow: 0 0 6px rgba(255,215,106,0.7); }
.vs-badge {
  font-family: 'Cinzel', serif; font-weight: 900; font-size: 18px;
  background: linear-gradient(180deg, #fff 0%, #ffd76a 50%, #c9861a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 10px rgba(255,190,60,0.4));
}

.round-row { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; border-radius: 16px; }
.round-info { display: flex; align-items: baseline; gap: 14px; }
.round-lbl { font-family: 'Cinzel', serif; font-weight: 900; font-size: 17px; color: var(--gold-soft); letter-spacing: 0.08em; }
.seq-lbl { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; color: var(--muted); }
.turn-ring { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.turn-ring svg { transform: rotate(-90deg); display: block; }
.turn-ring.danger { animation: kf-timer-danger .5s ease-in-out infinite; }
.turn-ring-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; font-size: 20px; font-weight: 900; color: #bfe2ff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.7);
}
.turn-ring.danger .turn-ring-num { color: #ff4d5e; }

/* ---------- Máquina estilo dispositivo físico ---------- */
.machine {
  position: relative; z-index: 2;
  width: min(560px, 100%);
  margin: 4px auto 0;
  padding: 26px 30px 22px;
  border-radius: 34px;
  background: linear-gradient(165deg, #262e47 0%, #1a2033 45%, #10152a 100%);
  box-shadow:
    0 24px 50px rgba(0,0,0,0.6),
    inset 0 2px 0 rgba(255,255,255,0.10),
    inset 0 -3px 0 rgba(0,0,0,0.5),
    inset 0 0 0 1.5px rgba(255,215,106,0.14);
}
.machine::after {
  content: ''; position: absolute; inset: 0; border-radius: 34px; pointer-events: none;
  background: linear-gradient(115deg, rgba(255,255,255,0.09) 0%, rgba(255,255,255,0.02) 28%, transparent 45%);
}
.machine-screws i {
  position: absolute; width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #8a93b5, #3a4160 65%, #181d33);
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.4), inset 0 -1px 2px rgba(0,0,0,0.7);
}
.machine-screws i::after {
  content: ''; position: absolute; left: 1.5px; right: 1.5px; top: 50%; height: 1.6px;
  background: rgba(0,0,0,0.55); transform: translateY(-50%) rotate(38deg);
}
.machine-screws i:nth-child(1) { top: 10px; left: 10px; }
.machine-screws i:nth-child(2) { top: 10px; right: 10px; }
.machine-screws i:nth-child(3) { bottom: 10px; left: 10px; }
.machine-screws i:nth-child(4) { bottom: 10px; right: 10px; }

.machine-top { display: flex; justify-content: center; gap: 16px; margin-bottom: 12px; }
.machine-btn {
  width: 34px; height: 12px; border-radius: 999px;
  background: linear-gradient(180deg, #3d4568, #232942);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18), inset 0 -2px 3px rgba(0,0,0,0.55), 0 2px 4px rgba(0,0,0,0.4);
}

.machine-banner {
  margin: 0 auto 14px; width: fit-content; max-width: 100%;
  padding: 8px 20px; border-radius: 999px;
  font-family: 'Cinzel', serif; font-weight: 900; font-size: clamp(11px, 1.4vw, 14px); letter-spacing: 0.1em;
  text-align: center; color: var(--gold-soft);
  background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(10,8,20,0.75));
  box-shadow: inset 0 0 0 1.5px rgba(255,215,106,0.35), 0 0 18px rgba(255,190,60,0.18);
}
.machine-banner.your-turn {
  color: #7dffa8;
  box-shadow: inset 0 0 0 1.5px rgba(125,255,168,0.6), 0 0 22px rgba(125,255,168,0.3);
  animation: kf-glow-green 1.2s ease-in-out infinite;
}
.machine-banner.wait-turn { color: #ff8ba0; box-shadow: inset 0 0 0 1.5px rgba(255,93,126,0.45), 0 0 18px rgba(255,93,126,0.2); }

/* banner de la regla del estilo activo (fijo: el hueco siempre existe) */
.rule-banner {
  margin: -6px auto 10px; width: fit-content; max-width: 100%; min-height: 24px;
  display: flex; align-items: center;
  padding: 4px 16px; border-radius: 999px;
  font-size: clamp(10px, 1.15vw, 12.5px); font-weight: 800; letter-spacing: 0.14em;
  color: var(--gold); background: rgba(0,0,0,0.4);
  box-shadow: inset 0 0 0 1px rgba(255,215,106,0.22);
}
.rule-banner.m-sums { color: #8affc0; box-shadow: inset 0 0 0 1px rgba(0,230,118,0.4); }
.rule-banner.m-subtract { color: #ffc389; box-shadow: inset 0 0 0 1px rgba(255,145,0,0.4); }
.rule-banner.m-sequence { color: #8fdcff; box-shadow: inset 0 0 0 1px rgba(64,196,255,0.4); }

.machine-display {
  display: flex; justify-content: center; align-items: center;
  padding: 10px 16px 14px; border-radius: 22px;
  background: linear-gradient(180deg, #05070f 0%, #0a0e1d 100%);
  box-shadow: inset 0 4px 14px rgba(0,0,0,0.85), inset 0 0 0 1.5px rgba(255,255,255,0.05), 0 1px 0 rgba(255,255,255,0.06);
}
/* dígito LED gigante de la máquina */
.led-digit {
  font-family: 'Cinzel', serif; font-weight: 900;
  font-size: clamp(56px, 9.5vw, 96px); line-height: 1.05;
  color: rgba(255,235,180,0.07);
  text-shadow: 0 0 10px rgba(255,215,106,0.05);
  transition: color .06s ease, text-shadow .06s ease, transform .08s ease;
}
.led-digit.on {
  color: #ffe9a8; transform: scale(1.05);
  text-shadow:
    0 0 12px rgba(255,215,106,0.9),
    0 0 34px rgba(255,190,60,0.65),
    0 0 74px rgba(232,160,19,0.4);
}

.machine-step {
  min-height: 20px; margin-top: 10px;
  text-align: center; font-size: 11px; font-weight: 700; letter-spacing: 0.2em; color: var(--muted);
}
.machine-grill { display: flex; justify-content: center; gap: 7px; margin-top: 4px; }
.machine-grill i {
  width: 26px; height: 4px; border-radius: 999px;
  background: rgba(0,0,0,0.5); box-shadow: inset 0 1px 2px rgba(0,0,0,0.8), 0 1px 0 rgba(255,255,255,0.05);
}

/* ---------- Tablero pop-it del jugador ---------- */
.board-zone { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 12px; padding-bottom: 8px; }
.turn-badge {
  padding: 6px 18px; border-radius: 999px;
  font-family: 'Cinzel', serif; font-size: 13px; font-weight: 900; letter-spacing: 0.14em;
  background: rgba(0,0,0,0.45); color: var(--muted);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}
.turn-badge.on {
  color: #06283f; background: linear-gradient(180deg, #bfe2ff, #3fa9f5);
  box-shadow: 0 0 22px rgba(63,169,245,0.55);
  animation: kf-turn-pulse 1.2s ease-in-out infinite;
}
.turn-badge.other { color: var(--muted); }

/* ---------- Tablero de cartas de memoria (ancho completo) ---------- */
.card-board {
  display: grid; justify-content: center; align-content: center;
  gap: clamp(6px, 0.9vw, 14px);
  padding: clamp(10px, 1.6vw, 22px); border-radius: 26px;
  background: linear-gradient(165deg, #232942 0%, #171c30 50%, #0f1426 100%);
  box-shadow:
    0 18px 40px rgba(0,0,0,0.55),
    inset 0 2px 0 rgba(255,255,255,0.08),
    inset 0 0 0 1.5px rgba(255,215,106,0.12);
}
/* columnas = ceil(n/4 filas): 10→3 · 15/20→5 · 30→8 · 40→10 columnas */
.card-board[data-total="10"] { grid-template-columns: repeat(3, auto); }
.card-board[data-total="15"] { grid-template-columns: repeat(5, auto); }
.card-board[data-total="20"] { grid-template-columns: repeat(5, auto); }
.card-board[data-total="30"] { grid-template-columns: repeat(8, auto); }
.card-board[data-total="40"] { grid-template-columns: repeat(10, auto); }
.card {
  position: relative; border: 0; padding: 0; cursor: pointer;
  width: clamp(52px, 7.2vw, 108px); height: clamp(70px, 9.6vw, 142px);
  border-radius: 12px; background: transparent;
  perspective: 600px;
  transition: transform .1s ease, filter .15s ease;
}
/* tableros grandes: cartas más compactas para que quepan a lo ancho */
.card-board[data-total="30"] .card { width: clamp(40px, 5.2vw, 72px); height: clamp(54px, 7vw, 96px); }
.card-board[data-total="40"] .card { width: clamp(34px, 4.4vw, 62px); height: clamp(46px, 5.9vw, 82px); border-radius: 9px; }
.card-board[data-total="30"] .card-face, .card-board[data-total="40"] .card-face { border-radius: 9px; }
.card-board[data-total="30"] .card-back .q, .card-board[data-total="30"] .card-front .num { font-size: clamp(16px, 2vw, 26px); }
.card-board[data-total="40"] .card-back .q, .card-board[data-total="40"] .card-front .num { font-size: clamp(13px, 1.7vw, 22px); }

.target-banner {
  padding: 7px 20px; border-radius: 999px;
  font-family: 'Cinzel', serif; font-size: 15px; font-weight: 900; letter-spacing: 0.1em;
  background: rgba(0,0,0,0.5); color: #ffe9a8;
  box-shadow: inset 0 0 0 1.5px rgba(255,215,106,0.45), 0 0 18px rgba(255,215,106,0.18);
}
.target-banner.t-seq { color: #8fdcff; box-shadow: inset 0 0 0 1.5px rgba(64,196,255,0.45), 0 0 18px rgba(64,196,255,0.18); }
.target-banner.t-sums { color: #8affc0; box-shadow: inset 0 0 0 1.5px rgba(0,230,118,0.45), 0 0 18px rgba(0,230,118,0.18); }
.target-banner.t-sub { color: #ffc389; box-shadow: inset 0 0 0 1.5px rgba(255,145,0,0.45), 0 0 18px rgba(255,145,0,0.18); }

.card:disabled { cursor: not-allowed; }
.card:not(:disabled):hover { transform: translateY(-4px); filter: brightness(1.12); }
.card-inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform .35s cubic-bezier(.4,1.6,.6,1);
}
.card.up .card-inner, .card.matched .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
/* dorso boca abajo: '?' dorado */
.card-back {
  background: linear-gradient(155deg, #2b3352 0%, #1a2038 55%, #12172c 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.12), inset 0 -3px 6px rgba(0,0,0,0.4),
    inset 0 0 0 1.5px rgba(255,215,106,0.28), 0 6px 14px rgba(0,0,0,0.45);
}
.card-back::before {
  content: ''; position: absolute; inset: 5px; border-radius: 8px;
  border: 1px dashed rgba(255,215,106,0.25);
}
.card-back .q {
  font-family: 'Cinzel', serif; font-weight: 900; font-size: clamp(22px, 2.6vw, 32px);
  color: var(--gold); text-shadow: 0 0 12px rgba(255,215,106,0.5), 0 2px 4px rgba(0,0,0,0.6);
}
/* cara revelada: número */
.card-front {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, #fff7dd 0%, #ffe9a8 60%, #f5cf6a 100%);
  box-shadow: inset 0 0 0 1.5px rgba(122,80,10,0.35), 0 6px 14px rgba(0,0,0,0.4);
}
.card-front .num {
  font-family: 'Cinzel', serif; font-weight: 900; font-size: clamp(22px, 2.8vw, 34px);
  color: #4a2f06; text-shadow: 0 1px 2px rgba(255,255,255,0.6);
}
/* selección pendiente (primera de la pareja) */
.card.sel .card-front {
  box-shadow: inset 0 0 0 2.5px #3fa9f5, 0 0 20px rgba(63,169,245,0.65);
}
/* carta que destapa LA MÁQUINA en SUMAS/RESTAS: marco cian brillante */
.card.shown .card-front {
  box-shadow: inset 0 0 0 2.5px #40c4ff, 0 0 24px rgba(64,196,255,0.75);
  animation: kf-shown-pulse 1.4s ease-in-out infinite;
}
@keyframes kf-shown-pulse {
  50% { box-shadow: inset 0 0 0 2.5px #40c4ff, 0 0 10px rgba(64,196,255,0.4); }
}
/* fallo: parpadeo rojizo antes de ocultarse */
.card.miss .card-front {
  background: linear-gradient(160deg, #ffd9de 0%, #ff9fae 60%, #e86a7e 100%);
  animation: kf-card-miss .3s ease 2;
}
@keyframes kf-card-miss { 50% { transform: scale(0.92); filter: brightness(1.25); } }
/* acierto: destello breve */
.card.hit .card-front { animation: kf-card-hit .45s ease; }
@keyframes kf-card-hit {
  0% { filter: brightness(1.9); box-shadow: 0 0 30px 8px rgba(255,215,106,0.85); }
  100% { filter: brightness(1); }
}
/* emparejadas: tinte por dueño (p1 oro / p2 violeta), siguen visibles */
.card.matched { cursor: default; }
.card.matched.own1 .card-front {
  background: linear-gradient(160deg, #fff3c4 0%, #ffd76a 55%, #d9a520 100%);
  box-shadow: inset 0 0 0 2px rgba(122,80,10,0.5), 0 0 16px rgba(255,215,106,0.45);
}
.card.matched.own2 .card-front {
  background: linear-gradient(160deg, #e6d5ff 0%, #b285ff 55%, #7b3ff2 100%);
  box-shadow: inset 0 0 0 2px rgba(58,20,120,0.5), 0 0 16px rgba(139,92,246,0.5);
}
.card.matched.own2 .card-front .num { color: #2a1160; }

/* marcador de puntaje */
.score-row {
  display: flex; align-items: center; gap: 14px;
  font-family: 'Cinzel', serif; font-weight: 900; font-size: 15px; letter-spacing: 0.08em;
}
.score-cell { padding: 5px 16px; border-radius: 999px; background: rgba(0,0,0,0.45); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1); }
.score-cell.you { color: var(--gold); }
.score-cell.you b { color: #fff3c4; }
.score-cell.foe { color: #b285ff; }
.score-cell.foe b { color: #e6d5ff; }
.score-mid { color: var(--dim); }

/* celda del valor por acierto en el lobby */
.pot-cell.pot-hit {
  box-shadow: inset 0 0 0 1px rgba(255,215,106,0.4), 0 0 14px rgba(255,215,106,0.15);
}
.pot-cell.pot-hit .pot-v { color: var(--gold); text-shadow: 0 0 10px rgba(255,215,106,0.45); }

/* ---------- Chat interno: drawer plegable (no ocupa ancho del juego) ---------- */
.chat-panel {
  position: fixed; right: 18px; top: 96px; bottom: 18px; z-index: 60;
  width: 300px; display: flex; flex-direction: column; padding: 12px;
  transform: translateX(calc(100% + 26px));
  transition: transform .3s ease;
  box-shadow: 0 18px 44px rgba(0,0,0,0.6);
}
.chat-panel.open { transform: translateX(0); }
.chat-empty {
  margin: auto; text-align: center; font-size: 11px; color: var(--dim);
  line-height: 1.6; padding: 12px;
}
.chat-head {
  display: flex; align-items: center; gap: 8px; padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-family: 'Cinzel', serif; font-size: 12px; font-weight: 900;
  letter-spacing: 0.14em; color: var(--gold-soft);
}
.chat-hint {
  margin-left: auto; font-family: 'Outfit', sans-serif;
  font-size: 8px; font-weight: 600; letter-spacing: 0.08em;
  color: var(--dim); text-transform: uppercase;
}
.chat-msgs {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px; padding: 10px 2px;
  scrollbar-width: thin; scrollbar-color: rgba(255,215,106,0.3) transparent;
}
.chat-msg {
  max-width: 86%; padding: 7px 10px; border-radius: 12px;
  font-size: 12.5px; line-height: 1.35; word-break: break-word;
  animation: kf-fade-up .25s ease both;
}
.chat-msg .chat-name {
  display: block; font-size: 8.5px; font-weight: 800;
  letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.7; margin-bottom: 2px;
}
.chat-msg.mine {
  align-self: flex-end; border-bottom-right-radius: 4px;
  background: linear-gradient(180deg, rgba(255,215,106,0.24), rgba(232,160,19,0.15));
  border: 1px solid rgba(255,215,106,0.4); color: var(--gold-soft);
}
.chat-msg.theirs {
  align-self: flex-start; border-bottom-left-radius: 4px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: #e8dcc0;
}
.chat-emoji-row { display: flex; gap: 4px; padding: 6px 0; }
.chat-emoji-row button {
  flex: 1; padding: 5px 0; border-radius: 8px; font-size: 15px; cursor: pointer;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  transition: transform .1s ease, background .15s ease;
}
.chat-emoji-row button:hover { background: rgba(255,215,106,0.14); transform: scale(1.12); }
.chat-input-row { display: flex; gap: 6px; }
.chat-input-row .txt-input { text-align: left; padding: 10px 12px; font-size: 13px; }
.chat-send {
  width: 42px; flex-shrink: 0; border-radius: 12px; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ==================================================================
   OVERLAY RESULTADO
   ================================================================== */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.62); backdrop-filter: blur(6px); padding: 18px;
}
.overlay.show { display: flex; }
.result-card { width: min(400px, 94vw); padding: 26px 24px; text-align: center; border-color: rgba(255,215,106,0.4); }
.result-orbs { display: flex; justify-content: center; gap: 8px; margin-bottom: 8px; }
.result-card h2 { margin: 4px 0 2px; font-size: 32px; font-weight: 900; letter-spacing: 0.05em; }
.result-card.lose h2 { color: #b9a98a; background: none; -webkit-background-clip: initial; }
.result-card p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.result-money { margin: 14px 0 4px; font-size: 38px; font-weight: 900; }
.result-money.neg { background: none; -webkit-background-clip: initial; color: #ff5d7e; }
.result-detail { margin: 10px 0 18px; font-size: 11px; color: var(--dim); line-height: 1.7; }
.result-detail b { color: var(--gold-soft); }

/* ---------- Modal CÓMO JUGAR ---------- */
.help-card {
  position: relative; width: min(620px, 94vw); max-height: 88dvh;
  display: flex; flex-direction: column;
  padding: 24px 26px 18px; text-align: left;
  border-color: rgba(255,215,106,0.4);
}
.help-card h2 {
  margin: 0; text-align: center;
  font-family: 'Cinzel', serif; font-size: clamp(22px, 4vw, 32px);
  font-weight: 900; letter-spacing: 0.06em;
}
.help-tag {
  text-align: center; margin: 4px 0 14px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.18em;
  color: var(--muted); text-transform: uppercase;
}
.help-x {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5); border: 1px solid rgba(255,215,106,0.35);
  color: var(--gold-soft); font-size: 16px;
  transition: transform .12s ease, background .15s ease;
}
.help-x:hover { transform: scale(1.1); background: rgba(255,215,106,0.18); }
.help-body {
  flex: 1; min-height: 0; overflow-y: auto; padding-right: 6px;
  display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px;
  scrollbar-width: thin; scrollbar-color: rgba(255,215,106,0.3) transparent;
}
.help-sec h4 {
  margin: 0 0 6px; font-family: 'Cinzel', serif; font-size: 13px;
  font-weight: 900; letter-spacing: 0.12em; color: var(--gold);
  display: flex; align-items: center; gap: 8px;
}
.help-sec h4 i { font-size: 13px; }
.help-sec p, .help-sec li {
  font-size: 12.5px; line-height: 1.6; color: #d9cdb4; margin: 0;
}
.help-sec ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; }
.help-sec b { color: var(--gold-soft); }
.help-sec code {
  background: rgba(0,0,0,0.45); padding: 1px 7px; border-radius: 6px;
  font-size: 11px; color: var(--gold-soft); border: 1px solid rgba(255,215,106,0.2);
}
.h-gold { color: var(--gold) !important; }
.h-blue { color: #8fdcff !important; }
.h-green { color: #8affc0 !important; }
.h-orange { color: #ffc389 !important; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 100;
  transform: translateX(-50%) translateY(18px);
  padding: 12px 22px; border-radius: 999px;
  background: rgba(14,12,28,0.92); border: 1px solid rgba(255,215,106,0.35);
  color: var(--gold-soft); font-size: 13px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: all .25s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(255,93,126,0.6); color: #ffb3c1; }
.toast.success { border-color: rgba(125,255,168,0.5); color: #b6f5cd; }

/* ==================================================================
   KEYFRAMES
   ================================================================== */
@keyframes kf-shimmer { 0% { background-position: 120% 0; } 100% { background-position: -120% 0; } }
@keyframes kf-drift {
  0% { transform: translateY(0); opacity: 0; }
  12% { opacity: 0.7; }
  88% { opacity: 0.5; }
  100% { transform: translateY(-110vh); opacity: 0; }
}
@keyframes kf-spin { to { transform: rotate(360deg); } }
@keyframes kf-zoom-in { 0% { opacity: 0; transform: scale(0.82); } 100% { opacity: 1; transform: scale(1); } }
.anim-zoom { animation: kf-zoom-in .4s cubic-bezier(.3,1.3,.5,1) both; }
@keyframes kf-fade-up { 0% { opacity: 0; transform: translateY(16px); } 100% { opacity: 1; transform: translateY(0); } }
.anim-fade-up { animation: kf-fade-up .45s ease both; }
@keyframes kf-turn-glow {
  0%,100% { box-shadow: 0 0 0 1.5px rgba(255,215,106,0.55), 0 0 16px rgba(255,190,60,0.3); }
  50% { box-shadow: 0 0 0 2px rgba(255,215,106,0.95), 0 0 30px rgba(255,190,60,0.55); }
}
@keyframes kf-turn-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes kf-timer-danger { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes kf-pad-flash { 0% { transform: scale(1); } 40% { transform: scale(1.09); } 100% { transform: scale(1); } }
@keyframes kf-glow-green {
  0%,100% { box-shadow: inset 0 0 0 1.5px rgba(125,255,168,0.6), 0 0 16px rgba(125,255,168,0.22); }
  50% { box-shadow: inset 0 0 0 1.5px rgba(125,255,168,0.9), 0 0 30px rgba(125,255,168,0.45); }
}

/* ==================================================================
   RESPONSIVE
   ================================================================== */

/* Tablet y pantallas medianas */
@media (max-width: 900px) {
  .lobby-body { flex-direction: column; gap: 20px; justify-content: flex-start; padding-top: 26px; }
  .lobby-hero .logo-title { font-size: clamp(34px, 8vw, 52px); }
  .lobby-hero .orb { width: 18px; height: 18px; }
  .lobby-hero .d-orb { width: 26px; height: 26px; font-size: 14px; border-radius: 7px; }
  .lobby-side { width: min(480px, 100%); }
  .screen-inner.center { padding: 16px; }
}

/* Móvil */
@media (max-width: 560px) {
  .screen-inner { padding: 12px 12px 16px; }
  .bet-grid { grid-template-columns: repeat(4, 1fr); }
  .game-topbar { flex-wrap: wrap; }
  .stats-bar { order: 3; flex-basis: 100%; }
  .players-row { gap: 6px; }
  .player-panel { padding: 8px 10px; gap: 8px; }
  .avatar { width: 38px; height: 38px; font-size: 15px; }
  .vs-badge { font-size: 14px; }
  .machine { padding: 22px 16px 16px; border-radius: 26px; }
  .led-digit { font-size: clamp(46px, 13vw, 66px); }
  .popit { padding: 12px 14px; border-radius: 26px; gap: 9px 10px; }
  .pad { width: clamp(44px, 13.5vw, 58px); height: clamp(44px, 13.5vw, 58px); }
  .pad-num { font-size: clamp(18px, 5.6vw, 24px); }
  .style-tx i { display: none; }
  .style-chip { padding: 8px 9px; gap: 7px; }
  .style-ic { font-size: 16px; }
  .round-row { padding: 6px 12px; }
  .round-lbl { font-size: 14px; }
  .turn-ring { width: 52px; height: 52px; }
  .turn-ring svg { width: 52px; height: 52px; }
  .result-card h2 { font-size: 26px; }
}

/* Pantallas muy anchas: limitar ancho de contenido de juego */
@media (min-width: 1400px) {
  #screen-game .screen-inner { max-width: 1200px; }
}

/* Altura baja (landscape móvil): compactar */
@media (max-height: 640px) {
  .machine { padding: 16px 20px 12px; }
  .machine-display { padding: 6px 12px 10px; }
  .led-digit { font-size: clamp(38px, 8vh, 52px); }
  .rule-banner { margin: -4px auto 6px; }
  .popit { padding: 10px 16px; gap: 8px 14px; }
  .board-zone { gap: 8px; }
}

/* Chat en tablet/móvil: drawer deslizante a todo alto (se abre con el botón) */
@media (max-width: 1024px) {
  .chat-panel {
    top: 0; right: 0; bottom: 0; left: auto; width: min(320px, 86vw);
    max-height: none; overflow: visible;
    transform: translateX(calc(100% + 26px)); transition: transform .3s ease;
    border-radius: 0;
  }
  .chat-panel.open { transform: translateX(0); max-height: none; }
  .chat-head::after { content: '×'; color: var(--dim); font-size: 15px; margin-left: 4px; }
  #screen-game .screen-inner { padding-bottom: 12px; }
}

/* ---------- Fase SETUP: overlay de elección de tamaño ---------- */
.setup-overlay {
  position: fixed; inset: 0; z-index: 55;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,3,12,0.72); backdrop-filter: blur(8px);
  border: 0; border-radius: 0; box-shadow: none; padding: 18px;
}
.setup-inner { width: min(560px, 94vw); text-align: center; }
.setup-title { font-size: clamp(20px, 3.4vw, 32px); font-weight: 900; letter-spacing: 0.06em; margin-bottom: 6px; }
.setup-sub { font-size: 12px; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 20px; }
.setup-hint { margin-top: 18px; font-size: 11px; color: var(--dim); line-height: 1.6; }
.size-chips { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.size-chip {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 130px; padding: 18px 22px; border-radius: 18px; cursor: pointer;
  background: linear-gradient(160deg, rgba(38,32,66,0.85), rgba(14,12,28,0.92));
  border: 1.5px solid rgba(255,215,106,0.22); color: #e8dcc0;
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
}
.size-chip:hover { transform: translateY(-4px); border-color: var(--gold); box-shadow: 0 12px 28px rgba(0,0,0,0.5), 0 0 20px rgba(255,215,106,0.25); }
.size-chip .sc-big { font-family: 'Cinzel', serif; font-size: 34px; font-weight: 900; color: var(--gold); text-shadow: 0 0 14px rgba(255,215,106,0.4); }
.size-chip .sc-lbl { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.size-chip .sc-cards { font-size: 10px; color: var(--dim); }
/* esperando al anfitrión: atenuado */
.setup-overlay.waiting .size-chip { opacity: 0.35; pointer-events: none; }
.setup-overlay.waiting .size-chips::after {
  content: 'ESPERANDO A QUE EL ANFITRIÓN ELIJA…';
  display: block; width: 100%; margin-top: 14px;
  font-size: 11px; letter-spacing: 0.16em; color: var(--gold-soft);
  animation: kf-turn-pulse 1.4s ease-in-out infinite;
}

/* ---------- Overlay EMPAREJAMIENTO ALEATORIO ---------- */
.mm-card { width: min(420px, 94vw); padding: 30px 24px 20px; text-align: center; border-color: rgba(255,215,106,0.4); }
.mm-title { font-family: 'Cinzel', serif; font-size: 22px; font-weight: 900; letter-spacing: 0.06em; color: var(--gold-soft); margin: 14px 0 4px; }
.mm-sub { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.mm-count { font-family: 'Cinzel', serif; font-size: 44px; font-weight: 900; color: #fff; text-shadow: 0 0 18px rgba(255,215,106,0.5); margin: 4px 0 10px; }
.mm-radar { position: relative; width: 96px; height: 96px; margin: 0 auto; }
.mm-ic { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 34px; color: var(--gold); }
.mm-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(255,215,106,0.55);
  animation: kf-mm-ping 2.2s ease-out infinite;
}
.mm-ring.r2 { animation-delay: 0.7s; }
.mm-ring.r3 { animation-delay: 1.4s; }
@keyframes kf-mm-ping {
  0% { transform: scale(0.45); opacity: 0.9; }
  100% { transform: scale(1.5); opacity: 0; }
}
.mm-offer-lbl { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.mm-offer-lbl b { color: #b285ff; }
.mm-offer-btns { display: flex; flex-direction: column; gap: 8px; }
.mm-cancel { margin-top: 12px; font-size: 11px; }

/* Altura limitada: compactar el juego para que quepa sin scroll */
@media (max-height: 780px) {
  #screen-game .screen-inner { gap: 8px; }
  .machine { padding: 14px 20px 10px; }
  .machine-top { margin-bottom: 8px; }
  .machine-banner { margin-bottom: 8px; padding: 5px 14px; }
  .machine-display { padding: 6px 12px 10px; }
  .led-digit { font-size: clamp(40px, 7vh, 56px); }
  .rule-banner { margin: -4px auto 6px; padding: 3px 12px; }
  .machine-step { margin-top: 6px; min-height: 16px; }
  .popit { padding: 10px 16px; gap: 8px 12px; }
  .pad { width: 46px; height: 46px; }
  .pad-num { font-size: 19px; }
  .player-panel { padding: 6px 10px; }
  .avatar { width: 34px; height: 34px; font-size: 14px; }
  .turn-ring, .turn-ring svg { width: 48px; height: 48px; }
  .round-row { padding: 5px 12px; }
}
@media (max-height: 720px) {
  .lobby-hero .logo-title { font-size: clamp(30px, 4.5vw, 44px); }
  .lobby-body { gap: 20px; }
}
