/* ¿Qué jugamos? — sobre los tokens y componentes de ../css/style.css */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ── Formularios ───────────────────────────────────────────────────────── */
.jg-form { display: grid; gap: 8px; margin-top: 1.6em; max-width: 520px; }
.jg-form--code { margin-top: 1.2em; }
.jg-label { font-size: .82rem; font-weight: 700; color: var(--text-dim); letter-spacing: .04em; margin: 0; }
.jg-row { display: flex; gap: 10px; }
.jg-input {
  flex: 1; min-width: 0;
  background: var(--surface); color: var(--text);
  border: 1px solid rgba(240,250,242,.35); border-radius: 999px;
  padding: .78em 1.2em; font: inherit; font-size: 1rem;
  transition: border-color .2s, box-shadow .2s;
}
.jg-input::placeholder { color: var(--text-faint); }
.jg-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(61,220,110,.18); }
.jg-input--code { text-transform: uppercase; letter-spacing: .28em; font-weight: 700; max-width: 220px; }
.jg-input--search { border-radius: var(--radius-sm); width: 100%; margin: 14px 0 12px; }
.jg-input--link { font-size: .85rem; color: var(--text-dim); border-radius: var(--radius-sm); }
.jg-error { color: #ff8a7a; font-size: .88rem; margin: 0; min-height: 1.3em; }
.jg-legal { margin: 0; max-width: 56ch; }
.jg-legal a { color: var(--text-dim); text-decoration: underline; text-underline-offset: 2px; }

/* ── Inicio ────────────────────────────────────────────────────────────── */
.jg-home__in { position: relative; display: grid; grid-template-columns: 1.15fr .85fr; gap: 56px; align-items: center; }
.jg-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; counter-reset: s; }
.jg-steps li {
  display: grid; grid-template-columns: 44px 1fr; gap: 16px; padding: 18px 0;
  border-top: 1px solid var(--glass-border);
}
.jg-steps li:last-child { border-bottom: 1px solid var(--glass-border); }
.jg-steps p { color: var(--text-dim); font-size: .94rem; margin: 0; }
.jg-steps h4 { margin-bottom: .2em; }
.jg-steps__n {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: rgba(61,220,110,.12); color: var(--green); font-weight: 900; font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

/* ── Unirse / mensaje ──────────────────────────────────────────────────── */
.jg-join__in { max-width: 620px; }
.jg-code-big { font-size: clamp(2.6rem, 8vw, 4.2rem); letter-spacing: .18em; color: var(--green); margin-bottom: .2em; font-variant-numeric: tabular-nums; }

/* ── Sala ──────────────────────────────────────────────────────────────── */
.jg-room { padding-top: clamp(28px, 4vw, 48px); }
.jg-room__in { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; align-items: start; }
.jg-main { display: grid; gap: 28px; min-width: 0; }
.jg-side { display: grid; gap: 16px; position: sticky; top: 84px; }

.jg-picker, .jg-results, .jg-panel {
  background: var(--surface); border: 1px solid var(--glass-border); border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(240,250,242,.04);
}
.jg-picker, .jg-results { padding: 26px; }
.jg-panel { padding: 20px; }
.jg-panel .kicker { margin: 0; }
.jg-panel__head, .jg-picker__head, .jg-results__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.jg-panel__head { margin-bottom: 12px; }
.jg-picker h2, .jg-results h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin: 0; }
.jg-results__head { margin-bottom: 18px; flex-wrap: wrap; }
.jg-results__head .meta { margin: 0; }
.jg-count { color: var(--text-faint); font-weight: 700; font-variant-numeric: tabular-nums; }
.jg-count.is-full { color: var(--green); }

