* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #03050a;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: monospace;
}

#gameContainer {
  position: relative;
  /* Fit the 480x720 (2:3) play field inside the viewport on any screen size
     or orientation — portrait phones, landscape phones, desktop windows. */
  width: min(100vw, 66.667vh);
  height: min(100vh, 150vw);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #060a14;
  box-shadow: 0 0 40px rgba(120, 200, 255, 0.15);
  border: 1px solid rgba(120, 200, 255, 0.25);
  image-rendering: pixelated;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Real DOM form for entering a display name — overlays the canvas only
   while Game.state === NAME_ENTRY, since canvas can't natively take text
   input. Uses the uploaded key-art (three ships + nebula) as a background;
   a bottom scrim fades its lower third to solid dark so our own live glass
   panel — not the flat pixels baked into that art — is what reads as the UI. */
#nameEntryOverlay {
  position: absolute;
  inset: 0;
  background: #03050a url("assets/name-entry-bg.jpg") center top / cover no-repeat;
  font-family: monospace;
}

/* A simple, even ~50% darken toward the bottom so the panel stays legible
   against the art without crushing it to black. */
#nameEntryOverlay::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(3, 5, 10, 0) 30%, rgba(3, 5, 10, 0.5) 55%, rgba(3, 5, 10, 0.5) 100%);
}

#nameEntryOverlay.hidden {
  display: none;
}

/* Animated gradient frame — a padding-as-border trick: this outer layer IS
   the border, its background gradient continuously scrolling; the inner
   layer's solid glass fill covers everything but that border ring. */
.nameEntryPanel {
  position: absolute;
  z-index: 1;
  top: 58%;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 320px;
  padding: 3px;
  border-radius: 16px;
  background: linear-gradient(115deg, #2d6bff, #a04dff, #3dd2ff, #2d6bff);
  background-size: 300% 300%;
  animation: panelGradientShift 7s ease infinite, panelGlow 7s ease infinite;
}

.nameEntryPanelInner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 24px;
  border-radius: 13px;
  background: rgba(6, 9, 18, 0.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@keyframes panelGradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes panelGlow {
  0%, 100% { box-shadow: 0 0 22px rgba(45, 107, 255, 0.45); }
  33% { box-shadow: 0 0 26px rgba(160, 77, 255, 0.5); }
  66% { box-shadow: 0 0 26px rgba(61, 210, 255, 0.5); }
}

.authTitle {
  color: #eaf6ff;
  font-weight: bold;
  font-size: clamp(22px, 6vw, 30px);
  letter-spacing: 2px;
  text-shadow: 0 0 18px rgba(123, 150, 255, 0.55);
}

.authSubtitle {
  color: #9fb6d0;
  font-size: 13px;
  margin-bottom: 6px;
}

#nameEntryOverlay input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(140, 170, 255, 0.35);
  border-radius: 7px;
  color: #eaf6ff;
  font-family: monospace;
  font-size: 14px;
  text-align: center;
}

#nameEntryOverlay input::placeholder {
  color: #5a6f88;
}

#nameEntryOverlay input:focus {
  outline: none;
  border-color: #a04dff;
  box-shadow: 0 0 0 3px rgba(160, 77, 255, 0.18);
}

#nameEntryError {
  min-height: 16px;
  color: #ff8a5c;
  font-size: 12px;
  text-align: center;
}

/* Animated gradient button — same continuously-scrolling-background trick as
   the frame, tuned to a longer scroll (300%) and a linear/no-reverse loop so
   the color keeps drifting forward rather than pulsing back and forth. */
#nameEntryOverlay button {
  width: 100%;
  padding: 13px;
  margin-top: 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-family: monospace;
  font-weight: bold;
  font-size: 15px;
  letter-spacing: 1px;
  cursor: pointer;
  color: #f4f8ff;
  background: linear-gradient(90deg, #2d6bff, #a04dff, #3dd2ff, #2d6bff);
  background-size: 300% 100%;
  animation: btnGradientShift 5s linear infinite;
  box-shadow: 0 0 18px rgba(123, 90, 255, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#nameEntryOverlay button:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 28px rgba(123, 90, 255, 0.8);
}

#nameEntryOverlay button:active {
  transform: translateY(0);
}

@keyframes btnGradientShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .nameEntryPanel,
  #nameEntryOverlay button {
    animation: none;
  }
}
