html, body {
      margin: 0;
      padding: 0;
      overflow: hidden;
      height: 100%;
      width: 100%;
      touch-action: none;
    }

    body {
      background-color: rgb(0, 0, 0);
      color: white;
      font-family: monospace;
      white-space: pre;
      overflow: hidden;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      height: 100vh;
      padding-top: env(safe-area-inset-top);
      padding-bottom: env(safe-area-inset-bottom);
      padding-left: env(safe-area-inset-left);
      padding-right: env(safe-area-inset-right);
      box-sizing: border-box;
    }

    canvas {
      border: 2px solid white;
      display: block;
      margin: 0;
      background-color: black;
      box-shadow: 0 0 30px rgba(0, 255, 255, 0.4), 0 0 10px rgba(255, 255, 255, 0.1);
    }


    .overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0,0,0,0.8);
      display: flex;
      flex-direction: column;
      align-items: center;
      color: white;
    }

    #mobileControls {
      margin-top: 20px;
      display: none;
      flex-direction: column;
      align-items: center;
      gap: 10px;
    }

    .modal {
      display: none;
      position: fixed;
      z-index: 1001;
      left: 0;
      top: 0;
      width: 100vw;
      height: 100vh;
      overflow: auto;
      background-color: rgba(0,0,0,0.8);
      align-items: center;
      justify-content: center;
    }

    .modal-content {
      display: flex; /* ✅ Enable flexbox */
      flex-direction: column; /* ✅ Stack items vertically */
      align-items: center; /* ✅ Center elements horizontally */
      justify-content: center; /* ✅ Optional: center vertically inside modal-content box */
        
      background: linear-gradient(135deg, #1b1b1b, #333);
      padding: 20px 30px;
      border-radius: 15px;
      box-shadow: 0 0 15px rgb(0, 255, 225);
      text-align: center;
      color: white;
      max-width: 500px;
      animation: fadeIn 0.5s ease-in-out;
      max-height: 80vh;
    }

    .modal-content a {
      color: #00ffe1;
      text-decoration: underline;
    }

    .modal-content button {
      margin-top: 20px;
    }

    .mobileButtons {
      background: transparent;
      border: none;
      font-size: 2rem;
      color: white;
      box-shadow: none;
      cursor: pointer;
      touch-action: manipulation;
    }


    .mobileButtons:active {
      transform: scale(0.95);
      box-shadow: 0 0 5px #00ffe1, 0 0 10px #00ffe1;
    }

    .mobileRow {
      display: flex;
      gap: 15px;
    }

    .menuButtons, .overButtons {
      display: flex;
      justify-content: center;
      flex-direction: column;
      align-items: center;
      gap: 20px;
      margin-top: 20px;
    }

    #controls {
      display: flex;
      justify-content: center;
      gap: 10px;
      margin-top: 4px;
    }

    #SnakeM, #OverHeader, .About {
      font-size: 1.5rem;
      letter-spacing: 2px;
      background: linear-gradient(135deg, #00ffea, #4a2eff, #962fbf, #ff3c83);
      background-clip: text;
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      margin-top: 10px; /* ✅ Add this line */
      animation: pulseText 3s infinite;
      margin-bottom: 20px;
      font-family: 'Press Start 2P', monospace;
    }

    #SnakeM, #OverHeader {
      font-family: 'Press Start 2P', monospace;
      font-size: 2rem;
    }

    .hidden { display: none; }

    #menu, #game, #gameOver {
      text-align: center;
    }

    button {
      font-size: 1rem;
      padding: 10px 25px;
      background: linear-gradient(135deg, #1f1f1f, #333);
      color: #ffffff;
      border: 2px solid #8562b3;
      cursor: pointer;
      border-radius: 30px;
      transition: all 0.3s ease;
      box-shadow: 0 4px 10px rgba(255, 255, 255, 0.1);
    }

    button:hover {
      background: linear-gradient(135deg, #00ffea, #4a2eff, #962fbf, #ff3c83);
      transform: scale(1.05);
      border-color: rgb(0, 240, 240);
      box-shadow: 0 0 10px #9f79ff;
    }

    #profile-btn, #settings-btn {
      border: none;
      font-size: larger;
      background: transparent;
    }

    .exitBtn {
      background: linear-gradient(135deg, #cd1100, #c00d00);
      border: 2px solid #8562b3;
    }

    .exitBtn:hover {
      background: linear-gradient(135deg, #9a0d00, #740800);
    }

    .buttons {
      display: flex;
      justify-content: center; /* or space-between / flex-end / flex-start as needed */
      gap: 20px; /* spacing between buttons */
      margin-top: 20px;
    }

    @keyframes pulseText {
      0% { opacity: 1; transform: scale(1); }
      50% { opacity: 0.8; transform: scale(1.05); }
      100% { opacity: 1; transform: scale(1); }
    }

    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(-10px); }
      to { opacity: 1; transform: translateY(0); }
    }

    #gameWrapper {
      display: flex;
      justify-content: center;
      align-items: flex-start;
      height: 100dvh;
      width: 100vw;
      overflow: hidden;
      box-sizing: border-box;
      transform: scale(
        min(
          calc((100vw - 20px) / 360),
          calc((100vh - 40px) / 540)
        )
      );
      transform-origin: top center;
    }

    #gameScaleBox {
      width: 360px;
      height: 540px;
      padding: 8px;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      position: relative; /* ✅ Required for countdown to center correctly */
    }

    #userList {
      list-style: none;
      padding: 0;
      margin: 0;
      font-family: monospace;
    }

    .countdown-overlay {
      display: none; /* ✅ Hide by default */
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.6); /* Optional: darken background */
      align-items: center;
      justify-content: center;
      z-index: 10;
      pointer-events: none;
    }

    .countdown-text {
      font-size: 5rem;
      font-weight: bold;
      color: white;
      text-shadow: 0 0 10px #00ffe1;
    }


    @keyframes pulse {
      0%, 100% { transform: scale(1); opacity: 1; }
      50% { transform: scale(1.2); opacity: 0.6; }
    }

    /* Leaderboard List */
    #leaderboardList {
      list-style: none;
      padding: 0;
      margin: 0;
    }

    /* Each leaderboard item */
    .leaderboard-item {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      margin: 6px 0;
      font-size: 16px;
      font-family: monospace;
    }

    /* Serial number */
    .leaderboard-serial {
      width: 30px;
      text-align: right;
      margin-right: 10px;
      font-weight: bold;
    }

    /* Name and score */
    .leaderboard-name-score span {
      color: gold;
      font-weight: bold;
    }

    /* Community List */
    #userList {
      list-style: none;
      padding: 0;
      margin: 0;
      font-family: monospace;
      max-height: 80vh; /* ✅ limits scroll area */
      overflow-y: auto; /* ✅ scroll here */
      width: 100%;
      align-items: center;
    }

    /* Each community item */
    .community-item {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      margin: 6px 0;
      font-size: 16px;
      font-family: monospace;
    }

    /* Serial number */
    .community-serial {
      width: 30px;
      text-align: right;
      margin-right: 10px;
      font-weight: bold;
    }

    /* Name */
    .community-name {
      flex-grow: 1;
    }

    #loadingOverlay {
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      background: black;
      color: white;
      font-family: monospace;
      z-index: 9999;
      text-align: center;
    }

    .dots {
      display: flex;
      justify-content: center;
      align-items: center;
      gap: 10px;
    }

    .dot {
      font-size: 4rem;
      animation: colorCycle 1.5s infinite;
    }

    #dot1 { animation-delay: 0s; }
    #dot2 { animation-delay: 0.5s; }
    #dot3 { animation-delay: 1s; }

    @keyframes colorCycle {
      0%   { color: rgb(0, 255, 234); }
      33%  { color: #5b42f3; }
      66%  { color: #ff3c83; }
      100% { color: rgb(0, 255, 234); }
    }

    .stars {
      display: flex;
      justify-content: center;
      font-size: 2.5rem;
      margin: 10px 0;
      gap: 10px;
    }

    .star {
      font-size: 3rem;
      color: white; /* default */
      cursor: pointer;
      transition: color 0.3s, transform 0.2s;
    }

    .star:hover {
      transform: scale(1.2);
    }

    .star.selected {
      color: gold;
      transform: scale(1.2);
    }

    #adminDeleteContainer {
      display: none;
    }

    .setting-option {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin: 10px 0;
      font-size: 0.8rem;
    }

    .setting-option label {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    #profile-btn {
      position: absolute;   /* ignores parent flex alignment */
      top: 10px;
      left: 10px;
      width: 40px;
      height: 40px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    #settings-btn {
      position: fixed;    /* stays at top-right even when scrolling */
      top: 10px;          /* distance from the top */
      right: 10px;        /* distance from the right */
      width: 40px;
      height: 40px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
    }

