:root {
  --red: #c8102e;
  --red-dark: #8b0a1f;
  --green: #1f7a3a;
  --green-dark: #0f4d24;
  --gold: #f5c542;
  --cream: #fff8ec;
  --ink: #2b1a12;
  --bg1: #0d2b1c;
  --bg2: #4a0d16;
  --card: rgba(255, 248, 236, 0.97);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 0%, #1b5e35 0%, var(--bg1) 45%, var(--bg2) 100%) fixed;
  min-height: 100vh;
  overflow-x: hidden;
}
h1, h2, h3, .festive { font-family: 'Mountains of Christmas', 'Nunito', cursive; font-weight: 700; margin: 0.2em 0; }
a { color: inherit; }
button { font-family: inherit; }

#snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.wrap { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 12px 16px 60px; }

/* Barra superior */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: linear-gradient(90deg, var(--red-dark), var(--red));
  color: #fff; box-shadow: var(--shadow);
  border-bottom: 3px solid var(--gold);
}
.topbar .home { text-decoration: none; font-size: 1.5rem; font-family: 'Mountains of Christmas', cursive; font-weight: 700; white-space: nowrap; }
.topbar .title { flex: 1; text-align: center; font-family: 'Mountains of Christmas', cursive; font-size: 1.6rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .me { display: flex; align-items: center; gap: 8px; font-weight: 800; white-space: nowrap; }
.topbar .host-badge { display: none; background: var(--gold); color: var(--ink); border-radius: 99px; padding: 2px 10px; font-size: .75rem; font-weight: 900; }
body.is-admin .topbar .host-badge { display: inline-block; }
@media (max-width: 600px) {
  .topbar .title { font-size: 1.2rem; }
  .topbar .me .name { display: none; }
}

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin: 14px 0; position: relative;
}
.card.glow { border: 3px solid var(--gold); }
.card h2 { color: var(--red); font-size: 2rem; }
.light { color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.muted { color: #7a6a5f; font-size: .92rem; }
.center { text-align: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.hidden { display: none !important; }

.btn {
  border: none; border-radius: 99px; padding: 12px 22px; font-size: 1.05rem; font-weight: 900; cursor: pointer;
  background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-dark); transition: transform .08s;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center; text-decoration: none;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--green-dark); }
.btn.red { background: var(--red); box-shadow: 0 4px 0 var(--red-dark); }
.btn.gold { background: var(--gold); color: var(--ink); box-shadow: 0 4px 0 #b88a12; }
.btn.ghost { background: #eee3d3; color: var(--ink); box-shadow: 0 4px 0 #c9b9a3; }
.btn.small { padding: 7px 14px; font-size: .9rem; }
.btn.big { padding: 18px 34px; font-size: 1.4rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

input, select {
  font: inherit; padding: 12px 14px; border-radius: 12px; border: 2px solid #d9c9b3; background: #fff; font-size: 1.05rem;
}
input:focus, select:focus { outline: 3px solid var(--gold); border-color: var(--gold); }

/* Avatares */
.face {
  display: inline-block; border-radius: 50%; background-repeat: no-repeat; background-color: #fff;
  border: 3px solid var(--gold); flex-shrink: 0; box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.pchip { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; }
.pchip.off { opacity: .45; }

/* Panel del anfitrión */
.host-panel { display: none; border: 3px dashed var(--gold); background: #fff3d6; }
body.is-admin .host-panel { display: block; }
.host-panel h3 { color: var(--red-dark); font-family: 'Nunito'; font-size: 1.05rem; margin: 0 0 8px; }
.host-panel h3::before { content: '🎙️ '; }

/* Lista y ranking */
.rank { list-style: none; padding: 0; margin: 0; }
.rank li { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px dashed #e2d4bf; }
.rank li .pos { width: 30px; text-align: center; font-weight: 900; font-size: 1.15rem; }
.rank li .pts { margin-left: auto; font-weight: 900; color: var(--green); }
.rank li.me { background: #fff1c4; border-radius: 10px; }

/* Toasts */
#toasts { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 520px); }
.toast { background: rgba(43, 26, 18, .93); color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 800; box-shadow: var(--shadow); animation: toastIn .3s ease-out; display: flex; align-items: center; gap: 8px; text-align: center; }
.toast.good { background: rgba(31, 122, 58, .96); }
.toast.bad { background: rgba(200, 16, 46, .96); }
@keyframes toastIn { from { transform: translateY(-20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Celebración */
#celebrate { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .65); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; color: #fff; text-align: center; padding: 20px; }
#celebrate img { max-height: 48vh; max-width: 80vw; border-radius: 20px; background: #fff; border: 6px solid var(--gold); animation: bounce 1s infinite alternate; }
#celebrate h1 { font-size: clamp(2.2rem, 7vw, 4rem); color: var(--gold); text-shadow: 0 3px 0 var(--red-dark); }
@keyframes bounce { from { transform: scale(1) rotate(-2deg); } to { transform: scale(1.05) rotate(2deg); } }
#confetti { position: fixed; inset: 0; z-index: 95; pointer-events: none; }

/* Inicio */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.char {
  background: #fff; border-radius: 16px; padding: 8px; text-align: center; cursor: pointer; border: 4px solid transparent;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .15); transition: transform .12s; position: relative;
}
.char:hover { transform: translateY(-3px); }
.char img { width: 100%; height: 170px; object-fit: contain; }
.char .cname { font-weight: 800; font-size: .88rem; }
.char.sel { border-color: var(--green); background: #e9f9ee; transform: scale(1.03); }
.char.taken { cursor: pointer; }
.char.taken img { filter: grayscale(.85) opacity(.55); }
.char .owner { position: absolute; top: 8px; left: 8px; right: 8px; background: var(--red); color: #fff; border-radius: 8px; font-size: .78rem; font-weight: 800; padding: 3px; }

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.game {
  border-radius: 20px; padding: 18px; color: #fff; text-decoration: none; box-shadow: var(--shadow); min-height: 150px;
  display: flex; flex-direction: column; justify-content: flex-end; position: relative; overflow: hidden; transition: transform .12s;
  padding-top: 72px;
}
.game:hover { transform: translateY(-4px) rotate(-.5deg); }
.game .emoji { font-size: 3rem; position: absolute; top: 10px; right: 14px; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .3)); }
.game h3 { font-size: 1.9rem; margin: 0; text-shadow: 0 2px 4px rgba(0, 0, 0, .4); }
.game p { margin: 4px 0 0; font-weight: 700; opacity: .92; }
.g1 { background: linear-gradient(135deg, #c8102e, #e8573f); }
.g2 { background: linear-gradient(135deg, #1f7a3a, #3fa45f); }
.g3 { background: linear-gradient(135deg, #2361a8, #4aa3df); }
.g4 { background: linear-gradient(135deg, #6b2fa3, #b155d8); }
.g5 { background: linear-gradient(135deg, #b8860b, #f5c542); }
.g6 { background: linear-gradient(135deg, #0f6b6b, #2fb5a5); }

.online-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.welcome { display: flex; align-items: center; gap: 16px; }
.welcome img { height: 150px; border-radius: 14px; background: #fff; }
.host-panel .mini { grid-template-columns: repeat(5, 8px); gap: 1px; }
.host-panel .mini i { width: 8px; height: 8px; border-radius: 2px; }
