:root {
  --bg-top: #14092d;
  --bg-mid: #1d1145;
  --bg-bot: #0d1638;
  --surface: rgba(30, 22, 66, 0.85);
  --surface-2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --muted: #c4b5fd;
  --primary: #6366f1;
  --accent: #10b981;
  --pink: #ec4899;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 22px;
  --font-display: "Fredoka", system-ui, -apple-system, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, sans-serif;
}

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

html {
  background-color: #0f172a;
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 15% 10%, rgba(236, 72, 153, 0.22), transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(56, 189, 248, 0.2), transparent 40%),
    radial-gradient(circle at 50% 85%, rgba(139, 92, 246, 0.22), transparent 45%),
    linear-gradient(165deg, var(--bg-top) 0%, var(--bg-mid) 50%, var(--bg-bot) 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

input, textarea, .room-code {
  user-select: text;
  -webkit-user-select: text;
}

#app {
  width: 100%;
  max-width: 480px;
  padding: 1rem 1rem 2.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hidden {
  display: none !important;
}

h1, h2, h3, .brand, .room-code, .game-title, .secret-word, .btn {
  font-family: var(--font-display);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.25rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.brand {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
  background: linear-gradient(90deg, #fff, #c4b5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hero {
  text-align: center;
  padding: 0.65rem 0 0.2rem;
}

.hero h1 {
  margin: 0 0 0.35rem;
  font-size: 2.1rem;
  font-weight: 700;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.card {
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: 0 12px 28px rgba(5, 3, 20, 0.38);
}

/* Tarjetas de colores reutilizables para juegos y secciones */
.card-purple {
  background: linear-gradient(145deg, rgba(109, 40, 217, 0.42), rgba(49, 46, 129, 0.65));
  border-color: rgba(167, 139, 250, 0.45);
}

.card-pink {
  background: linear-gradient(145deg, rgba(219, 39, 119, 0.38), rgba(88, 28, 135, 0.6));
  border-color: rgba(244, 114, 182, 0.45);
}

.card-blue {
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.38), rgba(30, 58, 138, 0.6));
  border-color: rgba(96, 165, 250, 0.45);
}

.card-green {
  background: linear-gradient(145deg, rgba(5, 150, 105, 0.38), rgba(6, 78, 59, 0.6));
  border-color: rgba(52, 211, 153, 0.45);
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  font-weight: 600;
}

.label {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
  font-weight: 800;
}

.input, .select {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: rgba(10, 7, 28, 0.65);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  outline: none;
}

.input:focus, .select:focus {
  border-color: #a78bfa;
}

.input-code {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.22em;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
}

.divider {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  margin: 0.1rem 0;
}

.btn {
  border: none;
  border-bottom: 4px solid rgba(0, 0, 0, 0.28);
  border-radius: 16px;
  padding: 0.85rem 1.25rem;
  font-size: 1.02rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-lg {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
}

.btn-sm {
  padding: 0.55rem 0.9rem;
  font-size: 0.88rem;
  border-radius: 12px;
}

.btn-primary { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.btn-accent { background: linear-gradient(135deg, #10b981, #059669); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); }
.btn-secondary { background: rgba(255, 255, 255, 0.12); border: 1.5px solid var(--border); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.28); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.42rem 0.8rem;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.toast {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  padding: 0.8rem 1rem;
  border-radius: 14px;
  font-weight: 800;
  text-align: center;
  font-size: 0.95rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.toast.info {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.room-banner {
  text-align: center;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.28), rgba(109, 40, 217, 0.45));
  border-color: rgba(147, 197, 253, 0.4);
}

.room-code-label {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  color: #ddd6fe;
  font-weight: 800;
}

.room-code {
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  margin: 0.2rem 0 0.75rem;
  color: #38bdf8;
  text-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}

.room-actions {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
}

.qr-container {
  margin-top: 1rem;
}

.qr-container img {
  width: 180px;
  height: 180px;
  border-radius: 16px;
  background: #fff;
  padding: 8px;
}

.player-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  padding: 0.7rem 0.95rem;
  border-radius: 14px;
  font-weight: 800;
}

.player-item.offline {
  opacity: 0.5;
}

.badge {
  font-size: 0.76rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-weight: 800;
}

.badge-host { background: rgba(251, 191, 36, 0.22); color: #fde68a; }
.badge-impostor { background: rgba(239, 68, 68, 0.24); color: #fca5a5; }
.badge-civil { background: rgba(16, 185, 129, 0.24); color: #6ee7b7; }

.score-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.28rem;
}

.game-card {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.game-title {
  font-size: 1.28rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.game-desc {
  color: #e9d5ff;
  font-size: 0.92rem;
  line-height: 1.45;
  font-weight: 600;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.section-title {
  margin: 0.25rem 0 0;
  font-size: 1.15rem;
  color: #e9d5ff;
  padding-left: 0.25rem;
}

.option-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: #ddd6fe;
  font-weight: 800;
}

.status-pill {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 700;
}

.status-pill strong {
  color: var(--text);
}

.secret-card {
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.45), rgba(30, 27, 75, 0.85));
  border: 2px solid #38bdf8;
  border-radius: var(--radius);
  padding: 1.35rem;
  text-align: center;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 12px 28px rgba(14, 165, 233, 0.22);
}

.secret-card.impostor:not(.is-hidden) {
  border-color: #fb7185;
  background: linear-gradient(145deg, rgba(225, 29, 72, 0.45), rgba(69, 10, 26, 0.85));
  box-shadow: 0 12px 28px rgba(244, 63, 94, 0.24);
}

.secret-hint {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #ddd6fe;
  font-weight: 800;
  margin-bottom: 0.6rem;
}

.role-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.28rem 0.8rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.22);
  color: #7dd3fc;
  margin-bottom: 0.5rem;
}

.secret-card.impostor .role-badge {
  background: rgba(251, 113, 133, 0.25);
  color: #fecdd3;
}

.secret-word {
  font-size: 2rem;
  font-weight: 700;
  margin: 0.2rem 0;
}

.secret-sub {
  font-size: 0.9rem;
  color: #e2e8f0;
  font-weight: 600;
}

.secret-hidden {
  padding: 1.2rem 0;
  font-weight: 800;
  color: var(--muted);
}

.secret-hidden span {
  font-weight: 600;
  font-size: 0.85rem;
}

.vote-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.vote-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.vote-btn.selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.22);
}

.vote-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.words-reveal {
  background: var(--surface-2);
  padding: 0.8rem;
  border-radius: 14px;
  margin-bottom: 1rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.center { text-align: center; }
.muted { color: var(--muted); font-size: 0.92rem; font-weight: 600; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 4, 24, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(160deg, #1e1545, #120b2e);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.55);
}

.modal-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}

.modal-card p {
  margin: 0 0 1.2rem;
  line-height: 1.45;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

/* ¿Qué prefieres? */
.qp-options {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.qp-choice {
  width: 100%;
  padding: 1.25rem 1rem;
  border-radius: 18px;
  border: 2px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: center;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}

.qp-choice:active {
  transform: scale(0.98);
}

.qp-a {
  border-color: rgba(56, 189, 248, 0.55);
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.25), rgba(30, 58, 138, 0.35));
}

.qp-b {
  border-color: rgba(244, 114, 182, 0.55);
  background: linear-gradient(145deg, rgba(219, 39, 119, 0.25), rgba(131, 24, 67, 0.35));
}

.qp-a.selected {
  border-color: #38bdf8;
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.55), rgba(30, 58, 138, 0.65));
}

.qp-b.selected {
  border-color: #f472b6;
  background: linear-gradient(145deg, rgba(219, 39, 119, 0.55), rgba(131, 24, 67, 0.65));
}

.qp-tag {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #ddd6fe;
}

.qp-text {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.35;
}

.qp-vs {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
}

.qp-result-box {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 0.85rem;
}

.qp-res-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.92rem;
  margin-bottom: 0.45rem;
}

.qp-bar-track {
  height: 12px;
  background: rgba(10, 7, 28, 0.65);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.45rem;
}

.qp-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}