/* Chips de géneros */
.jg-selected { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; min-height: 40px; align-items: center; }
.jg-selected:empty::before { content: attr(data-empty); color: var(--text-faint); font-size: .92rem; }
.jg-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.jg-chip {
  display: inline-flex; align-items: center; gap: .45em;
  background: transparent; color: var(--text-dim);
  border: 1px solid rgba(240,250,242,.3); border-radius: 999px;
  padding: .42em .95em; min-height: 36px; font: inherit; font-size: .9rem; cursor: pointer;
  transition: background .18s, color .18s, border-color .18s, transform .12s;
}
.jg-chip:hover { border-color: var(--green); color: var(--text); }
.jg-chip:active { transform: scale(.96); }
.jg-chip[aria-pressed="true"] { background: rgba(61,220,110,.16); border-color: rgba(61,220,110,.55); color: var(--text); }
.jg-chip--sel { background: var(--green); border-color: var(--green); color: #05130a; font-weight: 700; }
.jg-chip--sel:hover { color: #05130a; background: #55e883; }
.jg-chip--sel::after { content: "×"; font-weight: 900; opacity: .7; }
.jg-chip:disabled { opacity: .35; cursor: not-allowed; }
.jg-chip__n { color: var(--text-faint); font-size: .78em; font-variant-numeric: tabular-nums; }
.jg-more {
  margin-top: 14px; background: none; border: 0; padding: 0; color: var(--green);
  font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer;
}
.jg-more:hover { text-decoration: underline; }
.jg-ready { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--glass-border); }
.jg-ready .meta { margin: 0; }
#readyBtn[aria-pressed="true"] { background: rgba(61,220,110,.16); border-color: var(--green); color: var(--green); }

/* Panel de sala */
.jg-code { font-size: 2rem; font-weight: 900; letter-spacing: .2em; color: var(--green); margin: .1em 0 .5em; font-variant-numeric: tabular-nums; }
.jg-share { display: grid; gap: 8px; }
.jg-share .btn { justify-content: center; }

.jg-members { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.jg-members li { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid rgba(240,250,242,.06); }
.jg-members li:first-child { border-top: 0; }
.jg-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(240,250,242,.2); }
.jg-dot.is-on { background: var(--green); box-shadow: 0 0 0 3px rgba(61,220,110,.18); animation: jg-breathe 2.4s ease-in-out infinite; }
@keyframes jg-breathe { 50% { box-shadow: 0 0 0 5px rgba(61,220,110,.06); } }
.jg-members__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jg-members__name small { color: var(--text-faint); margin-left: .4em; font-size: .78em; }
.jg-members__state { font-size: .78rem; color: var(--text-faint); white-space: nowrap; }
.jg-members__state.is-ready { color: var(--green); font-weight: 700; }

/* Controles segmentados */
.jg-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; background: var(--bg); border-radius: 12px; margin: 8px 0 16px; }
.jg-seg--5 { grid-template-columns: repeat(5, 1fr); }
.jg-seg--5 button { font-size: .85rem; padding-inline: .2em; }
.jg-seg--sort { margin: 6px 0 18px; }
.jg-more-wrap { display: flex; justify-content: center; margin-top: 18px; }
.jg-seg button {
  background: transparent; border: 0; color: var(--text-dim); border-radius: 9px;
  padding: .55em .4em; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
  transition: background .18s, color .18s;
}
.jg-seg button:hover:not([aria-disabled="true"]) { color: var(--text); }
.jg-seg button[aria-checked="true"] { background: var(--surface-2); color: var(--green); box-shadow: inset 0 0 0 1px rgba(61,220,110,.3); }
.jg-seg button[aria-disabled="true"] { cursor: default; }
.jg-seg.is-locked button:not([aria-checked="true"]) { opacity: .45; }

