.hidden { display: none !important; }

.header-nav { display: flex; align-items: center; gap: 12px; }
.conn { font-size: 14px; }
.conn.on { color: var(--ok); }
.conn.off { color: var(--danger); }

.btn.small { padding: 7px 12px; font-size: 14px; }
.btn.tiny { padding: 3px 9px; font-size: 12px; border-radius: 8px; }

kbd {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
}

/* ----------------------------------------------------------- lobby */
.lobby-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.card h2 { margin: 0 0 16px; font-size: 20px; }
.subtitle { font-size: 14px; color: var(--muted); margin: 22px 0 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field span, .field-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.field-label { display: block; margin-bottom: 6px; }

.modes { display: grid; gap: 10px; margin-bottom: 18px; }
.mode {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  background: var(--bg-2);
  transition: border-color 0.15s;
}
.mode:has(input:checked) { border-color: var(--accent); background: #241f12; }
.mode input { margin-top: 3px; accent-color: var(--accent); }
.mode strong { display: block; }
.mode small { color: var(--muted); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.code-input { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; width: 140px; text-align: center; }

.room-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.room-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.room-list li.empty { color: var(--muted); justify-content: center; font-size: 14px; }
.room-list .r-mode { font-size: 12px; color: var(--accent); font-weight: 700; }
.room-list .r-host { font-weight: 600; }
.room-list .r-code { font-family: ui-monospace, monospace; color: var(--muted); font-size: 13px; }

.rules { margin-top: 20px; }
.rules ul { margin: 0; padding-left: 18px; line-height: 1.8; color: #cdd6e2; }

/* ----------------------------------------------------------- juego */
.game {
  padding: 12px 18px 18px;
  max-width: 1500px;
  margin: 0 auto;
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 10px;
}

.player-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  min-height: 74px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.player-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 24px rgba(242, 179, 61, 0.15); }
.player-card.right { text-align: right; }
.pc-top { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.player-card.right .pc-top { justify-content: flex-end; }
.pc-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.pc-dot.on { background: var(--ok); }
.pc-sub { font-size: 13px; color: var(--muted); margin: 2px 0 6px; min-height: 16px; }
.pc-balls { display: flex; gap: 4px; flex-wrap: wrap; min-height: 22px; }
.player-card.right .pc-balls { justify-content: flex-end; }
.mini-ball {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 800;
  color: #111;
  position: relative;
  box-shadow: inset -2px -3px 4px rgba(0, 0, 0, 0.35);
}
.mini-ball span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  line-height: 1;
}
.mini-ball.done { opacity: 0.25; }

.hud-center { text-align: center; display: flex; flex-direction: column; justify-content: center; gap: 6px; min-width: 280px; max-width: 520px; }
.room-info { color: var(--muted); font-size: 14px; display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; }
.room-info b { color: var(--text); letter-spacing: 2px; }
.sep { opacity: 0.5; }
.status {
  font-size: 15px;
  font-weight: 600;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
}
.status.mine { border-color: var(--accent); color: var(--accent-2); }

.stage {
  display: grid;
  grid-template-columns: 1fr 170px;
  gap: 14px;
  align-items: start;
}

.table-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2.92 / 1.65;
  max-height: calc(100vh - 230px);
  min-height: 260px;
  isolation: isolate;
}

#table-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}


.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 12, 0.55);
  backdrop-filter: blur(2px);
  border-radius: 10px;
}
.overlay-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 28px;
  text-align: center;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.overlay-box h2 { margin: 0 0 8px; }
.overlay-box p { color: var(--muted); margin: 0 0 16px; }
.big-code { font-size: 40px; font-weight: 800; letter-spacing: 8px; color: var(--accent); margin-bottom: 16px; font-family: ui-monospace, monospace; }

.side { display: flex; flex-direction: column; gap: 12px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.panel-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; }

