/* =====================================================================
   WORD BATTLE — hoja de estilos principal
   Paleta, tipografía y animaciones propias.
   ===================================================================== */

@font-face {
  font-family: 'Fredoka';
  src: url('/fonts/fredoka-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #0c0a17;
  --bg-soft: #141026;
  --panel: rgba(28, 23, 48, 0.78);
  --panel-strong: #1d1834;
  --panel-hi: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4f1ff;
  --muted: #a49dc4;
  --yellow: #ffd23f;
  --yellow-deep: #e8a413;
  --pink: #ff4f8b;
  --green: #45e08c;
  --red: #ff5d5d;
  --violet: #8c6cff;
  --cyan: #4fd6e0;
  --radius: 20px;
  --radius-sm: 13px;
  --shadow: 0 18px 40px rgba(6, 4, 18, 0.55);
  --shadow-soft: 0 8px 20px rgba(6, 4, 18, 0.35);
  --font: 'Fredoka', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

h1, h2, h3, h4, p { margin: 0; }

a { color: inherit; }

::selection { background: rgba(255, 210, 63, 0.35); }

/* ------------------------------- Fondo ------------------------------ */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% -10%, #201a3d 0%, #120f22 45%, #0a0813 100%);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  will-change: transform;
}

.blob--violet {
  width: 48vw;
  height: 48vw;
  left: -10vw;
  top: -14vw;
  background: radial-gradient(circle, rgba(124, 92, 255, 0.55), transparent 65%);
  animation: blobDrift 26s ease-in-out infinite alternate;
}

.blob--teal {
  width: 42vw;
  height: 42vw;
  right: -8vw;
  top: 20vh;
  background: radial-gradient(circle, rgba(48, 190, 190, 0.34), transparent 65%);
  animation: blobDrift 32s ease-in-out infinite alternate-reverse;
}

.blob--pink {
  width: 36vw;
  height: 36vw;
  left: 30vw;
  bottom: -16vw;
  background: radial-gradient(circle, rgba(255, 79, 139, 0.3), transparent 65%);
  animation: blobDrift 38s ease-in-out infinite alternate;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

@keyframes blobDrift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(3vw, 4vh, 0) scale(1.08); }
  100% { transform: translate3d(-2vw, -3vh, 0) scale(0.96); }
}

/* ----------------------------- Pantallas ---------------------------- */

.screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.screen.is-active {
  display: flex;
  animation: screenIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.screen.is-leaving {
  animation: screenOut 0.22s ease-in both;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px) scale(0.995); }
  to { opacity: 1; transform: none; }
}

@keyframes screenOut {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-10px) scale(0.997); }
}

/* --------------------------- Componentes ---------------------------- */

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.panel__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.panel__head h2,
.panel__head h3 {
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.spacer { flex: 1; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
}

.hint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.muted-link {
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.18);
  padding-bottom: 1px;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.muted-link:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.4); }

/* Botones */

.btn {
  --btn-bg: rgba(255, 255, 255, 0.1);
  --btn-shadow: rgba(0, 0, 0, 0.35);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: var(--btn-bg);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.12s cubic-bezier(0.3, 1.4, 0.5, 1), box-shadow 0.16s ease,
    background 0.16s ease, filter 0.16s ease;
  box-shadow: 0 4px 0 var(--btn-shadow);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-shadow); }
.btn:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; filter: none; }

