* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: radial-gradient(circle at 50% 35%, #162238 0%, #090d16 75%, #04060b 100%);
  color: #dce9ff;
  font-family: "Courier New", Courier, monospace;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cabinet {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding:
    max(4px, env(safe-area-inset-top))
    max(4px, env(safe-area-inset-right))
    max(4px, env(safe-area-inset-bottom))
    max(4px, env(safe-area-inset-left));
}

.screen-bezel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05070c;
  border: 3px solid #2b3c5e;
  border-radius: 8px;
  box-shadow:
    0 0 0 2px #0f172a,
    0 18px 50px rgba(0, 0, 0, 0.75),
    inset 0 0 0 2px #141c2e;
  padding: 4px;
  /* Expand game to fill as much of the viewport as possible while keeping exact 320:224 aspect ratio */
  width: min(96vw, calc((100dvh - 52px) * 320 / 224));
  height: min(calc(100dvh - 52px), calc(96vw * 224 / 320));
  aspect-ratio: 320 / 224;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: none;
  touch-action: none;
}

#game-canvas.show-cursor {
  cursor: pointer;
}

.controls-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #8ca8d6;
  min-height: 26px;
}

.mobile-only {
  display: none;
}

#mute-btn {
  background: #1b2a47;
  color: #ffe259;
  border: 2px solid #4d73b8;
  border-radius: 4px;
  padding: 3px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.1s ease;
}

#mute-btn:hover {
  background: #273d66;
}

#mute-btn:active {
  transform: translateY(1px);
}

/* Mobile & tablet touch viewports: maximize canvas size & streamline footer bar */
@media (max-width: 900px), (pointer: coarse) {
  .cabinet {
    gap: 4px;
    padding:
      max(2px, env(safe-area-inset-top))
      max(2px, env(safe-area-inset-right))
      max(2px, env(safe-area-inset-bottom))
      max(2px, env(safe-area-inset-left));
  }

  .screen-bezel {
    border-width: 2px;
    border-radius: 5px;
    padding: 2px;
    width: min(99vw, calc((100dvh - 36px) * 320 / 224));
    height: min(calc(100dvh - 36px), calc(99vw * 224 / 320));
  }

  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: inline;
  }

  .controls-bar {
    width: 100%;
    max-width: 99vw;
    justify-content: space-between;
    padding: 0 6px;
    font-size: 11px;
    gap: 6px;
    min-height: 24px;
  }

  #mute-btn {
    padding: 2px 8px;
    font-size: 11px;
  }
}
