* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

body {
  background: #000;
  overflow: hidden;
  font-family: 'Courier New', Courier, monospace;
  color: #fff;
  overscroll-behavior: none;
  touch-action: none;
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* UI Container */
#ui {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  display: none;
  /* Hidden by default, shown in JS */
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
}

#ui-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-item {
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #444;
  font-size: 14px;
  font-weight: bold;
  text-shadow: 0 1px 2px #000;
  color: #0ff;
}

.hud-item.best {
  color: #ffaa00;
  border-color: #aa6600;
}

/* Pause Button */
#pauseBtn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #0ff;
  background: rgba(0, 0, 0, 0.6);
  color: #0ff;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  pointer-events: auto;
  display: none;
}

/* Status Text */
#status {
  position: fixed;
  bottom: 20px;
  width: 100%;
  text-align: center;
  color: #fff;
  font-size: 16px;
  text-shadow: 0 0 4px #000;
  pointer-events: none;
  z-index: 5;
}

/* Pause Menu */
#pauseMenu,
#startMenu {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  z-index: 20;
}

#pauseMenu.visible,
#startMenu.visible {
  display: flex;
}

.hidden {
  display: none !important;
}

.no-script-warning {
  position: fixed;
  inset: 45% 1rem auto;
  z-index: 50;
  color: #fff;
  text-align: center;
}

.menu-panel {
  background: #111;
  border: 1px solid #0ff;
  border-radius: 8px;
  padding: 20px;
  min-width: 200px;
  text-align: center;
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
}

.menu-panel--wide {
  width: min(92vw, 560px);
}

.menu-copy {
  margin: 0 0 14px;
  color: #d4e7e7;
  line-height: 1.45;
}

.menu-copy--muted {
  min-height: 2.9em;
  margin-top: 12px;
  color: #8aa;
  font-size: 13px;
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.menu-panel .difficulty-btn {
  min-width: 0;
  margin: 0;
  padding: 10px 5px;
  color: #9bb;
  border-color: #355;
  background: #071515;
  font-size: 12px;
}

.menu-panel .difficulty-btn.active {
  color: #fff;
  border-color: #0ff;
  background: #064044;
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.2);
}

.menu-panel .difficulty-btn--danger.active {
  border-color: #ff5555;
  background: #4a1010;
}

.menu-store-link {
  display: block;
  margin-top: 10px;
  padding: 11px 14px;
  border: 1px solid rgba(255, 213, 74, .45);
  border-radius: 8px;
  color: #ffd54a;
  text-decoration: none;
  font: 700 12px monospace;
  letter-spacing: .04em;
  text-align: center;
  background: rgba(255, 213, 74, .08);
}

.portal-perks-info {
  margin-top: 7px;
  color: #8fa8a8;
  font: 11px/1.35 monospace;
  text-align: center;
}

.menu-best {
  margin-top: 14px;
  color: #ffaa00;
  font-size: 13px;
}

.menu-title {
  font-size: 24px;
  color: #0ff;
  margin-bottom: 20px;
  text-shadow: 0 0 10px #0ff;
}

.menu-panel button {
  display: block;
  width: 100%;
  margin: 10px 0;
  padding: 12px;
  background: #002222;
  border: 1px solid #0ff;
  color: #0ff;
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  pointer-events: auto;
}

.menu-panel button:active {
  background: #004444;
}

#exitBtn {
  border-color: #ff5555;
  color: #ff5555;
  background: #220000;
}

#exitBtn:active {
  background: #440000;
}

/* Mobile Adjustments */
@media (max-width: 480px) {
  #startMenu,
  #pauseMenu {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .menu-panel {
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .menu-title {
    font-size: 20px;
    margin-bottom: 12px;
  }

  .difficulty-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud-item {
    font-size: 12px;
    padding: 2px 6px;
  }

  #pauseBtn {
    width: 36px;
    height: 36px;
  }
}
