#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#uiLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.screen,
.floating,
#hud {
  pointer-events: auto;
}

/* Redesigned screen container with scrollable flex layout */
.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
  padding: 48px 24px;
  background: radial-gradient(circle at center, rgba(12, 34, 62, 0.45) 0%, rgba(3, 9, 18, 0.96) 100%);
  backdrop-filter: var(--glass-blur);
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  animation: fadeIn 0.4s ease-out;
}

/* Beautiful auto-centering trick for flex scrolling layouts */
.screen > *:first-child {
  margin-top: auto;
}

.screen > *:last-child {
  margin-bottom: auto;
}

/* Intro Brand Header Style */
.intro-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: fadeInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.intro-brand h1 {
  font-size: clamp(2.5rem, 6vw, 4.2rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, #00d2ff 0%, #0066ff 50%, #8c52ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(0, 210, 255, 0.35));
}

.creator-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 210, 255, 0.06);
  border: 1px solid rgba(0, 210, 255, 0.28);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  color: #b2f0ff;
  font-size: 0.85rem;
}

.creator-lockup span {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.1em;
}

.creator-lockup strong {
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 8px rgba(0, 210, 255, 0.5);
}

.subtitle {
  font-size: clamp(0.9rem, 2vw, 1.15rem);
  color: var(--muted);
  font-weight: 500;
  max-width: 600px;
  line-height: 1.5;
  animation: fadeInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s both;
}

/* Redesigned Menu Cards & Panels (Glassmorphism) */
.menu-card {
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 580px;
  padding: 24px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  box-shadow: var(--glass-shadow);
  animation: fadeInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s both;
}

/* Columns for Player Loadouts */
.menu-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  width: 100%;
  max-width: 1020px;
  box-sizing: border-box;
}

.menu-two-col > div {
  padding: 20px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}

/* Stagger column load animations */
.menu-two-col > div:nth-child(1) {
  animation: fadeInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s both;
}

.menu-two-col > div:nth-child(2) {
  animation: fadeInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s both;
}

.menu-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  width: 100%;
  animation: fadeInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.3s both;
}

/* Grids for weapon/skin cards */
.card-grid,
.weapon-grid,
.skin-grid {
  display: grid;
  gap: 12px;
}

.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  width: 100%;
  max-width: 900px;
}

.weapon-grid {
  grid-template-columns: 1fr;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.skin-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

/* Help Floating Panel Override */
.floating {
  position: absolute;
  right: 24px;
  bottom: 24px;
  width: calc(100vw - 48px);
  max-width: 940px;
  max-height: min(78vh, 700px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 20px;
  background: rgba(3, 9, 20, 0.92);
  border: 1px solid rgba(0, 210, 255, 0.25);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
  font-size: 0.88rem;
  z-index: 100;
  animation: fadeInUp 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
}

.help-panel {
  display: grid;
  gap: 18px;
  backdrop-filter: blur(24px);
}

.help-header {
  display: grid;
  gap: 4px;
  text-align: left;
}

.help-header h3 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
}

.help-header p {
  color: var(--muted);
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 14px;
}

.help-section {
  padding: 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  text-align: left;
  transition: border-color 0.3s ease;
}

.help-section:hover {
  border-color: rgba(0, 210, 255, 0.2);
}

.help-section h4 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  border-left: 3px solid var(--accent);
  padding-left: 8px;
}

.help-section dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.help-section dl > div {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  align-items: center;
}

.help-section dt {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
}

.help-section dd {
  margin: 0;
  color: #e2eeff;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* Mechanical Physical Keycap styling */
kbd {
  display: inline-block;
  min-width: 26px;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid rgba(0, 210, 255, 0.4);
  background: linear-gradient(to bottom, #0e1e33, #040912);
  color: var(--accent);
  font: 700 0.8rem 'Outfit', sans-serif;
  text-align: center;
  box-shadow: 
    inset 0 1px 1px rgba(255, 255, 255, 0.12),
    0 1px 0 rgba(0, 210, 255, 0.2),
    0 3px 5px rgba(0, 0, 0, 0.6);
  text-shadow: 0 0 5px rgba(0, 210, 255, 0.3);
  vertical-align: middle;
}

/* Responsive Overrides */
@media (max-width: 900px) {
  .menu-two-col {
    grid-template-columns: 1fr;
  }

  .floating {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 80vh;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .screen {
    padding: 32px 16px;
  }

  .help-section dl > div {
    grid-template-columns: 1fr;
    gap: 4px;
    align-items: flex-start;
  }

  .intro-brand h1 {
    font-size: 2.2rem;
  }
}

/* Force hardware accelerated screen caches to destroy when hidden to avoid ghosting overlays on mobile */
.screen.hidden,
.screen.hidden * {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  backdrop-filter: none !important;
  pointer-events: none !important;
}
