.ghost {
  margin: 0;
  position: absolute;
  z-index: 2;
}
* {
  font-family: "Press Start 2P", sans-serif;
}

body {
  margin: 0;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.overflow-mask {
  background-color: #0000ff;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  margin: 0;
  overflow: hidden;
  position: relative;
  touch-action: manipulation;
  -webkit-overflow-scrolling: touch;
}

.backdrop {
  position: absolute;
  visibility: hidden;
}

.fps-display {
  position: absolute;
  right: 10px;
  top: 10px;
  visibility: hidden;
}

.preload-div {
  align-items: baseline;
  bottom: 0;
  display: flex;
  flex-wrap: wrap-reverse;
  position: absolute;
  visibility: hidden;
}

.header-buttons {
  padding: 2rem 3rem;
  width: calc(100vw - 6rem);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.header-buttons a {
  font-family: none;
  display: inline-block;
}
.header-buttons img {
  height: 2rem;
}
.header-buttons button {
  background: none;
  border: 0;
  color: #fff;
  cursor: pointer;
  outline: none;
  padding: 0;
}
.header-buttons button .material-icons {
  font-size: 40px;
}

.paused-text {
  align-items: center;
  display: flex;
  font-size: 50px;
  height: 100%;
  justify-content: center;
  left: 0;
  position: absolute;
  user-select: none;
  visibility: hidden;
  width: 100%;
  z-index: 1;
}

.game-ui {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
  max-width: min(98vw, 98vh);
  margin: 0 auto;
  padding: 0.5rem;
  box-sizing: border-box;
  gap: 0.3rem;
}
.game-ui .one-up {
  animation: blink 0.6s infinite;
}
@keyframes blink {
  0% {
    opacity: 0;
  }
  49% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
}
.game-ui .row {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: 0.2rem 0;
  box-sizing: border-box;
}
.game-ui .top ._25 {
  width: 25%;
}
.game-ui .top ._50 {
  width: 50%;
}
.game-ui .top .column :first-child {
  text-align: center;
}
.game-ui .top .column :not(:first-child) {
  margin-right: calc(50% - 3em);
  text-align: right;
}
.game-ui .bottom {
  justify-content: space-between;
}
.game-ui .bottom .extra-lives {
  align-items: flex-start;
  display: flex;
}
.game-ui .bottom .fruit-display {
  display: flex;
  flex-direction: row-reverse;
}

.loading-cover {
  background: #0000ff;
  height: 100vh;
  position: absolute;
  top: 0;
  width: 50vw;
  z-index: 4;
}

.left {
  left: 0;
  transition: left 0.5s 0.5s;
}

.right {
  right: 0;
  transition: right 0.5s 0.5s;
}

.main-menu-container {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  left: 0;
  opacity: 0;
  position: absolute;
  transition: opacity 0.25s;
  visibility: hidden;
  width: 100%;
  z-index: 5;
  padding: 2rem;
  box-sizing: border-box;
}

.instructions {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 15px 0;
  border: 1px solid rgba(255, 255, 255, 0.3);
  max-width: 500px;
  text-align: center;
}

.instructions p {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: #ffff00;
}

.logo {
  width: 800px;
  max-width: 80vw;
  margin-bottom: 3rem;
  flex-shrink: 0;
}

.game-start {
  background-color: #fcc73f;
  border: 5px solid #231f20;
  border-radius: 10px;
  box-shadow: 5px 5px #ee2a29;
  color: #231f20;
  cursor: pointer;
  font-size: 48px;
  outline: none;
  padding: 16px 32px;
  flex-shrink: 0;
}
.game-start:active {
  box-shadow: none;
  transform: translateX(5px) translateY(5px);
}
.game-start:disabled {
  cursor: default;
}

@media only screen and (max-width: 600px) {
  .game-start {
    scale: 0.5;
  }
}

/* Enhanced Mobile and Tablet Responsive Design */

/* Tablet styles (768px and below) */
@media only screen and (max-width: 768px) {
  .header-buttons {
    padding: 1rem 2rem;
    width: calc(100vw - 4rem);
  }
  
  .header-buttons button {
    font-size: 1.5rem;
    padding: 0.5rem;
  }
  
  .logo {
    width: 600px;
    max-width: 85vw;
    margin-bottom: 2.5rem;
  }
  
  .game-start {
    font-size: 36px;
    padding: 12px 24px;
  }
  
  .main-menu-container {
    padding: 1.5rem;
  }
  
  .game-ui {
    max-width: min(98vw, 96vh);
    padding: 0.1rem;
    gap: 0.3rem;
  }
  
  .game-ui .row {
    padding: 0.2rem 0;
  }
  
  .maze-img {
    max-width: 100%;
    height: auto;
  }
}

/* Tablet Landscape styles */
@media only screen and (min-width: 769px) and (max-width: 1023px) and (orientation: landscape) {
  .game-ui {
    max-width: min(70vw, 90vh);
  }
  
  .logo {
    width: 500px;
    margin-bottom: 2rem;
  }
  
  .main-menu-container {
    padding: 1.5rem;
  }
}

/* Mobile styles (480px and below) */
@media only screen and (max-width: 480px) {
  .header-buttons {
    padding: 0.5rem 1rem;
    width: calc(100vw - 2rem);
  }
  
  .header-buttons button {
    font-size: 1.2rem;
    padding: 0.3rem;
  }
  
  .logo {
    width: 350px;
    max-width: 85vw;
    margin-bottom: 2rem;
  }
  
  .game-start {
    font-size: 24px;
    padding: 12px 20px;
  }
  
  .main-menu-container {
    padding: 1rem;
  }
  
  .game-ui {
    max-width: min(99vw, 98vh);
    min-width: unset; /* Remove minimum width constraint on mobile */
    padding: 0.02rem;
    gap: 0.2rem;
  }
  
  .game-ui .row {
    padding: 0.1rem 0;
  }
  
  .maze {
    width: 100%;
    min-width: unset;
  }
  
  .maze-img {
    width: 100%;
    height: auto;
    min-width: unset;
  }
  
  .game-ui .top ._25,
  .game-ui .top ._50 {
    font-size: 0.7rem;
  }
  
  .loading-container {
    width: 280px;
    transform: scale(0.8);
  }
  
  .paused-text {
    font-size: 1.8rem;
  }
}

/* Small mobile styles (360px and below) */
@media only screen and (max-width: 360px) {
  .header-buttons {
    padding: 0.4rem 0.8rem;
    flex-wrap: wrap;
    gap: 0.3rem;
  }
  
  .header-buttons button {
    font-size: 1rem;
    padding: 0.2rem;
    min-width: calc(50% - 0.15rem);
  }
  
  .logo {
    width: 280px;
    max-width: 90vw;
    margin-bottom: 1.5rem;
  }
  
  .game-start {
    font-size: 20px;
    padding: 10px 16px;
  }
  
  .main-menu-container {
    padding: 0.8rem;
  }
  
  .game-ui {
    max-width: min(99vw, 98vh);
    min-width: unset; /* Remove minimum width constraint */
    padding: 0.02rem;
    gap: 0.1rem;
  }
  
  .game-ui .row {
    padding: 0.05rem 0;
  }
  
  .maze {
    width: 100%;
    min-width: unset;
  }
  
  .maze-img {
    width: 100%;
    height: auto;
    min-width: unset;
  }
  
  .game-ui .top ._25,
  .game-ui .top ._50 {
    font-size: 0.5rem;
  }
  
  .loading-container {
    width: 260px;
    transform: scale(0.7);
  }
  
  .paused-text {
    font-size: 1.6rem;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .header-buttons button {
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem;
  }
  
  .game-start {
    min-height: 44px;
    touch-action: manipulation;
  }
}

/* Large screen optimizations */
@media only screen and (min-width: 1200px) {
  .game-ui {
    max-width: min(70vw, 85vh);
  }
  
  .logo {
    width: 600px;
    max-width: 50vw;
  }
}

/* Laptop/Medium Desktop styles (1024px - 1199px) */
@media only screen and (min-width: 1024px) and (max-width: 1199px) {
  .game-ui {
    max-width: min(75vw, 80vh);
  }
  
  .logo {
    width: 550px;
    max-width: 55vw;
  }
  
  .game-start {
    font-size: 40px;
  }
}

/* Ultra-wide screen optimizations */
@media only screen and (min-width: 1600px) {
  .game-ui {
    max-width: min(60vw, 90vh);
  }
}

/* Landscape mode optimizations for mobile */
@media only screen and (max-height: 500px) and (orientation: landscape) {
  .logo {
    margin-top: 5vh;
    max-width: 60vw;
  }
  
  .game-ui {
    max-width: min(75vw, 90vh);
  }
  
  .header-buttons {
    padding: 0.25rem 1rem;
  }
  
  .paused-text {
    font-size: 1.5rem;
  }
}

/* Very small height screens */
@media only screen and (max-height: 400px) {
  .logo {
    margin-top: 2vh;
    max-width: 50vw;
  }
  
  .game-ui {
    max-width: min(70vw, 95vh);
  }
  
  .game-start {
    scale: 0.7;
    font-size: 16px;
  }
}
.loading-container {
  background-color: #000;
  border: 5px solid #2121ff;
  border-radius: 10px;
  height: 48px;
  position: absolute;
  top: 50%;
  transition: opacity 0.5s 1s;
  width: 500px;
  z-index: 5;
}

@media only screen and (max-width: 600px) {
  .loading-container {
    transform: scale(0.5);
  }
}
.loading-pacman {
  animation: loading-animation 0.3s steps(4) infinite;
  background-color: #000;
  background-image: url("assets/graphics/spriteSheets/characters/pacman/pacman_right.svg");
  background-size: 192px;
  border-radius: 10px;
  height: 48px;
  position: absolute;
  transition: left 1s;
  width: 48px;
  z-index: 6;
}

@keyframes loading-animation {
  100% {
    background-position: -192px;
  }
}
.loading-dot-mask {
  background-color: #000;
  border-radius: 10px;
  height: 48px;
  left: 0;
  position: absolute;
  top: 0;
  transition: width 1s;
  z-index: -1;
}

.loading-dot {
  background-image: url("assets/graphics/spriteSheets/pickups/pacdot.svg");
  height: 6px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  z-index: -2;
}

._5 {
  left: 5%;
}

._10 {
  left: 10%;
}

._15 {
  left: 15%;
}

._20 {
  left: 20%;
}

._25 {
  left: 25%;
}

._30 {
  left: 30%;
}

._35 {
  left: 35%;
}

._40 {
  left: 40%;
}

._45 {
  left: 45%;
}

._50 {
  left: 50%;
}

._55 {
  left: 55%;
}

._60 {
  left: 60%;
}

._65 {
  left: 65%;
}

._70 {
  left: 70%;
}

._75 {
  left: 75%;
}

._80 {
  left: 80%;
}

._85 {
  left: 85%;
}

._90 {
  left: 90%;
}

._95 {
  left: 95%;
}

.error-message {
  color: #231f20;
  opacity: 0;
  position: absolute;
  top: 30vh;
  transition: opacity 0.5s;
  visibility: hidden;
  width: 50vw;
  z-index: 4;
}
.error-message .error-pacman {
  animation: error-animation 1.5s steps(12) infinite;
  background-image: url("assets/graphics/spriteSheets/characters/pacman/pacman_error.svg");
  background-size: 576px;
  height: 48px;
  margin-left: 10px;
  width: 48px;
  z-index: 6;
}
@keyframes error-animation {
  100% {
    background-position: -576px;
  }
}
.error-message .header {
  display: flex;
  font-size: 50px;
  margin-bottom: 30px;
}
.error-message .body {
  font-size: 20px;
  line-height: 1.25;
}
.maze-cover {
  background: #000;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  visibility: hidden;
  width: 100%;
  z-index: 3;
}

.maze {
  position: relative;
  width: 100%;
  margin: 0;
  display: block;
  box-sizing: border-box;
}

.maze-img {
  position: relative;
  user-select: none;
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.maze-row {
  display: flex;
}

.dot-container {
  height: 100%;
  position: absolute;
  width: 100%;
}
.pacman {
  margin: 0;
  position: absolute;
  z-index: 1;
}
.power-pellet {
  animation: blink 0.3s infinite;
}

@keyframes blink {
  0% {
    opacity: 0;
  }
  49% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
}
