html, body {
  margin: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
}

body {
  /* No double-tap zoom on the letterbox bars; pinch zoom stays available outside the canvas. */
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  /* Size is set from JS (letterbox); these keep touch input from scrolling or zooming the page. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  image-rendering: pixelated;
}

/* Player name form, laid over the menu (src/ui/nameEntry.js). Near the top so a phone keyboard
   in landscape doesn't cover it. 18 px text keeps iOS from zooming in on focus. */
#name-entry {
  position: fixed;
  top: max(12px, 8vh);
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px;
  background: rgba(0, 0, 20, 0.92);
  border: 3px solid #9ff0ff;
  border-radius: 12px;
  color: #fff;
  font: bold 20px "Trebuchet MS", Verdana, sans-serif;
  z-index: 5;
}

#name-entry[hidden] {
  display: none;
}

#name-entry input {
  font: bold 18px "Trebuchet MS", Verdana, sans-serif;
  padding: 10px 12px;
  border: 2px solid #1fb0e6;
  border-radius: 8px;
  background: #050816;
  color: #fff;
}

#name-entry input:focus {
  outline: 3px solid #ffe08a;
  outline-offset: 1px;
}

.name-error {
  margin: 0;
  min-height: 1.2em;
  color: #ff9de6;
  font-size: 16px;
}

.name-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.name-actions button {
  min-height: 44px;
  min-width: 112px;
  font: bold 18px "Trebuchet MS", Verdana, sans-serif;
  border-radius: 8px;
  border: 2px solid #9ff0ff;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.name-actions button[type="submit"] {
  background: #1fb0e6;
  border-color: #1fb0e6;
}

/* Phones in landscape: compact, so it stays above the on-screen keyboard. */
@media (max-height: 500px) {
  #name-entry {
    top: 8px;
    gap: 6px;
    padding: 10px 14px;
    font-size: 16px;
  }

  #name-entry input {
    padding: 6px 10px;
  }

  .name-error {
    font-size: 14px;
  }
}

/* Portrait notice on touch devices. The game is never rotated with CSS: it waits for landscape. */
#rotate-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: rgba(0, 0, 10, 0.92);
  color: #fff;
  font: bold 22px "Trebuchet MS", Verdana, sans-serif;
  text-align: center;
  padding: 16px;
  z-index: 10;
}

#rotate-overlay[hidden] {
  display: none;
}

#rotate-overlay p {
  margin: 0;
}

.rotate-icon {
  width: 48px;
  height: 80px;
  border: 4px solid #9ff0ff;
  border-radius: 10px;
  animation: rotate-hint 1.8s ease-in-out infinite;
}

@keyframes rotate-hint {
  0%, 30% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-icon { animation: none; transform: rotate(-90deg); }
}