.power-bar {
  position: relative;
  width: 34px;
  height: 190px;
  margin: 0 auto;
  border-radius: 18px;
  background: #0b0f14;
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
}
.power-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: linear-gradient(to top, #2ea043 0%, #a8d13b 40%, #f2b33d 70%, #e5534b 100%);
  background-size: 100% 190px;
  background-position: bottom;
  transition: height 0.04s linear;
}
.power-ticks {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to top, transparent 0 18px, rgba(255, 255, 255, 0.12) 18px 19px);
  pointer-events: none;
}
.power-val { margin-top: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }

#spin-pad { width: 120px; height: 120px; cursor: pointer; touch-action: none; }
/* alto fijo de dos líneas: el texto no debe mover la bola de efecto */
.spin-label {
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted);
  margin: 4px 0 6px;
  height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: pre-line;
  overflow: hidden;
}
.spin-panel { transition: border-color 0.15s, box-shadow 0.15s; }
.spin-panel.dragging { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 18px rgba(242, 179, 61, 0.2); }

.call-text { font-size: 14px; line-height: 1.4; }
.call-panel { border-color: var(--accent); }


.check { display: flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--accent); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.toast.error { border-color: var(--danger); }

@media (max-width: 1000px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .stage { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .power-bar { height: 120px; }
  .power-fill { background-size: 100% 120px; }
  .hud { grid-template-columns: 1fr 1fr; }
  .hud-center { grid-column: 1 / -1; grid-row: 1; max-width: none; }
}

/* ----------------------------------------------------------- cerveza y tiza */
.pc-face { font-size: 18px; line-height: 1; }
.pc-fun { display: flex; gap: 6px; margin-top: 8px; }
.player-card.right .pc-fun { justify-content: flex-end; }

.fun-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 6px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.fun-btn:hover:not(:disabled) { border-color: var(--accent); }
.fun-btn:active:not(:disabled) { transform: scale(0.95); }
.fun-btn:disabled { cursor: default; opacity: 0.85; }
.fun-btn:disabled .fun-label { display: none; }

/* Vaso de cerveza: --level = 0..1 */
.glass {
  --level: 1;
  position: relative;
  width: 16px;
  height: 22px;
  border: 2px solid rgba(220, 235, 255, 0.75);
  border-top: none;
  border-radius: 0 0 4px 4px;
  clip-path: polygon(0 0, 100% 0, 88% 100%, 12% 100%);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  transform-origin: 50% 100%;
}
.beer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--level) * 100%);
  background: linear-gradient(to right, #e59a12, #f9c23c 45%, #e59a12);
  transition: height 0.6s ease;
}
.foam {
  position: absolute;
  left: 0;
  right: 0;
  top: -3px;
  height: 5px;
  background: #fffbea;
  border-radius: 3px;
}
.bubbles {
  position: absolute;
  inset: 4px 3px 0;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.7) 0.8px, transparent 1.2px);
  background-size: 5px 6px;
  animation: bubbles 1.4s linear infinite;
  opacity: 0.6;
}
@keyframes bubbles { from { background-position: 0 0; } to { background-position: 0 -12px; } }

.fun-count {
  font-size: 11px;
  background: #3a2a0c;
  color: #ffcf6b;
  border-radius: 999px;
  padding: 0 6px;
  min-width: 18px;
  text-align: center;
}

.beer-btn.drinking .glass { animation: drink 1s ease; }
@keyframes drink {
  0% { transform: rotate(0); }
  25%, 70% { transform: rotate(-55deg) translate(-2px, -3px); }
  100% { transform: rotate(0); }
}

