* { box-sizing: border-box; }
/* mientras llegan las traducciones no se ve el texto provisional (si algo falla, la página se muestra igual a los 3 s) */
.i18n-pending body { visibility: hidden; animation: i18n-reveal 0s 3s forwards; }
@keyframes i18n-reveal { to { visibility: visible; } }
html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body { display: flex; align-items: center; justify-content: center; }
[hidden] { display: none !important; }

#app {
  position: relative; overflow: hidden; background: #000; color: #fff;
  width: 100vw; height: 100vh; height: 100dvh;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
@media (min-aspect-ratio: 10/16) {
  #app { width: calc(100vh * 9 / 16); width: calc(100dvh * 9 / 16); box-shadow: 0 0 60px var(--shadow-soft); }
}

/* ---------- feed ---------- */
#feed { position: absolute; inset: 0; }
.slide {
  position: absolute; inset: 0; overflow: hidden; will-change: transform;
  transition: transform .34s cubic-bezier(.22, .8, .24, 1);
  background: linear-gradient(165deg, var(--c1) 0%, #000 120%);
}
#feed.dragging .slide { transition: none; }
#feed.dragging iframe { pointer-events: none; }
.slide iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block;
  opacity: 0; transition: opacity .25s;
}
.slide.ready iframe { opacity: 1; }