.btn--primary {
  --btn-bg: linear-gradient(180deg, #ffe066 0%, var(--yellow) 45%, #f2b21f 100%);
  --btn-shadow: #a97507;
  color: #2a1d00;
  border-color: rgba(255, 255, 255, 0.35);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn--primary:hover { filter: brightness(1.05); }

.btn--ghost {
  --btn-bg: rgba(255, 255, 255, 0.06);
  --btn-shadow: rgba(0, 0, 0, 0.28);
  border-color: rgba(255, 255, 255, 0.08);
}

.btn--sm { padding: 7px 13px; font-size: 0.82rem; border-radius: 11px; }
.btn--big { width: 100%; padding: 14px 20px; font-size: 1.05rem; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  transition: background 0.16s ease, transform 0.12s ease;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.icon-btn:active { transform: scale(0.94); }

/* Campos */

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--muted);
}

.field span em { font-style: normal; opacity: 0.6; font-size: 0.78rem; }

.field input,
.share-link,
.chat__form input,
.modal input,
.word-form input {
  width: 100%;
  padding: 12px 15px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(9, 7, 20, 0.62);
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.field input::placeholder,
.chat__form input::placeholder,
.modal input::placeholder,
.word-form input::placeholder { color: rgba(196, 189, 224, 0.45); }

.field input:focus,
.share-link:focus,
.chat__form input:focus,
.modal input:focus {
  border-color: rgba(255, 210, 63, 0.65);
  box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.16);
  background: rgba(9, 7, 20, 0.8);
}

.field--code input {
  text-align: center;
  font-size: 1.9rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  padding: 10px 0 10px 0.35em;
  font-weight: 600;
}

/* Segmentado */

.seg {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 13px;
  background: rgba(9, 7, 20, 0.55);
  border: 1px solid var(--line);
}

.seg button {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.seg button em {
  display: block;
  font-style: normal;
  font-size: 0.7rem;
  font-weight: 500;
  opacity: 0.65;
  margin-top: 2px;
}

.seg button:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.seg button.is-on {
  background: linear-gradient(180deg, rgba(255, 210, 63, 0.95), rgba(242, 178, 31, 0.9));
  color: #2a1d00;
  box-shadow: 0 3px 10px rgba(242, 178, 31, 0.24);
}

.seg button.is-on em { opacity: 0.7; }

.seg--stack { flex-direction: column; }

.seg--stack button { text-align: left; }

.seg[data-disabled='true'] { opacity: 0.5; pointer-events: none; }

/* Sonido */

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease;
}

.sound-toggle:hover { background: rgba(255, 255, 255, 0.11); }
.sound-toggle--icon { width: 38px; height: 38px; padding: 0; justify-content: center; }

.sound-icon {
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: var(--icon-sound) center/contain no-repeat;
  mask: var(--icon-sound) center/contain no-repeat;
  --icon-sound: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9h3l4.5-4v14L7 15H4z'/%3E%3Cpath d='M16 8.5a4 4 0 0 1 0 7M18.5 6a7 7 0 0 1 0 12' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

.sound-toggle[aria-pressed='false'] { color: var(--muted); }
.sound-toggle[aria-pressed='false'] .sound-icon {
  --icon-sound: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9h3l4.5-4v14L7 15H4z'/%3E%3Cpath d='M16 9l6 6M22 9l-6 6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* Avisos flotantes */

.toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(88vw, 360px);
}

.toast {
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(30, 24, 52, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text);
  animation: toastIn 0.3s cubic-bezier(0.22, 1.4, 0.4, 1) both;
}

.toast--error { border-color: rgba(255, 93, 93, 0.5); background: rgba(52, 20, 30, 0.96); }
.toast--ok { border-color: rgba(69, 224, 140, 0.45); background: rgba(19, 44, 34, 0.96); }
.toast--info { border-color: rgba(124, 108, 255, 0.5); }

.toast.is-out { animation: toastOut 0.24s ease-in both; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(18px) scale(0.97); }
}

/* Modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(6, 4, 14, 0.7);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease both;
}

.modal[hidden] { display: none; }

.modal__card {
  width: min(92vw, 400px);
  padding: 26px;
  border-radius: var(--radius);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: popIn 0.32s cubic-bezier(0.22, 1.3, 0.4, 1) both;
}

.modal__card h2 { font-size: 1.3rem; }

/* ============================== INICIO ============================== */

.home {
  position: relative;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 44px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  flex: 1;
}

.home__brand { text-align: center; }

.brand-mark { display: inline-block; animation: bob 4s ease-in-out infinite; }

.brand-title {
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  margin-top: 6px;
  color: #fff;
  text-shadow: 0 5px 0 #2b2350, 0 14px 30px rgba(0, 0, 0, 0.5);
}

.brand-title span { color: var(--yellow); }

.brand-sub {
  margin-top: 14px;
  color: var(--muted);
  font-size: clamp(0.92rem, 2vw, 1.05rem);
}

.home__actions {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
}

.panel--create, .panel--join { padding: 24px; }

.panel h2 { font-size: 1.14rem; margin-bottom: 16px; font-weight: 600; }

.join-or {
  position: relative;
  text-align: center;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 0.78rem;
}

.join-or::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--line);
}

.join-or span {
  position: relative;
  padding: 0 10px;
  background: var(--panel-strong);
  border-radius: 8px;
}

.rooms-panel { padding: 20px 22px 22px; }

.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 68px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}

.room-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.14s ease;
}

.room-row:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 210, 63, 0.25);
  transform: translateX(2px);
}

.room-row__code {
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--yellow);
  font-size: 0.95rem;
  min-width: 62px;
}

