html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000033;
  color: white;
  font-family: sans-serif;
  font-size: 13pt;
  font-weight: normal;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
}

h1,
h2,
h3,
h4 {
  text-align: center;
  color : #EEE;
  margin: 0;
}

h2 a,
h3 a {
  color : #EEE;
}

a {
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a {
  color: #a2c2f2;
}

.unselectable {
  -webkit-user-select: none;
  -moz-user-select: none;
  -khtml-user-select: none;
  user-select: none;
}

#levelHeaderLine {
  display:flex;
  flex-flow:row wrap;
  margin-bottom: 0;
  height: 2.5em;
}

#scoreLine {
  margin-top: 0.2em;
  display:flex;
  justify-content: space-between;
}

#scoreText {
  line-height: 1em;
  padding-bottom: 1.2em;
  width: 70%;
}

.alignLeft {
  width: 33.33333%;
  text-align: left;
}

.alignCenter {
  width: 33.33333%;
  text-align: center;
}

.alignRight {
  width: 33.33333%;
  text-align: right;
  display: flex;
  justify-content: flex-end;
}

.verticalBottom {
  display: flex;
  align-items: flex-end;
}

#levelTitle {
  color: #EEE;
  margin: 0;
  font-family: sans-serif;
  font-size: 20px;
  font-weight: bold;
  vertical-align: top;
}

#muncherGrid table, td {
  border-collapse: collapse;
  border: 1px solid #666;
}

#muncherGrid table {
  table-layout: fixed;
  width: 100%;
  border: 2px solid white;
  background-color: #000080;
}

#muncherGrid {
  position: relative;
}

#muncherGrid td {
  text-align: center;
  vertical-align: middle;
  height: 60px;
  position: relative;
  padding: 0; /* Remove default padding */
  z-index: 3;
}

#muncherGrid .cell-div {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  border: 4px solid transparent;
  box-sizing: border-box;
  z-index: 4;
}

.safe-square {
  border-color: white !important;
}

#livesRemaining {
  width: 30%;
}

#livesRemaining img {
  height: 2em;
}

.muncher-image {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
}

.debugBG {
  background-color: orange;
  transition: background-color 1s;
}

#body {
  max-width: 850px;
  margin: 2em 10px 2em;
}

#body hr {
  display: block;
  height: 1px;
  border: 0;
  border-top: 1px solid #ccc;
  margin: 2em 0;
  padding: 0;
}

#gameView {
  position: relative;
}

#footer-container {
  margin-top: 0.1em;
  display: flex;
  justify-content: space-between;
}

#about {
  color: #738791;
  text-align: left;
  font-size: 10pt;
}

#byline {
  color: #738791;
  text-align: right;
  font-size: 10pt;
}

#gameOverlay {
  display: none; /* Hidden by default */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(66.66% - 2px); /* 4 cells wide minus cell border width * 2 */
  height: calc(60% - 2px);
  background-color: #000080;
  color: white;
  text-align: center;
  padding: 20px;
  box-sizing: border-box;
  z-index: 100; /* Ensure it's on top */
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#gameOverlay p {
  margin: 5px 0;
  font-size: 1.1em;
}

#gameOverlay.gameOverOverlay {
  background-color: #5A0000;
}

.animation-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  z-index: 2; /* Ensure it's above the muncher */
}

.muncher-animation-sprite {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  pointer-events: none;
  z-index: 1;
}

.troggle-animation-sprite {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  pointer-events: none;
  z-index: 2;
}

.emoji-font-size {
  font-size: 1.8em;
}

/* Constrain height on small devices in landscape */
@media all and (orientation:landscape) and (max-height: 450px) {
  #body {
    margin: 1.8em 10px 1.8em;
  }
  
  #levelTitle {
    font-size: 17px;
  }
  
  #muncherGrid td {
    height: 11vh;
  }
  
  #scoreText {
    line-height: 0.8em;
    padding-bottom: 0.9em;
  }
  
  #livesRemaining img {
    height: 1.5em;
  }
}

/* Handle skinny screens */
@media (max-width: 500px) {
  #levelTitle {
    font-size: 15px;
  }

  #gameOverlay p {
    font-size: 0.9em;
  }

  #gameOverlay {
    width: calc(100% - 2px - 4px); /* Full table width minus cell border width * 2 minus table border width * 2 */
  }
   
  #about {
    font-size: 8pt;
  }

  #byline {
    font-size: 8pt;
  }
}
