/* Expert Mobile CSS with Safe Area Support */
:root {
  /* Safe area CSS variables for Phaser.js integration with better fallbacks */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);  
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  
  /* Fallback values for devices without safe area support */
  --fallback-top: 20px; /* Status bar height fallback */
  --fallback-bottom: 34px; /* Home indicator fallback */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* Performance optimizations */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Orientation lock */
  writing-mode: horizontal-tb;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: #1a1a2e;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile browsers */
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  /* Apply safe area padding to body */
  padding-top: var(--sat);
  padding-right: var(--sar);
  padding-bottom: var(--sab);
  padding-left: var(--sal);
  /* Mobile performance optimizations */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transform: translateZ(0);
  will-change: auto;
}

/* Force portrait orientation (mobile devices only) */
@media screen and (orientation: landscape) and (max-width: 900px) {
  body {
    transform: rotate(90deg);
    transform-origin: left top;
    width: 100vh;
    height: 100vw;
    overflow: hidden;
    position: absolute;
    top: 100%;
    left: 0;
  }
}

#game-container {
  width: calc(100vw - var(--sal) - var(--sar));
  height: calc(100vh - var(--sat) - var(--sab));
  height: calc(100dvh - var(--sat) - var(--sab)); /* Dynamic viewport height */
  position: fixed;
  top: var(--sat);
  left: var(--sal);
  overflow: hidden;
  /* Remove conflicting padding */
}

/* Ensure canvas fills container completely */
canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  position: relative;
  top: 0;
  left: 0;
}

/* Mobile-specific adjustments */
@media (max-width: 900px) {
  body {
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height */
    min-height: -webkit-fill-available; /* iOS Safari fix */
  }
  
  #game-container {
    width: calc(100vw - var(--sal) - var(--sar));
    height: calc(100vh - var(--sat) - var(--sab));
    height: calc(100dvh - var(--sat) - var(--sab)); /* Dynamic viewport height */
    height: calc(-webkit-fill-available - var(--sat) - var(--sab)); /* iOS Safari fix */
    top: var(--sat);
    left: var(--sal);
  }
  
  canvas {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
  }
}

/* Remove iPhone specific hack - let safe areas handle it */