.room-row__name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.room-row__meta { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

.room-row__phase {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.room-row__phase.is-playing { background: rgba(255, 93, 93, 0.16); color: #ff9d9d; }

.rooms-empty {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 26px 10px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.home__footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.home__stats { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.home__stats strong { color: var(--text); font-weight: 600; }
.home__links { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
}

/* ============================== TOPBAR ============================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: rgba(14, 11, 27, 0.75);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar__left, .topbar__right { display: flex; align-items: center; gap: 10px; }
.topbar__left { flex: 1; }
.topbar__right { flex: 1; justify-content: flex-end; }
.topbar__center { display: flex; justify-content: center; }

.room-code {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 11px;
  background: rgba(255, 210, 63, 0.14);
  border: 1px solid rgba(255, 210, 63, 0.32);
  color: var(--yellow);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
}

.room-code--sm { font-size: 0.9rem; padding: 6px 11px; }

.room-title {
  font-size: 1.06rem;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 40vw;
}

.round-chip {
  color: var(--muted);
  font-size: 0.84rem;
}

.round-chip strong { color: var(--text); }

.turn-indicator {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  font-size: 0.86rem;
  color: var(--muted);
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.turn-indicator strong { color: var(--text); }

.turn-indicator__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.turn-indicator.is-mine {
  background: rgba(255, 210, 63, 0.14);
  border-color: rgba(255, 210, 63, 0.4);
  color: var(--yellow);
}

.turn-indicator.is-mine strong { color: var(--yellow); }

.turn-indicator.is-mine .turn-indicator__dot {
  background: var(--yellow);
  box-shadow: 0 0 0 4px rgba(255, 210, 63, 0.18);
  animation: dotPulse 1.1s ease-in-out infinite;
}

/* ================================ SALA ============================== */

.lobby {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  padding: 18px 20px 22px;
  width: min(1280px, 100%);
  margin: 0 auto;
  align-items: start;
}

.lobby__main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.lobby__side { display: flex; flex-direction: column; gap: 18px; }

.lobby-players-panel { padding: 20px; }

.lobby-players {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 12px;
  min-height: 120px;
}

.player-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.07);
  animation: cardPop 0.36s cubic-bezier(0.22, 1.3, 0.4, 1) both;
}

.player-card.is-me { border-color: rgba(255, 210, 63, 0.35); background: rgba(255, 210, 63, 0.07); }

.player-card.is-host::after {
  content: '♛';
  position: absolute;
  top: -9px;
  right: 8px;
  font-size: 0.95rem;
  color: var(--yellow);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.player-card.is-offline { opacity: 0.45; }

.player-card__info { min-width: 0; flex: 1; }

.player-card__name {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-card__meta { color: var(--muted); font-size: 0.74rem; }

.player-card__kick {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 0;
  background: rgba(255, 93, 93, 0.18);
  color: #ff9d9d;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.player-card:hover .player-card__kick { opacity: 1; }

/* Avatares SVG */

.avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.avatar svg { display: block; width: 100%; height: 100%; }

/* Ajustes */

.settings-panel { padding: 20px; }
.settings-panel .hint { margin-bottom: 16px; }

.setting { margin-bottom: 17px; }

.setting__label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 8px;
  gap: 10px;
}

.setting__label output {
  color: var(--yellow);
  font-weight: 700;
  background: rgba(255, 210, 63, 0.1);
  padding: 2px 9px;
  border-radius: 7px;
  font-size: 0.8rem;
  min-width: 38px;
  text-align: center;
}

.setting__title { display: block; font-size: 0.85rem; margin-bottom: 8px; }

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 210, 63, 0.9), rgba(255, 210, 63, 0.25));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--yellow);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  transition: transform 0.12s ease;
}

input[type='range']::-webkit-slider-thumb:hover { transform: scale(1.1); }

input[type='range']::-moz-range-track {
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 210, 63, 0.9), rgba(255, 210, 63, 0.25));
}

input[type='range']::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--yellow);
}

.settings-panel.is-locked input[type='range'] { pointer-events: none; opacity: 0.5; }
.settings-panel.is-locked .seg { opacity: 0.55; pointer-events: none; }

.share-panel { padding: 20px; }

.share-code {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  text-align: center;
  color: var(--yellow);
  padding: 8px 0 12px;
}

.share-link {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 10px;
}

/* Chat */

.chat-panel { padding: 20px; display: flex; flex-direction: column; min-height: 210px; }

.chat__messages {
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  flex: 1;
  max-height: 190px;
  padding-right: 4px;
  margin-bottom: 12px;
  scroll-behavior: smooth;
}

.chat-msg {
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--text);
  animation: chatIn 0.22s ease both;
  overflow-wrap: anywhere;
}

.chat-msg__name { font-weight: 700; margin-right: 6px; }
.chat-msg--system { color: var(--muted); font-size: 0.79rem; font-style: italic; }
.chat-msg--system b { color: var(--text); font-style: normal; }
.chat-msg--bomba { color: #ffc9a3; }

.chat__form { display: flex; gap: 8px; }
.chat__form input { flex: 1; padding: 9px 13px; font-size: 0.88rem; }

@keyframes chatIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

/* =============================== PARTIDA ============================ */

.game {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 16px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 14px 20px 22px;
  min-height: 0;
}

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 520px;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background:
    radial-gradient(80% 70% at 50% 45%, rgba(255, 210, 63, 0.05), transparent 70%),
    rgba(15, 12, 28, 0.35);
  overflow: hidden;
  isolation: isolate;
}