.qp-bar-a { background: linear-gradient(90deg, #3b82f6, #38bdf8); }
.qp-bar-b { background: linear-gradient(90deg, #ec4899, #f472b6); }

.qp-names {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 700;
}

.qp-losers-banner {
  margin: 0.9rem 0 0;
  padding: 0.75rem 0.95rem;
  border-radius: 14px;
  background: rgba(239, 68, 68, 0.22);
  border: 1.5px solid rgba(248, 113, 113, 0.45);
  color: #fecaca;
  text-align: center;
  font-weight: 800;
  font-size: 0.94rem;
}

.qp-losers-banner.tied {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.45);
  color: #bae6fd;
}

/* Desplegable de jugadores y cuadrícula de juegos */
.accordion-btn {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  cursor: pointer;
}

.chevron {
  font-size: 1.1rem;
  transition: transform 0.2s ease;
}

.chevron.open {
  transform: rotate(180deg);
}

.games-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.game-tile {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  text-align: center;
  cursor: pointer;
  color: var(--text);
  padding: 1rem;
  transition: transform 0.1s ease;
}

.game-tile:active {
  transform: scale(0.97);
}

.tile-icon {
  font-size: 2.8rem;
  line-height: 1;
}

.tile-title {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.2;
}

.back-btn {
  align-self: flex-start;
}

.host-only-banner {
  background: rgba(251, 191, 36, 0.16);
  border: 1.5px solid rgba(251, 191, 36, 0.45);
  color: #fde68a;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  font-weight: 800;
  font-size: 0.95rem;
  text-align: center;
  margin: 0;
}

/* La Bomba */
.bomba-topic {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  margin: 0.75rem 0 0.25rem;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.25);
}

.bomba-stage {
  overflow: visible;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, rgba(37, 99, 235, 0.42), rgba(30, 58, 138, 0.7));
  border-color: rgba(96, 165, 250, 0.45);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.bomba-stage.is-holder {
  border: none;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
  padding-bottom: 2.5rem;
  flex: 1;
}

body.bomba-fullscreen-holder {
  background: linear-gradient(170deg, #f97316 0%, #ea580c 45%, #dc2626 100%);
}

body.bomba-fullscreen-holder .topbar {
  display: none;
}

body.bomba-fullscreen-holder #app {
  min-height: 100dvh;
  padding-top: 0.85rem;
  padding-bottom: 1rem;
  gap: 0.65rem;
}

body.bomba-fullscreen-holder #screen-la-bomba,
body.bomba-fullscreen-holder #bomba-phase-ticking {
  flex: 1;
  display: flex;
  flex-direction: column;
}

body.bomba-fullscreen-holder .bomba-stage.is-holder {
  flex: 1;
  padding-top: 0.5rem;
  padding-bottom: 0;
}

body.bomba-fullscreen-holder .bomba-emoji {
  font-size: 5rem;
  margin: 0.1rem 0 0.4rem;
}

body.bomba-fullscreen-holder .bomba-return-btn {
  margin-top: auto;
}

body.bomba-fullscreen-holder .status-pill,
body.bomba-fullscreen-holder .card-blue {
  background: rgba(0, 0, 0, 0.18);
  border-color: rgba(255, 255, 255, 0.25);
}

.bomba-emoji {
  font-size: 6.2rem;
  line-height: 1;
  margin: 0.25rem 0 0.75rem;
  display: inline-block;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
}

.bomba-emoji.drop-in {
  animation: bombDropIn 0.42s cubic-bezier(0.22, 1.28, 0.36, 1) forwards,
             bombPulse 0.9s ease-in-out 0.42s infinite;
}

.bomba-emoji.pass-right {
  animation: bombPassRight 0.28s ease-in forwards;
}

.bomba-emoji.waiting {
  opacity: 0.7;
  animation: bombPulse 1.4s ease-in-out infinite;
}

.bomba-pass-btn {
  margin-top: 0.75rem;
  padding: 1.25rem;
  font-size: 1.25rem;
  background: #ffffff;
  color: #dc2626;
  border-bottom: 4px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.28);
}

