:root {
    --main-pink: #c01960;
    --main-blue: #728ea1;
    --glow-pink: 0 0 6px #c01960, 0 0 12px #c01960;
    --glow-blue: 0 0 15px #728ea1, 0 0 30px #728ea1;
    --wall-blue: #2c3e50;
  }
  
  * {
    box-sizing: border-box;
  }
  html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: Arial, sans-serif;
    background: black;
    color: var(--main-blue);
    overflow: hidden;
  }
  
  body {
    font-family: 'Arial', sans-serif;
    text-align: center;
    background: black;
    color: var(--main-blue);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
  }
  button {
    font-size: 1rem;
    padding: 10px 20px;
    background: var(--main-pink);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 0 10px var(--main-pink);
  }
  
  /* Responsive Title */
  h1 {
    margin-top: 20px;
    color: var(--main-pink);
    text-shadow: var(--glow-pink);
    font-size: clamp(1.5rem, 8vw, 3rem);
    animation: neonGlow 1.5s ease-in-out infinite alternate;
  }
  
  #score {
    margin: 10px 0;
    font-size: clamp(1rem, 5vw, 1.5rem);
    text-shadow: var(--glow-blue);
  }
  
  /* Game Wrapper */
  #gameWrapper {
    display: inline-block;
    position: relative;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 0 25px var(--main-pink);
    width: 90vw;
    max-width: 600px;
    aspect-ratio: 1;
  }
  
  /* Game Grid */
  #game {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    grid-template-rows: repeat(15, 1fr);
    gap: 2px;
    width: 100%;
    height: 100%;
  }
  
  .cell {
    background: black;
    border: 2px solid #222;
    box-sizing: border-box;
  }
  
  .wall {
    background-color: var(--wall-blue);
    position: relative;
  }
  
  .dot {
    background: black;
    position: relative;
    z-index: 1;
  }
  
  .dot::after {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--main-blue);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 8px var(--glow-blue), 0 0 12px var(--glow-blue);
    z-index: 1;
  }
  
  
  .cell.ghost.dot::after,
  .cell.ghost2.dot::after,
  .cell.pacman::after {
    display: none;
  }
  
  .pacman {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    z-index: 5;
    position: relative;
    background: conic-gradient(
      transparent 40deg,
      var(--main-pink) 40deg 320deg,
      transparent 320deg
    );
    transform: rotate(0deg);
    animation: chomping 0.3s infinite alternate;
  }
  
  @keyframes chomping {
    0% {
      background: conic-gradient(
        transparent 25deg,
        var(--main-pink) 25deg 335deg,
        transparent 335deg
      );
    }
    100% {
      background: conic-gradient(
        transparent 40deg,
        var(--main-pink) 40deg 320deg,
        transparent 320deg
      );
    }
  }
  
  .pac-eye {
    position: absolute;
    width: 10px;
    height: 10px;
    background: black;
    border-radius: 50%;
    pointer-events: none;
    top: 45%;
    left: 25%;
    transform: translate(-50%, -50%);
    z-index: 10;
  }
  @media (max-width: 600px) {
    .pac-eye {
      width: 3px;
      height: 3px;
    }
  }
  
  .ghost, .ghost2 {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 50% 50% 0 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    overflow: hidden;
    position: relative;
    z-index: 5;
    box-sizing: border-box;
  }
  
  .ghost {
    background: red;
    box-shadow: 0 0 8px red, 0 0 15px red;
  }
  
  .ghost2 {
    background: #39FF14;
    box-shadow: 0 0 8px #39FF14, 0 0 15px #39FF14;
  }

  .ghost-face, .ghost2-face {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 10% 0;
    box-sizing: border-box;
  }
  
  .eye-container {
    display: flex;
    justify-content: center;
    gap: 4px;
  }
  
  .eye {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 4px; /* 👈 Augen leicht nach unten schieben */
  }
  
  
  .pupil {
    width: 6px;
    height: 6px;
    background: blue;
    border-radius: 50%;
  }
  
  .mouth-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    height: 20%;
  }
  
  .mouth {
    width: 20px;
    height: 8px;
    border-bottom: 3px solid black;
    border-radius: 0 0 10px 10px;
  }
  
    
  @media (max-width: 600px) {
    .eye {
      width: 7px;
      height: 7px;
      margin-top: 2px; /* 👈 Augen leicht nach unten schieben */
    }
    .eye-container {
        gap: 1px;
    }
  
    .pupil {
      width: 4px;
      height: 4px;
    }
  
    .mouth {
      width: 14px;
      height: 5px;
      border-bottom: 2px solid black;
    }
    .ghost, .ghost2 {
        padding: 0;         /* Kein Innenabstand */
        margin: 0;          /* Kein Außenabstand */
        transform: scale(0.9); /* Optional kleiner skalieren */
      }
    
      .ghost-face, .ghost2-face {
        padding: 6% 0;      /* Weniger vertikaler Abstand */
      }
    
      .mouth-wrapper {
        height: 15%;        /* kompaktere Gesichter */
      }
    }
  
  .ghost::after, .ghost2::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 12px;
    background: inherit;
    border-radius: 50% 50% 0 0;
    background-repeat: repeat-x;
    background-size: 20% 100%;
    background-image: radial-gradient(circle at 50% 0%, black 4px, transparent 4px);
  }
  
  @keyframes floaty {
    0%, 100% {
      transform: translateY(0px);
    }
    50% {
      transform: translateY(2px);
    }
  }
  
  @keyframes neonGlow {
    0% {
      text-shadow: 0 0 5px var(--main-pink), 0 0 10px var(--main-pink);
    }
    100% {
      text-shadow: 0 0 20px var(--main-pink), 0 0 30px var(--main-pink), 0 0 40px var(--main-pink);
    }
  }
  
  .cell:hover {
    transform: scale(1.1);
  }
  
  #gameoverDiv, #nextLvlDiv, #lastLvlDiv {/* Responsive Popups */

    max-width: 90vw;
    font-size: clamp(1.2rem, 4vw, 2rem);
    padding: 1em;
    
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    text-shadow: 0 0 10px #c01960;
    background: rgba(0, 0, 0, 0.6);

    border-radius: 10px;
    z-index: 10;
    text-align: center;
    animation: fadein 0.5s ease;
    backdrop-filter: blur(4px);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease;
    max-width: 90vw;
  }
  
  #gameover-scores, #nextLvl-scores {
    font-size: clamp(1rem, 3vw, 1.5rem);
    margin-bottom: 15px;
  }
  
  #gameoverDiv button, #nextLvlDiv button, #lastLvlDiv button {
    font-size: 1rem;
    padding: 10px 20px;
    background: var(--main-pink);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 0 10px var(--main-pink);
    transition: transform 0.1s ease;
    margin: 0.5em;
  }
  
  #gameoverDiv button:active, #nextLvlDiv button:active, #lastLvlDiv button:active {
    transform: scale(0.95);
  }
  
  @keyframes fadein {
    0% { opacity: 0; }
    100% { opacity: 1; }
  }
  
  .touch-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, auto);
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin: 30px auto 0 auto;
    max-width: 240px;
  }
  
  
  .btn {
    background: var(--main-pink);
    border: none;
    color: white;
    font-size: 1.4rem;
    border-radius: 10px;
    box-shadow: var(--glow-pink);
    transition: transform 0.1s ease;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .btn:active {
    transform: scale(0.95);
  }


  #backButton {
    position: fixed;
    top: 20px;
    left: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4em;
    background: linear-gradient(135deg, #c01960 0%, #718D9F 100%);
    color: white;
    font-size: 1.6rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-decoration: none;
    border: none;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    z-index: 9999;
    transition: all 0.3s ease;
  }

  #backButton:focus {
    outline: none;
  }

  #backButton:hover {
    transform: scale(1.05);
  }

  #backButton .arrow-left {
    font-size: 2rem;
  }

  #backButton .back-text {
    display: inline;
  }

  @media (max-width: 768px) {
    #backButton {
      padding: 0;
      width: 40px;
      height: 40px;
      font-size: 0;
      top: 15px;
      left: 15px;
    }

    #backButton .back-text {
      display: none;
    }

    #backButton .arrow-left {
      font-size: 1.6rem;
    }
    .btn {
      font-size: 1.6rem;
      width: 70px;
      height: 70px;
    }
  }

  
  
  