/* Tiza: --chalk = 0..1 */
.chalk-cube {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: linear-gradient(135deg, #5e8fe0, #2f62b8);
  box-shadow: inset 0 -3px 0 #1f4a92, 0 0 0 1px rgba(255, 255, 255, 0.15);
  position: relative;
}
.chalk-cube::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #1c3f80;
}
.chalk-meter {
  --chalk: 1;
  width: 26px;
  height: 6px;
  border-radius: 3px;
  background: #0b0f14;
  border: 1px solid var(--line);
  overflow: hidden;
}
.chalk-meter i {
  display: block;
  height: 100%;
  width: calc(var(--chalk) * 100%);
  background: linear-gradient(to right, #2f62b8, #6fa1f0);
  transition: width 0.4s ease;
}
.chalk-btn.low { border-color: rgba(229, 83, 75, 0.7); }
.chalk-btn.low .chalk-meter i { background: var(--danger); }
.chalk-btn.chalking .chalk-cube { animation: chalking 0.9s ease; }
@keyframes chalking {
  0% { transform: rotate(0) scale(1); }
  20% { transform: rotate(35deg) scale(1.25); }
  40% { transform: rotate(-35deg) scale(1.25); }
  60% { transform: rotate(35deg) scale(1.25); }
  80% { transform: rotate(-20deg) scale(1.1); }
  100% { transform: rotate(0) scale(1); }
}

/* Un poco "alegre": la mesa se balancea suavemente */
.table-wrap.tipsy #table-canvas { animation: tipsy 5s ease-in-out infinite; }
.table-wrap.very-tipsy #table-canvas { animation: tipsy 3.2s ease-in-out infinite; filter: blur(0.35px) saturate(1.15); }
@keyframes tipsy {
  0%, 100% { transform: rotate(0) translate(0, 0); }
  25% { transform: rotate(0.35deg) translate(3px, 1px); }
  75% { transform: rotate(-0.35deg) translate(-3px, -1px); }
}

/* ----------------------------------------------------------- efectos flotantes */
.fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.fx-emoji {
  position: absolute;
  font-size: 44px;
  line-height: 1;
  transform: translate(-50%, 0);
  animation: float-up 2.2s ease-out forwards;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}
.fx-emoji.big { font-size: 72px; }
.fx-emoji small {
  display: block;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 3px #000;
  margin-top: 2px;
  white-space: nowrap;
}
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(0.5); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  30% { transform: translate(-50%, -10px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -160px) scale(1); }
}

/* Bocadillo de chat junto a la tarjeta del jugador */
.bubble {
  position: absolute;
  top: calc(100% + 8px);
  left: 14px;
  z-index: 20;
  max-width: 280px;
  background: #fff;
  color: #111;
  padding: 7px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  animation: bubble-in 0.2s ease;
  overflow-wrap: anywhere;
  pointer-events: none;
}
.bubble::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 18px;
  border: 6px solid transparent;
  border-top: none;
  border-bottom-color: #fff;
}
.player-card.right .bubble { left: auto; right: 14px; }
.player-card.right .bubble::before { left: auto; right: 18px; }
.bubble.out { opacity: 0; transition: opacity 0.4s; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(-4px); } }

