/* RESET & CORE SETTINGS */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  
  /* Safe Area Variables */
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
  --sal: env(safe-area-inset-left);
  --sar: env(safe-area-inset-right);
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden; /* CRITICAL: Prevent scroll */
  background-color: #000;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  overscroll-behavior: none; /* Prevent pull-to-refresh */
  touch-action: none; /* Prevent browser handling of touches */
}

/* GAME CONTAINER */
#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  
  /* Respect Safe Areas */
  padding-left: var(--sal);
  padding-right: var(--sar);
  padding-top: var(--sat);
  padding-bottom: var(--sab);
}

canvas {
  display: block;
  image-rendering: pixelated; /* Essential for pixel art */
}

/* UI LAYER */
#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Let touches pass through to canvas controls */
}

#ui-layer > * {
  pointer-events: auto; /* Re-enable pointer events for UI elements */
}

#debug-info {
  position: absolute;
  top: 5px;
  left: 5px;
  color: lime;
  font-family: monospace;
  font-size: 10px;
  z-index: 9999;
}

/* ORIENTATION OVERLAY */
#orientation-overlay {
  display: none; /* Hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #111;
  z-index: 10000;
  color: white;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

#orientation-overlay .message h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: #ff4444;
}

#orientation-overlay .icon {
  font-size: 4rem;
  margin-top: 1rem;
  animation: spin 2s infinite linear;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(90deg);
  }
}

/* FORCE LANDSCAPE RULES via CSS */
/* We also use JS for stricter control, but this is the first line of defense */
@media screen and (orientation: portrait) {
  #orientation-overlay {
    display: flex !important;
  }
  #game-container {
    display: none !important;
  }
}