.bomba-return-btn {
  margin-top: 2.5rem;
  width: 100%;
  background: rgba(0, 0, 0, 0.28);
  border-color: rgba(255, 255, 255, 0.35);
}

.bomba-exploded-card {
  border-color: #fb7185;
  background: linear-gradient(145deg, rgba(220, 38, 38, 0.45), rgba(69, 10, 26, 0.8));
}

.bomba-boom-icon {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 0.35rem;
}

@keyframes bombDropIn {
  0% {
    transform: translateY(-130px) scale(0.7);
    opacity: 0;
  }
  70% {
    transform: translateY(10px) scale(1.08);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes bombPassRight {
  0% {
    transform: translateX(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateX(220px) rotate(28deg) scale(0.75);
    opacity: 0;
  }
}

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

/* Botones de administración (anfitrión) y resultados Quiplash */
.btn-admin {
  background: rgba(245, 158, 11, 0.12);
  color: #fcd34d;
  border: 1px dashed rgba(245, 158, 11, 0.45);
  font-size: 0.88rem;
  padding: 0.65rem 1rem;
  margin-top: auto;
  width: 100%;
}

.btn-admin:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.22);
  border-color: rgba(251, 191, 36, 0.75);
}

.badge-neutral {
  background: rgba(148, 163, 184, 0.16);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.28);
}

.quip-entry-winner {
  border-color: rgba(250, 204, 21, 0.75);
  background: linear-gradient(145deg, rgba(234, 179, 8, 0.18), rgba(16, 185, 129, 0.14));
  box-shadow: 0 8px 24px rgba(234, 179, 8, 0.18);
}

.quip-entry-loser {
  opacity: 0.68;
  border-color: rgba(148, 163, 184, 0.2);
}

.quip-option-readonly {
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: #cbd5e1;
  text-align: center;
  font-weight: 600;
  cursor: default;
}