.stage::before {
  content: '';
  position: absolute;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.06);
  animation: slowSpin 90s linear infinite;
  pointer-events: none;
}

.ring {
  position: absolute;
  inset: 0;
  --r: 250px;
  pointer-events: none;
}

.ring-player {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 132px;
  transform:
    translate(-50%, -50%)
    rotate(var(--a, 0deg))
    translate(var(--r))
    rotate(calc(-1 * var(--a, 0deg)));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border-radius: 14px;
  background: rgba(20, 16, 36, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  transition: background 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease,
    transform 0.35s cubic-bezier(0.22, 1.2, 0.4, 1), opacity 0.4s ease, filter 0.5s ease;
  pointer-events: auto;
  animation: ringPop 0.45s cubic-bezier(0.22, 1.3, 0.4, 1) both;
}

.ring-player .avatar { width: 46px; height: 46px; }

.ring-player__name {
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.ring-player__hearts { display: flex; gap: 2px; align-items: center; min-height: 12px; }

.ring-player__status {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.ring-player.is-turn {
  background: linear-gradient(180deg, rgba(255, 210, 63, 0.22), rgba(255, 210, 63, 0.08));
  border-color: rgba(255, 210, 63, 0.75);
  box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.14), 0 0 34px rgba(255, 210, 63, 0.28),
    0 12px 28px rgba(0, 0, 0, 0.4);
}

.ring-player.is-turn .avatar {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2), 0 0 0 3px rgba(255, 210, 63, 0.7);
  animation: turnPulse 1.6s ease-in-out infinite;
}

.ring-player.is-me .ring-player__name { color: var(--yellow); }

.ring-player.is-offline { opacity: 0.5; }

.ring-player.is-out {
  filter: grayscale(1) brightness(0.6);
  opacity: 0.5;
  transform:
    translate(-50%, -50%)
    rotate(var(--a, 0deg))
    translate(var(--r))
    rotate(calc(-1 * var(--a, 0deg)))
    scale(0.92);
}

.ring-player.is-out::after {
  content: 'ELIMINADO';
  position: absolute;
  top: 50%;
  left: 50%;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(180, 30, 40, 0.92);
  color: #fff;
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-8deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: stampIn 0.4s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

/* Corazones */

.heart { display: inline-block; width: 13px; height: 13px; line-height: 1; }
.heart svg { display: block; width: 100%; height: 100%; }
.heart.is-empty { opacity: 0.22; }
.heart.is-new { animation: heartIn 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
.heart.is-lost { animation: heartOut 0.55s ease-in both; }

/* Núcleo: tarjeta + bomba */

.core {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-bottom: 4px;
}

.prompt-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 26px 14px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fff6d6 0%, #ffe89a 45%, #f7c94b 100%);
  border: 3px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 10px 0 rgba(150, 98, 12, 0.55), 0 22px 44px rgba(0, 0, 0, 0.45);
  transform: rotate(-1.6deg);
  transition: transform 0.2s ease;
}

.prompt-label {
  font-size: 0.62rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #8a6a10;
  font-weight: 600;
}

.prompt {
  font-size: clamp(2.4rem, 7vw, 4.2rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-indent: 0.1em;
  line-height: 1.05;
  color: #2b1c00;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.55);
}

.prompt span {
  display: inline-block;
  animation: letterPop 0.34s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

.prompt-card.is-new { animation: promptIn 0.45s cubic-bezier(0.22, 1.4, 0.4, 1) both; }

/* Bomba */

.bomb {
  position: relative;
  width: 178px;
  height: 178px;
  display: grid;
  place-items: center;
  animation: bob 3.6s ease-in-out infinite;
}

.bomb__body {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #55536f 0%, #2b2940 38%, #17151f 78%, #0d0c12 100%);
  box-shadow: inset -8px -12px 24px rgba(0, 0, 0, 0.75),
    inset 8px 8px 18px rgba(255, 255, 255, 0.06),
    0 18px 34px rgba(0, 0, 0, 0.55);
  z-index: 2;
}

.bomb__shine {
  position: absolute;
  top: 16%;
  left: 20%;
  width: 32%;
  height: 22%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  filter: blur(5px);
  transform: rotate(-24deg);
}

.bomb__cap {
  position: absolute;
  top: -10px;
  left: 50%;
  width: 40px;
  height: 22px;
  margin-left: -20px;
  border-radius: 7px 7px 4px 4px;
  background: linear-gradient(180deg, #ffe066, #e8a413);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
  transform: rotate(-6deg);
}

.bomb__fuse {
  position: absolute;
  top: 6px;
  left: 62%;
  width: 52px;
  height: 40px;
  border-right: 6px solid #8a6a3a;
  border-top: 6px solid #8a6a3a;
  border-radius: 0 26px 0 0;
  transform: rotate(-18deg);
  z-index: 1;
}

.bomb__spark {
  position: absolute;
  top: -4px;
  right: -5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffd23f 40%, #ff7b1c 70%, transparent 72%);
  box-shadow: 0 0 16px 6px rgba(255, 180, 60, 0.45);
  animation: spark 0.34s steps(2, end) infinite;
}

.bomb__timer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  padding-top: 60px;
  gap: 3px;
  z-index: 3;
  color: #fff;
  font-weight: 700;
  font-size: 2.1rem;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.75);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.bomb__timer small { font-size: 0.9rem; opacity: 0.6; font-weight: 500; }

.bomb__ring {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 4;
  pointer-events: none;
}

.bomb__ring svg { transform: rotate(-90deg); }

.bomb__ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 7;
}

.bomb__ring-fill {
  fill: none;
  stroke: var(--yellow);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 345.6;
  stroke-dashoffset: 0;
  transition: stroke 0.3s ease, stroke-dashoffset 0.12s linear;
  filter: drop-shadow(0 0 6px rgba(255, 210, 63, 0.55));
}

.bomb.is-hot .bomb__ring-fill { stroke: #ff9e3d; }
.bomb.is-critical .bomb__ring-fill { stroke: var(--red); filter: drop-shadow(0 0 8px rgba(255, 80, 80, 0.8)); }

.bomb.is-hot { animation: bob 3.6s ease-in-out infinite, tremble 0.5s ease-in-out infinite; }
.bomb.is-critical { animation: bob 3.6s ease-in-out infinite, tremble 0.22s ease-in-out infinite; }

.bomb.is-exploding { animation: explode 0.7s ease-out both; }

/* Formulario de palabra */

.word-form {
  position: relative;
  z-index: 4;
  display: flex;
  gap: 10px;
  width: min(600px, 88%);
  margin-top: 4px;
}

.word-form input {
  flex: 1;
  height: 58px;
  padding: 0 20px;
  border-radius: 16px;
  font-size: 1.22rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: rgba(12, 9, 24, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.45);
}

.word-form input:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 4px rgba(255, 210, 63, 0.14), inset 0 2px 10px rgba(0, 0, 0, 0.4);
}

.word-form input:disabled { opacity: 0.55; }

.word-form.is-shaking { animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
.word-form.is-good input { border-color: rgba(69, 224, 140, 0.85); box-shadow: 0 0 0 4px rgba(69, 224, 140, 0.16); }

.word-hint {
  position: relative;
  z-index: 4;
  font-size: 0.76rem;
  color: var(--muted);
}

kbd {
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-family: inherit;
  font-size: 0.72rem;
}

/* Panel lateral */

.game__side { display: flex; flex-direction: column; gap: 14px; min-height: 0; }

.alphabet-panel { padding: 18px; }

.alphabet {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.letter {
  position: relative;
  display: grid;
  place-items: center;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-weight: 700;
  font-size: 1rem;
  text-transform: uppercase;
  color: rgba(244, 241, 255, 0.82);
  transition: transform 0.18s ease, background 0.24s ease, color 0.24s ease,
    border-color 0.24s ease;
}

.letter.is-used {
  background: rgba(69, 224, 140, 0.14);
  border-color: rgba(69, 224, 140, 0.35);
  color: var(--green);
  animation: letterFlip 0.42s cubic-bezier(0.22, 1.4, 0.4, 1) both;
}

.letter.is-used::after {
  content: '';
  position: absolute;
  left: 18%;
  right: 18%;
  top: 50%;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.55;
  animation: strike 0.3s ease-out 0.1s both;
}

.letter.is-fresh {
  animation: letterNew 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  box-shadow: 0 0 0 2px rgba(255, 210, 63, 0.55), 0 0 18px rgba(255, 210, 63, 0.3);
}

.alphabet.is-new { animation: alphabetPulse 0.9s ease both; }

.lives-panel { padding: 16px 18px; overflow-y: auto; }

.lives-list { display: flex; flex-direction: column; gap: 7px; }

.lives-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.lives-row .avatar { width: 26px; height: 26px; }

.lives-row__name {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lives-row.is-turn { background: rgba(255, 210, 63, 0.12); }
.lives-row.is-out { opacity: 0.4; }

.lives-row__words {
  font-size: 0.7rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Chat flotante en partida */

.chat-dock {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 300px;
  max-height: 340px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: rgba(20, 16, 36, 0.95);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.4, 1), opacity 0.24s ease;
}

.chat-dock.is-collapsed {
  transform: translateY(calc(100% + 30px)) scale(0.96);
  opacity: 0;
  pointer-events: none;
}

.chat-dock__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}

.chat-dock .chat__messages { max-height: 210px; padding: 10px 12px 0; margin-bottom: 8px; }
.chat-dock .chat__form { padding: 0 10px 10px; }

/* Resultados */

.results {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 4, 14, 0.72);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease both;
}

.results[hidden] { display: none; }

.results__card {
  position: relative;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 30px 30px 24px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(41, 33, 72, 0.98), rgba(24, 19, 44, 0.99));
  border: 1px solid rgba(255, 210, 63, 0.28);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  text-align: center;
  animation: resultsIn 0.5s cubic-bezier(0.22, 1.3, 0.4, 1) both;
}

.results__trophy {
  font-size: 3.4rem;
  line-height: 1;
  animation: trophyBounce 1.2s cubic-bezier(0.22, 1.4, 0.4, 1) both;
  filter: drop-shadow(0 10px 18px rgba(255, 190, 40, 0.35));
}

.results__eyebrow {
  margin-top: 10px;
  font-size: 0.74rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.results__title {
  margin-top: 6px;
  font-size: clamp(1.7rem, 5vw, 2.3rem);
  font-weight: 700;
  color: var(--yellow);
  text-shadow: 0 3px 0 rgba(120, 80, 10, 0.6);
}

.results__sub { color: var(--muted); font-size: 0.9rem; margin-top: 6px; }

.ranking {
  list-style: none;
  padding: 0;
  margin: 20px 0 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
}

.ranking li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  animation: rankIn 0.4s cubic-bezier(0.22, 1.2, 0.4, 1) both;
}

.ranking li.is-winner { background: rgba(255, 210, 63, 0.14); border: 1px solid rgba(255, 210, 63, 0.3); }

.ranking__pos { width: 22px; font-weight: 700; color: var(--muted); font-size: 0.85rem; }
.ranking__name { flex: 1; font-weight: 600; font-size: 0.9rem; }
.ranking__meta { color: var(--muted); font-size: 0.78rem; }

.results__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.results .hint { margin-top: 12px; }

/* Efectos */

.fx-layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }

.fx-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 48%, rgba(255, 245, 210, 0.95), rgba(255, 180, 40, 0.55) 34%, transparent 68%);
  animation: flash 0.5s ease-out both;
}

