* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --sai-t: env(safe-area-inset-top, 0px);
  --sai-r: env(safe-area-inset-right, 0px);
  --sai-b: env(safe-area-inset-bottom, 0px);
  --sai-l: env(safe-area-inset-left, 0px);
}

html, body {
  width: 100%; height: 100%;
  background: #050810;
  color: #dff6ff;
  font-family: 'Courier New', ui-monospace, monospace;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  /* canvas is a replaced element — inset:0 alone won't stretch it, so on
     high-DPR phones the backing store (innerWidth*dpr) overflowed the
     viewport and only the top-left showed. Pin the displayed size here. */
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: rgba(5, 8, 16, 0.82);
  backdrop-filter: blur(3px);
  z-index: 10;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  /* scrollable when content overflows (short landscape phones) */
  overflow-y: auto;
  touch-action: pan-y;
}

/* auto margins center when there's room, collapse to 0 when overflowing —
   unlike justify-content:center this never clips the top edge */
.overlay > :first-child { margin-top: auto; }
.overlay > :last-child { margin-bottom: auto; }

.overlay.hidden { display: none; }

h1 {
  font-size: clamp(48px, 12vw, 96px);
  letter-spacing: 0.35em;
  margin-left: 0.35em; /* visually recenters letter-spaced text */
  color: #4df0ff;
  text-shadow: 0 0 24px rgba(77, 240, 255, 0.55);
  font-weight: 700;
}

.sub { opacity: 0.7; font-size: 14px; }

#name {
  background: #0a1020;
  border: 1px solid #2a4a5f;
  color: #dff6ff;
  font: inherit;
  font-size: 20px;
  text-align: center;
  padding: 10px 16px;
  border-radius: 6px;
  width: min(280px, 80vw);
  outline: none;
}
#name:focus { border-color: #4df0ff; }

#colors { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.swatch.sel { border-color: #fff; transform: scale(1.15); }

#join {
  background: #4df0ff;
  color: #050810;
  border: none;
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2em;
  padding: 12px 44px;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 6px;
}
#join:active { transform: scale(0.96); }

.help { opacity: 0.6; font-size: 12px; text-align: center; line-height: 1.8; margin-top: 4px; }

#share {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  opacity: 0.85;
}
#qr { width: 92px; height: 92px; image-rendering: pixelated; }
#urls { font-size: 12px; line-height: 1.7; opacity: 0.8; }

#dc h2 { color: #ff5d5d; letter-spacing: 0.2em; }
#dc p { opacity: 0.7; }
