/* Minijuegos: sala (hoja inferior) y pantalla de juego a pantalla completa. */

/* ---------- sala ---------- */
#games {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 9;
  margin: 0 auto; width: 100%; max-width: 640px;
  box-shadow: 0 -6px 0 rgba(30,30,30,.12);
  border-radius: 22px 22px 0 0; border-bottom: 0; padding: 10px 14px 10px;
}
#games-list { display: grid; gap: 8px; max-height: min(52vh, 440px); overflow-y: auto; padding: 2px; }
.game-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  border: 3px solid var(--ink); border-radius: 18px; padding: 8px 10px; box-shadow: var(--shadow);
  background: linear-gradient(135deg, color-mix(in srgb, var(--gc) 35%, white), var(--paper) 70%);
}
.game-card .gemo { font-size: 2.3rem; line-height: 1; filter: drop-shadow(0 2px 0 rgba(30,30,30,.25)); }
.game-card .ginfo { display: grid; gap: 1px; }
.game-card .ginfo strong { font-size: 1rem; }
.game-card .ginfo > span { font-size: .78rem; line-height: 1.2; }
.game-card .gmeta { font-size: .74rem; font-weight: 700; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.game-card .gmedals span { filter: grayscale(1); opacity: .3; }
.game-card .gmedals span.got { filter: none; opacity: 1; }
.game-card .gplay { font-size: .95rem; padding: 8px 14px; }
.games-note { font-size: .74rem; opacity: .75; text-align: center; margin: 6px 0 0; }
#games-btn { color: #FFE38A !important; }

/* ---------- pantalla de juego ---------- */
#mg {
  position: fixed; inset: 0; z-index: 40; background: #12142A; color: var(--paper);
  display: grid; grid-template-rows: auto auto 1fr; touch-action: none; user-select: none; -webkit-user-select: none;
}
#mg[hidden] { display: none; }
body.mg-on { overflow: hidden; }
.mg-top {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 6px;
  background: color-mix(in srgb, var(--gc) 30%, #12142A);
  border-bottom: 3px solid var(--ink);
}
.mg-top .icon-btn { width: 38px; height: 38px; }
.mg-title { font-weight: 900; font-size: 1.05rem; text-align: center; }
.mg-score { display: grid; justify-items: end; line-height: 1; }
.mg-score small { font-size: .62rem; opacity: .75; font-weight: 700; }
.mg-score strong { font-size: 1.45rem; font-weight: 900; color: var(--wapuu); }
.mg-extra { text-align: center; font-size: .9rem; font-weight: 700; padding: 4px 8px; min-height: 1.6em; background: rgba(0,0,0,.25); }
#mg-canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.mg-card {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 20px;
  background: rgba(10,12,30,.55); backdrop-filter: blur(3px);
}
.mg-card[hidden] { display: none; }
.mg-card-in {
  width: min(360px, 100%); background: var(--paper); color: var(--ink); text-align: center;
  border: 3px solid var(--ink); border-radius: 24px; padding: 18px 18px 16px; box-shadow: 0 6px 0 rgba(30,30,30,.35);
  animation: mgpop .25s ease-out;
}
@keyframes mgpop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.mg-card-in h3 { margin: 4px 0 6px; font-size: 1.35rem; }
.mg-card-in p { margin: 6px 0; font-size: .92rem; line-height: 1.35; }
.mg-big { font-size: 3.4rem; line-height: 1; }
.mg-final { font-size: 2rem !important; font-weight: 900; color: var(--blueberry); margin: 2px 0 !important; }
.mg-medal { font-weight: 900; color: #B8860B; }
.mg-reward { font-weight: 900; background: var(--wapuu); border: 2px solid var(--ink); border-radius: 999px; display: inline-block; padding: 2px 12px; }
.mg-btns { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.mg-btn {
  border: 3px solid var(--ink); border-radius: 999px; padding: 9px 18px; font: inherit; font-weight: 900;
  background: var(--paper); box-shadow: var(--shadow); color: var(--ink);
}
.mg-btn.primary { background: var(--wapuu); }
.mg-btn:active { transform: translateY(2px); box-shadow: none; }

/* la barra de habitaciones con 6 botones en móviles estrechos */
@media (max-width: 420px) {
  #rooms { gap: 2px; padding-left: 4px; padding-right: 4px; }
  #rooms button { font-size: .7rem; }
  #rooms button span { font-size: 1.35rem; }
}
.mg-top .icon-btn { color: var(--ink); }

/* ---------- ranking mundial ---------- */
#ranking {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 9;
  margin: 0 auto; width: 100%; max-width: 640px;
  box-shadow: 0 -6px 0 rgba(30,30,30,.12);
  border-radius: 22px 22px 0 0; border-bottom: 0; padding: 10px 14px 10px;
}
.rk-open {
  width: 100%; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; justify-content: center; margin: 0 0 8px;
  border: 3px solid var(--ink); border-radius: 16px; padding: 8px 12px; font: inherit; font-weight: 900;
  background: linear-gradient(90deg, #FFE38A, #FFF6D6); box-shadow: var(--shadow); color: var(--ink);
}
.rk-open small { font-weight: 700; font-size: .72rem; opacity: .7; flex-basis: 100%; text-align: center; }
.rk-sub { font-size: .78rem; text-align: center; margin: 4px 0 6px; opacity: .75; }
.rk-list { list-style: none; margin: 0; padding: 2px; display: grid; gap: 5px; max-height: min(40vh, 340px); overflow-y: auto; }
.rk-row {
  display: grid; grid-template-columns: 2.6em 1.8em 1fr auto; align-items: center; gap: 6px;
  border: 2px solid var(--ink); border-radius: 12px; padding: 5px 10px; background: var(--paper);
}
.rk-row.top1 { background: #FFF1B8; } .rk-row.top2 { background: #EEF1F6; } .rk-row.top3 { background: #FBE3CF; }
.rk-row.mine { border-color: var(--blueberry); box-shadow: 0 0 0 3px #C9D3FF; }
.rk-pos { font-weight: 900; font-size: .95rem; text-align: center; }
.rk-emo { font-size: 1.3rem; text-align: center; }
.rk-name { font-weight: 700; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-name small { font-weight: 700; opacity: .6; font-size: .72rem; }
.rk-name .rk-lvl { margin-left: 6px; }
.rk-val { font-weight: 900; font-variant-numeric: tabular-nums; }
.rk-msg { text-align: center; font-size: .85rem; padding: 16px 8px; opacity: .8; }
.rk-me { margin-top: 8px; text-align: center; font-size: .85rem; }
.rk-me p { margin: 4px 0 8px; }
.rk-me .rk-list { max-height: none; }
.mg-rank { font-weight: 900; color: var(--blueberry); min-height: 1.2em; }
.mg-btns .mg-btn { padding: 9px 14px; }
.rk-me .rk-row { text-align: left; }

/* ---------- dibujos 3D de los minijuegos dentro de textos y tarjetas ---------- */
.mg-ico { height: 1.35em; width: auto; vertical-align: -0.32em; filter: drop-shadow(0 1px 0 rgba(0,0,0,.25)); }
.mg-ico-inline { height: 1.6em; vertical-align: -0.45em; }
.mg-bigimg { height: 84px; width: auto; filter: drop-shadow(0 4px 4px rgba(0,0,0,.25)); }
.game-card .gicon { height: 54px; width: 54px; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(0,0,0,.2)); }
.game-card .gmedals .mg-ico { height: 1.5em; }
.mg-medal .mg-ico, .mg-card-in p .mg-ico { height: 1.5em; }
.mg-extra .mg-ico { height: 1.15em; vertical-align: -0.22em; }
.rk-trophy .mg-ico { height: 1.5em; vertical-align: -0.35em; }
.mg-btns { flex-wrap: wrap; }
.mg-btns .mg-btn { white-space: nowrap; font-size: .95rem; padding: 9px 13px; }