.fx-ring {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  border: 5px solid rgba(255, 210, 63, 0.85);
  animation: shockwave 0.7s ease-out both;
}

.fx-float {
  position: absolute;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.65);
  animation: floatUp 1.1s cubic-bezier(0.22, 1, 0.4, 1) both;
  white-space: nowrap;
}

.fx-float--bad { color: #ff8b8b; }
.fx-float--good { color: #7dffb4; }

canvas.confetti-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.stage.is-shaking { animation: stageShake 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }

body.is-exploding .stage::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 120, 40, 0.14);
  animation: fadeOut 0.5s ease-out both;
  pointer-events: none;
}

/* ============================= ANIMACIONES ========================== */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes slowSpin { to { transform: rotate(360deg); } }

@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.16); }
  50% { box-shadow: 0 0 0 7px rgba(255, 210, 63, 0.06); }
}

@keyframes cardPop {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

@keyframes ringPop {
  from { opacity: 0; scale: 0.85; }
  to { opacity: 1; scale: 1; }
}

@keyframes turnPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes stampIn {
  from { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(1.6); }
  to { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
}

@keyframes letterPop {
  from { opacity: 0; transform: translateY(12px) scale(0.6); }
  to { opacity: 1; transform: none; }
}

@keyframes promptIn {
  0% { opacity: 0; transform: rotate(-1.6deg) scale(0.7); }
  60% { opacity: 1; transform: rotate(-1.6deg) scale(1.06); }
  100% { transform: rotate(-1.6deg) scale(1); }
}

@keyframes spark {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.75; }
  100% { transform: scale(0.9); opacity: 1; }
}

@keyframes tremble {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-1.5px, 1px); }
  50% { transform: translate(1.5px, -1px); }
  75% { transform: translate(-1px, -1.5px); }
}

