html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    /* iOS standalone: percentage height alone leaves a top gap; fill-available matches the
       real screen. position:fixed + inset:0 pins the page to the visual screen so rotation
       and the translucent status bar cannot leave a black band. */
    min-height: 100%;
    min-height: -webkit-fill-available;
    min-height: 100vh;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.87);
    background-color: #000;
    -webkit-text-size-adjust: 100%;
    position: fixed;
    inset: 0;
    touch-action: none;
}

#app {
    position: fixed;
    inset: 0;
    width: 100%;
    /* Prefer inset-driven size. Do NOT set 100dvh here â€” on iOS Home Screen (standalone)
       landscape it disagrees with inset:0 and leaves a black band (~status-bar / safe-area
       height) at the top while the canvas sits below it. */
    height: 100%;
    height: -webkit-fill-available;
    min-height: 100%;
    min-height: -webkit-fill-available;
    overflow: hidden;
    display: block;
    background: #000;
}

#pixi-container {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: -webkit-fill-available;
    min-height: 100%;
    min-height: -webkit-fill-available;
    overflow: hidden;
    background: #06080a;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ONLY the Pixi game canvas (tagged in viewer.ts). Never match nested DOM-UI canvases
   (trade / login / NPC / friends / â€¦) â€” a descendant or untagged direct-child rule
   stretches their art to 100% and produces huge blurry panels. */
#pixi-container > canvas#gersang-game-canvas {
    display: block;
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    touch-action: none;
}

/* Belt-and-suspenders: any unmarked / DOM-UI canvas inside the shell must not inherit
   a leftover full-bleed rule from an old cached stylesheet. Inline pinDomCanvas()
   also sets width/height with !important. */
#pixi-container canvas.gersang-dom-canvas,
.gersang-dom-ui canvas,
.gersang-dom-ui img.gersang-dom-canvas {
    inset: auto !important;
    /* width/height left to inline !important from pinDomCanvas */
}

#gersang-boot-banner {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-width: min(92vw, 420px);
    padding: 14px 16px;
    border-radius: 10px;
    z-index: 30;
    font: 13px/1.45 system-ui, sans-serif;
    text-align: center;
    white-space: pre-wrap;
    background: rgba(12, 16, 22, 0.92);
    color: #e8eef8;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

/* Safe-area insets for HUD (notch is left/right in landscape). Canvas stays full-bleed. */
:root {
    --sa-top: env(safe-area-inset-top, 0px);
    --sa-right: env(safe-area-inset-right, 0px);
    --sa-bottom: env(safe-area-inset-bottom, 0px);
    --sa-left: env(safe-area-inset-left, 0px);
    --app-width: 100vw;
    --app-height: 100vh;
}

/* Rotate-to-landscape overlay: iOS Safari cannot lock orientation, so in portrait on a touch phone we ask the player to rotate. */
#gersang-rotate {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: #000;
    color: #e8eef8;
    font: 16px/1.5 system-ui, sans-serif;
    text-align: center;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: var(--sa-top) var(--sa-right) var(--sa-bottom) var(--sa-left);
}
#gersang-rotate .gr-icon { font-size: 56px; animation: gr-spin 2s ease-in-out infinite; }
@keyframes gr-spin { 0%, 30% { transform: rotate(0deg); } 60%, 100% { transform: rotate(90deg); } }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 900px) {
    #gersang-rotate { display: flex; }
}

/* ——— Mobile glass bottom sheet (isMobileLayout only; desktop unused) ——— */
.gersang-mobile-sheet-wrap {
  opacity: 0;
  transition: opacity 160ms ease-out;
}
.gersang-mobile-sheet-wrap.gersang-mobile-sheet-open {
  opacity: 1;
}
.gersang-mobile-sheet-wrap .gersang-mobile-sheet {
  transform: translateY(18%);
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}
.gersang-mobile-sheet-wrap.gersang-mobile-sheet-open .gersang-mobile-sheet {
  transform: translateY(0);
}
.gersang-mobile-float-chip {
  animation: gersang-mobile-float 3.6s ease-in-out infinite;
}
@keyframes gersang-mobile-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
.gersang-mobile-sheet-body {
  -webkit-overflow-scrolling: touch;
}

/* Mobile landscape right-half glass dock (stable / é¦¬å»„ etc.) */
.gersang-mobile-dock-wrap {
  opacity: 0;
  transition: opacity 160ms ease-out;
}
.gersang-mobile-dock-wrap.gersang-mobile-dock-open {
  opacity: 1;
}
.gersang-mobile-dock-wrap .gersang-mobile-dock-panel {
  transform: translateX(12%);
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}
.gersang-mobile-dock-wrap.gersang-mobile-dock-open .gersang-mobile-dock-panel {
  transform: translateX(0);
}
.gersang-mobile-dock-body {
  -webkit-overflow-scrolling: touch;
}

/* Mobile gaming comfort: finger-sized controls, readable type, no text zoom. */
@media (pointer: coarse) {
  button,
  .gersang-mobile-float-chip,
  .gersang-mobile-sheet button,
  .gersang-mobile-dock-panel button {
    min-height: 44px;
    min-width: 44px;
  }
  .gersang-mobile-sheet,
  .gersang-mobile-dock-panel {
    font-size: 14px;
    line-height: 1.4;
  }
  input, textarea, select {
    font-size: 16px; /* iOS: avoid auto-zoom on focus */
  }
}