.poster {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 0 24px;
}
.poster::before {
  content: ""; position: absolute; width: 120%; aspect-ratio: 1; left: -10%; top: 5%;
  background: radial-gradient(circle, var(--c2) 0%, transparent 60%); opacity: .28;
}
.p-icon { position: relative; font-size: 92px; filter: drop-shadow(0 8px 24px #0009); }
.p-title { position: relative; font-size: 32px; font-weight: 900; color: var(--c2); text-shadow: 0 2px 12px #000a; }
.p-desc { position: relative; font-size: 15px; opacity: .8; max-width: 280px; }
.p-load { position: relative; display: none; align-items: center; gap: 8px; font-size: 14px; opacity: .85; margin-top: 8px; }
.slide.loading:not(.ready) .p-load { display: flex; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff4; border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chip {
  position: absolute; z-index: 3; top: 72px; left: 50%; transform: translateX(-50%);
  padding: 6px 12px; border-radius: 99px; background: #000b; font-size: 13px; font-weight: 700;
  opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap;
}
.slide.frozen.ready .chip { opacity: 1; }

.feed-message {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; text-align: center; background: #0b0b12;
}
.feed-message .big { font-size: 56px; }
.feed-message button, .feed-message .btn {
  border: 0; border-radius: 12px; padding: 12px 18px; background: #f57b00; color: #fff; font: inherit; font-weight: 800; cursor: pointer; text-decoration: none;
}

/* ---------- overlays ---------- */
header, #rail, #info { transition: opacity .3s; }
header {
  position: absolute; z-index: 10; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(#000a, transparent); pointer-events: none;
}
.logo { font-weight: 900; font-size: 15px; letter-spacing: -.02em; color: #fff; text-decoration: none; pointer-events: auto; white-space: nowrap; min-width: 0; overflow: hidden; }
/* Audiowide es ancha: en pantallas estrechas el nombre se achica para no chocar con el avatar */
@media (max-width: 400px) { .logo { font-size: 13px; } }
.logo b { color: #f57b00; }
.header-actions, .header-left { display: flex; gap: 8px; align-items: center; }
.header-left { gap: 10px; }
.icon-btn {
  pointer-events: auto; border: 0; cursor: pointer; color: #fff; font: inherit;
  width: 38px; height: 38px; border-radius: 50%; background: #ffffff1c; font-size: 17px;
  display: grid; place-items: center;
}
.icon-btn[aria-pressed="true"] { background: #f57b00; }
.me-btn {
  pointer-events: auto; color: #fff; text-decoration: none; font-weight: 800; font-size: 14px;
  height: 38px; padding: 0 14px; border-radius: 99px; background: #f57b00; display: grid; place-items: center;
}
.me-btn.avatar { width: 38px; padding: 0; font-size: 20px; background: #ffffff26; border: 2px solid #fff; position: relative; overflow: hidden; }

/* La barra encoge con la altura de la ventana para no meterse bajo la cabecera en pantallas bajas
   (a partir de ~760px de alto se ve a tamaño completo). */
#rail {
  --rb: clamp(34px, 6.2dvh, 48px);   /* botón */
  --rg: clamp(6px, 1.8dvh, 14px);    /* separación */
  --ra: clamp(38px, 6.6dvh, 50px);   /* avatar */
  position: absolute; z-index: 10; right: 8px; bottom: clamp(84px, 17dvh, 132px);
  display: flex; flex-direction: column; align-items: center; gap: var(--rg);
}
.rail-btn {
  border: 0; background: none; color: #fff; cursor: pointer; font: inherit; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700; text-shadow: 0 1px 4px #000;
}
.rail-btn span:first-child {
  width: var(--rb); height: var(--rb); border-radius: 50%; display: grid; place-items: center;
  font-size: calc(var(--rb) * .46); background: #0006; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform .15s;
}
.rail-btn:active span:first-child { transform: scale(.88); }
.rail-btn svg { width: calc(var(--rb) / 2); height: calc(var(--rb) / 2); }
/* muy bajas: fuera los rótulos (el contador de me gusta se queda) */
@media (max-height: 600px) {
  .rail-btn:not(#likeBtn) span:last-child { display: none; }
}
#likeBtn.liked span:first-child { color: #ff3b5c; animation: pop .35s; }
@keyframes pop { 50% { transform: scale(1.3); } }
#avatar {
  width: var(--ra, 50px); height: var(--ra, 50px); border-radius: 50%; border: 2px solid #fff; display: grid; place-items: center;
  font-size: calc(var(--ra, 50px) * .52); background: var(--c1, #333); text-decoration: none; overflow: hidden; position: relative;
}
/* Foto de perfil recortada: la imagen entera colocada para que se vea el trozo elegido en Ajustes. */
img.av-crop.av-crop {
  position: absolute; top: calc(var(--ay) / var(--as) * -100%); left: calc(var(--ax) / var(--as) * -100%);
  width: calc(100% / var(--as)); height: auto; max-width: none; border-radius: 0; object-fit: fill;
}
/* foto de perfil subida por el usuario, en lugar del emoji */
.avatar-photo { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }

#info {
  position: absolute; z-index: 10; left: 12px; right: 76px;
  bottom: max(16px, env(safe-area-inset-bottom)); pointer-events: none; text-shadow: 0 1px 6px #000c;
}
#info .handle {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 5px;
  font-weight: 800; font-size: 15px; color: #fff; text-decoration: none;
}
#info .handle:hover span:first-child { text-decoration: underline; }
/* insignias: dorada solo el fundador, morada administración, azul creador, blanca email verificado; el ✓ siempre negro */
.verified {
  position: relative; display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%;
  background: #20d5ec; color: #000; font-size: 10px; font-weight: 900; text-shadow: none; cursor: help; outline: none;
}
.verified.admin { background: #a855f7; }
.verified.founder { background: linear-gradient(135deg, #ffe680, #f2b705 55%, #c98a00); }
.verified.email { background: #fff; box-shadow: 0 0 0 1px #0004; }
/* globo con lo que es: al pasar el ratón o al tocarla */
.verified::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translate(-50%, 4px);
  padding: 6px 10px; border-radius: 8px; background: #14141c; color: #fff; border: 1px solid #ffffff26;
  font-size: 12px; font-weight: 700; white-space: nowrap; box-shadow: 0 6px 18px #0009;
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 50;
}
.verified:hover::after, .verified:focus::after { opacity: 1; transform: translate(-50%, 0); }
#info h2 { margin: 4px 0 2px; font-size: 18px; }
#info p { margin: 0; font-size: 14px; line-height: 1.35; opacity: .92; }
#info .tags { margin-top: 4px; font-size: 13px; font-weight: 700; opacity: .85; }
#info .tags a { pointer-events: auto; color: #fff; text-decoration: none; margin-right: 8px; }
#info .tags a:hover { text-decoration: underline; }
#info .plays { margin-top: 4px; font-size: 12px; opacity: .7; }

/* Durante la partida, lo que la web deja encima del juego. A 0 no se ve nada;
   se puede subir a mano para volver a verlo (valores de antes: .35, .1 y .5).
   La pestañita se queda visible: es lo único que indica que se puede sacar el menú. */
:root {
  --play-header-opacity: 0;
  --play-info-opacity: 0;
  --play-peek-opacity: .5;
}

/* durante la partida: la barra lateral se esconde y no recibe toques */
#rail { transition: opacity .25s, transform .25s; }
#app.playing header { opacity: var(--play-header-opacity); }
#app.playing #debugBtn, #app.playing .me-btn, #app.playing .nav-toggle { opacity: 0; pointer-events: none; }
#app.playing .logo { pointer-events: none; }
#app.playing:not(.peek) #rail { opacity: 0; transform: translateX(80px); pointer-events: none; }
#app.playing #info { opacity: var(--play-info-opacity); }
#app.playing #info .handle, #app.playing #info .tags a { pointer-events: none; }
/* recién terminada la partida: los botones reaparecen pero ignoran toques un momento */
#app.guard #rail, #app.guard #info .handle, #app.guard #info .tags a, #app.guard .logo { pointer-events: none; }

#peek {
  position: absolute; z-index: 11; right: 0; top: 42%;
  width: 18px; height: 56px; padding: 0; border: 0; border-radius: 10px 0 0 10px;
  background: #0008; color: #fff; font-size: 14px; cursor: pointer;
  opacity: 0; transform: translateX(100%); pointer-events: none;
  transition: opacity .25s, transform .25s;
}
#app.playing:not(.peek) #peek { opacity: var(--play-peek-opacity); transform: none; pointer-events: auto; }

/* el anuncio entre juegos lo pinta ads.js (.gamead, en css/ads.css), igual que los que piden los juegos */
#app.ads header, #app.ads #rail, #app.ads #info, #app.ads #peek { opacity: 0; pointer-events: none; }

#hint {
  position: absolute; z-index: 12; left: 50%; bottom: 190px; transform: translateX(-50%);
  background: #000c; padding: 10px 16px; border-radius: 99px; font-size: 14px; font-weight: 700;
  white-space: nowrap; pointer-events: none; animation: nudge 1.6s ease-in-out infinite;
}
@keyframes nudge { 0%, 100% { margin-bottom: 0; } 50% { margin-bottom: 14px; } }

#debug {
  position: absolute; z-index: 20; top: 56px; right: 10px; width: 230px;
  background: #000d; border: 1px solid #fff2; border-radius: 12px; padding: 10px;
  font: 12px/1.5 ui-monospace, Consolas, monospace; pointer-events: none;
}
#debug .row { display: flex; gap: 6px; align-items: center; }
#debug .row.cur { color: #f57b00; font-weight: 700; }
#debug .st { margin-left: auto; padding: 0 6px; border-radius: 6px; background: #fff1; }
#debug .st.active { background: #1f9d55; }
#debug .st.frozen { background: #2b6cb0; }
#debug .st.loading { background: #b7791f; }

.toast {
  position: absolute; left: 50%; top: 64px; z-index: 30; max-width: calc(100% - 32px);
  transform: translate(-50%, -10px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  padding: 10px 14px; border-radius: 12px; font-size: 14px; font-weight: 700; text-align: center;
  background: #f4f4f8; color: #111; box-shadow: 0 10px 30px #0009;
}
.toast[data-kind="err"] { background: #ff6b7a; color: #fff; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

#desk-nav { display: none; }
@media (min-aspect-ratio: 10/16) and (min-width: 640px) {
  #desk-nav {
    position: fixed; top: 50%; transform: translateY(-50%);
    left: calc(50% + var(--nav-w, 0px) / 2 + 100dvh * 9 / 32 + 20px);
    display: flex; flex-direction: column; gap: 12px;
  }
  #desk-nav button { width: 48px; height: 48px; font-size: 20px; background: var(--fill-3); color: var(--text); }
  #desk-help { position: fixed; left: calc(var(--nav-w, 0px) + 20px); bottom: 16px; font-size: 12px; opacity: .45; }
}
/* con el panel lateral fijo (css/nav.css), el feed se centra en el espacio que queda */
@media (min-width: 1024px) {
  body.with-nav { padding-left: var(--nav-w); }
  body.with-nav #app { max-width: calc(100vw - var(--nav-w)); }
}
@media not all and (min-aspect-ratio: 10/16) { #desk-help { display: none; } }

/* ---------- juegos de creadores ---------- */
.p-icon.p-logo { width: 112px; height: 112px; object-fit: contain; filter: drop-shadow(0 8px 16px #0009); }
#info .warnings {
  display: inline-block; margin-top: 6px; padding: 3px 9px; border-radius: 99px;
  background: #ffb34733; color: #ffd08a; font-size: 12px; font-weight: 800; text-shadow: none;
}
#info .warnings::before { content: "\26A0\FE0F  "; }

/* Audiowide para el nombre de la marca. El archivo va en /fonts; si falta, se usa la fuente del sistema. */
@font-face {
  font-family: 'Audiowide';
  src: url('/fonts/audiowide.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
.logo {
  font-family: 'Audiowide', system-ui, -apple-system, sans-serif;
  font-weight: 400; text-transform: uppercase; letter-spacing: 0;
  display: inline-flex; align-items: center;
}
.logo b { font-weight: inherit; }
/* el icono, a la altura de las letras */
.brand-mark { height: 1.18em; width: auto; flex: none; display: block; margin-right: .38em; }

/* aviso de cuenta suspendida: arriba del todo, encima de la página, con su ✕ para cerrarlo */
.suspension-bar {
  position: fixed; z-index: 1000; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; background: #3a0d12; color: #ffd9dc; border-bottom: 2px solid #ff4d5e; box-shadow: 0 6px 20px #0008;
  font-size: 14px; line-height: 1.4; text-shadow: none;
}
.suspension-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; white-space: pre-line; }
.suspension-text b { color: #fff; font-size: 15px; }
.suspension-close {
  flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%; background: #ffffff1f; color: #fff;
  font-size: 15px; font-weight: 900; cursor: pointer;
}
.suspension-close:hover { background: #ffffff33; }