@keyframes explode {
  0% { transform: scale(1); filter: brightness(1); }
  18% { transform: scale(1.22); filter: brightness(2.4); }
  100% { transform: scale(0.7); opacity: 0; filter: brightness(3); }
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

@keyframes stageShake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  15% { transform: translate(-5px, 4px) rotate(-0.4deg); }
  30% { transform: translate(6px, -5px) rotate(0.5deg); }
  45% { transform: translate(-4px, 3px) rotate(-0.3deg); }
  60% { transform: translate(3px, -2px) rotate(0.2deg); }
  80% { transform: translate(-2px, 1px) rotate(0); }
}

@keyframes flash {
  0% { opacity: 0; }
  12% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes shockwave {
  0% { transform: scale(0.4); opacity: 1; border-width: 8px; }
  100% { transform: scale(22); opacity: 0; border-width: 1px; }
}

@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(0.8); }
  18% { opacity: 1; transform: translate(-50%, -6px) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -54px) scale(0.95); }
}

@keyframes heartIn {
  0% { transform: scale(0.2) rotate(-25deg); opacity: 0; }
  60% { transform: scale(1.3) rotate(6deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

@keyframes heartOut {
  0% { transform: scale(1); opacity: 1; filter: brightness(1); }
  35% { transform: scale(1.4); opacity: 1; filter: brightness(2); }
  100% { transform: scale(0.5) translateY(-6px); opacity: 0.25; filter: grayscale(1); }
}

@keyframes letterFlip {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(-72deg) scale(0.94); }
  100% { transform: rotateX(0); }
}

@keyframes letterNew {
  0% { transform: scale(0.5); opacity: 0; }
  55% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes strike {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes alphabetPulse {
  0% { box-shadow: 0 0 0 0 rgba(69, 224, 140, 0.45); }
  60% { box-shadow: 0 0 0 14px rgba(69, 224, 140, 0); }
  100% { box-shadow: 0 0 0 0 rgba(69, 224, 140, 0); }
}

@keyframes resultsIn {
  from { opacity: 0; transform: translateY(26px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

@keyframes trophyBounce {
  0% { transform: translateY(-40px) scale(0.6); opacity: 0; }
  55% { transform: translateY(6px) scale(1.08); opacity: 1; }
  75% { transform: translateY(-4px) scale(0.98); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes rankIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: none; }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: none; }
}

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

@media (max-width: 1080px) {
  .game { grid-template-columns: minmax(0, 1fr) 250px; }
  .alphabet { grid-template-columns: repeat(5, 1fr); }
  .ring { --r: 210px; }
  .ring-player { width: 116px; }
}

@media (max-width: 900px) {
  .home__actions { grid-template-columns: 1fr; }
  .lobby { grid-template-columns: 1fr; }
  .lobby__side { flex-direction: row; flex-wrap: wrap; }
  .lobby__side > .panel { flex: 1 1 260px; }
  .game { grid-template-columns: 1fr; }
  .game__side { flex-direction: row; }
  .game__side > .panel { flex: 1 1 0; }
  .lives-panel { display: none; }
  .chat-dock { display: none; }
  .room-title { display: none; }
  .turn-indicator { font-size: 0.8rem; padding: 6px 12px; }
  .prompt { font-size: clamp(2rem, 7vw, 3.2rem); }
}

@media (max-width: 780px) {
  body { overflow-y: auto; }
  .screen { position: relative; min-height: 100dvh; }
  .stage { min-height: auto; padding: 14px 10px 20px; }
  .stage::before { display: none; }
  .ring {
    position: static;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px;
    padding: 0 6px;
    margin-bottom: 8px;
    order: -1;
  }
  .ring-player {
    position: static;
    transform: none !important;
    width: auto;
    flex-direction: row;
    padding: 5px 9px;
    gap: 7px;
    animation: none;
  }
  .ring-player.is-out { opacity: 0.45; }
  .ring-player.is-out::after { display: none; }
  .ring-player .avatar { width: 30px; height: 30px; }
  .ring-player__name { font-size: 0.72rem; max-width: 74px; }
  .ring-player__hearts { display: none; }
  .ring-player__status { display: none; }
  .core { gap: 6px; }
  .bomb { width: 138px; height: 138px; }
  .bomb__body { width: 104px; height: 104px; }
  .bomb__timer { font-size: 1.6rem; padding-top: 46px; }
  .bomb__ring svg { width: 138px; height: 138px; }
  .prompt-card { padding: 8px 18px 10px; }
  .word-form { width: 100%; }
  .word-form input { height: 52px; font-size: 1.05rem; }
  .word-form .btn { padding: 0 16px; }
  .game__side { flex-direction: column; }
  .alphabet { grid-template-columns: repeat(9, 1fr); gap: 5px; }
  .letter { height: 33px; font-size: 0.88rem; border-radius: 9px; }
  .home { padding: 26px 16px; }
  .home__footer { justify-content: center; text-align: center; }
  .toasts { left: 12px; right: 12px; max-width: none; }
}

@media (max-width: 520px) {
  .topbar { padding: 9px 12px; gap: 8px; }
  .topbar__left .btn { display: none; }
  .room-title { display: none; }
  .lobby { padding: 14px 12px; }
  .panel--create, .panel--join { padding: 18px; }
  .brand-title { font-size: 2.5rem; }
  .home__actions { gap: 14px; }
  .word-form .btn { font-size: 0.85rem; }
  .word-hint { text-align: center; font-size: 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------- Extras de interfaz ----------------------- */

.sound-popover {
  position: fixed;
  z-index: 95;
  width: 244px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(28, 22, 48, 0.98);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: none;
  animation: popIn 0.18s ease both;
}

.sound-popover.is-open { display: block; }

.sound-popover__row { display: flex; align-items: center; gap: 10px; }
.sound-popover__row input[type='range'] { flex: 1; }

.sound-popover__value {
  font-size: 0.78rem;
  color: var(--yellow);
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sound-popover__mute {
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.sound-popover__mute.is-on { background: rgba(255, 93, 93, 0.18); border-color: rgba(255, 93, 93, 0.35); }
.sound-popover__hint { margin-top: 8px; font-size: 0.72rem; color: var(--muted); }

.ring.is-dense .ring-player { width: 106px; padding: 6px 4px; }
.ring.is-dense .ring-player .avatar { width: 38px; height: 38px; }
.ring.is-dense .ring-player__name { font-size: 0.72rem; max-width: 96px; }

@media (max-width: 780px) {
  .ring.is-dense .ring-player { width: auto; }
}

/* El atributo hidden debe ganar siempre a los display de los componentes. */
[hidden] { display: none !important; }

/* Altura controlada del tablero para ventanas muy altas o muy bajas. */
@media (min-width: 781px) {
  .game { align-content: center; }
  .stage { height: clamp(540px, 74dvh, 800px); }
}

.brand-title span { margin-left: 0.05em; }

/* =====================================================================
   Tablero: jugadores en fila inferior
   Un anillo queda bonito con pocos jugadores, pero se solapa con la
   tarjeta de letras y el campo de texto en pantallas bajas. La fila
   inferior es estable de 2 a 16 jugadores y se parece más a la referencia.
   ===================================================================== */

.stage { height: auto; min-height: clamp(540px, 74dvh, 820px); justify-content: center; gap: 12px; }

.ring {
  position: static;
  order: 5;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 14px 6px;
  pointer-events: auto;
}

.ring-player {
  position: static;
  transform: none !important;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  column-gap: 8px;
  row-gap: 1px;
  align-items: center;
  width: auto;
  min-width: 108px;
  max-width: 190px;
  padding: 6px 13px 6px 6px;
  border-radius: 12px;
  animation: cardPop 0.3s cubic-bezier(0.22, 1.2, 0.4, 1) both;
}

.ring-player .avatar { width: 36px; height: 36px; grid-row: 1 / span 2; }
.ring-player__name { grid-column: 2; text-align: left; max-width: none; font-size: 0.79rem; }
.ring-player__hearts { grid-column: 2; min-height: 11px; gap: 1px; }
.ring-player__hearts .heart { width: 11px; height: 11px; }
.ring-player__status { display: none; }

.ring-player.is-turn { background: linear-gradient(180deg, rgba(255, 210, 63, 0.26), rgba(255, 210, 63, 0.1)); }

.ring-player.is-out { transform: none !important; opacity: 0.42; filter: grayscale(1) brightness(0.8); }

.ring-player.is-out::after {
  content: 'ELIMINADO';
  font-size: 0.48rem;
  padding: 2px 5px;
  top: 6px;
  left: auto;
  right: 8px;
  transform: rotate(-4deg);
  animation: fadeIn 0.3s ease both;
}

.ring.is-dense .ring-player { width: auto; padding: 5px 10px 5px 5px; grid-template-columns: 28px minmax(0, 1fr); }
.ring.is-dense .ring-player .avatar { width: 28px; height: 28px; }
.ring.is-dense .ring-player__name { font-size: 0.72rem; }

/* Letras sin usar un poco más legibles */
.letter { color: rgba(244, 241, 255, 0.6); background: rgba(255, 255, 255, 0.055); }

.core { order: 1; }
.word-form { order: 2; }
.word-hint { order: 3; }

@media (max-width: 780px) {
  .stage { min-height: auto; }
  .ring { order: -1; margin-bottom: 6px; }
  .ring-player { max-width: 150px; }
}

/* Ajustes finos de móvil: barra superior compacta y vidas visibles. */
@media (max-width: 780px) {
  .ring-player__hearts { display: flex; }
}

@media (max-width: 560px) {
  .round-chip { display: none; }
  .turn-indicator { white-space: nowrap; font-size: 0.75rem; padding: 5px 10px; }
  .topbar__left { flex: 0 0 auto; }
  .topbar__right { flex: 0 0 auto; gap: 6px; }
  .topbar__center { flex: 1; justify-content: flex-end; }
  .room-code--sm { font-size: 0.8rem; padding: 5px 9px; letter-spacing: 0.14em; }
  .word-form input { font-size: 1rem; padding: 0 14px; }
}

/* Instrucciones */
.modal__card--help { width: min(94vw, 560px); text-align: left; gap: 14px; }
.modal__card--help h2 { text-align: center; }

.rules {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #d9d4ee;
  font-size: 0.9rem;
  line-height: 1.5;
}

.rules li {
  position: relative;
  padding-left: 22px;
}

.rules li::before {
  content: '💣';
  position: absolute;
  left: 0;
  top: 0;
  font-size: 0.78rem;
}

.rules strong { color: var(--text); }
.rules em { color: var(--yellow); font-style: normal; }

button.muted-link {
  background: none;
  border: 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.18);
  padding: 0 0 1px;
  cursor: pointer;
  font-size: 0.82rem;
}

button.muted-link:hover { color: var(--text); }
