/* Estilos de la página. Paleta del juego: celeste #1dbae5, azul #1b98c4, blanco #fcfafb, amarillo #f8ea29. */
:root {
  --cyan: #1dbae5;
  --blue: #1b98c4;
  --white: #fcfafb;
  --yellow: #f8ea29;
  --yellow-dark: #c9bb00;
  --ink: #06334a;        /* texto oscuro: contraste correcto sobre celeste y sobre blanco */
  --ink-soft: #0d5476;
  --tile-a: #2398cd;
  --tile-b: #1f8dbf;
  --discord: #5865f2;
  --danger: #c0392b;
  --font: "Arial Rounded MT Bold", "Nunito", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  /* Ancho del marco del juego: 625px, pero se achica si la pantalla es baja (el juego mantiene su proporción). */
  --frame-w: 625px;
  font-family: var(--font);
  color-scheme: light;
}
@supports (width: 1dvh) {
  :root { --frame-w: clamp(440px, calc((100dvh - 280px) * 0.84), 625px); }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; color: var(--ink); line-height: 1.45;
  background: linear-gradient(180deg, #55c6ec 0%, var(--tile-a) 55%, #1c86b8 100%);
  padding: 22px 14px 36px; position: relative; overflow-x: hidden;
}

/* Fondo de cuadrículas que sube de abajo hacia arriba y se desvanece arriba. */
.bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: repeating-conic-gradient(var(--tile-b) 0% 25%, transparent 0% 50%) 0 0 / 112px 112px;
  -webkit-mask-image: linear-gradient(to top, #000 0%, rgba(0, 0, 0, .55) 55%, transparent 95%);
  mask-image: linear-gradient(to top, #000 0%, rgba(0, 0, 0, .55) 55%, transparent 95%);
  animation: rise 16s linear infinite;
}
@keyframes rise { to { background-position: 0 -224px; } }

/* ---------- Panel principal ---------- */
.panel {
  position: relative; z-index: 1; width: min(1120px, 100%); margin: 0 auto;
  background: var(--cyan); border: 5px solid var(--white); border-radius: 34px;
  box-shadow: 0 10px 0 var(--blue), 0 26px 44px rgba(3, 50, 80, .35);
  padding: 22px 26px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--frame-w) minmax(0, 1fr);
  grid-template-areas:
    ". logo user"
    ". stage user"
    "foot foot foot";
  column-gap: 18px; row-gap: 14px;
}
.logo { grid-area: logo; justify-self: center; display: block; line-height: 0; }
.logo img { width: clamp(190px, 22vw, 260px); height: auto; filter: drop-shadow(0 4px 0 rgba(27, 152, 196, .55)); }
.user { grid-area: user; align-self: start; justify-self: end; width: 100%; max-width: 215px; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.stage { grid-area: stage; min-width: 0; }
.foot { grid-area: foot; }

/* ---------- Usuario y menú ---------- */
.user-id { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; max-width: 100%; }
.avatar {
  display: block; width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  background: var(--white); border: 4px solid var(--white); box-shadow: 0 4px 0 var(--blue);
}
.avatar-lg { width: 96px; height: 96px; }
.user-name { font-size: .95rem; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; max-width: 180px; }

.menu {
  width: 100%; display: flex; flex-direction: column; gap: 8px; padding: 8px;
  border: 3px solid var(--white); border-radius: 22px; background: rgba(255, 255, 255, .16);
}
body[data-view="login"] .menu { display: none; }
body:not([data-view="welcome"]) .only-welcome, body:not([data-view="game"]) .only-game { display: none; }
.menu-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; cursor: pointer;
  font: inherit; font-size: .88rem; font-weight: 700; color: var(--ink);
  background: var(--white); border: 2px solid var(--white); border-radius: 14px; padding: .5rem .7rem;
  box-shadow: 0 3px 0 var(--blue); transition: transform .08s, box-shadow .08s, background .12s;
}
.menu-btn:hover:not(:disabled) { background: var(--yellow); }
.menu-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--blue); }
.menu-btn-danger { color: var(--danger); }
.menu-btn:disabled { opacity: .6; cursor: progress; }
.menu-btn svg { flex: none; }
.menu-btn[hidden] { display: none; }

