/* Mobile UX polish: modal visibility, zoom guard, loading overlay, Safari toolbar tip, ultra-short landscape. */

dialog.jumi-modal-dialog:not([open]) { display: none !important; }
dialog.jumi-modal-dialog[open] { display: flex; }

html, body,
.jumi-stage-shell,
#game-canvas,
.title-overlay,
.victory-banner,
.loading-overlay,
.safari-bar-tip {
  touch-action: none;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

dialog.jumi-modal-dialog[open] .parent-helper-body {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

button,
.hero-card,
.mode-chip,
.btn-play-cta,
.safari-bar-tip-close,
.safari-bar-tip-fs {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#loading-overlay.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: max(16px, var(--safe-t, 0px), env(safe-area-inset-top, 0px)) max(16px, var(--safe-r, 0px), env(safe-area-inset-right, 0px)) max(16px, var(--safe-b, 0px), env(safe-area-inset-bottom, 0px)) max(16px, var(--safe-l, 0px), env(safe-area-inset-left, 0px));
  background:
    radial-gradient(ellipse at 50% 35%, rgba(94, 234, 212, 0.14), transparent 60%),
    radial-gradient(circle at 20% 80%, rgba(251, 191, 36, 0.10), transparent 45%),
    linear-gradient(180deg, #050b1f 0%, #0a1733 55%, #0d1f3d 100%);
  color: #f8f1dc;
  opacity: 1;
  transition: opacity 0.26s ease;
  overflow: hidden;
}

.loading-overlay.is-complete { opacity: 0; pointer-events: none; transition: opacity 0.26s ease; }

[hidden] { display: none !important; }

.loading-compass {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(251, 191, 36, 0.75);
  background: radial-gradient(circle, rgba(94, 234, 212, 0.35) 0%, rgba(5, 11, 31, 0.9) 70%);
  box-shadow: 0 0 24px rgba(251, 191, 36, 0.35);
  display: grid;
  place-items: center;
  font-size: 30px;
  color: #fde68a;
  animation: loading-compass-spin 2.4s linear infinite;
}

.loading-title { margin: 0; font-size: 1.05rem; letter-spacing: 0.04em; font-weight: 600; }

.loading-bar {
  width: min(280px, 72vw);
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.loading-bar-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #fbbf24 0%, #d9b45a 45%, #5eead4 100%);
  box-shadow: 0 0 10px rgba(94, 234, 212, 0.55);
  transition: width 0.2s ease-out;
}

.loading-percent { font-variant-numeric: tabular-nums; font-size: 0.9rem; color: #fde68a; }

.loading-hint { margin: 0; font-size: 0.82rem; line-height: 1.4; text-align: center; color: rgba(248, 241, 220, 0.82); }

@keyframes loading-compass-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .loading-compass { animation: none; }
}

.safari-bar-tip {
  position: fixed;
  top: max(10px, var(--safe-t, 0px), env(safe-area-inset-top, 0px));
  left: calc(50% + (var(--safe-l, 0px) - var(--safe-r, 0px)) * 0.5);
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(500px, calc(100vw - max(12px, var(--safe-l, 0px)) - max(12px, var(--safe-r, 0px)) - 144px));
  padding: 6px 6px 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.7);
  background-color: rgba(8, 22, 50, 0.86);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: #f8f1dc;
  font-size: 0.86rem;
  line-height: 1.35;
}

.safari-bar-tip-text { flex: 1 1 auto; min-width: 0; }

.safari-bar-tip-fs,
.safari-bar-tip-close,
.safari-bar-dismiss,
.safari-bar-fullscreen {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 36px;
  width: auto;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.14);
  color: #fde68a;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

/* The tip is adult-facing text: it lives only inside the parent drawer, never over the game view. */
.parent-settings-panel .safari-bar-tip {
  position: static;
  transform: none;
  z-index: auto;
  flex: 1 1 100%;
  max-width: none;
  margin: 0;
  border-radius: 14px;
}

html[data-vh-tier="ultra-short"] .safari-bar-tip {
  top: max(4px, var(--safe-t, 0px));
  font-size: 0.74rem;
  padding: 3px 6px 3px 12px;
  max-width: min(500px, calc(100vw - max(12px, var(--safe-l, 0px)) - max(12px, var(--safe-r, 0px)) - 144px));
}

html[data-vh-tier="ultra-short"] .title-card-container {
  max-height: calc(100vh - 8px);
  max-height: calc(var(--vvh, 100vh) - max(6px, var(--safe-t, 0px)) - max(6px, var(--safe-b, 0px)) - 4px);
  overflow-y: auto;
  padding: 4px 10px;
  gap: 4px;
}

html[data-vh-tier="ultra-short"] .hero-grid { display: flex; flex-wrap: nowrap; gap: 6px; overflow: visible; }
html[data-vh-tier="ultra-short"] .hero-grid .hero-card { flex: 1 1 0; min-width: 0; padding: 4px 6px; }
html[data-vh-tier="ultra-short"] .hero-grid .hero-avatar img { width: 44px; height: 44px; }

html[data-vh-tier="ultra-short"] dialog.jumi-modal-dialog[open] {
  max-height: 92vh;
  max-height: calc(var(--vvh, 100vh) - max(6px, var(--safe-t, 0px)) - max(6px, var(--safe-b, 0px)) - 8px);
  padding: 8px 12px;
}

html[data-vh-tier="ultra-short"] .bilingual-toast { top: 44px; transform: translateX(-50%) scale(0.92); }

.modal-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pause-locale-select {
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.38);
  background: rgba(15, 23, 42, 0.85);
  color: #fde68a;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

@media (orientation: landscape) and (max-height: 335px) {
  .title-card-container { padding: 4px 10px; gap: 4px; }
  .hero-grid { display: flex; flex-wrap: nowrap; gap: 6px; overflow: visible; }
  .hero-grid .hero-card { flex: 1 1 0; min-width: 0; padding: 4px 6px; }
  .hero-grid .hero-avatar img { width: 44px; height: 44px; }
  dialog.jumi-modal-dialog[open] {
    max-height: 92vh;
    max-height: calc(var(--vvh, 100vh) - max(6px, var(--safe-t, 0px)) - max(6px, var(--safe-b, 0px)) - 8px);
    padding: 8px 12px;
  }
  .bilingual-toast { top: 44px; transform: translateX(-50%) scale(0.92); }
}

/* Wordless wake curtain: after a background or call interruption the child sees one large play disc. */
#wake-curtain-dialog h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#wake-curtain-dialog {
  inset: 0;
  margin: auto;
  width: fit-content;
  height: fit-content;
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

#wake-curtain-dialog .wake-inner { padding: 8px; }
#wake-curtain-dialog .compass-emblem { display: none; }

#wake-curtain-dialog #btn-wake-resume {
  min-width: 96px;
  width: 96px;
  height: 96px;
  min-height: 96px;
  min-width: clamp(84px, 28vh, 112px);
  width: clamp(84px, 28vh, 112px);
  height: clamp(84px, 28vh, 112px);
  min-height: clamp(84px, 28vh, 112px);
  min-width: clamp(84px, 28dvh, 112px);
  width: clamp(84px, 28dvh, 112px);
  height: clamp(84px, 28dvh, 112px);
  min-height: clamp(84px, 28dvh, 112px);
  padding: 0;
  border-radius: 50%;
  font-size: 0;
  line-height: 0;
  display: grid;
  place-items: center;
}

#wake-curtain-dialog #btn-wake-resume::before {
  content: "\25B6";
  font-size: 42px;
  font-size: clamp(36px, 12vh, 48px);
  font-size: clamp(36px, 12dvh, 48px);
  line-height: 1;
}

.jumi-action-button.is-softgate-hint { min-width: 48px; min-height: 48px; }