.jg-leave { background: none; border: 0; color: var(--text-faint); font: inherit; font-size: .88rem; cursor: pointer; justify-self: start; padding: 4px 0; }
.jg-leave:hover { color: #ff8a7a; }

/* ── Resultados ────────────────────────────────────────────────────────── */
.jg-list { display: grid; gap: 14px; }
.jg-game {
  display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 0;
  background: var(--surface-2); border: 1px solid rgba(240,250,242,.06); border-radius: 14px; overflow: hidden;
  transition: border-color .2s, transform .2s;
  animation: jg-in .45s cubic-bezier(.16,1,.3,1) both; animation-delay: calc(var(--i, 0) * 45ms);
}
.jg-game:hover { border-color: rgba(61,220,110,.35); transform: translateY(-2px); }
@keyframes jg-in { from { opacity: 0; transform: translateY(10px); } }
.jg-game__img { position: relative; background: var(--bg); min-height: 107px; } /* se estira a lo alto de la tarjeta */
.jg-game__img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.jg-game__rank {
  position: absolute; left: 8px; top: 8px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 8px;
  display: grid; place-items: center; background: rgba(10,15,10,.82); color: var(--text); font-weight: 900; font-size: .85rem;
  font-variant-numeric: tabular-nums;
}
.jg-game__body { padding: 14px 18px; display: grid; gap: 6px; min-width: 0; }
.jg-game__top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.jg-game__name { font-size: 1.08rem; font-weight: 700; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jg-game__name a { color: var(--text); }
.jg-game__price { white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.jg-game__price .is-free { color: var(--green); }
.jg-off { background: var(--green); color: #05130a; font-size: .75rem; font-weight: 900; padding: .15em .45em; border-radius: 5px; margin-right: .4em; }
.jg-game__meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-dim); font-size: .86rem; }
.jg-game__meta strong { color: var(--text); font-weight: 700; }
.jg-cover { display: inline-flex; align-items: center; gap: 8px; }
.jg-cover__bar { width: 54px; height: 6px; border-radius: 3px; background: rgba(240,250,242,.1); overflow: hidden; }
.jg-cover__bar span { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.jg-game .tags { margin: 2px 0 0; }
.jg-game .tags li { font-size: .76rem; }
.jg-game .tags li.is-match { color: var(--green); border-color: rgba(61,220,110,.4); }

.jg-game--featured { grid-column: 1 / -1; border-color: rgba(61,220,110,.4); background: linear-gradient(135deg, rgba(61,220,110,.08), transparent 60%), var(--surface-2); }
.jg-feat { font-size: .7rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: var(--green); }

/* Estados */
.jg-empty { text-align: left; padding: 28px 4px 12px; color: var(--text-dim); max-width: 46ch; }
.jg-empty h4 { color: var(--text); }
.jg-skel { display: grid; grid-template-columns: 230px 1fr; gap: 0; border-radius: 14px; overflow: hidden; background: var(--surface-2); }
.jg-skel__img { aspect-ratio: 460 / 215; }
.jg-skel__body { padding: 16px 18px; display: grid; gap: 10px; align-content: start; }
.jg-skel__line { height: 12px; border-radius: 6px; }
.jg-skel__img, .jg-skel__line {
  background: linear-gradient(90deg, rgba(240,250,242,.05) 0%, rgba(240,250,242,.1) 50%, rgba(240,250,242,.05) 100%);
  background-size: 200% 100%; animation: jg-shimmer 1.3s linear infinite;
}
@keyframes jg-shimmer { to { background-position: -200% 0; } }

.jg-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--glass-border); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: .92rem; font-weight: 500; z-index: 60;
  box-shadow: 0 12px 30px -12px rgba(0,0,0,.7); transition: opacity .25s, transform .25s cubic-bezier(.16,1,.3,1);
}
.jg-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .jg-game, .jg-skel__img, .jg-skel__line, .jg-dot.is-on { animation: none; }
}

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1020px) {
  /* Una columna: se aplanan main y aside para intercalar paneles y que el
     selector quede arriba, no debajo de todo el lateral. */
  .jg-room__in { grid-template-columns: 1fr; gap: 16px; }
  .jg-main, .jg-side { display: contents; }
  .jg-panel--share   { order: 1; }
  .jg-panel--members { order: 2; }
  .jg-picker         { order: 3; }
  .jg-panel--filters { order: 4; }
  .jg-results        { order: 5; }
  .jg-leave          { order: 6; }
}
@media (max-width: 960px) {
  .jg-home__in { grid-template-columns: 1fr; gap: 36px; }
}
@media (max-width: 720px) {
  .jg-side { grid-template-columns: 1fr; }
  .jg-row { flex-direction: column; }
  .jg-row .btn { justify-content: center; }
  .jg-input--code { max-width: none; }
  .jg-picker, .jg-results { padding: 20px; }
  .jg-game, .jg-skel { grid-template-columns: 1fr; }
  .jg-game__img { aspect-ratio: 460 / 215; min-height: 0; }
  .jg-game__name { white-space: normal; }
  .jg-seg--sort { grid-template-columns: repeat(2, 1fr); }
}