/* ---------- Mensajes ---------- */
#status {
  margin: 0 auto 10px; width: fit-content; max-width: 100%; padding: .45rem 1rem; text-align: center;
  background: var(--white); color: var(--ink); font-weight: 700; font-size: .92rem;
  border: 3px solid var(--yellow); border-radius: 999px; box-shadow: 0 3px 0 var(--blue);
}
#status:empty { display: none; }
#status.error { border-color: #ff6b5e; color: #8a1c10; }

.note {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem .9rem;
  margin: 14px auto 0; width: fit-content; max-width: 100%; padding: .55rem 1rem;
  background: var(--yellow); color: #3b3300; font-size: .92rem; border: 3px solid var(--white);
  border-radius: 20px; box-shadow: 0 4px 0 var(--yellow-dark);
}
.note[hidden] { display: none; }
.note-btn {
  font: inherit; font-size: .88rem; font-weight: 800; cursor: pointer; color: #fff; background: var(--discord);
  border: 2px solid var(--white); border-radius: 999px; padding: .35rem .9rem; box-shadow: 0 3px 0 #3c45a5;
}
.note-btn:hover { background: #6b77f5; }
.note-btn-discord { display: inline-flex; align-items: center; gap: .4em; }
.note-btn-google { display: inline-flex; align-items: center; gap: .4em; color: var(--ink); background: var(--white); border-color: var(--cyan); box-shadow: 0 3px 0 var(--blue); }
.note-btn-google:hover { background: #eefaff; }

/* ---------- Marco del juego ---------- */
.frame {
  position: relative; width: min(100%, var(--frame-w)); aspect-ratio: 625 / 744; margin: 0 auto;
  container-type: size; overflow: hidden; border: 6px solid var(--white); border-radius: 30px;
  background: linear-gradient(180deg, #86dcf4 0%, #c9f1fb 52%, var(--white) 100%);
  box-shadow: 0 7px 0 var(--blue), inset 0 0 0 3px rgba(29, 186, 229, .35);
}
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(8px, 1.8vh, 18px); padding: clamp(14px, 4cqw, 34px); text-align: center; overflow-y: auto;
}
.screen[hidden], #game[hidden] { display: none; }

.title {
  margin: 0; color: #fff; font-weight: 900; line-height: 1.05; text-align: center; overflow-wrap: anywhere;
  font-size: clamp(1.9rem, 9cqw, 3.4rem); letter-spacing: .01em;
  -webkit-text-stroke: .14em var(--blue); paint-order: stroke fill; text-shadow: 0 .07em 0 var(--blue);
}
.lead { margin: 0; max-width: 34ch; color: var(--ink); font-size: clamp(.92rem, 3.1cqw, 1.1rem); font-weight: 700; }

/* ---------- Botones grandes ---------- */
.btn {
  display: block; width: 100%; font: inherit; font-weight: 900; cursor: pointer; text-align: center;
  font-size: clamp(1.05rem, 3.9cqw, 1.35rem); padding: .75em 1em; border-radius: 999px;
  border: 4px solid var(--white); transition: transform .08s, box-shadow .08s, filter .12s;
}
.btn:active:not(:disabled) { transform: translateY(3px); }
.btn:disabled { opacity: .65; cursor: progress; }
.btn-discord {
  display: flex; align-items: center; justify-content: center; gap: .6em; color: #fff; background: var(--discord);
  box-shadow: 0 6px 0 #3c45a5, 0 0 0 3px var(--blue);
}
.btn-discord svg { flex: none; width: 1.3em; height: 1.3em; }
.btn-discord:active:not(:disabled) { box-shadow: 0 3px 0 #3c45a5, 0 0 0 3px var(--blue); }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: .6em; color: var(--ink); background: var(--white);
  box-shadow: 0 6px 0 var(--blue), 0 0 0 3px var(--cyan);
}
.btn-google:active:not(:disabled) { box-shadow: 0 3px 0 var(--blue), 0 0 0 3px var(--cyan); }
.btn-google svg { flex: none; width: 1.15em; height: 1.15em; }
.choice .btn + .btn { margin-top: 16px; }
.choice .btn + p { margin-top: 1em; }
.btn-light { color: var(--ink); background: var(--white); box-shadow: 0 6px 0 var(--blue), 0 0 0 3px var(--cyan); }
.btn-light:active:not(:disabled) { box-shadow: 0 3px 0 var(--blue), 0 0 0 3px var(--cyan); }
.btn-play {
  width: auto; min-width: min(80%, 16em); color: #4a3f00; background: var(--yellow);
  font-size: clamp(1.5rem, 7cqw, 2.4rem); padding: .55em 1.6em; letter-spacing: .02em;
  box-shadow: 0 8px 0 var(--yellow-dark), 0 0 0 3px var(--blue);
}
.btn-play:active:not(:disabled) { box-shadow: 0 4px 0 var(--yellow-dark), 0 0 0 3px var(--blue); }
.btn:hover:not(:disabled) { filter: brightness(1.06); }

/* Aviso solo para pantallas táctiles */
.tip { display: none; margin: 0; max-width: 32ch; padding: .4em .8em; font-size: .82rem; font-weight: 700; color: var(--ink);
  background: rgba(255, 255, 255, .8); border-radius: 14px; }
@media (pointer: coarse) { .tip { display: block; } }

/* ---------- Pantalla de entrada ---------- */
.choices { width: min(100%, 25rem); display: flex; flex-direction: column; gap: clamp(8px, 1.8vh, 16px); }
.choice {
  background: rgba(255, 255, 255, .78); border: 3px solid var(--white); border-radius: 22px;
  padding: clamp(10px, 2.8cqw, 16px); box-shadow: 0 4px 0 rgba(27, 152, 196, .45);
}
.choice p { margin: .7em 0 0; color: var(--ink); font-size: clamp(.8rem, 2.7cqw, .95rem); line-height: 1.35; }
.help { width: min(100%, 25rem); color: var(--ink); font-size: clamp(.78rem, 2.6cqw, .9rem); text-align: left; }
.help summary { cursor: pointer; font-weight: 800; text-align: center; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }
.help p { margin: .6em 0 0; padding: .7em .9em; background: rgba(255, 255, 255, .85); border-radius: 16px; }
.help a { color: var(--ink-soft); font-weight: 800; }
@container (max-height: 560px) { .lead { display: none; } .help p { font-size: .78rem; } }

/* ---------- Bienvenida ---------- */
.buddy {
  flex: none; width: 113px; height: 127px; margin-top: 6px;
  background: url("/img/buddy.png") 0 0 / 1695px 127px no-repeat;
  animation: buddy 1.1s steps(15) infinite; filter: drop-shadow(0 6px 3px rgba(27, 152, 196, .35));
}
@keyframes buddy { to { background-position: -1695px 0; } }
@container (max-height: 520px) { .buddy { display: none; } }

/* ---------- Juego ---------- */
#game { position: absolute; inset: 0; background: #000; }
#game > * { display: block; width: 100% !important; height: 100% !important; border: 0; max-width: none; }
/* Sin manijas para redimensionar el marco del juego. */
#game, #game > * { resize: none !important; }

/* ---------- Pie ---------- */
.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; padding-top: 4px; }
.foot-text { flex: 1 1 280px; max-width: 62ch; font-size: .82rem; color: var(--ink); }
.foot-text a { display: inline-block; margin-bottom: .25rem; font-weight: 900; font-size: .95rem; color: var(--ink); text-underline-offset: 3px; }
.foot-text p { margin: 0; }
.foot-text .foot-about { margin-bottom: .6rem; }
.foot-logos { display: flex; align-items: center; gap: 18px; list-style: none; margin: 0; padding: 0; }
.foot-logos li { display: flex; align-items: center; }
.foot-logos img { display: block; height: 48px; width: auto; }
.maker { display: block; border-radius: 50%; line-height: 0; transition: transform .15s; }
.maker img { height: 56px; width: 56px; border-radius: 50%; }
.maker:hover { transform: rotate(-8deg) scale(1.08); }

a:focus-visible, button:focus-visible, summary:focus-visible { outline: 4px solid var(--yellow); outline-offset: 3px; border-radius: 12px; }
.panel a:focus-visible, .frame button:focus-visible { outline-color: #fff; box-shadow: 0 0 0 7px var(--blue); }

/* ---------- Pantallas más angostas: una sola columna ---------- */
@media (max-width: 980px) {
  .panel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "user" "logo" "stage" "foot";
    padding: 16px 14px 18px; border-radius: 28px;
  }
  .user { max-width: none; flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
  .user-id { flex-direction: row; gap: 10px; text-align: left; }
  .avatar { width: 56px; height: 56px; }
  .user-name { max-width: 14rem; }
  .menu { width: auto; flex-direction: row; flex-wrap: wrap; padding: 6px; gap: 6px; }
  .menu-btn { width: auto; padding: .45rem .65rem; }
  .logo img { width: clamp(190px, 52vw, 260px); }
  .menu { flex: 1 1 100%; justify-content: stretch; }
  .menu-btn { flex: 1 1 auto; justify-content: center; }
  /* Entrada y bienvenida: el contenido define la altura (el juego sí conserva su proporción). */
  body:not([data-view="game"]) .frame { aspect-ratio: auto; container-type: inline-size; }
  body:not([data-view="game"]) .screen { position: relative; inset: auto; min-height: 430px; }
  .foot { justify-content: center; text-align: center; }
  .foot-logos { justify-content: center; }
}
@media (max-width: 480px) {
  body { padding: 12px 8px 28px; }
  .frame { border-width: 5px; border-radius: 24px; }
  .foot-logos img { height: 40px; }
  .maker img { height: 48px; width: 48px; }
}

/* ---------- Controles táctiles (solo pantallas táctiles, mientras se juega) ---------- */
.pad, .rotate-hint { display: none; }
.pad, .pad * { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.pad { --d: 172px; --f: 110px; align-items: center; justify-content: space-between; gap: 16px; width: min(100%, 430px); margin: 18px auto 0; }
/* --d = diámetro de la cruz, --f = diámetro del botón Disparar. En el celular en vertical los calcula el CSS de más abajo. */
.dpad {
  position: relative; flex: none; width: var(--d); height: var(--d); border-radius: 50%;
  background: rgba(255, 255, 255, .24); border: 4px solid var(--white); box-shadow: 0 5px 0 var(--blue);
}
.dp {
  position: absolute; display: grid; place-items: center; width: 34%; height: 34%; padding: 0; pointer-events: none;
  color: var(--ink); background: var(--white); border: 3px solid var(--white); border-radius: 18px; box-shadow: 0 4px 0 var(--blue);
  transition: transform .06s, background .08s, box-shadow .06s;
}
.dp svg { width: 58%; height: 58%; }
.dp-up { top: 5%; left: 33%; }
.dp-down { bottom: 5%; left: 33%; }
.dp-left { left: 5%; top: 33%; }
.dp-right { right: 5%; top: 33%; }
.dp.on { background: var(--yellow); transform: translateY(3px); box-shadow: 0 1px 0 var(--yellow-dark); }
.pad-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.pad-btn {
  font: inherit; font-weight: 900; cursor: pointer; color: var(--ink); background: var(--white);
  border: 4px solid var(--white); border-radius: 999px; box-shadow: 0 6px 0 var(--blue), 0 0 0 3px var(--cyan);
  transition: transform .06s, box-shadow .06s, background .08s;
}
.pad-btn.on { transform: translateY(4px); box-shadow: 0 2px 0 var(--blue), 0 0 0 3px var(--cyan); }
.pad-fire { width: var(--f); height: var(--f); font-size: clamp(.85rem, calc(var(--f) * .16), 1.3rem); color: #4a3f00; background: var(--yellow); box-shadow: 0 7px 0 var(--yellow-dark), 0 0 0 3px var(--blue); }
.pad-fire.on { box-shadow: 0 3px 0 var(--yellow-dark), 0 0 0 3px var(--blue); }
.pad-enter { width: calc(var(--f) * 1.15); padding: .55em 0; font-size: .95rem; }

.rotate-hint {
  margin: 14px auto 0; width: fit-content; max-width: 100%; padding: .5rem 1rem; text-align: center;
  background: var(--white); color: var(--ink); font-weight: 700; font-size: .9rem; border: 3px solid var(--yellow); border-radius: 18px;
}

@media (pointer: coarse) {
  body[data-view="game"] .pad { display: flex; }
  #btn-fullscreen { display: none; }   /* el layout ya aprovecha la pantalla del teléfono */
  #game { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
}
/* Celular en horizontal: no entra el juego entero con los controles, se pide girarlo. */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  body[data-view="game"] .rotate-hint { display: block; }
  body[data-view="game"] .pad { display: none; }
}
/* Celular en vertical, jugando: PANTALLA COMPLETA de la página. Arriba una barra finita, el juego a todo el ancho
   y, en el espacio que sobra debajo, la cruz y los botones. Nada se scrollea ni se superpone con el juego. */
@media (pointer: coarse) and (max-width: 700px) and (orientation: portrait) {
  :root {
    --frame-w: 625px;
    --bar-h: 50px;       /* alto de la barra de arriba */
    --pad-min: 200px;    /* alto mínimo que se reserva para cruz + botones (+ aviso de invitado) */
  }
  body[data-view="game"] {
    height: 100vh; height: 100dvh; min-height: 0; padding: 0; overflow: hidden;
    overscroll-behavior: none; background: var(--cyan);
  }
  body[data-view="game"] .bg, body[data-view="game"] .logo, body[data-view="game"] .foot { display: none; }
  body[data-view="game"] .panel {
    display: flex; flex-direction: column; gap: 0; width: 100%; height: 100%; margin: 0;
    border: 0; border-radius: 0; box-shadow: none; background: var(--cyan);
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  }

  /* Barra de arriba: foto + nombre a la izquierda, "Volver" a la derecha (el idioma no hace falta mientras se juega). */
  body[data-view="game"] .user {
    flex: none; width: 100%; max-width: none; height: var(--bar-h); padding: 0 10px; gap: 10px;
    flex-direction: row; flex-wrap: nowrap; align-items: center; justify-content: space-between;
  }
  body[data-view="game"] .lang-switch, body[data-view="game"] .install-btn { display: none; }
  body[data-view="game"] .user-id { flex: 1 1 auto; min-width: 0; flex-direction: row; gap: 8px; text-align: left; }
  body[data-view="game"] .avatar { width: 36px; height: 36px; border-width: 3px; box-shadow: 0 2px 0 var(--blue); }
  body[data-view="game"] .user-name { max-width: none; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body[data-view="game"] .menu { flex: 0 0 auto; width: auto; padding: 0; border: 0; background: none; }
  body[data-view="game"] .menu-btn { flex: none; padding: .4rem .75rem; }

  /* Juego: a todo el ancho. Solo se achica si la pantalla es tan baja que no quedaría lugar para los controles
     (svh = alto con las barras del navegador visibles, así el juego no cambia de tamaño cuando se esconden). */
  body[data-view="game"] .stage { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  body[data-view="game"] #status { flex: none; margin: 0 auto 6px; }
  body[data-view="game"] .frame {
    flex: none; border: 0; border-radius: 0; box-shadow: none;
  }
  @supports (height: 1svh) {
    body[data-view="game"] .frame {
      width: min(100%, calc((100svh - var(--bar-h) - var(--pad-min) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) * 0.84));
    }
  }

  /* Controles: ocupan todo el espacio que deja el juego, y la cruz y los botones se adaptan a ese espacio. */
  body[data-view="game"] .pad { flex: 1 1 0; min-height: 0; width: 100%; margin: 0; padding: 0 clamp(14px, 5vw, 28px); }
  body[data-view="game"] .pad-actions { gap: 10px; }
  @supports (width: 1cqw) {
    body[data-view="game"] .pad {
      container-type: size;
      --d: min(50cqw, 94cqh, 240px);
      --f: max(76px, min(30cqw, calc(100cqh - 62px), 140px));
    }
  }

  /* Aviso de invitado: una sola tira finita, con los botones de Discord/Google solo con el ícono. */
  body[data-view="game"] .note {
    flex: none; width: auto; max-width: none; margin: 4px 10px 8px; padding: .3rem .4rem .3rem .75rem;
    flex-wrap: nowrap; justify-content: space-between; gap: 8px; font-size: .76rem; line-height: 1.2;
    border-width: 2px; border-radius: 14px; box-shadow: 0 2px 0 var(--yellow-dark);
  }
  body[data-view="game"] .note-btn { flex: none; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; box-shadow: 0 2px 0 #3c45a5; }
  body[data-view="game"] .note-btn-google { box-shadow: 0 2px 0 var(--blue); }
  body[data-view="game"] .note-btn span {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
}

/* ---------- Juego dibujado a menor resolución y estirado (pantalla completa y celular) ---------- */
/* app.js calcula --fs-w/--fs-h (tamaño al que Ruffle dibuja) y --fs-scale (cuánto lo estira el navegador) y pone
   la clase .scaled. Dibujar menos píxeles es lo que más ayuda a que el juego ande fluido en el celular. */
#game.scaled { display: flex; align-items: center; justify-content: center; overflow: hidden; }
#game.scaled > * {
  flex: none; max-width: none; transform-origin: center;
  width: var(--fs-w, 100%) !important; height: var(--fs-h, 100%) !important; transform: scale(var(--fs-scale, 1));
}
/* Mientras se juega, la animación del fondo se frena: repinta toda la pantalla en cada cuadro y le quita tiempo a Ruffle. */
body[data-view="game"] .bg, .is-fullscreen .bg, .is-fullscreen .buddy { animation: none !important; }

/* Contador de cuadros para medir en el celular: abrir la página con ?fps al final de la dirección. */
.fps-meter {
  position: fixed; z-index: 2000; top: calc(env(safe-area-inset-top, 0px) + 4px); left: 4px; padding: 2px 8px;
  font: 700 12px/1.5 ui-monospace, Menlo, Consolas, monospace; color: #0f0; background: rgba(0, 0, 0, .72);
  border-radius: 8px; pointer-events: none; white-space: pre;
}

@media (prefers-reduced-motion: reduce) {
  .bg, .buddy { animation: none; }
  .btn, .menu-btn, .maker { transition: none; }
}

/* Switch de idioma (ES | EN) */
.lang-switch { display: inline-flex; gap: 2px; padding: 3px; background: rgba(255, 255, 255, .45); border-radius: 999px; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6); }
.lang-switch button {
  min-width: 2.6rem; min-height: 2rem; padding: 0 .7rem; font: inherit; font-size: .85rem; font-weight: 900; letter-spacing: .04em;
  color: var(--ink); background: transparent; border: 0; border-radius: 999px; cursor: pointer;
}
.lang-switch button:hover { background: rgba(255, 255, 255, .6); }
.lang-switch button[aria-pressed="true"] { background: var(--yellow); box-shadow: 0 2px 0 var(--yellow-dark); cursor: default; }
.lang-switch button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 6px var(--blue); }
@media (max-width: 980px) { .lang-switch { order: 3; margin-left: auto; } }

/* Si un texto (por ejemplo en inglés) no entra en pantallas bajas, el cuadro se desplaza en vez de cortar el título. */
.screen { justify-content: safe center; }

/* Ventana con la imagen de SHARE */
.share-overlay {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(6, 51, 74, .72);
}
.share-box {
  width: min(560px, 100%); max-height: 100%; overflow: auto; padding: 18px; text-align: center;
  background: var(--white); color: var(--ink); border: 4px solid var(--cyan); border-radius: 22px;
  box-shadow: 0 8px 0 var(--blue), 0 18px 40px rgba(0, 0, 0, .35);
}
.share-title { margin: 0 0 10px; font-size: 1.3rem; font-weight: 700; }
.share-img { display: block; width: 100%; height: auto; border-radius: 12px; border: 2px solid var(--cyan); }
.share-hint { margin: 12px 0; font-size: .95rem; color: var(--ink-soft); }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.share-btn {
  font: inherit; font-weight: 700; color: var(--ink); background: var(--yellow); text-decoration: none;
  border: 3px solid var(--yellow-dark); border-radius: 14px; padding: .5rem 1rem; cursor: pointer;
}
.share-btn:hover { filter: brightness(1.05); }
.share-btn-alt { background: var(--white); border-color: var(--cyan); }

/* ---------- Pantallas grandes de PC: el juego se ve más grande ----------
   Solo desde 1280px de ancho (en pantallas más chicas todo queda como antes). El ancho del juego sube hasta 720px
   (antes 625px) y se achica solo si la ventana es baja, para que el juego siga entrando sin scroll.
   Para ajustar: 720px = tamaño máximo; 200px = lo que ocupan arriba y abajo el logo, los márgenes y el marco. */
@media (min-width: 1280px) {
  :root { --frame-w: 720px; }
  .panel { width: min(1240px, 100%); }
  body[data-view="game"] { padding-top: 12px; padding-bottom: 18px; }
  body[data-view="game"] .logo img { width: 190px; }
}
@supports (width: 1dvh) {
  @media (min-width: 1280px) {
    :root { --frame-w: clamp(440px, calc((100dvh - 200px) * 0.84), 720px); }
  }
}