/* ----------------------------------------------------------- chat flotante */
.chat-panel {
  position: fixed;
  top: var(--header-h, 75px);
  right: 0;
  bottom: 0;
  z-index: 40;
  width: var(--chat-w);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.25);
}
body { --chat-w: 320px; }
body.with-chat .game { margin-right: var(--chat-w); }
body.with-chat .game { max-width: none; }
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 85%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg .who { font-size: 11px; color: var(--muted); margin: 0 6px 2px; }
.msg .text {
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 6px 11px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.msg.me .text { background: #3a2a0c; border-color: #6b4f16; }
.msg.emoji-only .text { background: none; border: none; font-size: 34px; padding: 0 4px; }
.msg.sys { align-self: center; max-width: 95%; }
.msg.sys .text { background: none; border: none; color: #7f8ea3; font-style: italic; font-size: 12px; text-align: center; padding: 0; }

.quick-reactions {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.quick-reactions button {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 18px;
  padding: 3px 7px;
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
  flex: none;
}
.quick-reactions button:hover { border-color: var(--accent); }
.quick-reactions .txt { font-size: 13px; }

.chat-form {
  position: relative;
  display: flex;
  gap: 6px;
  padding: 8px 10px 10px;
}
.chat-form input { flex: 1; min-width: 0; padding: 8px 10px; }
.emoji-btn {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 20px;
  width: 40px;
  cursor: pointer;
}
.emoji-btn:hover { border-color: var(--accent); }
.emoji-picker {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 10px;
  right: 10px;
  max-height: 210px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.emoji-picker button {
  background: none;
  border: none;
  font-size: 22px;
  padding: 4px 0;
  border-radius: 8px;
  cursor: pointer;
}
.emoji-picker button:hover { background: var(--bg-2); }

/* ----------------------------------------------------------- avisos (tarjetas) */
.announce {
  position: absolute;
  top: 9%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  z-index: 5;
  width: min(460px, 86%);
}
.ann {
  --c: #93a1b5;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 18px 12px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(20, 26, 36, 0.92), rgba(12, 16, 22, 0.88));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 5px solid var(--c);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.3), 0 0 40px -10px var(--c);
  backdrop-filter: blur(6px);
  animation: ann-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
  transition: opacity 0.4s, transform 0.4s;
}
.ann.out { opacity: 0; transform: translateY(-12px) scale(0.96); }
@keyframes ann-in {
  from { opacity: 0; transform: translateY(-24px) scale(0.85); }
  to { opacity: 1; transform: none; }
}
.ann-icon {
  font-size: 34px;
  line-height: 1;
  width: 50px;
  height: 50px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  animation: ann-icon 0.6s ease 0.1s;
}
@keyframes ann-icon { 0% { transform: scale(0.4) rotate(-20deg); } 60% { transform: scale(1.2) rotate(8deg); } 100% { transform: none; } }
.ann-body { min-width: 0; flex: 1; }
.ann-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: var(--c);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.ann-text { font-size: 14px; color: #d5dde8; margin-top: 2px; line-height: 1.35; }
.ann-footer {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #c7d1de;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  padding: 2px 10px;
}
.ann-footer.mine { background: var(--accent); color: #1a1205; }
.ann-balls { display: flex; gap: 4px; margin: 4px 0 2px; }
.ann-ball {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: inset -3px -4px 6px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.4);
  animation: ann-ball 0.5s ease backwards;
}
.ann-ball:nth-child(2) { animation-delay: 0.08s; }
.ann-ball:nth-child(3) { animation-delay: 0.16s; }
.ann-ball span {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  color: #111;
  font-size: 9px;
  font-weight: 800;
  display: grid;
  place-items: center;
}
@keyframes ann-ball { from { transform: translateY(-14px) scale(0.3); opacity: 0; } }

.ann-foul { --c: #ff6b61; }
.ann-good { --c: #4fd17a; }
.ann-info { --c: #8fb4ff; }
.ann-miscue { --c: #ffa94d; }
.ann-lose { --c: #a0a8b4; }
.ann-win {
  --c: #ffd25e;
  padding: 18px 22px;
  background: linear-gradient(135deg, rgba(60, 42, 8, 0.95), rgba(20, 14, 4, 0.92));
  border-left-width: 6px;
}
.ann-win .ann-title { font-size: 26px; }
.ann-win .ann-icon { font-size: 44px; width: 64px; height: 64px; }

/* ----------------------------------------------------------- cerveza grande */
.fx-beer, .fx-chalk {
  position: absolute;
  top: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transform: translate(-50%, -50%);
  z-index: 4;
  pointer-events: none;
}
.fx-beer.left, .fx-chalk.left { left: 27%; }
.fx-beer.right, .fx-chalk.right { left: 73%; }
.fx-beer { animation: fx-pop 2.6s ease forwards; }
.fx-chalk { animation: fx-pop 2.2s ease forwards; }
@keyframes fx-pop {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.4); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  20% { transform: translate(-50%, -50%) scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(0.95); }
}

.mug {
  position: relative;
  width: 96px;
  height: 128px;
  transform-origin: 70% 90%;
  animation: mug-drink 2.6s ease forwards;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.55));
}
@keyframes mug-drink {
  0%, 15% { transform: rotate(0); }
  30%, 70% { transform: rotate(-38deg) translate(-6px, -10px); }
  82%, 100% { transform: rotate(0); }
}
.mug-glass {
  position: absolute;
  inset: 0 14px 0 0;
  border: 4px solid rgba(235, 245, 255, 0.85);
  border-top-width: 2px;
  border-radius: 8px 8px 16px 16px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.04) 40%, rgba(255, 255, 255, 0.14));
  overflow: hidden;
}
.mug-glass::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 10px;
  left: 9px;
  width: 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.45);
}
.mug-beer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--from) * 88%);
  background: linear-gradient(90deg, #d98a0b, #ffc93c 40%, #f7b021 70%, #c97a06);
  animation: beer-level 2.6s ease forwards;
}
@keyframes beer-level {
  0%, 30% { height: calc(var(--from) * 88%); }
  70%, 100% { height: calc(var(--to) * 88%); }
}
.mug-foam {
  position: absolute;
  left: -4px;
  right: -4px;
  top: -12px;
  height: 16px;
  border-radius: 10px;
  background:
    radial-gradient(circle at 15% 60%, #fff 0 7px, transparent 8px),
    radial-gradient(circle at 40% 40%, #fffdf2 0 8px, transparent 9px),
    radial-gradient(circle at 68% 55%, #fff 0 7px, transparent 8px),
    radial-gradient(circle at 90% 45%, #fffaf0 0 6px, transparent 7px),
    #fff6dc;
}
.mug-bubble {
  position: absolute;
  bottom: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  animation: bubble-rise 1.3s linear infinite;
}
@keyframes bubble-rise {
  from { transform: translateY(0); opacity: 0.9; }
  to { transform: translateY(-110px); opacity: 0; }
}
.mug-handle {
  position: absolute;
  right: 0;
  top: 28px;
  width: 30px;
  height: 62px;
  border: 7px solid rgba(235, 245, 255, 0.85);
  border-left: none;
  border-radius: 0 26px 26px 0;
}
.glup {
  position: absolute;
  font-weight: 900;
  font-size: 22px;
  color: #ffd25e;
  text-shadow: 0 2px 0 #6b4a0a, 0 4px 10px rgba(0, 0, 0, 0.6);
  opacity: 0;
  animation: glup 0.9s ease forwards;
  white-space: nowrap;
}
.glup.g1 { top: -6px; left: -46px; animation-delay: 0.7s; transform: rotate(-12deg); }
.glup.g2 { top: 20px; right: -58px; animation-delay: 1.1s; transform: rotate(10deg); }
.glup.g3 { top: -40px; left: 50%; animation-delay: 1.75s; font-size: 26px; color: #fff; text-shadow: 0 2px 0 #444, 0 4px 10px rgba(0, 0, 0, 0.6); }
@keyframes glup {
  0% { opacity: 0; scale: 0.4; }
  30% { opacity: 1; scale: 1.2; }
  70% { opacity: 1; scale: 1; }
  100% { opacity: 0; translate: 0 -20px; }
}
.fx-caption {
  background: rgba(10, 14, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 15px;
  color: #e8edf3;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}
.fx-caption b { color: var(--accent-2); }

/* ----------------------------------------------------------- tiza grande */
.chalk-scene {
  position: relative;
  width: 140px;
  height: 150px;
}
.big-cue {
  position: absolute;
  left: 50%;
  top: 50px;
  width: 26px;
  transform: translateX(-50%) rotate(8deg);
  transform-origin: 50% 0;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.55));
}
.big-tip {
  height: 16px;
  border-radius: 12px 12px 3px 3px;
  background: linear-gradient(90deg, #6e5a3a, #c4a87a 40%, #7a6442);
  animation: tip-chalked 2.2s ease forwards;
}
@keyframes tip-chalked {
  0%, 35% { background: linear-gradient(90deg, #6e5a3a, #c4a87a 40%, #7a6442); }
  60%, 100% { background: linear-gradient(90deg, #1d3e78, #4f8ee6 40%, #1d3e78); }
}
.big-ferrule { height: 22px; background: linear-gradient(90deg, #b8b09a, #fbf7ec 40%, #b8b09a); }
.big-shaft { height: 80px; background: linear-gradient(90deg, #a98552, #f0d9a8 40%, #a98552); border-radius: 0 0 4px 4px; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.big-chalk {
  position: absolute;
  left: 50%;
  top: 4px;
  width: 46px;
  height: 46px;
  margin-left: -23px;
  border-radius: 6px;
  background: linear-gradient(135deg, #78a7f0, #2a5bb0 60%, #1d468e);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.25), inset 0 3px 0 rgba(255, 255, 255, 0.3), 0 8px 16px rgba(0, 0, 0, 0.5);
  animation: chalk-rub 2.2s ease forwards;
}
.big-chalk::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 26px;
  height: 10px;
  margin-left: -13px;
  border-radius: 50%;
  background: #173a78;
}
@keyframes chalk-rub {
  0% { transform: translateY(-40px) rotate(0); opacity: 0; }
  15% { transform: translateY(0) rotate(0); opacity: 1; }
  25% { transform: translateY(14px) rotate(25deg); }
  35% { transform: translateY(14px) rotate(-25deg); }
  45% { transform: translateY(14px) rotate(25deg); }
  55% { transform: translateY(14px) rotate(-25deg); }
  65% { transform: translateY(14px) rotate(15deg); }
  80% { transform: translateY(-10px) rotate(0); opacity: 1; }
  100% { transform: translateY(-40px) rotate(0); opacity: 0; }
}
.dust {
  position: absolute;
  left: 50%;
  top: 56px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8bb4ff;
  box-shadow: 0 0 6px #8bb4ff;
  opacity: 0;
  animation: dust 0.9s ease-out forwards;
}
@keyframes dust {
  0% { opacity: 0.9; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

/* ----------------------------------------------------------- confeti y temblor */
.confetti { position: absolute; inset: 0; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation-name: confetti-fall;
  animation-timing-function: cubic-bezier(0.25, 0.6, 0.5, 1);
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  to { transform: translate(var(--drift), 115vh) rotate(var(--rot)); }
}
.table-wrap.shake { animation: shake 0.38s ease; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(calc(var(--shake) * -1), calc(var(--shake) * 0.5)); }
  40% { transform: translate(var(--shake), calc(var(--shake) * -0.5)); }
  60% { transform: translate(calc(var(--shake) * -0.6), 0); }
  80% { transform: translate(calc(var(--shake) * 0.4), calc(var(--shake) * 0.3)); }
}

/* ambiente alrededor de la mesa (luz cálida de bar) */
.table-wrap::before {
  content: "";
  position: absolute;
  inset: -40px -60px;
  background: radial-gradient(ellipse at 50% 45%, rgba(255, 214, 150, 0.1), rgba(255, 214, 150, 0.03) 45%, transparent 70%);
  pointer-events: none;
  z-index: -1;
}

/* ----------------------------------------------------------- personalización (lobby) */
.custom-card { margin-top: 20px; }
.custom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2.92 / 1.65;
  border-radius: 14px;
  background: radial-gradient(ellipse at 50% 45%, #2a2318, #0d1117 75%);
  overflow: hidden;
}
#preview-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.preview-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.swatch {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 -6px 10px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(242, 179, 61, 0.3), inset 0 -6px 10px rgba(0, 0, 0, 0.35); }
.swatch.selected::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  text-shadow: 0 1px 3px #000;
}
.cue-list { display: grid; gap: 6px; }
.cue-option {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  cursor: pointer;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}
.cue-option:hover { border-color: #5b6b80; }
.cue-option.selected { border-color: var(--accent); background: #241f12; }
.cue-option canvas { width: 100%; height: 22px; }
.cue-option span { order: -1; }
.custom-label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.custom-label small { font-weight: 400; }

@media (max-width: 900px) {
  .custom-grid { grid-template-columns: 1fr; }
}

.style-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin: -4px 0 14px;
  flex-wrap: wrap;
}
.style-summary a { color: var(--accent); font-weight: 600; text-decoration: none; }
.style-summary a:hover { text-decoration: underline; }
.sum-dot { width: 18px; height: 18px; border-radius: 5px; border: 3px solid; flex: none; }

.fine-aim {
  position: absolute;
  left: 50%;
  bottom: 7%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(10, 14, 20, 0.85);
  border: 1px solid var(--accent);
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.fine-aim small { color: var(--muted); font-weight: 500; }

/* ----------------------------------------------------------- ajustes (engranaje) */
.settings { position: relative; }
.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.icon-btn:hover, .icon-btn.active { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { transition: transform 0.4s ease; }
.icon-btn.active svg { transform: rotate(90deg); }
.settings-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 70;
  width: 280px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  animation: menu-in 0.15s ease;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px); } }
.settings-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 4px 8px 8px;
}
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
}
.setting:hover { background: var(--bg-2); }
.setting b { display: block; font-size: 14px; }
.setting small { display: block; font-size: 12px; color: var(--muted); }
/* interruptor */
.switch {
  appearance: none;
  flex: none;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: #3a4556;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  margin: 0;
  padding: 0;
  border: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* En pantallas angostas el chat va debajo de la mesa */
@media (max-width: 1100px) {
  .chat-panel {
    position: static;
    width: auto;
    height: 380px;
    margin: 0 18px 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: none;
  }
  body.with-chat .game { margin-right: 0; }
}

/* ----------------------------------------------------------- sticker IZI */
.sticker-izi {
  font-family: "Arial Black", "Segoe UI Black", Impact, sans-serif;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #fff3b0 0%, #ffd23f 45%, #f08c00 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1px #7a3d00;
  filter: drop-shadow(0 2px 0 #4a2500) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
}
.emoji-picker .sticker-izi, .quick-reactions .sticker-izi { font-size: 17px; }
.emoji-picker button.sticker-izi { grid-column: span 2; }
.quick-reactions button.sticker-izi {
  -webkit-background-clip: border-box;
  background-clip: border-box;
  background: linear-gradient(180deg, #3a2a08, #1d1404);
  border-color: #8a6418;
  color: #ffd23f;
  -webkit-text-stroke: 0;
  filter: none;
  text-shadow: 0 1px 0 #000;
}
.msg.sticker-msg .text {
  font-family: "Arial Black", "Segoe UI Black", Impact, sans-serif;
  font-style: italic;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #fff3b0 0%, #ffd23f 45%, #f08c00 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1.5px #7a3d00;
  filter: drop-shadow(0 2px 0 #4a2500);
  transform: rotate(-6deg);
  padding: 4px 8px;
}
.fx-emoji.fx-sticker {
  font-size: 64px;
  -webkit-text-stroke: 2px #7a3d00;
}
.fx-emoji.fx-sticker.big { font-size: 84px; }
.fx-emoji.fx-sticker small {
  -webkit-text-stroke: 0;
  color: #fff;
  background: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  font-family: Inter, system-ui, sans-serif;
  font-style: normal;
  letter-spacing: 0;
}

/* =================================================================
   Vista de juego a pantalla completa: todo cabe en la ventana, sin
   scroll. La mesa ocupa el espacio que queda y el chat va fijo.
   ================================================================= */
body.in-game {
  --chat-w: clamp(240px, 22vw, 330px);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}
body.in-game .site-header { padding-top: 10px; padding-bottom: 10px; }

body.in-game .game {
  box-sizing: border-box;
  height: calc(100dvh - var(--header-h, 60px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: none;
  margin: 0 var(--chat-w) 0 0;
  padding: 8px 12px 10px;
}

body.in-game .hud {
  flex: none;
  margin: 0;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}
body.in-game .hud-center { grid-column: auto; grid-row: auto; min-width: 0; max-width: 460px; }
body.in-game .player-card { min-height: 0; padding: 8px 12px; }

body.in-game .stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(110px, 11vw, 160px);
  gap: 10px;
  align-items: stretch;
}
body.in-game .table-wrap {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  aspect-ratio: auto;
}

/* panel lateral: la barra de fuerza se estira, el resto es compacto */
body.in-game .side {
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: flex-start;
  min-height: 0;
  overflow: hidden;
  gap: 8px;
}
body.in-game .panel { padding: 8px; }
body.in-game .power-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.in-game .power-bar { flex: 1; height: auto; min-height: 50px; }
body.in-game .spin-panel { flex: none; }
body.in-game #spin-pad { width: min(110px, 100%); height: auto; aspect-ratio: 1; }

/* chat fijo a la derecha */
body.in-game .chat-panel {
  position: fixed;
  top: var(--header-h, 60px);
  right: 0;
  bottom: 0;
  left: auto;
  width: var(--chat-w);
  height: auto;
  margin: 0;
  border: none;
  border-left: 1px solid var(--line);
  border-radius: 0;
}

/* pantallas bajas: HUD y paneles más compactos */
@media (max-height: 760px) {
  body.in-game .pc-sub { display: none; }
  body.in-game .pc-top { font-size: 15px; }
  body.in-game .pc-fun { margin-top: 4px; }
  body.in-game .status { padding: 5px 10px; font-size: 14px; }
  body.in-game .panel-title { margin-bottom: 4px; }
  body.in-game #spin-pad { width: min(84px, 100%); }
  body.in-game .spin-label { margin: 2px 0; font-size: 11px; }
}
@media (max-height: 560px) {
  body.in-game .pc-balls, body.in-game .room-info { display: none; }
  body.in-game .btn-spin-reset, body.in-game #btn-spin-reset { display: none; }
}

/* pantallas angostas: el chat pasa a una franja inferior */
@media (max-width: 900px) {
  body.in-game { --chat-h: 30dvh; }
  body.in-game .game {
    margin-right: 0;
    height: calc(100dvh - var(--header-h, 60px) - var(--chat-h));
  }
  body.in-game .chat-panel {
    top: auto;
    left: 0;
    width: auto;
    height: var(--chat-h);
    border-left: none;
    border-top: 1px solid var(--line);
  }
  body.in-game .hud { grid-template-columns: 1fr 1fr; }
  body.in-game .hud-center { grid-column: 1 / -1; grid-row: 1; max-width: none; }
  body.in-game .hud-center .room-info { display: none; }
}

/* la barra de fuerza se rellena recortando un degradado fijo */
.power-fill {
  top: 0;
  height: 100% !important;
  background-size: 100% 100%;
  clip-path: inset(100% 0 0 0);
  transition: clip-path 0.04s linear;
}
html:has(body.in-game) { overflow: hidden; overscroll-behavior: none; }
body.in-game .table-wrap::before { inset: -20px -40px 0; }

/* pantallas angostas: fuerza y efecto lado a lado, chat más bajo */
@media (max-width: 900px) {
  body.in-game { --chat-h: 26dvh; }
  body.in-game .chat-header { display: none; }
  body.in-game .stage { grid-template-columns: minmax(0, 1fr) auto; }
  body.in-game .side { flex-direction: row; align-items: stretch; }
  body.in-game .power-panel { flex: none; width: 50px; }
  body.in-game .power-panel .panel-title { font-size: 9px; letter-spacing: 0; }
  body.in-game .power-bar { width: 22px; }
  body.in-game .power-val { font-size: 12px; }
  body.in-game .spin-panel { width: 104px; overflow: hidden; }
  body.in-game #spin-pad { width: 80px; }
}

/* ----------------------------------------------------------- Pool Corrido */
.variants { display: grid; gap: 8px; margin: -6px 0 18px; padding-left: 14px; border-left: 2px solid var(--accent); }
.variant {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  background: var(--bg-2);
}
.variant:has(input:checked) { border-color: var(--accent); background: #241f12; }
.variant input { margin-top: 3px; accent-color: var(--accent); }
.variant strong { display: block; font-size: 14px; }
.variant small { color: var(--muted); }

.pc-score {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  margin-left: auto;
  padding: 2px 10px 5px;
  border-radius: 10px;
  background: #241f12;
  border: 1px solid #6b4f16;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}
.player-card.right .pc-score { margin-left: 0; margin-right: auto; order: -1; }
.pc-score b { font-size: 20px; color: var(--accent-2); line-height: 1; }
.pc-score small { font-size: 12px; color: var(--muted); }
.pc-score i {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: calc(var(--p, 0) * 100%);
  background: linear-gradient(90deg, #f2b33d, #3fb950);
  transition: width 0.5s ease;
}
.pc-score.hidden { display: none; }

/* ----------------------------------------------------------- Carambola */
.target-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 4px 0;
  font-size: 14px;
  font-weight: 600;
}
.target-row select { padding: 6px 10px; }
