:root {
  --bg: #f3eee6;
  --panel: #fffaf3;
  --ink: #3f372f;
  --muted: #786b5f;
  --line: #e3d5c4;
  --gold: #cba35e;
  --gold-dark: #ae8037;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top, #fffdf8 0%, #f4f0e9 48%, #ece5da 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.page { width: min(1420px, 100%); margin: 0 auto; padding: 20px 24px 28px; }
.topbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; }
.topbar h1 { margin: 0; font-size: clamp(1.9rem, 4vw, 2.8rem); letter-spacing: -0.04em; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.controls { display: flex; flex-wrap: wrap; gap: 9px; }
.controls span { padding: 8px 11px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,250,243,.96); box-shadow: 0 5px 15px rgba(70,50,28,.06); font-size: .93rem; }
.gameFrame { position: relative; padding: 12px; border: 1px solid var(--line); border-radius: 24px; background: #faf5ed; box-shadow: 0 24px 70px rgba(67,48,26,.14); overflow: hidden; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 16px; outline: none; background: #101219; touch-action: none; }
.overlay { position: absolute; inset: 12px; display: none; align-items: center; justify-content: center; border-radius: 16px; background: rgba(21, 20, 24, .62); backdrop-filter: blur(5px); z-index: 50; }
.overlay.show { display: flex; }
.panel { width: min(760px, calc(100% - 38px)); padding: 24px; border: 1px solid #e7d7c2; border-radius: 24px; background: linear-gradient(180deg,#fffdf8,#fbf3e7); box-shadow: 0 22px 70px rgba(0,0,0,.28); }
.panel.compact { width: min(520px, calc(100% - 38px)); }
.panel.center { text-align: center; }
.introPanel { display: grid; grid-template-columns: 190px 1fr; gap: 25px; align-items: center; }
.heroSprite { width: 100%; max-height: 250px; object-fit: contain; image-rendering: pixelated; }
.brand { width: 76px; height: 76px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 22px; background: linear-gradient(145deg,#eed4a0,#bb8d43); color: white; font-family: Georgia, serif; font-size: 2rem; }
.panel h2 { margin: 4px 0 10px; font-size: 1.7rem; }
.panel p { color: #62564a; line-height: 1.55; }
.eyebrow { color: #9c7845; font-size: .78rem; font-weight: 850; letter-spacing: .12em; }
button { border: 1px solid var(--gold-dark); border-radius: 13px; padding: 11px 17px; margin-top: 12px; background: linear-gradient(#deb56d,#bd8d43); color: white; font-weight: 800; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255,255,255,.4),0 7px 20px rgba(93,60,23,.17); }
button:hover { filter: brightness(1.04); }
.party { font-size: 3.2rem; }
.dialog { position: absolute; left: 24px; right: 24px; bottom: 24px; display: grid; grid-template-columns: 170px 1fr; gap: 16px; padding: 14px; border: 1px solid #e3d2bc; border-radius: 22px; background: rgba(255,250,242,.98); box-shadow: 0 20px 50px rgba(0,0,0,.26); z-index: 30; }
.dialog.hidden { display: none; }
.portraitPanel { height: 170px; display: grid; place-items: center; overflow: hidden; border-radius: 16px; background: linear-gradient(145deg,#f3e7d5,#dfc6a3); border: 1px solid #dbc4a5; }
.portraitPanel img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.dialogBody { min-width: 0; }
.dialogTop { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.dialogTop h3 { margin: 2px 0 2px; font-size: 1.35rem; }
.role { color: #857567; font-size: .94rem; }
.hint { padding: 7px 9px; border: 1px solid #eadbca; background: #fbf5ed; border-radius: 10px; color: #8d7d6e; white-space: nowrap; font-size: .9rem; }
.dialogBody > p { margin: 18px 0 0; font-size: 1.08rem; line-height: 1.58; color: #4d443c; }
.footerNote { margin: 13px 2px 0; color: #786c61; font-size: .94rem; }
.mobileControls, .mobileOnly { display: none; }

/* ==========================================================
   CONTROLES MÓVILES
   ==========================================================
   Puedes cambiar bottom/left/right o tamaños sin tocar game.js.
   ========================================================== */
@media (hover: none), (pointer: coarse), (max-width: 900px) {
  html, body { overscroll-behavior: none; }
  body { -webkit-user-select: none; user-select: none; }
  .page { padding: 6px; }
  .topbar { margin: 0 2px 6px; align-items: center; }
  .topbar h1 { font-size: 1.15rem; }
  .topbar p { font-size: .76rem; margin-top: 1px; }
  .desktopHelp, .desktopOnly { display: none !important; }
  .mobileOnly { display: block; }
  .gameFrame { padding: 4px; border-radius: 14px; }
  canvas { border-radius: 10px; }
  .footerNote { display: none; }
  .overlay { inset: 4px; border-radius: 10px; }
  .panel { padding: 16px; width: min(94%, 680px); border-radius: 18px; }
  .introPanel { grid-template-columns: 120px 1fr; gap: 14px; }
  .heroSprite { max-height: 160px; }
  .panel h2 { font-size: 1.32rem; }
  .panel p { font-size: .88rem; margin: 5px 0; }
  .startMobileTip { color: #8a6f49 !important; }

  .mobileControls {
    position: absolute;
    inset: 0;
    display: block;
    pointer-events: none;
    z-index: 40;
  }
  .dpad {
    position: absolute;
    left: max(14px, env(safe-area-inset-left));
    bottom: max(14px, env(safe-area-inset-bottom));
    width: 154px;
    height: 154px;
    transition: opacity .15s ease;
  }
  .touchKey, .mobileTalk {
    position: absolute;
    margin: 0;
    pointer-events: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    border: 2px solid rgba(255,255,255,.75);
    background: rgba(40, 34, 30, .72);
    color: #fffaf1;
    box-shadow: 0 4px 14px rgba(0,0,0,.30), inset 0 1px 0 rgba(255,255,255,.18);
    backdrop-filter: blur(4px);
  }
  .touchKey {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    padding: 0;
    font-size: 1.25rem;
    display: grid;
    place-items: center;
  }
  .touchKey:active, .touchKey.pressed, .mobileTalk:active {
    transform: scale(.94);
    background: rgba(190, 142, 66, .88);
  }
  .touchKey.up { left: 51px; top: 0; }
  .touchKey.left { left: 0; top: 51px; }
  .touchKey.right { right: 0; top: 51px; }
  .touchKey.down { left: 51px; bottom: 0; }
  .mobileTalk {
    right: max(18px, env(safe-area-inset-right));
    bottom: max(24px, env(safe-area-inset-bottom));
    width: 112px;
    height: 72px;
    border-radius: 36px;
    padding: 0;
    font-size: .9rem;
    letter-spacing: .04em;
    font-weight: 900;
  }

  .dialog {
    left: 8px;
    right: 8px;
    bottom: 104px;
    grid-template-columns: 86px 1fr;
    gap: 10px;
    padding: 9px;
    border-radius: 16px;
  }
  .portraitPanel { width: 86px; height: 104px; border-radius: 12px; }
  .dialogTop h3 { font-size: 1rem; }
  .role { font-size: .75rem; }
  .dialogBody > p { margin: 7px 0 0; font-size: .84rem; line-height: 1.35; }
  body.dialog-active .dpad { opacity: .18; pointer-events: none; }
}

@media (max-width: 560px) and (orientation: portrait) {
  .topbar p { display: none; }
  .introPanel { grid-template-columns: 92px 1fr; }
  .dpad { width: 132px; height: 132px; }
  .touchKey { width: 45px; height: 45px; border-radius: 14px; }
  .touchKey.up { left: 44px; }
  .touchKey.left { top: 44px; }
  .touchKey.right { top: 44px; }
  .touchKey.down { left: 44px; }
  .mobileTalk { width: 96px; height: 62px; font-size: .78rem; }
  .dialog { bottom: 88px; }
}

/* ==========================================================
   V1.4 · IDENTIDAD BÈL
   ========================================================== */
.titleLockup { display: flex; align-items: center; gap: 14px; min-width: 0; }
.companyLogo { width: 180px; height: 58px; object-fit: contain; object-position: left center; }
.overlayLogo { width: min(260px, 68%); max-height: 90px; object-fit: contain; margin-bottom: 8px; }
.introLogo { width: min(250px, 68%); max-height: 78px; object-fit: contain; object-position: left center; margin-bottom: 6px; }

/* ==========================================================
   V1.4 · CELEBRACIÓN FINAL
   ========================================================== */
.celebrationPanel { width: min(1060px, calc(100% - 30px)); padding: 16px 18px 20px; }
#celebrationCanvas { display: block; width: 100%; height: auto; aspect-ratio: 980 / 430; border-radius: 18px; background: linear-gradient(180deg,#f6e5bd,#ead1a3); border: 1px solid #d9bd88; box-shadow: inset 0 1px 0 rgba(255,255,255,.7); }
.celebrationPanel h2 { margin-top: 12px; }
.celebrationPanel p { margin-bottom: 0; }

/* ==========================================================
   V1.4 · FORMULARIO ¿QUIERES APARECER?
   ========================================================== */
.signupSection { margin-top: 22px; padding: 26px; border: 1px solid var(--line); border-radius: 24px; background: linear-gradient(180deg,#fffaf3,#f9f1e6); box-shadow: 0 18px 45px rgba(67,48,26,.08); }
.signupIntro { max-width: 760px; }
.signupIntro h2 { margin: 5px 0 8px; font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -.025em; }
.signupIntro p { margin: 0 0 18px; color: var(--muted); line-height: 1.55; }
.appearanceForm { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.appearanceForm label, .phrasesFieldset { min-width: 0; }
.appearanceForm label > span, .phrasesFieldset legend { display: block; margin-bottom: 7px; font-size: .92rem; font-weight: 800; color: #554a41; }
.appearanceForm input[type="text"], .appearanceForm input[type="file"] { width: 100%; min-height: 47px; padding: 11px 12px; border: 1px solid #d9c9b6; border-radius: 12px; background: #fffdf9; color: var(--ink); font: inherit; outline: none; }
.appearanceForm input[type="text"]:focus, .appearanceForm input[type="file"]:focus { border-color: #ba8d49; box-shadow: 0 0 0 3px rgba(203,163,94,.16); }
.appearanceForm small { display: block; margin-top: 5px; color: #897c70; }
.phrasesFieldset { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin: 0; padding: 14px; border: 1px solid #ddcfbd; border-radius: 14px; }
.phrasesFieldset legend { padding: 0 5px; }
.consentRow { grid-column: 1 / -1; display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px; border-radius: 13px; background: #f4eadc; border: 1px solid #e2d1ba; }
.consentRow input { margin-top: 3px; width: 18px; height: 18px; flex: 0 0 auto; }
.consentRow span { margin: 0 !important; font-weight: 600 !important; line-height: 1.45; }
.formActions { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.formActions button { margin-top: 0; }
.formStatus { margin: 0; color: #716256; font-size: .94rem; }
.formStatus.success { color: #3f7042; font-weight: 700; }
.formStatus.error { color: #9e3f38; font-weight: 700; }
.siteFooter { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin: 14px 2px 0; color: #786c61; font-size: .94rem; }
.siteFooter p { margin: 0; }
.adminLink { color: #816039; text-decoration: none; border-bottom: 1px solid rgba(129,96,57,.35); }
.adminLink:hover { color: #5f4527; }

@media (max-width: 900px) {
  .companyLogo { width: 128px; height: 40px; }
  .titleLockup { gap: 8px; }
  .signupSection { padding: 18px 14px; border-radius: 18px; }
  .appearanceForm { grid-template-columns: 1fr; }
  .phrasesFieldset { grid-column: 1; grid-template-columns: 1fr; }
  .consentRow, .formActions { grid-column: 1; }
  .siteFooter { flex-direction: column; align-items: flex-start; }
  .celebrationPanel { padding: 8px; width: min(98%, 1060px); }
  .celebrationPanel h2 { font-size: 1.25rem; }
  .celebrationPanel p { font-size: .88rem; }
}

@media (max-width: 560px) and (orientation: portrait) {
  .companyLogo { width: 100px; height: 32px; }
  .titleLockup h1 { font-size: 1rem; }
  #celebrationCanvas { border-radius: 12px; }
  .signupIntro h2 { font-size: 1.45rem; }
}


/* ==========================================================
   V1.5 · MÓVIL 9:16 / SCROLL / ACCESO AL FORMULARIO
   ==========================================================
   El juego conserva un canvas lógico que se redimensiona desde game.js
   al aspect ratio real del teléfono. En móvil el encabezado de la web se
   oculta: la identidad Bèl ya vive dentro del HUD del juego.
   ========================================================== */
html { scroll-behavior: smooth; }
.jumpToSignup, .backToGameBtn { display: none; }
.endActions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.secondaryAction { background: #fff8ed; color: #78582e; border-color: #cba35e; }

@media (hover: none), (pointer: coarse), (max-width: 900px) {
  html, body {
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body { user-select: auto; -webkit-user-select: auto; }
  .page { width: 100%; padding: 0; }

  /* La barra superior era la que se comía gran parte de una pantalla 9:16. */
  .topbar { display: none !important; }

  /* Un viewport completo para el juego en vertical u horizontal. */
  .gameFrame {
    width: 100vw;
    height: 100dvh;
    min-height: 100svh;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #101219;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
  }
  #game {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    aspect-ratio: auto;
    border-radius: 0;
    /* Permite deslizar la página sobre el propio mapa. Los botones de
       movimiento mantienen touch-action:none, así que siguen funcionando. */
    touch-action: pan-y;
  }

  .overlay { inset: 0; border-radius: 0; padding: max(10px, env(safe-area-inset-top)) 8px max(10px, env(safe-area-inset-bottom)); }
  .panel {
    width: min(94vw, 680px);
    max-height: calc(100svh - 20px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .introPanel { grid-template-columns: 96px 1fr; gap: 12px; }
  .heroSprite { max-height: 145px; }

  .jumpToSignup {
    display: block;
    position: absolute;
    z-index: 46;
    top: calc(84px + env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    margin: 0;
    padding: 8px 11px;
    border-radius: 999px;
    font-size: .72rem;
    line-height: 1;
    background: rgba(255,250,243,.92);
    color: #604a2d;
    border: 1px solid rgba(203,163,94,.9);
    box-shadow: 0 4px 16px rgba(0,0,0,.20);
    backdrop-filter: blur(6px);
    pointer-events: auto;
    touch-action: manipulation;
  }

  /* Dejamos aire para la barra segura del teléfono. */
  .dpad {
    left: max(12px, env(safe-area-inset-left));
    bottom: max(14px, env(safe-area-inset-bottom));
  }
  .mobileTalk {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
  }

  /* Caja de diálogo pensada para vertical: no tapa media pantalla. */
  .dialog {
    left: 8px;
    right: 8px;
    bottom: calc(104px + env(safe-area-inset-bottom));
    grid-template-columns: 72px 1fr;
    gap: 8px;
    padding: 8px;
    max-height: 38svh;
    overflow-y: auto;
  }
  .portraitPanel { width: 72px; height: 88px; }
  .dialogTop h3 { font-size: .98rem; }
  .role { font-size: .72rem; }
  .dialogBody > p { margin-top: 6px; font-size: .82rem; line-height: 1.32; }

  /* La celebración se puede leer y navegar en vertical. */
  .celebrationPanel {
    width: min(96vw, 720px);
    max-height: calc(100svh - 18px);
    overflow-y: auto;
    padding: 10px;
  }
  #celebrationCanvas {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    max-height: 58svh;
    object-fit: contain;
  }
  .endActions { position: sticky; bottom: 0; padding: 8px 0 2px; background: linear-gradient(180deg,rgba(251,243,231,0),#fbf3e7 24%); }
  .endActions button { margin-top: 8px; }

  /* El formulario vuelve a ser una página normal con scroll. */
  .signupSection {
    margin: 0;
    padding: 30px 16px calc(34px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    box-shadow: none;
    min-height: 100svh;
    user-select: auto;
    -webkit-user-select: auto;
  }
  .signupIntro { position: relative; padding-top: 40px; }
  .backToGameBtn {
    display: inline-flex;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    padding: 7px 11px;
    background: #fffaf3;
    color: #76572e;
    border-color: #d4b77f;
    box-shadow: none;
    touch-action: manipulation;
  }
  .appearanceForm input,
  .appearanceForm button,
  .appearanceForm label,
  .phrasesFieldset { touch-action: manipulation; }
  .siteFooter { padding: 0 16px 24px; margin: 0; background: #f9f1e6; }
}

@media (max-width: 560px) and (orientation: portrait) {
  .introPanel { grid-template-columns: 82px 1fr; }
  .heroSprite { max-height: 125px; }
  .panel h2 { font-size: 1.18rem; }
  .panel p { font-size: .82rem; }
  .eyebrow { font-size: .66rem; }
  .jumpToSignup { font-size: .66rem; padding: 7px 9px; }

  .dpad { width: 124px; height: 124px; }
  .touchKey { width: 42px; height: 42px; border-radius: 13px; font-size: 1.05rem; }
  .touchKey.up { left: 41px; }
  .touchKey.left { top: 41px; }
  .touchKey.right { top: 41px; }
  .touchKey.down { left: 41px; }
  .mobileTalk { width: 88px; height: 58px; border-radius: 30px; font-size: .72rem; }
  .dialog { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .signupIntro h2 { font-size: 1.5rem; }
}

@media (max-width: 900px) and (orientation: landscape) {
  #celebrationCanvas { aspect-ratio: 980 / 430; max-height: 48svh; }
  .jumpToSignup { top: calc(74px + env(safe-area-inset-top)); }
}


/* ==========================================================
   V1.6 · MODO MÓVIL DE ENTREGA / FULLSCREEN REAL
   ==========================================================
   Problema resuelto:
   - 100dvh no coincide siempre con el área visible real cuando Chrome muestra
     la barra de direcciones en horizontal.
   - game.js escribe --app-height usando VisualViewport.height.
   - Al comenzar en móvil se solicita Fullscreen API para ocultar la barra.
   ========================================================== */
:root { --app-height: 100dvh; --app-width: 100vw; }
.fullscreenBtn { display: none; }

@media (hover: none), (pointer: coarse), (max-width: 900px) {
  .gameFrame {
    height: var(--app-height, 100svh) !important;
    min-height: 0 !important;
    max-height: var(--app-height, 100svh);
  }

  /* Botones superiores siempre visibles dentro del área REAL del juego. */
  .fullscreenBtn,
  .jumpToSignup {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    position: absolute;
    z-index: 48;
    top: max(8px, env(safe-area-inset-top));
    margin: 0;
    min-height: 34px;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: .70rem;
    line-height: 1;
    color: #fffaf2;
    border: 1px solid rgba(255,255,255,.70);
    background: rgba(38,33,30,.72);
    box-shadow: 0 4px 14px rgba(0,0,0,.28);
    backdrop-filter: blur(5px);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .fullscreenBtn { left: max(8px, env(safe-area-inset-left)); }
  .jumpToSignup {
    right: max(8px, env(safe-area-inset-right));
    background: rgba(166,119,48,.86);
  }

  /* En fullscreen el frame ES la pantalla; nada puede quedar debajo del navegador. */
  .gameFrame:fullscreen,
  .gameFrame:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    background: #101219;
  }
  .gameFrame:fullscreen #game,
  .gameFrame:-webkit-full-screen #game {
    width: 100% !important;
    height: 100% !important;
  }

  /* El formulario no depende del gesto de scroll: los botones lo abren
     después de salir de fullscreen. Aun así mantenemos scroll normal. */
  #game { touch-action: pan-y !important; }
}

/* Horizontal corto: teléfonos reales con barra de Chrome / Android visible. */
@media (hover: none) and (orientation: landscape) and (max-height: 650px),
       (pointer: coarse) and (orientation: landscape) and (max-height: 650px) {
  .fullscreenBtn,
  .jumpToSignup {
    top: max(6px, env(safe-area-inset-top));
    min-height: 30px;
    padding: 6px 9px;
    font-size: .62rem;
  }
  .fullscreenBtn span { display: none; }
  .fullscreenBtn { width: 36px; padding: 0; font-size: 1.05rem; }

  /* Cruceta más compacta y completamente dentro del VisualViewport. */
  .dpad {
    left: max(8px, env(safe-area-inset-left)) !important;
    bottom: max(7px, env(safe-area-inset-bottom)) !important;
    width: 116px !important;
    height: 116px !important;
  }
  .touchKey {
    width: 40px !important;
    height: 40px !important;
    border-radius: 12px !important;
    font-size: .95rem !important;
  }
  .touchKey.up { left: 38px !important; top: 0 !important; }
  .touchKey.left { left: 0 !important; top: 38px !important; }
  .touchKey.right { right: 0 !important; top: 38px !important; }
  .touchKey.down { left: 38px !important; bottom: 0 !important; }
  .mobileTalk {
    right: max(8px, env(safe-area-inset-right)) !important;
    bottom: max(8px, env(safe-area-inset-bottom)) !important;
    width: 88px !important;
    height: 54px !important;
    border-radius: 28px !important;
    font-size: .68rem !important;
  }

  .dialog {
    left: 132px !important;
    right: 104px !important;
    bottom: 8px !important;
    grid-template-columns: 58px 1fr !important;
    max-height: min(42vh, 165px) !important;
    padding: 7px !important;
    gap: 7px !important;
  }
  .portraitPanel { width: 58px !important; height: 70px !important; }
  .dialogTop h3 { font-size: .82rem !important; }
  .role { font-size: .62rem !important; }
  .dialogBody > p { font-size: .72rem !important; line-height: 1.25 !important; margin-top: 4px !important; }

  /* Inicio y final caben incluso sin fullscreen. */
  .panel { max-height: calc(var(--app-height, 100vh) - 12px) !important; padding: 10px 12px !important; }
  .introPanel { grid-template-columns: 76px 1fr !important; gap: 10px !important; }
  .heroSprite { max-height: 92px !important; }
  .introLogo { max-height: 34px !important; margin-bottom: 2px !important; }
  .panel h2 { font-size: 1.02rem !important; margin: 2px 0 4px !important; }
  .panel p { font-size: .72rem !important; line-height: 1.28 !important; margin: 3px 0 !important; }
  .eyebrow { font-size: .57rem !important; }
  .panel button { margin-top: 6px !important; padding: 8px 12px !important; }

  .celebrationPanel {
    width: min(98vw, 900px) !important;
    max-height: calc(var(--app-height, 100vh) - 8px) !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1.4fr) minmax(210px, .7fr) !important;
    grid-template-rows: auto 1fr auto !important;
    column-gap: 10px !important;
    align-items: center !important;
    overflow: hidden !important;
  }
  #celebrationCanvas {
    grid-column: 1;
    grid-row: 1 / 4;
    width: 100% !important;
    max-height: calc(var(--app-height, 100vh) - 28px) !important;
    aspect-ratio: 980 / 430 !important;
    object-fit: contain;
  }
  .celebrationPanel h2 { grid-column: 2; grid-row: 1; margin: 0 0 4px !important; font-size: 1.05rem !important; }
  .celebrationPanel > p { grid-column: 2; grid-row: 2; margin: 0 !important; font-size: .72rem !important; line-height: 1.3 !important; }
  .endActions {
    grid-column: 2;
    grid-row: 3;
    position: static !important;
    display: grid !important;
    gap: 5px !important;
    padding: 0 !important;
    background: none !important;
  }
  .endActions button { width: 100%; margin: 0 !important; padding: 8px 8px !important; font-size: .72rem !important; }
}


/* ==========================================================
   V1.7 · MÓVIL HORIZONTAL ROBUSTO (SIN DEPENDER DE FULLSCREEN)
   ==========================================================
   En Chrome Android la barra del navegador puede seguir visible y su altura
   cambia dinámicamente. La solución es NO ocuparla: el juego usa solamente
   el VisualViewport y, en horizontal, reserva una franja inferior propia
   para los controles. Así ningún botón queda cortado.
   ========================================================== */
:root { --control-dock-height: 0px; --play-height: var(--app-height, 100dvh); }

/* Fullscreen eliminado como requisito: era inconsistente en Chrome Android. */
.fullscreenBtn { display: none !important; }

/* Touch real o móvil horizontal grande (algunos Android reportan >900 CSS px). */
@media (hover: none), (pointer: coarse), (max-width: 1400px) and (max-height: 800px) {
  .topbar { display: none !important; }
  .page { width: 100%; padding: 0 !important; margin: 0; }
  .gameFrame {
    width: 100vw !important;
    height: var(--app-height, 100dvh) !important;
    min-height: 0 !important;
    max-height: var(--app-height, 100dvh) !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    background: #17161b !important;
  }
  #game {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    width: 100% !important;
    height: var(--play-height, 100%) !important;
    max-height: var(--play-height, 100%) !important;
    border-radius: 0 !important;
    touch-action: pan-y !important;
  }
  .mobileControls {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    height: var(--control-dock-height, 0px) !important;
    min-height: var(--control-dock-height, 0px) !important;
    display: block !important;
    z-index: 60 !important;
    pointer-events: none !important;
    background: linear-gradient(180deg, rgba(23,22,27,.82), rgba(23,22,27,.98));
    border-top: 1px solid rgba(255,255,255,.10);
    box-shadow: 0 -8px 22px rgba(0,0,0,.20);
  }
  .jumpToSignup {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    z-index: 65 !important;
    top: auto !important;
    right: 108px !important;
    bottom: max(20px, calc((var(--control-dock-height, 96px) - 42px) / 2)) !important;
    width: 120px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 10px !important;
    margin: 0 !important;
    border-radius: 22px !important;
    font-size: .67rem !important;
    background: rgba(166,119,48,.94) !important;
    color: #fffaf2 !important;
    border: 1px solid rgba(255,255,255,.60) !important;
    box-shadow: 0 4px 14px rgba(0,0,0,.24) !important;
    touch-action: manipulation !important;
  }
}

@media (orientation: landscape) and (max-height: 800px) {
  /* El canvas termina ANTES de esta franja. Los controles ya no están encima
     del mapa ni pueden quedar debajo de la barra del navegador. */
  .dpad {
    position: absolute !important;
    left: max(8px, env(safe-area-inset-left)) !important;
    bottom: max(2px, env(safe-area-inset-bottom)) !important;
    width: 92px !important;
    height: 92px !important;
  }
  .touchKey {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    border-radius: 10px !important;
    padding: 0 !important;
    font-size: .80rem !important;
  }
  .touchKey.up { left: 30px !important; top: 0 !important; }
  .touchKey.left { left: 0 !important; top: 30px !important; }
  .touchKey.right { right: 0 !important; top: 30px !important; }
  .touchKey.down { left: 30px !important; bottom: 0 !important; }
  .mobileTalk {
    position: absolute !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    bottom: max(20px, calc((var(--control-dock-height, 96px) - 48px) / 2)) !important;
    width: 88px !important;
    height: 48px !important;
    min-height: 48px !important;
    border-radius: 25px !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: .68rem !important;
  }

  /* HUD simple: nada en la zona superior que pueda confundirse con la barra de Chrome. */
  .jumpToSignup { top: auto !important; }

  /* Diálogo vive sobre el área de juego y termina antes del dock. */
  .dialog {
    left: 104px !important;
    right: 8px !important;
    bottom: calc(var(--control-dock-height, 96px) + 6px) !important;
    max-height: 116px !important;
    grid-template-columns: 52px 1fr !important;
    gap: 6px !important;
    padding: 6px !important;
    border-radius: 12px !important;
  }
  .portraitPanel { width: 52px !important; height: 64px !important; }
  .dialogTop h3 { font-size: .78rem !important; }
  .role { font-size: .58rem !important; }
  .dialogBody > p { font-size: .68rem !important; line-height: 1.20 !important; margin: 3px 0 0 !important; }

  /* Overlays solo sobre la zona visible completa, y sus paneles caben. */
  .overlay { inset: 0 !important; border-radius: 0 !important; }
  .panel { max-height: calc(var(--app-height, 100vh) - 12px) !important; overflow-y: auto !important; }

  /* La celebración deja sus acciones siempre visibles. */
  .celebrationPanel {
    width: min(98vw, 900px) !important;
    max-height: calc(var(--app-height, 100vh) - 10px) !important;
    overflow-y: auto !important;
  }
}

/* En vertical no reservamos dock: controles siguen superpuestos y compactos. */
@media (orientation: portrait) and (max-width: 900px) {
  .mobileControls { background: transparent !important; border-top: 0 !important; box-shadow: none !important; }
  .jumpToSignup { right: max(8px, env(safe-area-inset-right)) !important; bottom: auto !important; top: max(8px, env(safe-area-inset-top)) !important; width: auto !important; height: 34px !important; min-height: 34px !important; }
}
